[dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.4, 1.5 mail-storage.c, 1.25, 1.26 mail-storage.h, 1.71, 1.72 proxy-mailbox.c, 1.7, 1.8

cras at dovecot.org cras at dovecot.org
Mon Jul 12 14:35:53 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv2470/lib-storage

Modified Files:
	mail-storage-private.h mail-storage.c mail-storage.h 
	proxy-mailbox.c 
Log Message:
Broke mailbox_sync() into iterator.



Index: mail-storage-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mail-storage-private.h	22 Jun 2004 07:48:18 -0000	1.4
+++ mail-storage-private.h	12 Jul 2004 11:35:51 -0000	1.5
@@ -66,9 +66,17 @@
 	int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
 			  struct mailbox_status *status);
 
-	int (*sync)(struct mailbox *box, enum mailbox_sync_flags flags);
-	void (*auto_sync)(struct mailbox *box, enum mailbox_sync_flags flags,
-			  unsigned int min_newmail_notify_interval);
+	struct mailbox_sync_context *
+		(*sync_init)(struct mailbox *box,
+			     enum mailbox_sync_flags flags);
+	int (*sync_next)(struct mailbox_sync_context *ctx,
+			 struct mailbox_sync_rec *sync_rec_r);
+	int (*sync_deinit)(struct mailbox_sync_context *ctx,
+			   struct mailbox_status *status_r);
+
+	void (*notify_changes)(struct mailbox *box, unsigned int min_interval,
+			       mailbox_notify_callback_t *callback,
+			       void *context);
 
 	struct mailbox_transaction_context *
 		(*transaction_begin)(struct mailbox *box, int hide);
@@ -116,6 +124,10 @@
 	struct mailbox *box;
 };
 
+struct mailbox_sync_context {
+	struct mailbox *box;
+};
+
 /* Set error message in storage. Critical errors are logged with i_error(),
    but user sees only "internal error" message. */
 void mail_storage_clear_error(struct mail_storage *storage);

Index: mail-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mail-storage.c	10 Jul 2004 17:24:08 -0000	1.25
+++ mail-storage.c	12 Jul 2004 11:35:51 -0000	1.26
@@ -334,15 +334,28 @@
 	return box->get_status(box, items, status);
 }
 
-int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags)
+struct mailbox_sync_context *
+mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 {
-	return box->sync(box, flags);
+	return box->sync_init(box, flags);
 }
 
-void mailbox_auto_sync(struct mailbox *box, enum mailbox_sync_flags flags,
-		       unsigned int min_newmail_notify_interval)
+int mailbox_sync_next(struct mailbox_sync_context *ctx,
+		      struct mailbox_sync_rec *sync_rec_r)
 {
-	box->auto_sync(box, flags, min_newmail_notify_interval);
+	return ctx->box->sync_next(ctx, sync_rec_r);
+}
+
+int mailbox_sync_deinit(struct mailbox_sync_context *ctx,
+			struct mailbox_status *status_r)
+{
+	return ctx->box->sync_deinit(ctx, status_r);
+}
+
+void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
+			    mailbox_notify_callback_t *callback, void *context)
+{
+	box->notify_changes(box, min_interval, callback, context);
 }
 
 struct mail *mailbox_fetch(struct mailbox_transaction_context *t, uint32_t seq,

Index: mail-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- mail-storage.h	10 Jul 2004 17:24:08 -0000	1.71
+++ mail-storage.h	12 Jul 2004 11:35:51 -0000	1.72
@@ -89,6 +89,11 @@
 	MAILBOX_SYNC_AUTO_STOP		= 0x04
 };
 
+enum mailbox_sync_type {
+	MAILBOX_SYNC_TYPE_EXPUNGE	= 0x01,
+	MAILBOX_SYNC_TYPE_FLAGS		= 0x02
+};
+
 struct mail_storage;
 struct mail_storage_callbacks;
 struct mailbox_list;
@@ -123,6 +128,11 @@
 	const char **keywords;
 };
 
