]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
next_hook should be called after our hook is finished with its doings, that
authorTimo Sirainen <tss@iki.fi>
Thu, 24 Apr 2008 22:31:05 +0000 (01:31 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 24 Apr 2008 22:31:05 +0000 (01:31 +0300)
way they get executed in the intended order. This should fix some problems
when multiple plugins are used.

--HG--
branch : HEAD

src/plugins/acl/acl-mailbox-list.c
src/plugins/acl/acl-storage.c
src/plugins/convert/convert-plugin.c
src/plugins/expire/expire-plugin.c
src/plugins/fts/fts-storage.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/mail-log/mail-log-plugin.c
src/plugins/mbox-snarf/mbox-snarf-plugin.c
src/plugins/quota/quota-storage.c
src/plugins/zlib/zlib-plugin.c

index bb06bbfdd7d1674432170d76bf7bdee5b7b7c376..6339682a402f823756b34a9fe197167b97d5aeeb 100644 (file)
@@ -387,9 +387,6 @@ void acl_mailbox_list_created(struct mailbox_list *list)
        const char *acl_env, *current_username, *owner_username;
        bool owner = TRUE;
 
-       if (acl_next_hook_mailbox_list_created != NULL)
-               acl_next_hook_mailbox_list_created(list);
-
        acl_env = getenv("ACL");
        i_assert(acl_env != NULL);
 
@@ -437,4 +434,7 @@ void acl_mailbox_list_created(struct mailbox_list *list)
        acl_storage_rights_ctx_init(&alist->rights, backend);
 
        MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist);
+
+       if (acl_next_hook_mailbox_list_created != NULL)
+               acl_next_hook_mailbox_list_created(list);
 }
index ba9e8e9406b2ac4ae49efafc43012a10b511923d..dcc82bb78cf31cde2d86f2fe6d3a63b4b033314c 100644 (file)
@@ -160,9 +160,6 @@ void acl_mail_storage_created(struct mail_storage *storage)
        struct acl_mail_storage *astorage;
        struct acl_backend *backend;
 
-       if (acl_next_hook_mail_storage_created != NULL)
-               acl_next_hook_mail_storage_created(storage);
-
        astorage = p_new(storage->pool, struct acl_mail_storage, 1);
        astorage->module_ctx.super = storage->v;
        storage->v.destroy = acl_storage_destroy;
@@ -173,5 +170,8 @@ void acl_mail_storage_created(struct mail_storage *storage)
        acl_storage_rights_ctx_init(&astorage->rights, backend);
 
        MODULE_CONTEXT_SET(storage, acl_storage_module, astorage);
+
+       if (acl_next_hook_mail_storage_created != NULL)
+               acl_next_hook_mail_storage_created(storage);
 }
 
index dcef7e5aff0c5c0b348db21428b0a4e2af2202ba..b01006a271578058916797fed7a4624e528ab40c 100644 (file)
@@ -12,19 +12,12 @@ const char *convert_plugin_version = PACKAGE_VERSION;
 static void (*convert_next_hook_mail_namespaces_created)
        (struct mail_namespace *namespaces);
 
-static void
-convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+static void convert_mail_storage(struct mail_namespace *namespaces,
+                                const char *convert_mail)
 {
-       const char *convert_mail, *str;
+       const char *str;
        struct convert_settings set;
 
-       if (convert_next_hook_mail_namespaces_created != NULL)
-               convert_next_hook_mail_namespaces_created(namespaces);
-
-       convert_mail = getenv("CONVERT_MAIL");
-       if (convert_mail == NULL)
-               return;
-
        memset(&set, 0, sizeof(set));
        set.user = getenv("USER");
        if (set.user == NULL)
@@ -44,6 +37,19 @@ convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
                i_fatal("Mailbox conversion failed, exiting");
 }
 
