]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mail_namespaces_added hook.
authorTimo Sirainen <tss@iki.fi>
Wed, 10 Apr 2013 11:13:51 +0000 (14:13 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 10 Apr 2013 11:13:51 +0000 (14:13 +0300)
src/lib-storage/mail-storage-hooks.c
src/lib-storage/mail-storage-hooks.h
src/lib-storage/mail-user.c

index fd8d9a6a30e6ed18719c7a8f6392afbdd96a1434..c553ca4132421ae51ab1fd43ef94dead81c1f08a 100644 (file)
@@ -281,6 +281,16 @@ void hook_mail_namespaces_created(struct mail_namespace *namespaces)
        }
 }
 
+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;
index 0cba2a08f4d7620d3bc8be55c6fab2671b4f4324..beb3fa2d04be6cde9d28f32031aaf71cb702b0f7 100644 (file)
@@ -12,7 +12,13 @@ struct mail;
 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 mail_storage_hooks_remove_internal(const struct mail_storage_hooks *hooks);
 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);
index b0ac752f92812f71fc0bec7527156b2882d696b8..ed10fc9a9fa6877fb9809fd7dd5668e75ff8c298 100644 (file)
@@ -258,6 +258,10 @@ void mail_user_add_namespace(struct mail_user *user,
                *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)