]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Plugin hook API changed to support per-user plugins within a process.
authorTimo Sirainen <tss@iki.fi>
Fri, 4 Dec 2009 22:15:51 +0000 (16:15 -0600)
committerTimo Sirainen <tss@iki.fi>
Fri, 4 Dec 2009 22:15:51 +0000 (16:15 -0600)
--HG--
branch : HEAD

59 files changed:
src/lib-storage/Makefile.am
src/lib-storage/list/index-mailbox-list-sync.c
src/lib-storage/list/index-mailbox-list.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-user.c
src/lib-storage/mail-user.h
src/lib-storage/mailbox-list-private.h
src/lib-storage/mailbox-list.c
src/lib/module-dir.c
src/lib/module-dir.h
src/lib/strfuncs.c
src/lib/strfuncs.h
src/plugins/acl/acl-mailbox-list.c
src/plugins/acl/acl-plugin.c
src/plugins/acl/acl-plugin.h
src/plugins/acl/acl-storage.c
src/plugins/autocreate/autocreate-plugin.c
src/plugins/autocreate/autocreate-plugin.h
src/plugins/convert/convert-plugin.c
src/plugins/convert/convert-plugin.h
src/plugins/expire/expire-plugin.c
src/plugins/expire/expire-plugin.h
src/plugins/fts-lucene/fts-lucene-plugin.c
src/plugins/fts-lucene/fts-lucene-plugin.h
src/plugins/fts-solr/fts-solr-plugin.c
src/plugins/fts-solr/fts-solr-plugin.h
src/plugins/fts-squat/fts-squat-plugin.c
src/plugins/fts-squat/fts-squat-plugin.h
src/plugins/fts/fts-plugin.c
src/plugins/fts/fts-plugin.h
src/plugins/fts/fts-storage.c
src/plugins/imap-acl/imap-acl-plugin.c
src/plugins/imap-acl/imap-acl-plugin.h
src/plugins/imap-quota/imap-quota-plugin.c
src/plugins/imap-quota/imap-quota-plugin.h
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/lazy-expunge/lazy-expunge-plugin.h
src/plugins/listescape/listescape-plugin.c
src/plugins/listescape/listescape-plugin.h
src/plugins/mail-log/mail-log-plugin.c
src/plugins/mail-log/mail-log-plugin.h
src/plugins/mbox-snarf/mbox-snarf-plugin.c
src/plugins/mbox-snarf/mbox-snarf-plugin.h
src/plugins/notify/notify-plugin-private.h
src/plugins/notify/notify-plugin.c
src/plugins/notify/notify-plugin.h
src/plugins/notify/notify-storage.c
src/plugins/quota/quota-plugin.c
src/plugins/quota/quota-plugin.h
src/plugins/quota/quota-storage.c
src/plugins/trash/trash-plugin.c
src/plugins/trash/trash-plugin.h
src/plugins/virtual/virtual-plugin.c
src/plugins/virtual/virtual-plugin.h
src/plugins/zlib/zlib-plugin.c
src/plugins/zlib/zlib-plugin.h

index ac9b4dbd82d75d452b3ff98cfc4c47faab6d40fe..dddc2924c91bf90b2e3a16f6cd421794f89f518a 100644 (file)
@@ -23,6 +23,7 @@ libstorage_la_SOURCES = \
        mail-search.c \
        mail-search-build.c \
        mail-storage.c \
+       mail-storage-hooks.c \
        mail-storage-settings.c \
        mail-thread.c \
        mail-user.c \
@@ -43,6 +44,7 @@ headers = \
        mail-thread.h \
        mail-storage.h \
        mail-storage-private.h \
+       mail-storage-hooks.h \
        mail-storage-service.h \
        mail-storage-settings.h \
        mail-user.h \
index 5543fa5dbc1a6af0edede18a25085983304246de..c64cf4a483b580b8dd78dd27aed7a4c4a57f468a 100644 (file)
@@ -42,8 +42,6 @@ static struct index_list_map index_list_map[] = {
        { NULL, 0, 0 }
 };
 
-static void (*index_list_next_hook_mailbox_created)(struct mailbox *box);
-
 static MODULE_CONTEXT_DEFINE_INIT(index_list_storage_module,
                                  &mail_storage_module_register);
 
@@ -363,9 +361,6 @@ static void index_list_mail_mailbox_allocated(struct mailbox *box)
                INDEX_LIST_CONTEXT(box->list);
        struct index_list_mailbox *ibox;
 
-       if (index_list_next_hook_mailbox_created != NULL)
-               index_list_next_hook_mailbox_created(box);
-
        if (ilist == NULL)
                return;
 
@@ -394,8 +389,11 @@ void index_mailbox_list_sync_init_list(struct mailbox_list *list)
        }
 }
 
+static struct mail_storage_hooks index_mailbox_list_sync_hooks = {
+       .mailbox_allocated = index_list_mail_mailbox_allocated
+};
+
 void index_mailbox_list_sync_init(void)
 {
-       index_list_next_hook_mailbox_created = hook_mailbox_allocated;
-       hook_mailbox_allocated = index_list_mail_mailbox_allocated;
+       mail_storage_hooks_add_internal(&index_mailbox_list_sync_hooks);
 }
index edb2e041992fe7aec82dd3e70335e267c091d553..9cae0ee1fd1074f4e63ff98124d94e5864a2fdec 100644 (file)
@@ -7,6 +7,7 @@
 #include "imap-match.h"
 #include "mail-index.h"
 #include "mail-storage.h"
+#include "mail-storage-hooks.h"
 #include "mailbox-tree.h"
 #include "mailbox-list-subscriptions.h"
 #include "mailbox-list-index.h"
@@ -21,7 +22,6 @@
 
 struct index_mailbox_list_module index_mailbox_list_module =
        MODULE_CONTEXT_INIT(&mailbox_list_module_register);
-static void (*index_next_hook_mailbox_list_created)(struct mailbox_list *list);
 
 static enum mailbox_info_flags
 index_mailbox_list_index_flags_translate(enum mailbox_list_index_flags flags)
@@ -533,12 +533,14 @@ static void index_mailbox_list_created(struct mailbox_list *list)
        }
 }
 
+static struct mail_storage_hooks index_mailbox_list_hooks = {
+       .mailbox_list_created = index_mailbox_list_created
+};
+
 void index_mailbox_list_init(void); /* called in mailbox-list-register.c */
 
 void index_mailbox_list_init(void)
 {
-       index_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = index_mailbox_list_created;
-
+       mail_storage_hooks_add_internal(&index_mailbox_list_hooks);
        index_mailbox_list_sync_init();
 }
index 3b0b22ad86c14efa892fba1d14ed52a0985e8eee..df4c7d84e58327927e80cfa66af258024e1bd6ab 100644 (file)
@@ -10,8 +10,6 @@
 
 #include <stdlib.h>
 
-void (*hook_mail_namespaces_created)(struct mail_namespace *namespaces);
-
 void mail_namespace_add_storage(struct mail_namespace *ns,
                                struct mail_storage *storage)
 {
@@ -260,11 +258,9 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r)
                }
                mail_user_add_namespace(user, &namespaces);
 
-               if (hook_mail_namespaces_created != NULL) {
-                       T_BEGIN {
-                               hook_mail_namespaces_created(namespaces);
-                       } T_END;
-               }
+               T_BEGIN {
+                       hook_mail_namespaces_created(namespaces);
+               } T_END;
                return 0;
        }
 
index 69a41950f437527d9337aaa633869a78edbf6a7f..1bb420810c2ea5446ba49669468e4c97c0505740 100644 (file)
@@ -66,9 +66,6 @@ struct mail_namespace {
        const struct mail_storage_settings *mail_set;
 };
 