+static void
+convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+{
+       const char *convert_mail;
+
+       convert_mail = getenv("CONVERT_MAIL");
+       if (convert_mail != NULL)
+               convert_mail_storage(namespaces, convert_mail);
+
+       if (convert_next_hook_mail_namespaces_created != NULL)
+               convert_next_hook_mail_namespaces_created(namespaces);
+}
+
 void convert_plugin_init(void)
 {
        convert_next_hook_mail_namespaces_created =
index 0e19e22b6cbfaa1e1411aec55b692e7148d12f78..6d77ae19cedff2c48c4ec708d944b965fb5f8cc0 100644 (file)
@@ -271,15 +271,15 @@ static void expire_mail_storage_created(struct mail_storage *storage)
 {
        union mail_storage_module_context *xpr_storage;
 
-       if (expire.next_hook_mail_storage_created != NULL)
-               expire.next_hook_mail_storage_created(storage);
-
        xpr_storage =
                p_new(storage->pool, union mail_storage_module_context, 1);
        xpr_storage->super = storage->v;
        storage->v.mailbox_open = expire_mailbox_open;
 
        MODULE_CONTEXT_SET_SELF(storage, expire_storage_module, xpr_storage);
+
+       if (expire.next_hook_mail_storage_created != NULL)
+               expire.next_hook_mail_storage_created(storage);
 }
 
 void expire_plugin_init(void)
index 1108f59fcca4a87586dda7e89a513f1bae2c6662..55f68e9f2d1249d723da91d16095456b259b93a4 100644 (file)
@@ -659,17 +659,9 @@ static int fts_transaction_commit(struct mailbox_transaction_context *t,
        return ret;
 }
 
-void fts_mailbox_opened(struct mailbox *box)
+static void fts_mailbox_init(struct mailbox *box, const char *env)
 {
        struct fts_mailbox *fbox;
-       const char *env;
-
-       if (fts_next_hook_mailbox_opened != NULL)
-               fts_next_hook_mailbox_opened(box);
-
-       env = getenv("FTS");
-       if (env == NULL)
-               return;
 
        fbox = i_new(struct fts_mailbox, 1);
        fbox->env = env;
@@ -686,3 +678,15 @@ void fts_mailbox_opened(struct mailbox *box)
 
        MODULE_CONTEXT_SET(box, fts_storage_module, fbox);
 }
+
+void fts_mailbox_opened(struct mailbox *box)
+{
+       const char *env;
+
+       env = getenv("FTS");
+       if (env != NULL)
+               fts_mailbox_init(box, env);
+
+       if (fts_next_hook_mailbox_opened != NULL)
+               fts_next_hook_mailbox_opened(box);
+}
index ee1d6130df04c1d7a250c0adb451c9c1e736a6ee..98548f2d45eccc6bf6ebcfe10932cf8f5b22c27e 100644 (file)
@@ -472,7 +472,7 @@ lazy_expunge_mailbox_list_delete(struct mailbox_list *list, const char *name)
        return 0;
 }
 
-static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
+static void lazy_expunge_mail_storage_init(struct mail_storage *storage)
 {
        struct lazy_expunge_mailbox_list *llist =
                LAZY_EXPUNGE_LIST_CONTEXT(storage->list);
@@ -480,13 +480,6 @@ static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
        const char *const *p;
        unsigned int i;
 
-       if (lazy_expunge_next_hook_mail_storage_created != NULL)
-               lazy_expunge_next_hook_mail_storage_created(storage);
-
-       /* only maildir supported for now */
-       if (strcmp(storage->name, "maildir") != 0)
-               return;
-
        /* if this is one of our internal storages, mark it as such before
           quota plugin sees it */
        p = t_strsplit_spaces(getenv("LAZY_EXPUNGE"), " ");
@@ -506,6 +499,16 @@ static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
        MODULE_CONTEXT_SET(storage, lazy_expunge_mail_storage_module, lstorage);
 }
 
