changeset 5465:014236cf3dcc HEAD

Moved notify settings to struct mailbox. Removed the parameters from notify_changes(), they're now set before calling it.
author Timo Sirainen <tss@iki.fi>
date Fri, 30 Mar 2007 21:41:05 +0300
parents 91b1f01b9307
children 8141168f86e1
files src/lib-storage/index/cydir/cydir-storage.c src/lib-storage/index/dbox/dbox-storage.c src/lib-storage/index/index-mailbox-check.c src/lib-storage/index/index-storage.h src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c
diffstat 8 files changed, 34 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/cydir/cydir-storage.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/cydir/cydir-storage.c	Fri Mar 30 21:41:05 2007 +0300
@@ -367,22 +367,14 @@
 	return 0;
 }
 
-static void
-cydir_notify_changes(struct mailbox *box, unsigned int min_interval,
-		     mailbox_notify_callback_t *callback, void *context)
+static void cydir_notify_changes(struct mailbox *box)
 {
 	struct cydir_mailbox *mbox = (struct cydir_mailbox *)box;
 
-	mbox->ibox.min_notify_interval = min_interval;
-	mbox->ibox.notify_callback = callback;
-	mbox->ibox.notify_context = context;
-
-	if (callback == NULL) {
+	if (box->notify_callback == NULL)
 		index_mailbox_check_remove_all(&mbox->ibox);
-		return;
-	}
-
-	index_mailbox_check_add(&mbox->ibox, mbox->path);
+	else
+		index_mailbox_check_add(&mbox->ibox, mbox->path);
 }
 
 static int cydir_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
--- a/src/lib-storage/index/dbox/dbox-storage.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-storage.c	Fri Mar 30 21:41:05 2007 +0300
@@ -502,22 +502,14 @@
 	return 0;
 }
 
-static void
-dbox_notify_changes(struct mailbox *box, unsigned int min_interval,
-		    mailbox_notify_callback_t *callback, void *context)
+static void dbox_notify_changes(struct mailbox *box)
 {
 	struct dbox_mailbox *mbox = (struct dbox_mailbox *)box;
 
-	mbox->ibox.min_notify_interval = min_interval;
-	mbox->ibox.notify_callback = callback;
-	mbox->ibox.notify_context = context;
-
-	if (callback == NULL) {
+	if (box->notify_callback == NULL)
 		index_mailbox_check_remove_all(&mbox->ibox);
-		return;
-	}
-
-	index_mailbox_check_add(&mbox->ibox, mbox->path);
+	else
+		index_mailbox_check_add(&mbox->ibox, mbox->path);
 }
 
 static int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
--- a/src/lib-storage/index/index-mailbox-check.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/index-mailbox-check.c	Fri Mar 30 21:41:05 2007 +0300
@@ -31,7 +31,7 @@
 	/* check changes only when we can also notify of new mail */
 	last_check = I_MAX(ibox->sync_last_check, ibox->notify_last_check);
 	if ((unsigned int)(ioloop_time - last_check) <
-	    ibox->min_notify_interval)
+	    ibox->box.notify_min_interval)
 		return;
 
 	ibox->notify_last_check = ioloop_time;
@@ -48,7 +48,7 @@
 	if (notify) {
 		ibox->notify_last_sent = ioloop_time;
 		ibox->notify_pending = FALSE;
-		ibox->notify_callback(&ibox->box, ibox->notify_context);
+		ibox->box.notify_callback(&ibox->box, ibox->box.notify_context);
 	}
 }
 
@@ -56,10 +56,10 @@
 {
 	ibox->notify_last_check = ioloop_time;
 	if ((unsigned int)(ioloop_time - ibox->notify_last_sent) >=
-	    ibox->min_notify_interval) {
+	    ibox->box.notify_min_interval) {
 		ibox->notify_last_sent = ioloop_time;
                 ibox->notify_pending = FALSE;
-		ibox->notify_callback(&ibox->box, ibox->notify_context);
+		ibox->box.notify_callback(&ibox->box, ibox->box.notify_context);
 	} else {
 		ibox->notify_pending = TRUE;
 	}
--- a/src/lib-storage/index/index-storage.h	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/index-storage.h	Fri Mar 30 21:41:05 2007 +0300
@@ -41,9 +41,6 @@
 	struct index_notify_file *notify_files;
         struct index_notify_io *notify_ios;
 	time_t notify_last_check, notify_last_sent;
-	unsigned int min_notify_interval;
-	mailbox_notify_callback_t *notify_callback;
-	void *notify_context;
 
 	time_t next_lock_notify; /* temporary */
 	enum mailbox_lock_notify_type last_notify_type;
--- a/src/lib-storage/index/maildir/maildir-storage.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Fri Mar 30 21:41:05 2007 +0300
@@ -876,25 +876,18 @@
 	return ret;
 }
 
