dovecot-2.2: lib-storage: Added mail_namespaces_added hook.

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 10 14:17:49 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/3d8c08c19190
changeset: 16261:3d8c08c19190
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 10 14:13:51 2013 +0300
description:
lib-storage: Added mail_namespaces_added hook.

diffstat:

 src/lib-storage/mail-storage-hooks.c |  10 ++++++++++
 src/lib-storage/mail-storage-hooks.h |   7 +++++++
 src/lib-storage/mail-user.c          |   4 ++++
 3 files changed, 21 insertions(+), 0 deletions(-)

diffs (59 lines):

diff -r 52233547b371 -r 3d8c08c19190 src/lib-storage/mail-storage-hooks.c
--- a/src/lib-storage/mail-storage-hooks.c	Wed Apr 10 14:00:47 2013 +0300
+++ b/src/lib-storage/mail-storage-hooks.c	Wed Apr 10 14:13:51 2013 +0300
@@ -281,6 +281,16 @@
 	}
 }
 
+void hook_mail_namespaces_added(struct mail_namespace *namespaces)
+{
+	const struct mail_storage_hooks *const *hooks;
+
+	array_foreach(&namespaces->user->hooks, hooks) {
+		if ((*hooks)->mail_namespaces_added != NULL)
+			(*hooks)->mail_namespaces_added(namespaces);
+	}
+}
+
 void hook_mail_storage_created(struct mail_storage *storage)
 {
 	const struct mail_storage_hooks *const *hooks;
diff -r 52233547b371 -r 3d8c08c19190 src/lib-storage/mail-storage-hooks.h
--- a/src/lib-storage/mail-storage-hooks.h	Wed Apr 10 14:00:47 2013 +0300
+++ b/src/lib-storage/mail-storage-hooks.h	Wed Apr 10 14:13:51 2013 +0300
@@ -12,7 +12,13 @@
 struct mail_storage_hooks {
 	void (*mail_user_created)(struct mail_user *user);
 	void (*mail_namespace_storage_added)(struct mail_namespace *ns);
+	/* called the first time user's initial namespaces were added */
 	void (*mail_namespaces_created)(struct mail_namespace *namespaces);
+	/* called every time namespaces are added. most importantly called
+	   when shared mailbox accesses trigger creating new namespaces.
+	   this is called before mail_namespaces_created() at startup.
+	   The namespaces parameter contains all of the current namespaces. */
+	void (*mail_namespaces_added)(struct mail_namespace *namespaces);
 	void (*mail_storage_created)(struct mail_storage *storage);
 	void (*mailbox_list_created)(struct mailbox_list *list);
 	void (*mailbox_allocated)(struct mailbox *box);
@@ -37,6 +43,7 @@
 void hook_mail_user_created(struct mail_user *user);
 void hook_mail_namespace_storage_added(struct mail_namespace *ns);
 void hook_mail_namespaces_created(struct mail_namespace *namespaces);
+void hook_mail_namespaces_added(struct mail_namespace *namespaces);
 void hook_mail_storage_created(struct mail_storage *storage);
 void hook_mailbox_list_created(struct mailbox_list *list);
 void hook_mailbox_allocated(struct mailbox *box);
diff -r 52233547b371 -r 3d8c08c19190 src/lib-storage/mail-user.c
--- a/src/lib-storage/mail-user.c	Wed Apr 10 14:00:47 2013 +0300
+++ b/src/lib-storage/mail-user.c	Wed Apr 10 14:13:51 2013 +0300
@@ -258,6 +258,10 @@
 		*tmp = ns;
 	}
 	*namespaces = user->namespaces;
+
+	T_BEGIN {
+		hook_mail_namespaces_added(user->namespaces);
+	} T_END;
 }
 
 void mail_user_drop_useless_namespaces(struct mail_user *user)


More information about the dovecot-cvs mailing list