+struct mailbox_sync_rec {
+	uint32_t seq1, seq2;
+	enum mailbox_sync_type type;
+};
+
 struct mail_storage_callbacks {
 	/* Alert: Not enough disk space */
 	void (*alert_no_diskspace)(struct mailbox *mailbox, void *context);
@@ -133,27 +143,10 @@
 	void (*notify_no)(struct mailbox *mailbox, const char *text,
 			  void *context);
 
-	/* EXPUNGE */
-	void (*expunge)(struct mailbox *mailbox, unsigned int seq,
-			void *context);
-	/* FETCH FLAGS */
-	void (*update_flags)(struct mailbox *mailbox, unsigned int seq,
-			     const struct mail_full_flags *flags,
-			     void *context);
-
-	/* EXISTS */
-	void (*message_count_changed)(struct mailbox *mailbox,
-				      unsigned int count, void *context);
-	/* RECENT */
-	void (*recent_count_changed)(struct mailbox *mailbox,
-				     unsigned int count, void *context);
-	/* FLAGS, PERMANENTFLAGS */
-	void (*new_keywords)(struct mailbox *mailbox,
-			     const char *keywords[],
-			     unsigned int keywords_count, void *context);
-
 };
 
+typedef void mailbox_notify_callback_t(struct mailbox *box, void *context);
+
 extern int full_filesystem_access;
 
 void mail_storage_init(void);
@@ -271,12 +264,17 @@
 		       struct mailbox_status *status);
 
 /* Synchronize the mailbox. */
-int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags);
+struct mailbox_sync_context *
+mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
+int mailbox_sync_next(struct mailbox_sync_context *ctx,
+		      struct mailbox_sync_rec *sync_rec_r);
+int mailbox_sync_deinit(struct mailbox_sync_context *ctx,
+			struct mailbox_status *status_r);
 
-/* Synchronize mailbox in background. It's done until this function is
-   called with flags = MAILBOX_SYNC_AUTO_STOP. */
-void mailbox_auto_sync(struct mailbox *box, enum mailbox_sync_flags flags,
-		       unsigned int min_newmail_notify_interval);
+/* Call given callback function when something changes in the mailbox.
+   It's done until this function is called with callback = NULL. */
+void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
+			    mailbox_notify_callback_t *callback, void *context);
 
 struct mailbox_transaction_context *
 mailbox_transaction_begin(struct mailbox *box, int hide);

Index: proxy-mailbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/proxy-mailbox.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- proxy-mailbox.c	21 Jun 2004 18:13:21 -0000	1.7
+++ proxy-mailbox.c	12 Jul 2004 11:35:51 -0000	1.8
@@ -32,19 +32,20 @@
 	return p->box->get_status(p->box, items, status);
 }
 
-static int _sync(struct mailbox *box, enum mailbox_sync_flags flags)
+static struct mailbox_sync_context *
+_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 {
 	struct proxy_mailbox *p = (struct proxy_mailbox *) box;
 
-	return p->box->sync(p->box, flags);
+	return p->box->sync_init(p->box, flags);
 }
 
-static void _auto_sync(struct mailbox *box, enum mailbox_sync_flags flags,
-		       unsigned int min_newmail_notify_interval)
+static void _notify_changes(struct mailbox *box, unsigned int min_interval,
+			    mailbox_notify_callback_t *callback, void *context)
 {
 	struct proxy_mailbox *p = (struct proxy_mailbox *) box;
 
-	p->box->auto_sync(p->box, flags, min_newmail_notify_interval);
+	return p->box->notify_changes(box, min_interval, callback, context);
 }
 
 static struct mail *_fetch(struct mailbox_transaction_context *t, uint32_t seq,
@@ -150,8 +151,10 @@
 	pb->allow_new_keywords = _allow_new_keywords;
 	pb->close = _close;
 	pb->get_status = _get_status;
-	pb->sync = _sync;
-	pb->auto_sync = _auto_sync;
+	pb->sync_init = _sync_init;
+	pb->sync_next = box->sync_next;
+	pb->sync_deinit = box->sync_deinit;
+	pb->notify_changes = _notify_changes;
 	pb->fetch = _fetch;
 	pb->get_uids = _get_uids;
 



More information about the dovecot-cvs mailing list