Mercurial > dovecot > core-2.2
changeset 10484:43895027cab9 HEAD
plugins: Use mail_namespace_storage_added hook instead of mailbox_list_created.
In mailbox_list_created the storage hasn't yet overridden the list functions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 14 Dec 2009 14:32:01 -0500 |
parents | bc9dbd257811 |
children | b2f31df5f5da |
files | src/plugins/acl/acl-mailbox-list.c src/plugins/acl/acl-plugin.c src/plugins/acl/acl-plugin.h src/plugins/lazy-expunge/lazy-expunge-plugin.c src/plugins/listescape/listescape-plugin.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 | 9 files changed, 36 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/acl/acl-mailbox-list.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/acl/acl-mailbox-list.c Mon Dec 14 14:32:01 2009 -0500 @@ -607,17 +607,17 @@ MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist); } -void acl_mailbox_list_created(struct mailbox_list *list) +void acl_mail_namespace_storage_added(struct mail_namespace *ns) { - struct acl_user *auser = ACL_USER_CONTEXT(list->ns->user); + struct acl_user *auser = ACL_USER_CONTEXT(ns->user); if (auser == NULL) { /* ACLs disabled for this user */ - } else if ((list->ns->flags & NAMESPACE_FLAG_NOACL) != 0) { + } else if ((ns->flags & NAMESPACE_FLAG_NOACL) != 0) { /* no ACL checks for internal namespaces (lda, shared) */ - if (list->ns->type == NAMESPACE_SHARED) - acl_mailbox_list_init_shared(list); + if (ns->type == NAMESPACE_SHARED) + acl_mailbox_list_init_shared(ns->list); } else { - acl_mailbox_list_init_default(list); + acl_mailbox_list_init_default(ns->list); } }
--- a/src/plugins/acl/acl-plugin.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/acl/acl-plugin.c Mon Dec 14 14:32:01 2009 -0500 @@ -12,7 +12,7 @@ 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 + .mail_namespace_storage_added = acl_mail_namespace_storage_added }; void acl_plugin_init(struct module *module)
--- a/src/plugins/acl/acl-plugin.h Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/acl/acl-plugin.h Mon Dec 14 14:32:01 2009 -0500 @@ -40,7 +40,7 @@ &mailbox_list_module_register); void acl_mail_storage_created(struct mail_storage *storage); -void acl_mailbox_list_created(struct mailbox_list *list); +void acl_mail_namespace_storage_added(struct mail_namespace *ns); void acl_mail_user_created(struct mail_user *list); struct mailbox *
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Mon Dec 14 14:32:01 2009 -0500 @@ -341,10 +341,11 @@ return 0; } -static void lazy_expunge_mailbox_list_created(struct mailbox_list *list) +static void lazy_expunge_mail_namespace_storage_added(struct mail_namespace *ns) { + struct mailbox_list *list = ns->list; struct lazy_expunge_mail_user *luser = - LAZY_EXPUNGE_USER_CONTEXT(list->ns->user); + LAZY_EXPUNGE_USER_CONTEXT(ns->user); struct lazy_expunge_mailbox_list *llist; const char *const *p; unsigned int i; @@ -353,13 +354,13 @@ quota plugin sees it */ p = t_strsplit_spaces(luser->env, " "); for (i = 0; i < LAZY_NAMESPACE_COUNT; i++, p++) { - if (strcmp(list->ns->prefix, *p) == 0) { - list->ns->flags |= NAMESPACE_FLAG_NOQUOTA; + if (strcmp(ns->prefix, *p) == 0) { + ns->flags |= NAMESPACE_FLAG_NOQUOTA; break; } } - if (luser != NULL && list->ns->type == NAMESPACE_PRIVATE) { + if (luser != NULL && ns->type == NAMESPACE_PRIVATE) { llist = p_new(list->pool, struct lazy_expunge_mailbox_list, 1); llist->module_ctx.super = list->v; list->v.delete_mailbox = lazy_expunge_mailbox_list_delete; @@ -421,7 +422,7 @@ 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, + .mail_namespace_storage_added = lazy_expunge_mail_namespace_storage_added, .mailbox_allocated = lazy_expunge_mailbox_allocated };
--- a/src/plugins/listescape/listescape-plugin.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/listescape/listescape-plugin.c Mon Dec 14 14:32:01 2009 -0500 @@ -301,15 +301,16 @@ MODULE_CONTEXT_SET(storage, listescape_storage_module, mstorage); } -static void listescape_mailbox_list_created(struct mailbox_list *list) +static void listescape_mail_namespace_storage_added(struct mail_namespace *ns) { + struct mailbox_list *list = ns->list; struct listescape_mailbox_list *mlist; const char *env; - if (list->hierarchy_sep == list->ns->sep) + if (list->hierarchy_sep == ns->sep) return; - list->ns->real_sep = list->ns->sep; + ns->real_sep = ns->sep; mlist = p_new(list->pool, struct listescape_mailbox_list, 1); mlist->module_ctx.super = list->v; @@ -333,7 +334,7 @@ static struct mail_storage_hooks listescape_mail_storage_hooks = { .mail_storage_created = listescape_mail_storage_created, - .mailbox_list_created = listescape_mailbox_list_created + .mail_namespace_storage_added = listescape_mail_namespace_storage_added }; void listescape_plugin_init(struct module *module)
--- a/src/plugins/notify/notify-storage.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/notify/notify-storage.c Mon Dec 14 14:32:01 2009 -0500 @@ -266,8 +266,9 @@ MODULE_CONTEXT_SET_SELF(storage, notify_storage_module, lstorage); } -static void notify_mailbox_list_created(struct mailbox_list *list) +static void notify_mail_namespace_storage_added(struct mail_namespace *ns) { + struct mailbox_list *list = ns->list; union mailbox_list_module_context *llist; llist = p_new(list->pool, union mailbox_list_module_context, 1); @@ -280,7 +281,7 @@ static struct mail_storage_hooks notify_mail_storage_hooks = { .mail_storage_created = notify_mail_storage_created, - .mailbox_list_created = notify_mailbox_list_created + .mail_namespace_storage_added = notify_mail_namespace_storage_added }; void notify_plugin_init_storage(struct module *module)
--- a/src/plugins/quota/quota-plugin.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/quota/quota-plugin.c Mon Dec 14 14:32:01 2009 -0500 @@ -13,7 +13,7 @@ .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 + .mail_namespace_storage_added = quota_mail_namespace_storage_added }; void quota_plugin_init(struct module *module)
--- a/src/plugins/quota/quota-plugin.h Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/quota/quota-plugin.h Mon Dec 14 14:32:01 2009 -0500 @@ -20,7 +20,7 @@ void quota_mail_user_created(struct mail_user *user); void quota_mail_storage_created(struct mail_storage *storage); -void quota_mailbox_list_created(struct mailbox_list *list); +void quota_mail_namespace_storage_added(struct mail_namespace *ns); void quota_mail_namespaces_created(struct mail_namespace *namespaces); void quota_plugin_init(struct module *module);
--- a/src/plugins/quota/quota-storage.c Mon Dec 14 14:30:44 2009 -0500 +++ b/src/plugins/quota/quota-storage.c Mon Dec 14 14:32:01 2009 -0500 @@ -528,23 +528,24 @@ return NULL; } -void quota_mailbox_list_created(struct mailbox_list *list) +void quota_mail_namespace_storage_added(struct mail_namespace *ns) { + struct mailbox_list *list = ns->list; struct quota_mailbox_list *qlist; struct quota *quota = NULL; struct quota_root *root; bool add; - if ((list->ns->flags & NAMESPACE_FLAG_NOQUOTA) != 0) + if ((ns->flags & NAMESPACE_FLAG_NOQUOTA) != 0) add = FALSE; - else if (list->ns->owner == NULL) { + else if (ns->owner == NULL) { /* see if we have a quota explicitly defined for this namespace */ - quota = quota_get_mail_user_quota(list->ns->user); - root = quota_find_root_for_ns(quota, list->ns); + quota = quota_get_mail_user_quota(ns->user); + root = quota_find_root_for_ns(quota, ns); add = root != NULL; if (root != NULL) - root->ns = list->ns; + root->ns = ns; } else { add = TRUE; } @@ -557,10 +558,10 @@ MODULE_CONTEXT_SET(list, quota_mailbox_list_module, qlist); /* register to owner's quota roots */ - quota = list->ns->owner != NULL ? - quota_get_mail_user_quota(list->ns->owner) : - quota_get_mail_user_quota(list->ns->user); - quota_add_user_namespace(quota, list->ns); + quota = ns->owner != NULL ? + quota_get_mail_user_quota(ns->owner) : + quota_get_mail_user_quota(ns->user); + quota_add_user_namespace(quota, ns); } }