]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
plugins: Simplified code by using mailbox_allocated hook.
authorTimo Sirainen <tss@iki.fi>
Thu, 17 Dec 2009 18:33:45 +0000 (13:33 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 17 Dec 2009 18:33:45 +0000 (13:33 -0500)
--HG--
branch : HEAD

src/plugins/acl/acl-mailbox.c
src/plugins/acl/acl-plugin.c
src/plugins/acl/acl-plugin.h
src/plugins/acl/acl-storage.c
src/plugins/notify/notify-storage.c
src/plugins/quota/quota-plugin.c
src/plugins/quota/quota-plugin.h
src/plugins/quota/quota-storage.c

index 8214492cc5b323f361803fa4347fa6d13502369f..f395dc0626f0abd10482ccabd292aba7648fc244 100644 (file)
@@ -444,17 +444,15 @@ static int acl_mailbox_open(struct mailbox *box)
        return abox->module_ctx.super.open(box);
 }
 
-struct mailbox *
-acl_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
-                 const char *name, struct istream *input,
-                 enum mailbox_flags flags)
+void acl_mailbox_allocated(struct mailbox *box)
 {
-       union mail_storage_module_context *astorage = ACL_CONTEXT(storage);
-       struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(list);
+       struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
        struct acl_mailbox *abox;
-       struct mailbox *box;
 
-       box = astorage->super.mailbox_alloc(storage, list, name, input, flags);
+       if (alist == NULL) {
+               /* ACLs disabled */
+               return;
+       }
 
        abox = p_new(box->pool, struct acl_mailbox, 1);
        abox->module_ctx.super = box->v;
@@ -475,5 +473,4 @@ acl_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                box->v.transaction_commit = acl_transaction_commit;
        }
        MODULE_CONTEXT_SET(box, acl_storage_module, abox);
-       return box;
 }
index 8b8687512aa4d404a022292314b877a7d69f55d1..ff9ff9b9dfc53f4e26722ade7561954869c0e6a8 100644 (file)
@@ -11,8 +11,8 @@ const char *acl_plugin_version = PACKAGE_VERSION;
 
 static struct mail_storage_hooks acl_mail_storage_hooks = {
        .mail_user_created = acl_mail_user_created,
-       .mail_storage_created = acl_mail_storage_created,
-       .mail_namespace_storage_added = acl_mail_namespace_storage_added
+       .mail_namespace_storage_added = acl_mail_namespace_storage_added,
+       .mailbox_allocated = acl_mailbox_allocated
 };
 
 void acl_plugin_init(struct module *module)
index 5a35037d440a9b9883b04f030d967fa68a2d0fbd..457f95389ac32425cc9d2d5de6b6e1da4df9abfb 100644 (file)
@@ -39,14 +39,10 @@ extern MODULE_CONTEXT_DEFINE(acl_user_module, &mail_user_module_register);
 extern MODULE_CONTEXT_DEFINE(acl_mailbox_list_module,
                             &mailbox_list_module_register);
 
-void acl_mail_storage_created(struct mail_storage *storage);
 void acl_mail_namespace_storage_added(struct mail_namespace *ns);
 void acl_mail_user_created(struct mail_user *list);
 
-struct mailbox *
-acl_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
-                 const char *name, struct istream *input,
-                 enum mailbox_flags flags);
+void acl_mailbox_allocated(struct mailbox *box);
 
 struct acl_backend *acl_mailbox_list_get_backend(struct mailbox_list *list);
 int acl_mailbox_list_have_right(struct mailbox_list *list, const char *name,
index a36029df8e68a676ef7a12f4085edbbda42b6361..2b3fb353b94e045d2cbe909298f4dac49611253b 100644 (file)
@@ -16,23 +16,6 @@ struct acl_storage_module acl_storage_module =
 struct acl_user_module acl_user_module =
        MODULE_CONTEXT_INIT(&mail_user_module_register);
 
-void acl_mail_storage_created(struct mail_storage *storage)
-{
-       struct acl_user *auser = ACL_USER_CONTEXT(storage->user);
-       union mail_storage_module_context *astorage;
-
-       if (auser == NULL) {
-               /* ACLs disabled for this user */
-               return;
-       }
-
-       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)
 {
        struct acl_user *auser = ACL_USER_CONTEXT(user);
index 97faf848d5fe7d0932ed733d413f8d54e3967de9..93d64da9feeb22bb56998c773228f83cf50f4e22 100644 (file)
@@ -199,17 +199,10 @@ notify_transaction_rollback(struct mailbox_transaction_context *t)
        lbox->super.transaction_rollback(t);
 }
 
-static struct mailbox *
-notify_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
-                    const char *name, struct istream *input,
-                    enum mailbox_flags flags)
+static void notify_mailbox_allocated(struct mailbox *box)
 {
-       union mail_storage_module_context *lstorage = NOTIFY_CONTEXT(storage);
-       struct mailbox *box;
        union mailbox_module_context *lbox;
 
-       box = lstorage->super.mailbox_alloc(storage, list, name, input, flags);
-
        lbox = p_new(box->pool, union mailbox_module_context, 1);
        lbox->super = box->v;
 
@@ -221,7 +214,6 @@ notify_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        box->v.transaction_commit = notify_transaction_commit;
        box->v.transaction_rollback = notify_transaction_rollback;
        MODULE_CONTEXT_SET_SELF(box, notify_storage_module, lbox);
-       return box;
 }
 
 static int