+static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
+{
+       /* only maildir supported for now */
+       if (strcmp(storage->name, "maildir") == 0)
+               lazy_expunge_mail_storage_init(storage);
+
+       if (lazy_expunge_next_hook_mail_storage_created != NULL)
+               lazy_expunge_next_hook_mail_storage_created(storage);
+}
+
 static void lazy_expunge_mailbox_list_created(struct mailbox_list *list)
 {
        struct lazy_expunge_mailbox_list *llist;
index 17643e43595efc2eea20aad7dec9d61eaf838f41..d7b86e113125c62fcf844101e733daaa3d1aad21 100644 (file)
@@ -499,29 +499,29 @@ static void mail_log_mail_storage_created(struct mail_storage *storage)
 {
        union mail_storage_module_context *lstorage;
 
-       if (mail_log_next_hook_mail_storage_created != NULL)
-               mail_log_next_hook_mail_storage_created(storage);
-
        lstorage = p_new(storage->pool, union mail_storage_module_context, 1);
        lstorage->super = storage->v;
        storage->v.mailbox_open = mail_log_mailbox_open;
 
        MODULE_CONTEXT_SET_SELF(storage, mail_log_storage_module, lstorage);
+
+       if (mail_log_next_hook_mail_storage_created != NULL)
+               mail_log_next_hook_mail_storage_created(storage);
 }
 
 static void mail_log_mailbox_list_created(struct mailbox_list *list)
 {
        union mailbox_list_module_context *llist;
 
-       if (mail_log_next_hook_mailbox_list_created != NULL)
-               mail_log_next_hook_mailbox_list_created(list);
-
        llist = p_new(list->pool, union mailbox_list_module_context, 1);
        llist->super = list->v;
        list->v.delete_mailbox = mail_log_mailbox_list_delete;
        list->v.rename_mailbox = mail_log_mailbox_list_rename;
 
        MODULE_CONTEXT_SET_SELF(list, mail_log_mailbox_list_module, llist);
+
+       if (mail_log_next_hook_mailbox_list_created != NULL)
+               mail_log_next_hook_mailbox_list_created(list);
 }
 
 static enum mail_log_field mail_log_parse_fields(const char *str)
index 11d1bd23cb001f3973c2fbfcac0432bc199e4672..53d0a9430da2a0aa1d267509565bfd98a59e514c 100644 (file)
@@ -164,9 +164,6 @@ static void mbox_snarf_mail_storage_created(struct mail_storage *storage)
 {
        struct mbox_snarf_mail_storage *mstorage;
 
-       if (mbox_snarf_next_hook_mail_storage_created != NULL)
-               mbox_snarf_next_hook_mail_storage_created(storage);
-
        mstorage = p_new(storage->pool, struct mbox_snarf_mail_storage, 1);
        mstorage->snarf_inbox_path =
                p_strdup(storage->pool, home_expand(getenv("MBOX_SNARF")));
@@ -174,6 +171,9 @@ static void mbox_snarf_mail_storage_created(struct mail_storage *storage)
        storage->v.mailbox_open = mbox_snarf_mailbox_open;
 
        MODULE_CONTEXT_SET(storage, mbox_snarf_storage_module, mstorage);
+
+       if (mbox_snarf_next_hook_mail_storage_created != NULL)
+               mbox_snarf_next_hook_mail_storage_created(storage);
 }
 
 void mbox_snarf_plugin_init(void)
index a0022eb58fbca9d13e398756f578da4d84517896..7aa6867ebdacca48a9358193583df9af3b1bb19e 100644 (file)
@@ -454,9 +454,6 @@ void quota_mail_storage_created(struct mail_storage *storage)
        struct quota_mailbox_list *qlist = QUOTA_LIST_CONTEXT(storage->list);
        union mail_storage_module_context *qstorage;
 
-       if (quota_next_hook_mail_storage_created != NULL)
-               quota_next_hook_mail_storage_created(storage);
-
        qlist->storage = storage;
 
        qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
@@ -471,18 +468,21 @@ void quota_mail_storage_created(struct mail_storage *storage)
                /* register to user's quota roots */
                quota_add_user_storage(quota_set, storage);
        }
+
+       if (quota_next_hook_mail_storage_created != NULL)
+               quota_next_hook_mail_storage_created(storage);
 }
 
 void quota_mailbox_list_created(struct mailbox_list *list)
 {
        struct quota_mailbox_list *qlist;
 
-       if (quota_next_hook_mailbox_list_created != NULL)
-               quota_next_hook_mailbox_list_created(list);
-
        qlist = p_new(list->pool, struct quota_mailbox_list, 1);
        qlist->module_ctx.super = list->v;
        list->v.delete_mailbox = quota_mailbox_list_delete;
 
        MODULE_CONTEXT_SET(list, quota_mailbox_list_module, qlist);
+
+       if (quota_next_hook_mailbox_list_created != NULL)
+               quota_next_hook_mailbox_list_created(list);
 }
index 6a4ce21d401731ba011500aacc558e0ad4dbc28d..41e0d0c54fa82b1be5827059f767ddd892e83154 100644 (file)
@@ -140,14 +140,14 @@ static void zlib_mail_storage_created(struct mail_storage *storage)
 {
        union mail_storage_module_context *qstorage;
 
-       if (zlib_next_hook_mail_storage_created != NULL)
-               zlib_next_hook_mail_storage_created(storage);
-
        qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
        qstorage->super = storage->v;
        storage->v.mailbox_open = zlib_mailbox_open;
 
        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)