-/* Called after namespaces has been created */
-extern void (*hook_mail_namespaces_created)(struct mail_namespace *namespaces);
-
 int mail_namespaces_init(struct mail_user *user, const char **error_r);
 struct mail_namespace *mail_namespaces_init_empty(struct mail_user *user);
 /* Deinitialize all namespaces. mail_user_deinit() calls this automatically
index 202bf6058cec16db68be0667664e0929849e8e28..b0ffd9bb84f34e1825a205e2442f32915f6e8b93 100644 (file)
@@ -4,6 +4,7 @@
 #include "module-context.h"
 #include "file-lock.h"
 #include "mail-storage.h"
+#include "mail-storage-hooks.h"
 #include "mail-storage-settings.h"
 #include "mail-index-private.h"
 
 /* Block size when read()ing message (header and) body. */
 #define MAIL_READ_FULL_BLOCK_SIZE (1024*8)
 
-/* Called after mail storage has been created */
-extern void (*hook_mail_storage_created)(struct mail_storage *storage);
-/* Called after mailbox has been allocated */
-extern void (*hook_mailbox_allocated)(struct mailbox *box);
-/* Called after mailbox index has been opened */
-extern void (*hook_mailbox_index_opened)(struct mailbox *box);
-
 struct mail_storage_module_register {
        unsigned int id;
 };
index b9dafb9deb96e0b81db53aabff728abb3fb6f95e..b06369367c94f73136e996b5bf68bf5d36a5715d 100644 (file)
@@ -23,15 +23,12 @@ struct mail_module_register mail_module_register = { 0 };
 struct mail_storage_mail_index_module mail_storage_mail_index_module =
        MODULE_CONTEXT_INIT(&mail_index_module_register);
 
-void (*hook_mail_storage_created)(struct mail_storage *storage);
-void (*hook_mailbox_allocated)(struct mailbox *box) = NULL;
-void (*hook_mailbox_index_opened)(struct mailbox *box) = NULL;
-
 ARRAY_TYPE(mail_storage) mail_storage_classes;
 
 void mail_storage_init(void)
 {
        mailbox_lists_init();
+       mail_storage_hooks_init();
        i_array_init(&mail_storage_classes, 8);
 }
 
@@ -39,6 +36,7 @@ void mail_storage_deinit(void)
 {
        if (array_is_created(&mail_storage_classes))
                array_free(&mail_storage_classes);
+       mail_storage_hooks_deinit();
        mailbox_lists_deinit();
 }
 
@@ -298,7 +296,7 @@ int mail_storage_create(struct mail_namespace *ns, const char *driver,
                return -1;
        }
 