@@ -255,17 +247,6 @@ notify_mailbox_list_rename(struct mailbox_list *oldlist, const char *oldname,
        return 0;
 }
 
-static void notify_mail_storage_created(struct mail_storage *storage)
-{
-       union mail_storage_module_context *lstorage;
-
-       lstorage = p_new(storage->pool, union mail_storage_module_context, 1);
-       lstorage->super = storage->v;
-       storage->v.mailbox_alloc = notify_mailbox_alloc;
-
-       MODULE_CONTEXT_SET_SELF(storage, notify_storage_module, lstorage);
-}
-
 static void notify_mail_namespace_storage_added(struct mail_namespace *ns)
 {
        struct mailbox_list *list = ns->list;
@@ -280,7 +261,7 @@ static void notify_mail_namespace_storage_added(struct mail_namespace *ns)
 }
 
 static struct mail_storage_hooks notify_mail_storage_hooks = {
-       .mail_storage_created = notify_mail_storage_created,
+       .mailbox_allocated = notify_mailbox_allocated,
        .mail_namespace_storage_added = notify_mail_namespace_storage_added
 };
 
index 184089b3da7bf16a454f6ced4845b257ac2f6197..27263156d88244684f484629d9a9960b4addb983 100644 (file)
@@ -12,8 +12,8 @@ const char *quota_plugin_version = PACKAGE_VERSION;
 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,
-       .mail_namespace_storage_added = quota_mail_namespace_storage_added
+       .mail_namespace_storage_added = quota_mail_namespace_storage_added,
+       .mailbox_allocated = quota_mailbox_allocated
 };
 
 void quota_plugin_init(struct module *module)
index 3686d12783096c64197435fb3ebdbe46b9456c1c..b2d9d66d17efa80872312905cf2ed2efbcba5636 100644 (file)
@@ -19,9 +19,9 @@ struct mail_storage;
 extern MODULE_CONTEXT_DEFINE(quota_user_module, &mail_user_module_register);
 
 void quota_mail_user_created(struct mail_user *user);
-void quota_mail_storage_created(struct mail_storage *storage);
 void quota_mail_namespace_storage_added(struct mail_namespace *ns);
 void quota_mail_namespaces_created(struct mail_namespace *namespaces);
+void quota_mailbox_allocated(struct mailbox *box);
 
 void quota_plugin_init(struct module *module);
 void quota_plugin_deinit(void);
index a7b2d49750aa18c2c4001fc69ed43af449334216..a629c22cb017aef7f1404411d1d309118c0a667b 100644 (file)
@@ -345,18 +345,12 @@ static void quota_mailbox_close(struct mailbox *box)
        qbox->module_ctx.super.close(box);
 }
 
-static struct mailbox *
-quota_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
-                   const char *name, struct istream *input,
-                   enum mailbox_flags flags)
+void quota_mailbox_allocated(struct mailbox *box)
 {
-       union mail_storage_module_context *qstorage = QUOTA_CONTEXT(storage);
-       struct mailbox *box;
        struct quota_mailbox *qbox;
 
-       box = qstorage->super.mailbox_alloc(storage, list, name, input, flags);
-       if (box == NULL || QUOTA_LIST_CONTEXT(list) == NULL)
-               return box;
+       if (QUOTA_LIST_CONTEXT(box->list) == NULL)
+               return;
 
        qbox = p_new(box->pool, struct quota_mailbox, 1);
        qbox->module_ctx.super = box->v;
@@ -372,7 +366,6 @@ quota_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        box->v.sync_deinit = quota_mailbox_sync_deinit;
        box->v.close = quota_mailbox_close;
        MODULE_CONTEXT_SET(box, quota_storage_module, qbox);
-       return box;
 }
 
 static int
@@ -488,17 +481,6 @@ void quota_mail_user_created(struct mail_user *user)
        }
 }
 
-void quota_mail_storage_created(struct mail_storage *storage)
-{
-       union mail_storage_module_context *qstorage;
-
-       qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
-       qstorage->super = storage->v;
-       storage->v.mailbox_alloc = quota_mailbox_alloc;
-
-       MODULE_CONTEXT_SET_SELF(storage, quota_storage_module, qstorage);
-}
-
 static struct quota_root *
 quota_find_root_for_ns(struct quota *quota, struct mail_namespace *ns)
 {