-static void
-maildir_notify_changes(struct mailbox *box, unsigned int min_interval,
-		       mailbox_notify_callback_t *callback, void *context)
+static void maildir_notify_changes(struct mailbox *box)
 {
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
 
-	mbox->ibox.min_notify_interval = min_interval;
-	mbox->ibox.notify_callback = callback;
-	mbox->ibox.notify_context = context;
-
-	if (callback == NULL) {
+	if (box->notify_callback == NULL)
 		index_mailbox_check_remove_all(&mbox->ibox);
-		return;
+	else {
+		index_mailbox_check_add(&mbox->ibox,
+					t_strconcat(mbox->path, "/new", NULL));
+		index_mailbox_check_add(&mbox->ibox,
+					t_strconcat(mbox->path, "/cur", NULL));
 	}
-
-	index_mailbox_check_add(&mbox->ibox,
-		t_strconcat(mbox->path, "/new", NULL));
-	index_mailbox_check_add(&mbox->ibox,
-		t_strconcat(mbox->path, "/cur", NULL));
 }
 
 static int
--- a/src/lib-storage/index/mbox/mbox-storage.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Fri Mar 30 21:41:05 2007 +0300
@@ -784,17 +784,11 @@
 	return ret;
 }
 
-static void
-mbox_notify_changes(struct mailbox *box, unsigned int min_interval,
-		    mailbox_notify_callback_t *callback, void *context)
+static void mbox_notify_changes(struct mailbox *box)
 {
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)box;
 
-	mbox->ibox.min_notify_interval = min_interval;
-	mbox->ibox.notify_callback = callback;
-	mbox->ibox.notify_context = context;
-
-	if (callback == NULL)
+	if (box->notify_callback == NULL)
 		index_mailbox_check_remove_all(&mbox->ibox);
 	else if (!mbox->no_mbox_file)
 		index_mailbox_check_add(&mbox->ibox, mbox->path);
--- a/src/lib-storage/mail-storage-private.h	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/mail-storage-private.h	Fri Mar 30 21:41:05 2007 +0300
@@ -94,9 +94,7 @@
 			   enum mailbox_status_items status_items,
 			   struct mailbox_status *status_r);
 
-	void (*notify_changes)(struct mailbox *box, unsigned int min_interval,
-			       mailbox_notify_callback_t *callback,
-			       void *context);
+	void (*notify_changes)(struct mailbox *box);
 
 	struct mailbox_transaction_context *
 		(*transaction_begin)(struct mailbox *box,
@@ -167,6 +165,11 @@
 
 	unsigned int transaction_count;
 
+	/* Mailbox notification settings: */
+	unsigned int notify_min_interval;
+	mailbox_notify_callback_t *notify_callback;
+	void *notify_context;
+
 	/* Module-specific contexts. See mail_storage_module_id. */
 	ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
 
--- a/src/lib-storage/mail-storage.c	Fri Mar 30 21:31:57 2007 +0300
+++ b/src/lib-storage/mail-storage.c	Fri Mar 30 21:41:05 2007 +0300
@@ -489,12 +489,17 @@
 void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
 			    mailbox_notify_callback_t *callback, void *context)
 {
-	box->v.notify_changes(box, min_interval, callback, context);
+	box->notify_min_interval = min_interval;
+	box->notify_callback = callback;
+	box->notify_context = context;
+
+	box->v.notify_changes(box);
 }
 
 void mailbox_notify_changes_stop(struct mailbox *box)
 {
-	box->v.notify_changes(box, 0, NULL, NULL);
+
+	mailbox_notify_changes(box, 0, NULL, NULL);
 }
 
 struct mail_keywords *