dovecot-2.0: plugins: Use mail_namespace_storage_added hook inst...

dovecot at dovecot.org dovecot at dovecot.org
Mon Dec 14 21:40:21 EET 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/43895027cab9
changeset: 10484:43895027cab9
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Dec 14 14:32:01 2009 -0500
description:
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.

diffstat:

9 files changed, 43 insertions(+), 39 deletions(-)
src/plugins/acl/acl-mailbox-list.c             |   18 +++++++++---------
src/plugins/acl/acl-plugin.c                   |    2 +-
src/plugins/acl/acl-plugin.h                   |    2 +-
src/plugins/lazy-expunge/lazy-expunge-plugin.c |   15 ++++++++-------
src/plugins/listescape/listescape-plugin.c     |   11 ++++++-----
src/plugins/notify/notify-storage.c            |    7 ++++---
src/plugins/quota/quota-plugin.c               |    2 +-
src/plugins/quota/quota-plugin.h               |    2 +-
src/plugins/quota/quota-storage.c              |   23 ++++++++++++-----------

diffs (229 lines):

diff -r bc9dbd257811 -r 43895027cab9 src/plugins/acl/acl-mailbox-list.c
--- 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 @@ static void acl_mailbox_list_init_defaul
 	MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist);
 }
 
-void acl_mailbox_list_created(struct mailbox_list *list)
-{
-	struct acl_user *auser = ACL_USER_CONTEXT(list->ns->user);
+void acl_mail_namespace_storage_added(struct mail_namespace *ns)
+{
+	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);
+	}
+}
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/acl/acl-plugin.c
--- 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_mai
 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)
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/acl/acl-plugin.h
--- 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 @@ extern MODULE_CONTEXT_DEFINE(acl_mailbox
 			     &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 *
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/lazy-expunge/lazy-expunge-plugin.c
--- 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 @@ lazy_expunge_mailbox_list_delete(struct 
 	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 @@ static void lazy_expunge_mailbox_list_cr
 	   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_ex
 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
 };
 
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/listescape/listescape-plugin.c
--- 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 @@ static void listescape_mail_storage_crea
 	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 void listescape_mailbox_list_crea
 
 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)
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/notify/notify-storage.c
--- 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 @@ static void notify_mail_storage_created(
 	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 void notify_mailbox_list_created(
 
 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)
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/quota/quota-plugin.c
--- 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 @@ static struct mail_storage_hooks quota_m
 	.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)
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/quota/quota-plugin.h
--- 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 @@ extern MODULE_CONTEXT_DEFINE(quota_user_
 
 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);
diff -r bc9dbd257811 -r 43895027cab9 src/plugins/quota/quota-storage.c
--- 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 @@ quota_find_root_for_ns(struct quota *quo
 	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 @@ void quota_mailbox_list_created(struct m
 		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);
 	}
 }
 


More information about the dovecot-cvs mailing list