From: Timo Sirainen Date: Sat, 6 Sep 2003 17:44:51 +0000 (+0300) Subject: Added "inbox" setting to specify which namespace has the INBOX. X-Git-Tag: 1.1.alpha1~4356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebaf8808cb1e9ab2571ab553793beae1e56e2db4;p=thirdparty%2Fdovecot%2Fcore.git Added "inbox" setting to specify which namespace has the INBOX. --HG-- branch : HEAD --- diff --git a/src/imap/namespace.c b/src/imap/namespace.c index 97b1ea5bcb..16818c1422 100644 --- a/src/imap/namespace.c +++ b/src/imap/namespace.c @@ -12,12 +12,14 @@ namespace_add_env(pool_t pool, const char *data, unsigned int num, { struct namespace *ns; const char *sep, *type, *prefix; + int inbox; ns = p_new(pool, struct namespace, 1); sep = getenv(t_strdup_printf("NAMESPACE_%u_SEP", num)); type = getenv(t_strdup_printf("NAMESPACE_%u_TYPE", num)); prefix = getenv(t_strdup_printf("NAMESPACE_%u_PREFIX", num)); + inbox = getenv(t_strdup_printf("NAMESPACE_%u_INBOX", num)) != NULL; if (type == NULL || *type == '\0' || strncmp(type, "private", 7) == 0) ns->type = NAMESPACE_PRIVATE; @@ -32,6 +34,7 @@ namespace_add_env(pool_t pool, const char *data, unsigned int num, prefix = ""; ns->prefix = p_strdup(pool, prefix); + ns->inbox = inbox; ns->storage = mail_storage_create_with_data(data, user, ns->prefix, sep != NULL ? *sep : '\0'); if (ns->storage == NULL) { @@ -99,6 +102,7 @@ struct namespace *namespace_init(pool_t pool, const char *user) } ns->type = NAMESPACE_PRIVATE; + ns->inbox = TRUE; ns->prefix = p_strdup(pool, ""); ns->hierarchy_sep = ns->storage->hierarchy_sep; if (hook_mail_storage_created != NULL) @@ -123,6 +127,17 @@ namespace_find(struct namespace *namespaces, const char *mailbox) int inbox; inbox = strncasecmp(mailbox, "INBOX", 5) == 0; + if (inbox && mailbox[5] == '\0') { + /* find the INBOX namespace */ + while (namespaces != NULL) { + if (namespaces->inbox) + return namespaces; + if (namespaces->prefix == NULL) + best = namespaces; + namespaces = namespaces->next; + } + return best; + } while (namespaces != NULL) { len = namespaces->prefix == NULL ? 0 : diff --git a/src/imap/namespace.h b/src/imap/namespace.h index 16dcf0a596..d70b7ac024 100644 --- a/src/imap/namespace.h +++ b/src/imap/namespace.h @@ -13,6 +13,7 @@ struct namespace { enum namespace_type type; char hierarchy_sep; char *prefix; + int inbox; struct mail_storage *storage; }; diff --git a/src/master/mail-process.c b/src/master/mail-process.c index fb954fb243..4738218749 100644 --- a/src/master/mail-process.c +++ b/src/master/mail-process.c @@ -133,6 +133,8 @@ static void env_put_namespace(struct namespace_settings *ns, env_put(t_strdup_printf("NAMESPACE_%u_PREFIX=%s", i, ns->prefix)); } + if (ns->inbox) + env_put(t_strdup_printf("NAMESPACE_%u_INBOX=1", i)); t_pop(); } } diff --git a/src/master/master-settings.c b/src/master/master-settings.c index 5db71ea804..958a74f1aa 100644 --- a/src/master/master-settings.c +++ b/src/master/master-settings.c @@ -142,6 +142,7 @@ static struct setting_def namespace_setting_defs[] = { DEF(SET_STR, separator), DEF(SET_STR, prefix), DEF(SET_STR, location), + DEF(SET_BOOL, inbox), { 0, NULL, 0 } }; diff --git a/src/master/master-settings.h b/src/master/master-settings.h index 8fea5ba14b..2edd90352e 100644 --- a/src/master/master-settings.h +++ b/src/master/master-settings.h @@ -120,6 +120,8 @@ struct namespace_settings { const char *separator; const char *prefix; const char *location; + + int inbox; }; struct server_settings {