Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5800:c192277a81b3 HEAD
Added list setting to namespaces to control whether mailboxes in the
namespace are visible with LIST command without giving the namespace prefix
(eg. does LIST "" * show the mailboxes or not)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 25 Jun 2007 19:24:53 +0300 |
parents | 75e3aedc0568 |
children | 3d14f363f921 |
files | dovecot-example.conf src/imap/cmd-list.c src/lib-storage/mail-namespace.c src/lib-storage/mail-namespace.h src/master/mail-process.c src/master/master-settings.c src/master/master-settings.h |
diffstat | 7 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Mon Jun 25 18:35:17 2007 +0300 +++ b/dovecot-example.conf Mon Jun 25 19:24:53 2007 +0300 @@ -250,6 +250,10 @@ # but still keep working. For example you can create hidden namespaces with # prefixes "~/mail/", "~%u/mail/" and "mail/". #hidden = yes + + # Show the mailboxes under this namespace with LIST command. This makes the + # namespace visible for clients that don't support NAMESPACE extension. + #list = yes #} # Grant access to these extra groups for mail processes. Typical use would be
--- a/src/imap/cmd-list.c Mon Jun 25 18:35:17 2007 +0300 +++ b/src/imap/cmd-list.c Mon Jun 25 19:24:53 2007 +0300 @@ -308,15 +308,16 @@ cur_ns_prefix = t_strndup(cur_ns_prefix, len-1); } - /* hidden namespaces should still be seen without wildcards. - some clients rely on this. */ - match = (ns->hidden && list_mask_has_wildcards(cur_mask)) ? + /* hidden and non-listable namespaces should still be seen + without wildcards. */ + match = (!ns->list_prefix && + list_mask_has_wildcards(cur_mask)) ? IMAP_MATCH_NO : imap_match(ctx->glob, cur_ns_prefix); if (match < 0) return; len = strlen(ns->prefix); - if (match == IMAP_MATCH_YES && + if (match == IMAP_MATCH_YES && ctx->ns->list_prefix && (ctx->list_flags & MAILBOX_LIST_ITER_SUBSCRIBED) == 0 && (!ctx->ns->inbox || strncmp(ns->prefix, "INBOX", len-1) != 0)) {
--- a/src/lib-storage/mail-namespace.c Mon Jun 25 18:35:17 2007 +0300 +++ b/src/lib-storage/mail-namespace.c Mon Jun 25 19:24:53 2007 +0300 @@ -40,6 +40,8 @@ ns->inbox = getenv(t_strdup_printf("NAMESPACE_%u_INBOX", num)) != NULL; ns->hidden = getenv(t_strdup_printf("NAMESPACE_%u_HIDDEN", num)) != NULL; + ns->list_prefix = !ns->hidden && *prefix != '\0' && + getenv(t_strdup_printf("NAMESPACE_%u_LIST", num)) != NULL; ns->subscriptions = getenv(t_strdup_printf("NAMESPACE_%u_SUBSCRIPTIONS", num)) != NULL; @@ -59,10 +61,11 @@ if ((flags & MAIL_STORAGE_FLAG_DEBUG) != 0) { i_info("Namespace: type=%s, prefix=%s, sep=%s, " - "inbox=%s, hidden=%s, subscriptions=%s", + "inbox=%s, hidden=%s, list=%s, subscriptions=%s", type == NULL ? "" : type, prefix, sep == NULL ? "" : sep, ns->inbox ? "yes" : "no", ns->hidden ? "yes" : "no", + ns->list ? "yes" : "no", ns->subscriptions ? "yes" : "no"); } @@ -98,6 +101,13 @@ private_ns = ns; private_ns_count++; } + if (ns->list_prefix && + ns->prefix[strlen(ns->prefix)-1] != ns->sep) { + i_error("namespace configuration error: " + "list=yes requires prefix=%s " + "to end with separator", ns->prefix); + return FALSE; + } } if (inbox_ns == NULL) {
--- a/src/lib-storage/mail-namespace.h Mon Jun 25 18:35:17 2007 +0300 +++ b/src/lib-storage/mail-namespace.h Mon Jun 25 19:24:53 2007 +0300 @@ -16,7 +16,7 @@ const char *prefix; size_t prefix_len; - bool inbox, hidden, subscriptions; + bool inbox, hidden, list_prefix, subscriptions; struct mailbox_list *list; /* FIXME: we should support multiple storages in one namespace */ struct mail_storage *storage;
--- a/src/master/mail-process.c Mon Jun 25 18:35:17 2007 +0300 +++ b/src/master/mail-process.c Mon Jun 25 19:24:53 2007 +0300 @@ -193,6 +193,8 @@ env_put(t_strdup_printf("NAMESPACE_%u_INBOX=1", i)); if (ns->hidden) env_put(t_strdup_printf("NAMESPACE_%u_HIDDEN=1", i)); + else if (ns->list) + env_put(t_strdup_printf("NAMESPACE_%u_LIST=1", i)); t_pop(); } }
--- a/src/master/master-settings.c Mon Jun 25 18:35:17 2007 +0300 +++ b/src/master/master-settings.c Mon Jun 25 19:24:53 2007 +0300 @@ -149,6 +149,7 @@ DEF_STR(location), DEF_BOOL(inbox), DEF_BOOL(hidden), + DEF_BOOL(list), { 0, NULL, 0 } }; @@ -332,7 +333,8 @@ MEMBER(location) "", MEMBER(inbox) FALSE, - MEMBER(hidden) FALSE + MEMBER(hidden) FALSE, + MEMBER(list) TRUE }; static pool_t settings_pool, settings2_pool;