-       if (hook_mail_storage_created != NULL) T_BEGIN {
+       T_BEGIN {
                hook_mail_storage_created(storage);
        } T_END;
 
@@ -466,8 +464,7 @@ struct mailbox *mailbox_alloc(struct mailbox_list *list, const char *name,
        T_BEGIN {
                box = storage->v.mailbox_alloc(storage, new_list,
                                               name, input, flags);
-               if (hook_mailbox_allocated != NULL)
-                       hook_mailbox_allocated(box);
+               hook_mailbox_allocated(box);
        } T_END;
        return box;
 }
index fd5ee2296410e60373774a8605c90a36c798b7b9..72cc61a157ca64cdcbd7f12ae1b74e25f09f7b6b 100644 (file)
@@ -22,8 +22,6 @@
 struct mail_user_module_register mail_user_module_register = { 0 };
 struct auth_master_connection *mail_user_auth_master_conn;
 
-void (*hook_mail_user_created)(struct mail_user *user) = NULL;
-
 static void mail_user_deinit_base(struct mail_user *user)
 {
        mail_namespaces_deinit(&user->namespaces);
@@ -107,8 +105,7 @@ int mail_user_init(struct mail_user *user, const char **error_r)
        user->mail_debug = mail_set->mail_debug;
 
        user->initialized = TRUE;
-       if (hook_mail_user_created != NULL)
-               hook_mail_user_created(user);
+       hook_mail_user_created(user);
        return 0;
 }
 
index 88ee81c77cd3b5eb3187d97ff4be3cf6277734fd..1593626f14aa61ededaa27a84f4edf0d01364493 100644 (file)
@@ -30,6 +30,7 @@ struct mail_user {
        struct mail_user_settings *set;
        struct mail_namespace *namespaces;
        struct mail_storage *storages;
+       ARRAY_DEFINE(hooks, const struct mail_storage_hooks *);
 
        /* Module-specific contexts. See mail_storage_module_id. */
        ARRAY_DEFINE(module_contexts, union mail_user_module_context *);
@@ -56,9 +57,6 @@ union mail_user_module_context {
 extern struct mail_user_module_register mail_user_module_register;
 extern struct auth_master_connection *mail_user_auth_master_conn;
 
-/* Called after user has been created */
-extern void (*hook_mail_user_created)(struct mail_user *user);
-
 struct mail_user *mail_user_alloc(const char *username,
                                  const struct setting_parser_info *set_info,
                                  const struct mail_user_settings *set);
index db75a592074ecb1ce2c41eb1e56e7f176507ed57..8eb47f03e0554d7fa3c4e5f396afdfcb3cee8857 100644 (file)
@@ -132,8 +132,6 @@ struct mailbox_list_iter_update_context {
    use objects' module_contexts[id] for their own purposes. */
 extern struct mailbox_list_module_register mailbox_list_module_register;
 
-extern void (*hook_mailbox_list_created)(struct mailbox_list *list);
-
 void mailbox_lists_init(void);
 void mailbox_lists_deinit(void);
 
index 774443a56a55610873df7c392a71ab6888e52719..86df9d8caf4af1d16f75e51180594272326658aa 100644 (file)
@@ -43,8 +43,6 @@ struct ns_list_iterate_context {
 
 struct mailbox_list_module_register mailbox_list_module_register = { 0 };
 
-void (*hook_mailbox_list_created)(struct mailbox_list *list);
-
 static ARRAY_DEFINE(mailbox_list_drivers, const struct mailbox_list *);
 
 void mailbox_lists_init(void)
@@ -168,8 +166,7 @@ int mailbox_list_create(const char *driver, struct mail_namespace *ns,
        }
        mail_namespace_finish_list_init(ns, list);
 
-       if (hook_mailbox_list_created != NULL)
-               hook_mailbox_list_created(list);
+       hook_mailbox_list_created(list);
        return 0;
 }
 
index ffe40a958d4f9693529be9d7b4c7ffa1cbcf19c8..06ce9a39466beaab14d2ba8bb2f87a7aacc2d4f5 100644 (file)
@@ -146,7 +146,7 @@ module_load(const char *path, const char *name, bool require_init_funcs,
        }
 
        /* get our init func */
-       module->init = (void (*)(void))
+       module->init = (void (*)(struct module *))
                get_symbol(module, t_strconcat(name, "_init", NULL),
                           !require_init_funcs);
        module->deinit = module->init == NULL ? NULL : (void (*)(void))
@@ -346,7 +346,7 @@ void module_dir_init(struct module *modules)
        for (module = modules; module != NULL; module = module->next) {
                if (module->init != NULL) {
                        T_BEGIN {
-                               module->init();
+                               module->init(module);
                        } T_END;
                }
        }
index 6846668b68bc1703860fb7a9106a0ca572a970ad..0f83a34f4fd2f4d8a0f81355cf0affb06d4e4cbe 100644 (file)
@@ -5,7 +5,7 @@ struct module {
        char *path, *name;
 
        void *handle;
-       void (*init)(void);
+       void (*init)(struct module *module);
        void (*deinit)(void);
 
         struct module *next;
index f072646fd7c6b50c67d35cc1fa3bc36522c3e569..b9f310b469461d34aa52c9c55b9cc508b7535395 100644 (file)
@@ -541,6 +541,15 @@ bool str_array_remove(const char **arr, const char *value)
        return FALSE;
 }
 
+bool str_array_find(const char *const *arr, const char *value)
+{
+       for (; *arr != NULL; arr++) {
+               if (strcmp(*arr, value) == 0)
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 bool str_array_icase_find(const char *const *arr, const char *value)
 {
        for (; *arr != NULL; arr++) {
index 63902bc35bf65a7b985ccb5889223e32c5490443..f6ed85c1ff35dbb6dfc58268c834ad1a39255a1c 100644 (file)
@@ -80,8 +80,9 @@ const char *t_strarray_join(const char *const *arr, const char *separator)
        ATTR_MALLOC;
 /* Removes a value from NULL-terminated string array. Returns TRUE if found. */
 bool str_array_remove(const char **arr, const char *value);
-/* Returns TRUE if value exists in NULL-terminated string array.
-   Strings are compared case-insensitively. */
+/* Returns TRUE if value exists in NULL-terminated string array. */
+bool str_array_find(const char *const *arr, const char *value);
+/* Like str_array_find(), but use strcasecmp(). */
 bool str_array_icase_find(const char *const *arr, const char *value);
 
 /* INTERNAL */
index f191f80fe0b3025f717c7c2ac743942ac8805bce..75397770236c36b60a71014d3388ccb5d6a03fb1 100644 (file)
@@ -620,7 +620,4 @@ void acl_mailbox_list_created(struct mailbox_list *list)
        } else {
                acl_mailbox_list_init_default(list);
        }
-
-       if (acl_next_hook_mailbox_list_created != NULL)
-               acl_next_hook_mailbox_list_created(list);
 }
index a7a2019bea33416da457f5edeec4eb5ae3af619f..9ac8645ea7f48c1e9d8f4cc55281b8122d3d7f55 100644 (file)
@@ -7,27 +7,20 @@
 
 #include <stdlib.h>
 
-void (*acl_next_hook_mail_storage_created)(struct mail_storage *storage);
-void (*acl_next_hook_mailbox_list_created)(struct mailbox_list *list);
-void (*acl_next_hook_mail_user_created)(struct mail_user *user);
-
 const char *acl_plugin_version = PACKAGE_VERSION;
 
-void acl_plugin_init(void)
-{
-       acl_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = acl_mail_storage_created;
-
-       acl_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = acl_mailbox_list_created;
+static struct mail_storage_hooks acl_mail_storage_hooks = {
+       .mail_user_created = acl_mail_user_created,
+       .mail_storage_created = acl_mail_storage_created,
+       .mailbox_list_created = acl_mailbox_list_created
+};
 
-       acl_next_hook_mail_user_created = hook_mail_user_created;
-       hook_mail_user_created = acl_mail_user_created;
+void acl_plugin_init(struct module *module)
+{
+       mail_storage_hooks_add(module, &acl_mail_storage_hooks);
 }
 
 void acl_plugin_deinit(void)
 {
-       hook_mail_storage_created = acl_next_hook_mail_storage_created;
-       hook_mailbox_list_created = acl_next_hook_mailbox_list_created;
-       hook_mail_user_created = acl_next_hook_mail_user_created;
+       mail_storage_hooks_remove(&acl_mail_storage_hooks);
 }
index ae5f233fe5663704a5683f3f5dc9b3c38ed3ef84..221bd68bbf85622bbf085e6c0a25eb7bbd4e7062 100644 (file)
@@ -34,9 +34,6 @@ struct acl_mailbox_list {
        struct acl_storage_rights_context rights;
 };
 
-extern void (*acl_next_hook_mail_storage_created)(struct mail_storage *storage);
-extern void (*acl_next_hook_mailbox_list_created)(struct mailbox_list *list);
-extern void (*acl_next_hook_mail_user_created)(struct mail_user *user);
 extern MODULE_CONTEXT_DEFINE(acl_storage_module, &mail_storage_module_register);
 extern MODULE_CONTEXT_DEFINE(acl_user_module, &mail_user_module_register);
 extern MODULE_CONTEXT_DEFINE(acl_mailbox_list_module,
@@ -56,7 +53,7 @@ int acl_mailbox_list_have_right(struct mailbox_list *list, const char *name,
                                bool parent, unsigned int acl_storage_right_idx,
                                bool *can_see_r);
 
-void acl_plugin_init(void);
+void acl_plugin_init(struct module *module);
 void acl_plugin_deinit(void);
 
 #endif
index 1d12835a2e22e59146fbc881ce27ce1ed4956ce1..a36029df8e68a676ef7a12f4085edbbda42b6361 100644 (file)
@@ -23,17 +23,14 @@ void acl_mail_storage_created(struct mail_storage *storage)
 
        if (auser == NULL) {
                /* ACLs disabled for this user */
-       } else {
-               astorage = p_new(storage->pool,
-                                union mail_storage_module_context, 1);
-               astorage->super = storage->v;
-               storage->v.mailbox_alloc = acl_mailbox_alloc;
-
-               MODULE_CONTEXT_SET_SELF(storage, acl_storage_module, astorage);
+               return;
        }
 
-       if (acl_next_hook_mail_storage_created != NULL)
-               acl_next_hook_mail_storage_created(storage);
+       astorage = p_new(storage->pool, union mail_storage_module_context, 1);
+       astorage->super = storage->v;
+       storage->v.mailbox_alloc = acl_mailbox_alloc;
+
+       MODULE_CONTEXT_SET_SELF(storage, acl_storage_module, astorage);
 }
 
 static void acl_user_deinit(struct mail_user *user)
@@ -76,7 +73,4 @@ void acl_mail_user_created(struct mail_user *user)
                if (user->mail_debug)
                        i_debug("acl: No acl setting - ACLs are disabled");
        }
-
-       if (acl_next_hook_mail_user_created != NULL)
-               acl_next_hook_mail_user_created(user);
 }
index e331be6c2789065c4718f819316539914a26659d..fdf9757c3b8f189bb0dbee20b5371b0b979b3395 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "mail-storage.h"
+#include "mail-storage-hooks.h"
 #include "mail-namespace.h"
 #include "autocreate-plugin.h"
 
@@ -9,9 +10,6 @@
 
 const char *autocreate_plugin_version = PACKAGE_VERSION;
 
-static void (*autocreate_next_hook_mail_namespaces_created)
-       (struct mail_namespace *ns);
-
 static void
 autocreate_mailbox(struct mail_namespace *namespaces, const char *name)
 {
@@ -102,20 +100,18 @@ autocreate_mail_namespaces_created(struct mail_namespace *namespaces)
 {
        autocreate_mailboxes(namespaces);
        autosubscribe_mailboxes(namespaces);
-
-       if (autocreate_next_hook_mail_namespaces_created != NULL)
-               autocreate_next_hook_mail_namespaces_created(namespaces);
 }
 
-void autocreate_plugin_init(void)
+static struct mail_storage_hooks autocreate_mail_storage_hooks = {
+       .mail_namespaces_created = autocreate_mail_namespaces_created
+};
+
+void autocreate_plugin_init(struct module *module)
 {
-       autocreate_next_hook_mail_namespaces_created =
-               hook_mail_namespaces_created;
-       hook_mail_namespaces_created = autocreate_mail_namespaces_created;
+       mail_storage_hooks_add(module, &autocreate_mail_storage_hooks);
 }
 
 void autocreate_plugin_deinit(void)
 {
-       hook_mail_namespaces_created =
-               autocreate_next_hook_mail_namespaces_created;
+       mail_storage_hooks_remove(&autocreate_mail_storage_hooks);
 }
index d24d801eac51f44086f67d0bc85b952e1265095e..59a363db3a731339d9462b3780c24cf6b9b2b7f4 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef AUTOCREATE_PLUGIN_H
 #define AUTOCREATE_PLUGIN_H
 
-void autocreate_plugin_init(void);
+void autocreate_plugin_init(struct module *module);
 void autocreate_plugin_deinit(void);
 
 #endif
index 1052892c36bc63ed6b6b491c16011adc133427a7..0ec468f943f55f73917816950a427b08daac863e 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "mail-namespace.h"
+#include "mail-storage-hooks.h"
 #include "convert-storage.h"
 #include "convert-plugin.h"
 
@@ -9,9 +10,6 @@
 
 const char *convert_plugin_version = PACKAGE_VERSION;
 
-static void (*convert_next_hook_mail_namespaces_created)
-       (struct mail_namespace *namespaces);
-
 static void convert_mail_storage(struct mail_namespace *namespaces,
                                 const char *convert_mail)
 {
@@ -38,7 +36,7 @@ static void convert_mail_storage(struct mail_namespace *namespaces,
 }
 
 static void
-convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+convert_mail_namespaces_created(struct mail_namespace *namespaces)
 {
        const char *convert_mail;
 
@@ -48,20 +46,18 @@ convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
                convert_mail_storage(namespaces, convert_mail);
        else if (namespaces->user->mail_debug)
                i_debug("convert: No convert_mail setting - plugin disabled");
-
-       if (convert_next_hook_mail_namespaces_created != NULL)
-               convert_next_hook_mail_namespaces_created(namespaces);
 }
 
-void convert_plugin_init(void)
+static struct mail_storage_hooks convert_mail_storage_hooks = {
+       .mail_namespaces_created = convert_mail_namespaces_created
+};
+
+void convert_plugin_init(struct module *module)
 {
-       convert_next_hook_mail_namespaces_created =
-               hook_mail_namespaces_created;
-       hook_mail_namespaces_created = convert_hook_mail_namespaces_created;
+       mail_storage_hooks_add(module, &convert_mail_storage_hooks);
 }
 
 void convert_plugin_deinit(void)
 {
-       hook_mail_namespaces_created =
-               convert_next_hook_mail_namespaces_created;
+       mail_storage_hooks_remove(&convert_mail_storage_hooks);
 }
index e8822b12c9b9456a4d1870a32e431ce0bd6e9b43..7df2ca1e37284ecdeaab5c35c9d7eefa91c902b5 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef CONVERT_PLUGIN_H
 #define CONVERT_PLUGIN_H
 
-void convert_plugin_init(void);
+void convert_plugin_init(struct module *module);
 void convert_plugin_deinit(void);
 
 #endif
index a2e3108d23a1d99fcb61ae15ce879ef9cf433306..611f431d386cac0d6e6d175babdcebc2e0bc340c 100644 (file)
@@ -43,9 +43,6 @@ struct expire_transaction_context {
 
 const char *expire_plugin_version = PACKAGE_VERSION;
 
-static void (*next_hook_mailbox_allocated)(struct mailbox *box);
-static void (*next_hook_mail_namespaces_created)(struct mail_namespace *ns);
-
 static MODULE_CONTEXT_DEFINE_INIT(expire_storage_module,
                                  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(expire_mail_module, &mail_module_register);
@@ -280,9 +277,6 @@ static void expire_mailbox_allocated(struct mailbox *box)
 
        if (euser != NULL)
                expire_mailbox_allocate_init(box, euser);
-
-       if (next_hook_mailbox_allocated != NULL)
-               next_hook_mailbox_allocated(box);
 }
 
 static void expire_mail_user_deinit(struct mail_user *user)
@@ -329,22 +323,19 @@ static void expire_mail_namespaces_created(struct mail_namespace *ns)
                else
                        MODULE_CONTEXT_SET(user, expire_mail_user_module, euser);
        }
-
-       if (next_hook_mail_namespaces_created != NULL)
-               next_hook_mail_namespaces_created(ns);
 }
 
-void expire_plugin_init(void)
-{
-       next_hook_mailbox_allocated = hook_mailbox_allocated;
-       hook_mailbox_allocated = expire_mailbox_allocated;
+static struct mail_storage_hooks expire_mail_storage_hooks = {
+       .mail_namespaces_created = expire_mail_namespaces_created,
+       .mailbox_allocated = expire_mailbox_allocated
+};
 
-       next_hook_mail_namespaces_created = hook_mail_namespaces_created;
-       hook_mail_namespaces_created = expire_mail_namespaces_created;
+void expire_plugin_init(struct module *module)
+{
+       mail_storage_hooks_add(module, &expire_mail_storage_hooks);
 }
 
 void expire_plugin_deinit(void)
 {
-       hook_mailbox_allocated = next_hook_mailbox_allocated;
-       hook_mail_namespaces_created = next_hook_mail_namespaces_created;
+       mail_storage_hooks_remove(&expire_mail_storage_hooks);
 }
index 827ab940d398ef8e9d51f209286f3de8390a55b8..9f46c0ac89107f3f01fab2e658cc68231d2396f8 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef EXPIRE_PLUGIN_H
 #define EXPIRE_PLUGIN_H
 
-void expire_plugin_init(void);
+void expire_plugin_init(struct module *module);
 void expire_plugin_deinit(void);
 
 #endif
index 7dd9420c5f0f92247528c5e2498a142c30da330a..4cd99941f7f4b4bce7151e858176d2f971d480df 100644 (file)
@@ -8,7 +8,7 @@ const char *fts_lucene_plugin_version = PACKAGE_VERSION;
 
 unsigned int fts_lucene_storage_module_id;
 
-void fts_lucene_plugin_init(void)
+void fts_lucene_plugin_init(struct module *module ATTR_UNUSED)
 {
        fts_backend_register(&fts_backend_lucene);
 }
index 66d68b2d685af2a48c938c2847d15053de6e75cf..2a371d0b1a9119a745c2a7b851fc6f3cb883ef52 100644 (file)
@@ -5,7 +5,7 @@
 
 extern struct fts_backend fts_backend_lucene;
 
-void fts_lucene_plugin_init(void);
+void fts_lucene_plugin_init(struct module *module);
 void fts_lucene_plugin_deinit(void);
 
 #endif
index bbff7cf1f6b01f4aac8f5d35681e35ebb4603f12..1e686fbd1c2ee1a75bebbc862c73f239af2f49ad 100644 (file)
@@ -3,13 +3,13 @@
 #include "lib.h"
 #include "array.h"
 #include "mail-user.h"
+#include "mail-storage-hooks.h"
 #include "fts-solr-plugin.h"
 
 #include <stdlib.h>
 
 const char *fts_solr_plugin_version = PACKAGE_VERSION;
 
-static void (*fts_solr_next_hook_mail_user_created)(struct mail_user *user);
 struct fts_solr_user_module fts_solr_user_module =
        MODULE_CONTEXT_INIT(&mail_user_module_register);
 
@@ -65,23 +65,22 @@ static void fts_solr_mail_user_created(struct mail_user *user)
        env = mail_user_plugin_getenv(user, "fts_solr");
        if (env != NULL)
                fts_solr_mail_user_create(user, env);
-
-       if (fts_solr_next_hook_mail_user_created != NULL)
-               fts_solr_next_hook_mail_user_created(user);
 }
 
-void fts_solr_plugin_init(void)
+static struct mail_storage_hooks fts_solr_mail_storage_hooks = {
+       .mail_user_created = fts_solr_mail_user_created
+};
+
+void fts_solr_plugin_init(struct module *module)
 {
        fts_backend_register(&fts_backend_solr);
-
-       fts_solr_next_hook_mail_user_created = hook_mail_user_created;
-       hook_mail_user_created = fts_solr_mail_user_created;
+       mail_storage_hooks_add(module, &fts_solr_mail_storage_hooks);
 }
 
 void fts_solr_plugin_deinit(void)
 {
        fts_backend_unregister(fts_backend_solr.name);
-       hook_mail_user_created = fts_solr_next_hook_mail_user_created;
+       mail_storage_hooks_remove(&fts_solr_mail_storage_hooks);
 }
 
 const char *fts_solr_plugin_dependencies[] = { "fts", NULL };
index 2069d131ff77123b64e5578aaa722cabfaa10088..aa2025704d0f3d4e9d5c31a9ebcc4d00340567fc 100644 (file)
@@ -22,7 +22,7 @@ extern const char *fts_solr_plugin_dependencies[];
 extern struct fts_backend fts_backend_solr;
 extern MODULE_CONTEXT_DEFINE(fts_solr_user_module, &mail_user_module_register);
 
-void fts_solr_plugin_init(void);
+void fts_solr_plugin_init(struct module *module);
 void fts_solr_plugin_deinit(void);
 
 #endif
index 2b88600768b8ad8ad04f547246a6674c63adf7ab..f3f15c48e8fc223ca52c4319ba370fdaf55448dd 100644 (file)
@@ -5,7 +5,7 @@
 
 const char *fts_squat_plugin_version = PACKAGE_VERSION;
 
-void fts_squat_plugin_init(void)
+void fts_squat_plugin_init(struct module *module ATTR_UNUSED)
 {
        fts_backend_register(&fts_backend_squat);
 }
index b37951189e95e3dba01c540d9e0d1bdd640c6a7a..0d6bfcbfe654a5207029d7bea03fe9f73d8650c8 100644 (file)
@@ -3,10 +3,12 @@
 
 #include "fts-api-private.h"
 
+struct module;
+
 extern const char *fts_squat_plugin_dependencies[];
 extern struct fts_backend fts_backend_squat;
 
-void fts_squat_plugin_init(void);
+void fts_squat_plugin_init(struct module *module);
 void fts_squat_plugin_deinit(void);
 
 #endif
index 2309237978ea4f210ad193ba95a3befadb26b713..80926dc332124590bea616aeeb8149326edb2a1f 100644 (file)
@@ -1,22 +1,23 @@
 /* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
-#include "mail-storage-private.h"
+#include "mail-storage-hooks.h"
 #include "fts-plugin.h"
 
 #include <stdlib.h>
 
 const char *fts_plugin_version = PACKAGE_VERSION;
 
-void (*fts_next_hook_mailbox_allocated)(struct mailbox *box);
+static struct mail_storage_hooks fts_mail_storage_hooks = {
+       .mailbox_allocated = fts_mailbox_allocated
+};
 
-void fts_plugin_init(void)
+void fts_plugin_init(struct module *module)
 {
-       fts_next_hook_mailbox_allocated = hook_mailbox_allocated;
-       hook_mailbox_allocated = fts_mailbox_allocated;
+       mail_storage_hooks_add(module, &fts_mail_storage_hooks);
 }
 
 void fts_plugin_deinit(void)
 {
-       hook_mailbox_allocated = fts_next_hook_mailbox_allocated;
+       mail_storage_hooks_remove(&fts_mail_storage_hooks);
 }
index 93fc68b1194452990d68f5931d64224d2317c0d8..13533dfd83b96f614a3afd336f4105a682650428 100644 (file)
@@ -1,11 +1,9 @@
 #ifndef FTS_PLUGIN_H
 #define FTS_PLUGIN_H
 
-extern void (*fts_next_hook_mailbox_allocated)(struct mailbox *box);
-
 void fts_mailbox_allocated(struct mailbox *box);
 
-void fts_plugin_init(void);
+void fts_plugin_init(struct module *module);
 void fts_plugin_deinit(void);
 
 #endif
index 4a6704e759ecd3de4b660b6b427a85a2f6665833..c7b3a7810db6f6572978701f18f836fd014f2145 100644 (file)
@@ -1050,7 +1050,4 @@ void fts_mailbox_allocated(struct mailbox *box)
        env = mail_user_plugin_getenv(box->storage->user, "fts");
        if (env != NULL)
                fts_mailbox_init(box, env);
-
-       if (fts_next_hook_mailbox_allocated != NULL)
-               fts_next_hook_mailbox_allocated(box);
 }
index aaefb1aaccbe252a8ee8bf81907e7c4786d52322..b1d5ecf4692731faa68e34b290a92ea69c9d9db9 100644 (file)
@@ -621,7 +621,7 @@ static void imap_acl_client_created(struct client **client)
                next_hook_client_created(client);
 }
 
-void imap_acl_plugin_init(void)
+void imap_acl_plugin_init(struct module *module ATTR_UNUSED)
 {
        command_register("LISTRIGHTS", cmd_listrights, 0);
        command_register("GETACL", cmd_getacl, 0);
index 71ce66b02855ad3922347a20689a7b2aaa07adf6..0435ac6331e6de0afb51d6116fedb03888c202c0 100644 (file)
@@ -3,7 +3,7 @@
 
 extern const char *imap_acl_plugin_dependencies[];
 
-void imap_acl_plugin_init(void);
+void imap_acl_plugin_init(struct module *module);
 void imap_acl_plugin_deinit(void);
 
 #endif
index 86ecd7330a825d55a491d199c36bbac0e91c280c..740849b7a7c6e0d3b62c5a20d792bafac6bb412d 100644 (file)
@@ -205,7 +205,7 @@ static void imap_quota_client_created(struct client **client)
                next_hook_client_created(client);
 }
 
-void imap_quota_plugin_init(void)
+void imap_quota_plugin_init(struct module *module ATTR_UNUSED)
 {
        command_register("GETQUOTAROOT", cmd_getquotaroot, 0);
        command_register("GETQUOTA", cmd_getquota, 0);
index 057e4f6acef7e469baa2c54cb03c1042704a5d05..dc0ed542a13e7957d23f156c96a47466a9e2c40b 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef IMAP_QUOTA_PLUGIN_H
 #define IMAP_QUOTA_PLUGIN_H
 
+struct module;
+
 extern const char *imap_quota_plugin_dependencies[];
 
-void imap_quota_plugin_init(void);
+void imap_quota_plugin_init(struct module *module);
 void imap_quota_plugin_deinit(void);
 
 #endif
index 38587b39157ef88bd289714203091874ce60fdca..d56a953c1b41e3f12e1d757c812aca8e3be81733 100644 (file)
@@ -59,13 +59,6 @@ struct lazy_expunge_transaction {
 
 const char *lazy_expunge_plugin_version = PACKAGE_VERSION;
 
-static void (*lazy_expunge_next_hook_mail_namespaces_created)
-       (struct mail_namespace *namespaces);
-static void (*lazy_expunge_next_hook_mailbox_allocated)(struct mailbox *box);
-static void (*lazy_expunge_next_hook_mailbox_list_created)
-       (struct mailbox_list *list);
-static void (*lazy_expunge_next_hook_mail_user_created)(struct mail_user *user);
-
 static MODULE_CONTEXT_DEFINE_INIT(lazy_expunge_mail_storage_module,
                                  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(lazy_expunge_mail_module,
@@ -254,9 +247,6 @@ static void lazy_expunge_mailbox_allocated(struct mailbox *box)
                MODULE_CONTEXT_SET_SELF(box, lazy_expunge_mail_storage_module,
                                        mbox);
        }
-
-       if (lazy_expunge_next_hook_mailbox_allocated != NULL)
-               lazy_expunge_next_hook_mailbox_allocated(box);
 }
 
 static int
@@ -377,13 +367,10 @@ static void lazy_expunge_mailbox_list_created(struct mailbox_list *list)
                MODULE_CONTEXT_SET(list, lazy_expunge_mailbox_list_module,
                                   llist);
        }
-
-       if (lazy_expunge_next_hook_mailbox_list_created != NULL)
-               lazy_expunge_next_hook_mailbox_list_created(list);
 }
 
 static void
-lazy_expunge_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+lazy_expunge_mail_namespaces_created(struct mail_namespace *namespaces)
 {
        struct lazy_expunge_mail_user *luser =
                LAZY_EXPUNGE_USER_CONTEXT(namespaces->user);
@@ -411,9 +398,6 @@ lazy_expunge_hook_mail_namespaces_created(struct mail_namespace *namespaces)
                llist = LAZY_EXPUNGE_LIST_CONTEXT(luser->lazy_ns[i]->list);
                llist->internal_namespace = TRUE;
        }
-
-       if (lazy_expunge_next_hook_mail_namespaces_created != NULL)
-               lazy_expunge_next_hook_mail_namespaces_created(namespaces);
 }
 
 static void lazy_expunge_mail_user_created(struct mail_user *user)
@@ -432,33 +416,21 @@ static void lazy_expunge_mail_user_created(struct mail_user *user)
                i_debug("lazy_expunge: No lazy_expunge setting - "
                        "plugin disabled");
        }
-
-       if (lazy_expunge_next_hook_mail_user_created != NULL)
-               lazy_expunge_next_hook_mail_user_created(user);
 }
 
-void lazy_expunge_plugin_init(void)
-{
-       lazy_expunge_next_hook_mail_namespaces_created =
-               hook_mail_namespaces_created;
-       hook_mail_namespaces_created =
-               lazy_expunge_hook_mail_namespaces_created;
-
-       lazy_expunge_next_hook_mailbox_allocated = hook_mailbox_allocated;
-       hook_mailbox_allocated = lazy_expunge_mailbox_allocated;
-
-       lazy_expunge_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = lazy_expunge_mailbox_list_created;
+static struct mail_storage_hooks lazy_expunge_mail_storage_hooks = {
+       .mail_user_created = lazy_expunge_mail_user_created,
+       .mail_namespaces_created = lazy_expunge_mail_namespaces_created,
+       .mailbox_list_created = lazy_expunge_mailbox_list_created,
+       .mailbox_allocated = lazy_expunge_mailbox_allocated
+};
 
-       lazy_expunge_next_hook_mail_user_created = hook_mail_user_created;
-       hook_mail_user_created = lazy_expunge_mail_user_created;
+void lazy_expunge_plugin_init(struct module *module)
+{
+       mail_storage_hooks_add(module, &lazy_expunge_mail_storage_hooks);
 }
 
 void lazy_expunge_plugin_deinit(void)
 {
-       hook_mail_namespaces_created =
-               lazy_expunge_hook_mail_namespaces_created;
-       hook_mailbox_allocated = lazy_expunge_next_hook_mailbox_allocated;
-       hook_mailbox_list_created = lazy_expunge_next_hook_mailbox_list_created;
-       hook_mail_user_created = lazy_expunge_next_hook_mail_user_created;
+       mail_storage_hooks_remove(&lazy_expunge_mail_storage_hooks);
 }
index a49326b7e6ac3089dcf859a989246d5dfc003edf..4875c69b62cf4b942b6b8cfdc9c2c1643bdbab5a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LAZY_EXPUNGE_PLUGIN_H
 #define TLAZY_EXPUNGE_PLUGIN_H
 
-void lazy_expunge_plugin_init(void);
+void lazy_expunge_plugin_init(struct module *module);
 void lazy_expunge_plugin_deinit(void);
 
 #endif
index 5ca6afedaa8bda70a3965268755de835a15ddd14..8cf3a00a9a1ad05825d3f1cb93b0a648e56b40d4 100644 (file)
@@ -32,11 +32,6 @@ struct listescape_mailbox_list {
 
 const char *listescape_plugin_version = PACKAGE_VERSION;
 
-static void (*listescape_next_hook_mail_storage_created)
-       (struct mail_storage *storage);
-static void (*listescape_next_hook_mailbox_list_created)
-       (struct mailbox_list *list);
-
 static MODULE_CONTEXT_DEFINE_INIT(listescape_storage_module,
                                  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(listescape_list_module,
@@ -299,9 +294,6 @@ static void listescape_mail_storage_created(struct mail_storage *storage)
 {
        struct listescape_mail_storage *mstorage;
 
-       if (listescape_next_hook_mail_storage_created != NULL)
-               listescape_next_hook_mail_storage_created(storage);
-
        mstorage = p_new(storage->pool, struct listescape_mail_storage, 1);
        mstorage->module_ctx.super = storage->v;
        storage->v.mailbox_alloc = listescape_mailbox_alloc;
@@ -314,9 +306,6 @@ static void listescape_mailbox_list_created(struct mailbox_list *list)
        struct listescape_mailbox_list *mlist;
        const char *env;
 
-       if (listescape_next_hook_mailbox_list_created != NULL)
-               listescape_next_hook_mailbox_list_created(list);
-
        if (list->hierarchy_sep == list->ns->sep)
                return;
 
@@ -342,17 +331,17 @@ static void listescape_mailbox_list_created(struct mailbox_list *list)
        MODULE_CONTEXT_SET(list, listescape_list_module, mlist);
 }
 
-void listescape_plugin_init(void)
-{
-       listescape_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = listescape_mail_storage_created;
+static struct mail_storage_hooks listescape_mail_storage_hooks = {
+       .mail_storage_created = listescape_mail_storage_created,
+       .mailbox_list_created = listescape_mailbox_list_created
+};
 
-       listescape_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = listescape_mailbox_list_created;
+void listescape_plugin_init(struct module *module)
+{
+       mail_storage_hooks_add(module, &listescape_mail_storage_hooks);
 }
 
 void listescape_plugin_deinit(void)
 {
-       hook_mail_storage_created = listescape_next_hook_mail_storage_created;
-       hook_mailbox_list_created = listescape_next_hook_mailbox_list_created;
+       mail_storage_hooks_remove(&listescape_mail_storage_hooks);
 }
index d088191dc185f822a5a6c627d91baf831b5afeb2..f8ff4fc5aed32f261ac27aedd97c9f7a36eb1ff3 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LISTESCAPE_PLUGIN_H
 #define LISTESCAPE_PLUGIN_H
 
-void listescape_plugin_init(void);
+void listescape_plugin_init(struct module *module);
 void listescape_plugin_deinit(void);
 
 #endif
index be5652ffaab62e6f170ac4a6b5bb7f2baefe203f..f379d6f63aefaed848d4f2b6025be4524a67ee7d 100644 (file)
@@ -420,7 +420,7 @@ static const struct notify_vfuncs mail_log_vfuncs = {
 
 static struct notify_context *mail_log_ctx;
 
-void mail_log_plugin_init(void)
+void mail_log_plugin_init(struct module *module ATTR_UNUSED)
 {
        mail_log_read_settings(&mail_log_set);
        mail_log_ctx = notify_register(&mail_log_vfuncs);
index face3ca39d1f64c5914092dce303ebb219c33baa..0af47ac7aea838c14a75dc6a2231dd235e3f294d 100644 (file)
@@ -3,7 +3,7 @@
 
 extern const char *mail_log_plugin_dependencies[];
 
-void mail_log_plugin_init(void);
+void mail_log_plugin_init(struct module *module);
 void mail_log_plugin_deinit(void);
 
 #endif
index aac7bfa389e3e1833261e2fd56409535f7eec3be..578d3092fe6a15d44157e140a478debf8d02031e 100644 (file)
@@ -28,9 +28,6 @@ struct mbox_snarf_mailbox {
 
 const char *mbox_snarf_plugin_version = PACKAGE_VERSION;
 
-static void (*mbox_snarf_next_hook_mail_storage_created)
-       (struct mail_storage *storage);
-
 static MODULE_CONTEXT_DEFINE_INIT(mbox_snarf_storage_module,
                                  &mail_storage_module_register);
 
@@ -190,18 +187,18 @@ static void mbox_snarf_mail_storage_created(struct mail_storage *storage)
        path = mail_user_plugin_getenv(storage->user, "mbox_snarf");
        if (path != NULL)
                mbox_snarf_mail_storage_create(storage, path);
-
-       if (mbox_snarf_next_hook_mail_storage_created != NULL)
-               mbox_snarf_next_hook_mail_storage_created(storage);
 }
 
-void mbox_snarf_plugin_init(void)
+static struct mail_storage_hooks mbox_snarf_mail_storage_hooks = {
+       .mail_storage_created = mbox_snarf_mail_storage_created
+};
+
+void mbox_snarf_plugin_init(struct module *module)
 {
-       mbox_snarf_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = mbox_snarf_mail_storage_created;
+       mail_storage_hooks_add(module, &mbox_snarf_mail_storage_hooks);
 }
 
 void mbox_snarf_plugin_deinit(void)
 {
-       hook_mail_storage_created = mbox_snarf_next_hook_mail_storage_created;
+       mail_storage_hooks_remove(&mbox_snarf_mail_storage_hooks);
 }
index f6cac265f6601f32c233e1afcc3e5f9c13e98ee4..6d82f0c60b5260450a36eb0c1c69ddc3a621ef00 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef MBOX_SNARF_PLUGIN_H
 #define MBOX_SNARF_PLUGIN_H
 
-void mbox_snarf_plugin_init(void);
+void mbox_snarf_plugin_init(struct module *module);
 void mbox_snarf_plugin_deinit(void);
 
 #endif
index d464cfe7aba680cec9b2fdc3f1638a16fc8d73d4..a5f0c529a9a849fb4d582560e3b9ec911585db5f 100644 (file)
@@ -24,7 +24,7 @@ void notify_contexts_mailbox_rename(struct mailbox_list *oldlist,
                                    struct mailbox_list *newlist,
                                    const char *newname, bool rename_children);
 
-void notify_plugin_init_storage(void);
+void notify_plugin_init_storage(struct module *module);
 void notify_plugin_deinit_storage(void);
 
 #endif
index ccd6f6f87445c0d7a2cba9fbbe9f2c4245b6c23a..779631691eca319bf3193942a73a72b0faee34b4 100644 (file)
@@ -199,9 +199,9 @@ void notify_unregister(struct notify_context *ctx)
        i_free(ctx);
 }
 
-void notify_plugin_init(void)
+void notify_plugin_init(struct module *module)
 {
-       notify_plugin_init_storage();
+       notify_plugin_init_storage(module);
 }
 
 void notify_plugin_deinit(void)
index f268897d5e5a669df9ba2acf1a3e6bffafd2bec9..560b22e3d48c287ec80a110d6811e3dbf173467f 100644 (file)
@@ -8,6 +8,7 @@ struct mail_storage;
 struct mailbox_transaction_context;
 struct mailbox_list;
 struct notify_context;
+struct module;
 
 struct notify_vfuncs {
        void *(*mail_transaction_begin)(struct mailbox_transaction_context *t);
@@ -57,7 +58,7 @@ struct notify_context *
 notify_register(const struct notify_vfuncs *vfuncs);
 void notify_unregister(struct notify_context *ctx);
 
-void notify_plugin_init(void);
+void notify_plugin_init(struct module *module);
 void notify_plugin_deinit(void);
 
 #endif
index b5bdea852b4e9b66589fa60a170e4abb18ac03ec..c24d8c2a8fb06d034f315266099be5f999adbc9d 100644 (file)
@@ -23,11 +23,6 @@ static MODULE_CONTEXT_DEFINE_INIT(notify_mail_module,
 static MODULE_CONTEXT_DEFINE_INIT(notify_mailbox_list_module,
                                  &mailbox_list_module_register);
 
-static void (*notify_next_hook_mail_storage_created)
-       (struct mail_storage *storage);
-static void (*notify_next_hook_mailbox_list_created)
-       (struct mailbox_list *list);
-
 static void
 notify_mail_expunge(struct mail *_mail)
 {
@@ -269,9 +264,6 @@ static void notify_mail_storage_created(struct mail_storage *storage)
        storage->v.mailbox_alloc = notify_mailbox_alloc;
 
        MODULE_CONTEXT_SET_SELF(storage, notify_storage_module, lstorage);
-
-       if (notify_next_hook_mail_storage_created != NULL)
-               notify_next_hook_mail_storage_created(storage);
 }
 
 static void notify_mailbox_list_created(struct mailbox_list *list)
@@ -284,22 +276,19 @@ static void notify_mailbox_list_created(struct mailbox_list *list)
        list->v.rename_mailbox = notify_mailbox_list_rename;
 
        MODULE_CONTEXT_SET_SELF(list, notify_mailbox_list_module, llist);
-
-       if (notify_next_hook_mailbox_list_created != NULL)
-               notify_next_hook_mailbox_list_created(list);
 }
 
-void notify_plugin_init_storage(void)
-{
-       notify_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = notify_mail_storage_created;
+static struct mail_storage_hooks notify_mail_storage_hooks = {
+       .mail_storage_created = notify_mail_storage_created,
+       .mailbox_list_created = notify_mailbox_list_created
+};
 
-       notify_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = notify_mailbox_list_created;
+void notify_plugin_init_storage(struct module *module)
+{
+       mail_storage_hooks_add(module, &notify_mail_storage_hooks);
 }
 
 void notify_plugin_deinit_storage(void)
 {
-       hook_mail_storage_created = notify_next_hook_mail_storage_created;
-       hook_mailbox_list_created = notify_next_hook_mailbox_list_created;
+       mail_storage_hooks_remove(&notify_mail_storage_hooks);
 }
index 44f3c96f58cdb1ee341cdf7032f865c484422624..89dec660c49c1c42b52c3cc7f8c953c58981dc6d 100644 (file)
@@ -1,42 +1,27 @@
 /* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
-#include "mail-storage.h"
-#include "mailbox-list-private.h"
-#include "quota.h"
+#include "mail-user.h"
+#include "mail-storage-hooks.h"
 #include "quota-plugin.h"
 
 #include <stdlib.h>
 
-/* defined by imap, pop3, lda */
-extern void (*hook_mail_storage_created)(struct mail_storage *storage);
-
-void (*quota_next_hook_mail_user_created)(struct mail_user *user);
-void (*quota_next_hook_mail_storage_created)(struct mail_storage *storage);
-void (*quota_next_hook_mailbox_list_created)(struct mailbox_list *list);
-void (*quota_next_hook_mail_namespaces_created)(struct mail_namespace *namespaces);
-
 const char *quota_plugin_version = PACKAGE_VERSION;
 
-void quota_plugin_init(void)
-{
-       quota_next_hook_mail_user_created = hook_mail_user_created;
-       hook_mail_user_created = quota_mail_user_created;
-
-       quota_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = quota_mail_storage_created;
-
-       quota_next_hook_mailbox_list_created = hook_mailbox_list_created;
-       hook_mailbox_list_created = quota_mailbox_list_created;
+static struct mail_storage_hooks quota_mail_storage_hooks = {
+       .mail_user_created = quota_mail_user_created,
+       .mail_namespaces_created = quota_mail_namespaces_created,
+       .mail_storage_created = quota_mail_storage_created,
+       .mailbox_list_created = quota_mailbox_list_created
+};
 
-       quota_next_hook_mail_namespaces_created = hook_mail_namespaces_created;
-       hook_mail_namespaces_created = quota_mail_namespaces_created;
+void quota_plugin_init(struct module *module)
+{
+       mail_storage_hooks_add(module, &quota_mail_storage_hooks);
 }
 
 void quota_plugin_deinit(void)
 {
-       hook_mail_user_created = quota_next_hook_mail_user_created;
-       hook_mail_storage_created = quota_next_hook_mail_storage_created;
-       hook_mailbox_list_created = quota_next_hook_mailbox_list_created;
-       hook_mail_namespaces_created = quota_next_hook_mail_namespaces_created;
+       mail_storage_hooks_remove(&quota_mail_storage_hooks);
 }
index 24edb9f1ccc3d757e62b0901e8980bee195976a0..2b0268ecdd9e94aaab15bfea7c8ad73c51b98c18 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "module-context.h"
 
+struct module;
+
 #define QUOTA_USER_CONTEXT(obj) \
        MODULE_CONTEXT(obj, quota_user_module)
 
@@ -14,11 +16,6 @@ struct quota_user {
 
 struct mail_storage;
 
-extern void (*quota_next_hook_mail_user_created)(struct mail_user *user);
-extern void (*quota_next_hook_mail_storage_created)
-       (struct mail_storage *storage);
-extern void (*quota_next_hook_mailbox_list_created)(struct mailbox_list *list);
-
 extern MODULE_CONTEXT_DEFINE(quota_user_module, &mail_user_module_register);
 
 void quota_mail_user_created(struct mail_user *user);
@@ -26,7 +23,7 @@ void quota_mail_storage_created(struct mail_storage *storage);
 void quota_mailbox_list_created(struct mailbox_list *list);
 void quota_mail_namespaces_created(struct mail_namespace *namespaces);
 
-void quota_plugin_init(void);
+void quota_plugin_init(struct module *module);
 void quota_plugin_deinit(void);
 
 #endif
index a8225aa1a5e5c375e9163a0af320eb7c1e1d96d2..4b9db099995f644be94a2ff9009e7d25809e21d3 100644 (file)
@@ -487,9 +487,6 @@ void quota_mail_user_created(struct mail_user *user)
        } else if (user->mail_debug) {
                i_debug("quota: No quota setting - plugin disabled");
        }
-
-       if (quota_next_hook_mail_user_created != NULL)
-               quota_next_hook_mail_user_created(user);
 }
 
 static void quota_maildir_storage_set(struct mail_storage *storage)
@@ -514,9 +511,6 @@ void quota_mail_storage_created(struct mail_storage *storage)
 
        MODULE_CONTEXT_SET_SELF(storage, quota_storage_module, qstorage);
        quota_maildir_storage_set(storage);
-
-       if (quota_next_hook_mail_storage_created != NULL)
-               quota_next_hook_mail_storage_created(storage);
 }
 
 static struct quota_root *
@@ -568,8 +562,6 @@ void quota_mailbox_list_created(struct mailbox_list *list)
                        quota_get_mail_user_quota(list->ns->user);
                quota_add_user_namespace(quota, list->ns);
        }
-       if (quota_next_hook_mailbox_list_created != NULL)
-               quota_next_hook_mailbox_list_created(list);
 }
 
 static void quota_root_set_namespace(struct quota_root *root,
index a6a91f06c70b5df9af2996ebe68ccbcff31260ba..e4380ecbdae53ccc6f68bfb61fb21d9647b92375 100644 (file)
@@ -45,8 +45,6 @@ const char *trash_plugin_version = PACKAGE_VERSION;
 
 static MODULE_CONTEXT_DEFINE_INIT(trash_user_module,
                                  &mail_user_module_register);
-static void (*trash_next_hook_mail_namespaces_created)
-       (struct mail_namespace *namespaces);
 static int (*trash_next_quota_test_alloc)(struct quota_transaction_context *,
                                          uoff_t, bool *);
 
@@ -294,7 +292,7 @@ static int read_configuration(struct mail_user *user, const char *path)
 }
 
 static void
-trash_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+trash_mail_namespaces_created(struct mail_namespace *namespaces)
 {
        struct mail_user *user = namespaces->user;
        struct quota_user *quser = QUOTA_USER_CONTEXT(user);
@@ -318,20 +316,20 @@ trash_hook_mail_namespaces_created(struct mail_namespace *namespaces)
                        quser->quota->set->test_alloc = trash_quota_test_alloc;
                }
        }
-
-       if (trash_next_hook_mail_namespaces_created != NULL)
-               trash_next_hook_mail_namespaces_created(namespaces);
 }
 
-void trash_plugin_init(void)
+static struct mail_storage_hooks trash_mail_storage_hooks = {
+       .mail_namespaces_created = trash_mail_namespaces_created
+};
+
+void trash_plugin_init(struct module *module)
 {
-       trash_next_hook_mail_namespaces_created = hook_mail_namespaces_created;
-       hook_mail_namespaces_created = trash_hook_mail_namespaces_created;
+       mail_storage_hooks_add(module, &trash_mail_storage_hooks);
 }
 
 void trash_plugin_deinit(void)
 {
-       hook_mail_namespaces_created = trash_hook_mail_namespaces_created;
+       mail_storage_hooks_remove(&trash_mail_storage_hooks);
 }
 
 const char *trash_plugin_dependencies[] = { "quota", NULL };
index 6d9873f3fb5951b9eb361e2e7c357f3a9057dc6c..bd6db6bfd2870ef67b9a9d3f1b8a61f62da072fa 100644 (file)
@@ -3,7 +3,7 @@
 
 extern const char *trash_plugin_dependencies[];
 
-void trash_plugin_init(void);
+void trash_plugin_init(struct module *module);
 void trash_plugin_deinit(void);
 
 #endif
index c5ed5f40d2690b8b43740d5601f895e9a265d890..0e678fe4060acccebf539bba5d03f0d907288231 100644 (file)
@@ -7,7 +7,7 @@
 
 const char *virtual_plugin_version = PACKAGE_VERSION;
 
-void virtual_plugin_init(void)
+void virtual_plugin_init(struct module *module ATTR_UNUSED)
 {
        mail_storage_class_register(&virtual_storage);
 }
index 59b5c7a2a6f28010a5e03b222c9282771bcae3f5..39f04bbc07318535144c83a04468b3ab77c73506 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef VIRTUAL_PLUGIN_H
 #define VIRTUAL_PLUGIN_H
 
-void virtual_plugin_init(void);
+void virtual_plugin_init(struct module *module);
 void virtual_plugin_deinit(void);
 
 #endif
index c196408ebedcec0d0f30b0b3c075608bf13f48ab..e87307400a04ada1c33c59e61486c279488e17d8 100644 (file)
@@ -37,9 +37,6 @@ struct zlib_transaction_context {
 
 const char *zlib_plugin_version = PACKAGE_VERSION;
 
-static void (*zlib_next_hook_mail_storage_created)
-       (struct mail_storage *storage);
-
 static MODULE_CONTEXT_DEFINE_INIT(zlib_storage_module,
                                  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(zlib_mail_module, &mail_module_register);
@@ -333,18 +330,18 @@ static void zlib_mail_storage_created(struct mail_storage *storage)
        storage->v.mailbox_alloc = zlib_mailbox_alloc;
 
        MODULE_CONTEXT_SET_SELF(storage, zlib_storage_module, qstorage);
-
-       if (zlib_next_hook_mail_storage_created != NULL)
-               zlib_next_hook_mail_storage_created(storage);
 }
 
-void zlib_plugin_init(void)
+static struct mail_storage_hooks zlib_mail_storage_hooks = {
+       .mail_storage_created = zlib_mail_storage_created
+};
+
+void zlib_plugin_init(struct module *module)
 {
-       zlib_next_hook_mail_storage_created = hook_mail_storage_created;
-       hook_mail_storage_created = zlib_mail_storage_created;
+       mail_storage_hooks_add(module, &zlib_mail_storage_hooks);
 }
 
 void zlib_plugin_deinit(void)
 {
-       hook_mail_storage_created = zlib_next_hook_mail_storage_created;
+       mail_storage_hooks_remove(&zlib_mail_storage_hooks);
 }
index 809c8842247225d5c9dbb807a11ac1bca639618e..98f520d9b789d370cbe2894d0983a5d2b8e4df4e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ZLIB_PLUGIN_H
 #define ZLIB_PLUGIN_H
 
-void zlib_plugin_init(void);
+void zlib_plugin_init(struct module *module);
 void zlib_plugin_deinit(void);
 
 #endif