[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.182, 1.183 mbox-sync-private.h, 1.68, 1.69 mbox-sync-update.c, 1.53, 1.54 mbox-sync.c, 1.208, 1.209

tss at dovecot.org tss at dovecot.org
Tue Apr 17 15:41:32 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv21471/index/mbox

Modified Files:
	mbox-storage.c mbox-sync-private.h mbox-sync-update.c 
	mbox-sync.c 
Log Message:
Added sync_notify() callback to struct mail_storage. It's now called for
expunges and flag/keyword changes (except with cydir).



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- mbox-storage.c	11 Apr 2007 10:55:36 -0000	1.182
+++ mbox-storage.c	17 Apr 2007 12:41:29 -0000	1.183
@@ -998,6 +998,7 @@
 		mbox_storage_sync_init,
 		index_mailbox_sync_next,
 		index_mailbox_sync_deinit,
+		NULL,
 		mbox_notify_changes,
 		index_transaction_begin,
 		index_transaction_commit,

Index: mbox-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- mbox-sync-private.h	6 Apr 2007 18:13:16 -0000	1.68
+++ mbox-sync-private.h	17 Apr 2007 12:41:29 -0000	1.69
@@ -165,7 +165,7 @@
 
 void mbox_sync_apply_index_syncs(struct mbox_sync_context *sync_ctx,
 				 struct mbox_sync_mail *mail,
-				 bool *keywords_changed_r);
+				 enum mailbox_sync_type *sync_type_r);
 int mbox_sync_seek(struct mbox_sync_context *sync_ctx, uoff_t from_offset);
 void mbox_sync_file_update_ext_modified(struct mbox_sync_context *sync_ctx);
 void mbox_sync_file_updated(struct mbox_sync_context *sync_ctx, bool dirty);

Index: mbox-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-update.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- mbox-sync-update.c	10 Mar 2007 16:05:48 -0000	1.53
+++ mbox-sync-update.c	17 Apr 2007 12:41:29 -0000	1.54
@@ -382,7 +382,7 @@
 void mbox_sync_update_header(struct mbox_sync_mail_context *ctx)
 {
 	uint8_t old_flags;
-	bool keywords_changed;
+	enum mailbox_sync_type sync_type;
 
 	i_assert(ctx->mail.uid != 0 || ctx->mail.pseudo);
 
@@ -390,12 +390,12 @@
 
 	if (array_count(&ctx->sync_ctx->syncs) > 0) {
 		mbox_sync_apply_index_syncs(ctx->sync_ctx, &ctx->mail,
-					    &keywords_changed);
+					    &sync_type);
 
 		if ((old_flags & XSTATUS_FLAGS_MASK) !=
 		    (ctx->mail.flags & XSTATUS_FLAGS_MASK))
 			mbox_sync_update_xstatus(ctx);
-		if (keywords_changed)
+		if ((sync_type & MAILBOX_SYNC_TYPE_KEYWORDS) != 0)
 			mbox_sync_update_xkeywords(ctx);
 	}
 

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -d -r1.208 -r1.209
--- mbox-sync.c	6 Apr 2007 18:13:17 -0000	1.208
+++ mbox-sync.c	17 Apr 2007 12:41:29 -0000	1.209
@@ -284,18 +284,18 @@
 
 void mbox_sync_apply_index_syncs(struct mbox_sync_context *sync_ctx,
 				 struct mbox_sync_mail *mail,
-				 bool *keywords_changed_r)
+				 enum mailbox_sync_type *sync_type_r)
 {
 	const struct mail_index_sync_rec *syncs;
 	unsigned int i, count;
-
-	*keywords_changed_r = FALSE;
+	enum mailbox_sync_type sync_type = 0;
 
 	syncs = array_get(&sync_ctx->syncs, &count);
 	for (i = 0; i < count; i++) {
 		switch (syncs[i].type) {
 		case MAIL_INDEX_SYNC_TYPE_FLAGS:
 			mail_index_sync_flags_apply(&syncs[i], &mail->flags);
+			sync_type |= MAILBOX_SYNC_TYPE_FLAGS;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD:
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE:
@@ -313,12 +313,14 @@
 			}
 			if (mail_index_sync_keywords_apply(&syncs[i],
 							   &mail->keywords))
-				*keywords_changed_r = TRUE;
+				sync_type |= MAILBOX_SYNC_TYPE_KEYWORDS;
 			break;
 		default:
 			break;
 		}
 	}
+
+	*sync_type_r = sync_type;
 }
 
 static int
@@ -481,8 +483,9 @@
 static int mbox_sync_update_index(struct mbox_sync_mail_context *mail_ctx,
 				  const struct mail_index_record *rec)
 {
-        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+	struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
 	struct mbox_sync_mail *mail = &mail_ctx->mail;
+	struct mailbox *box = &sync_ctx->mbox->ibox.box;
 	uint8_t mbox_flags;
 
 	mbox_flags = mail->flags & MAIL_FLAGS_MASK;
@@ -509,7 +512,7 @@
 		   sync records are automatically applied to rec->flags at the
 		   end of index syncing, so calculate those new flags first */
 		struct mbox_sync_mail idx_mail;
-		bool keywords_changed;
+		enum mailbox_sync_type sync_type;
 
 		memset(&idx_mail, 0, sizeof(idx_mail));
 		idx_mail.flags = rec->flags;
@@ -525,7 +528,9 @@
 			return -1;
 		}
 		mbox_sync_apply_index_syncs(sync_ctx, &idx_mail,
-					    &keywords_changed);
+					    &sync_type);
+		if (sync_type != 0 && box->v.sync_notify != NULL)
+			box->v.sync_notify(box, rec->uid, sync_type);
 
 #define SYNC_FLAGS (MAIL_RECENT | MAIL_INDEX_MAIL_FLAG_DIRTY)
 		if ((idx_mail.flags & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0) {
@@ -720,6 +725,12 @@
 static void mbox_sync_handle_expunge(struct mbox_sync_mail_context *mail_ctx)
 {
 	struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+	struct mailbox *box = &sync_ctx->mbox->ibox.box;
+
+	if (box->v.sync_notify != NULL) {
+		box->v.sync_notify(box, mail_ctx->mail.uid,
+				   MAILBOX_SYNC_TYPE_EXPUNGE);
+	}
 
 	mail_ctx->mail.expunged = TRUE;
 	mail_ctx->mail.offset = mail_ctx->mail.from_offset;
@@ -727,6 +738,7 @@
 		mail_ctx->body_offset - mail_ctx->mail.from_offset +
 		mail_ctx->mail.body_size;
 	mail_ctx->mail.body_size = 0;
+	mail_ctx->mail.uid = 0;
 
 	if (sync_ctx->seq == 1) {
 		/* expunging first message, fix space to contain next
@@ -1210,7 +1222,6 @@
 				return -1;
 			sync_ctx->dest_first_mail = FALSE;
 		} else {
-			mail_ctx->mail.uid = 0;
 			mbox_sync_handle_expunge(mail_ctx);
 		}
 



More information about the dovecot-cvs mailing list