Mercurial > dovecot > core-2.2
changeset 10515:8e9e67a94e16 HEAD
plugins: Simplified code by using mailbox_allocated hook.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 17 Dec 2009 13:33:45 -0500 |
parents | 55baae8ed874 |
children | bb04510465d3 |
files | 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 |
diffstat | 8 files changed, 17 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/acl/acl-mailbox.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/acl/acl-mailbox.c Thu Dec 17 13:33:45 2009 -0500 @@ -444,17 +444,15 @@ 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 @@ box->v.transaction_commit = acl_transaction_commit; } MODULE_CONTEXT_SET(box, acl_storage_module, abox); - return box; }
--- a/src/plugins/acl/acl-plugin.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/acl/acl-plugin.c Thu Dec 17 13:33:45 2009 -0500 @@ -11,8 +11,8 @@ 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)
--- a/src/plugins/acl/acl-plugin.h Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/acl/acl-plugin.h Thu Dec 17 13:33:45 2009 -0500 @@ -39,14 +39,10 @@ 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,
--- a/src/plugins/acl/acl-storage.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/acl/acl-storage.c Thu Dec 17 13:33:45 2009 -0500 @@ -16,23 +16,6 @@ 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);
--- a/src/plugins/notify/notify-storage.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/notify/notify-storage.c Thu Dec 17 13:33:45 2009 -0500 @@ -199,17 +199,10 @@ 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 @@ 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 @@ 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 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 };
--- a/src/plugins/quota/quota-plugin.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/quota/quota-plugin.c Thu Dec 17 13:33:45 2009 -0500 @@ -12,8 +12,8 @@ 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)
--- a/src/plugins/quota/quota-plugin.h Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/quota/quota-plugin.h Thu Dec 17 13:33:45 2009 -0500 @@ -19,9 +19,9 @@ 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);
--- a/src/plugins/quota/quota-storage.c Wed Dec 16 22:50:36 2009 -0500 +++ b/src/plugins/quota/quota-storage.c Thu Dec 17 13:33:45 2009 -0500 @@ -345,18 +345,12 @@ 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 @@ 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_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) {