dovecot-1.2: autocreate plugin: Added support for namespaces.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Oct 18 23:54:54 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/e88c6b43665a
changeset: 8298:e88c6b43665a
user: Timo Sirainen <tss at iki.fi>
date: Sat Oct 18 23:54:50 2008 +0300
description:
autocreate plugin: Added support for namespaces.
diffstat:
1 file changed, 27 insertions(+), 21 deletions(-)
src/plugins/autocreate/autocreate-plugin.c | 48 +++++++++++++++-------------
diffs (79 lines):
diff -r 0d1bd98a6387 -r e88c6b43665a src/plugins/autocreate/autocreate-plugin.c
--- a/src/plugins/autocreate/autocreate-plugin.c Sat Oct 18 23:45:41 2008 +0300
+++ b/src/plugins/autocreate/autocreate-plugin.c Sat Oct 18 23:54:50 2008 +0300
@@ -12,48 +12,54 @@ static void (*autocreate_next_hook_mail_
static void (*autocreate_next_hook_mail_namespaces_created)
(struct mail_namespace *ns);
-static void autocreate_mailboxes(struct mail_storage *storage)
+static void autocreate_mailboxes(struct mail_namespace *namespaces)
{
+ struct mail_namespace *ns;
char env_name[20];
- const char *env;
+ const char *name;
unsigned int i;
i = 1;
- env = getenv("AUTOCREATE");
- while (env != NULL) {
- (void)mail_storage_mailbox_create(storage, env, FALSE);
+ name = getenv("AUTOCREATE");
+ while (name != NULL) {
+ ns = mail_namespace_find(namespaces, &name);
+ if (ns != NULL) {
+ (void)mail_storage_mailbox_create(ns->storage,
+ name, FALSE);
+ }
+
i_snprintf(env_name, sizeof(env_name), "AUTOCREATE%d", ++i);
- env = getenv(env_name);
+ name = getenv(env_name);
}
}
-static void autosubscribe_mailboxes(struct mailbox_list *list)
+static void autosubscribe_mailboxes(struct mail_namespace *namespaces)
{
+ struct mail_namespace *ns;
char env_name[20];
- const char *env;
+ const char *name;
unsigned int i;
i = 1;
- env = getenv("AUTOSUBSCRIBE");
- while (env != NULL) {
- (void)mailbox_list_set_subscribed(list, env, TRUE);
+ name = getenv("AUTOSUBSCRIBE");
+ while (name != NULL) {
+ ns = mail_namespace_find(namespaces, &name);
+ if (ns != NULL)
+ (void)mailbox_list_set_subscribed(ns->list, name, TRUE);
+
i_snprintf(env_name, sizeof(env_name), "AUTOSUBSCRIBE%d", ++i);
- env = getenv(env_name);
+ name = getenv(env_name);
}
}
-static void autocreate_mail_namespaces_created(struct mail_namespace *ns)
+static void
+autocreate_mail_namespaces_created(struct mail_namespace *namespaces)
{
if (autocreate_next_hook_mail_namespaces_created != NULL)
- autocreate_next_hook_mail_namespaces_created(ns);
+ autocreate_next_hook_mail_namespaces_created(namespaces);
- for (; ns != NULL; ns = ns->next) {
- if (ns->type == NAMESPACE_PRIVATE) {
- autocreate_mailboxes(ns->storage);
- autosubscribe_mailboxes(ns->list);
- break;
- }
- }
+ autocreate_mailboxes(namespaces);
+ autosubscribe_mailboxes(namespaces);
}
void autocreate_plugin_init(void)
More information about the dovecot-cvs
mailing list