dovecot-2.2: lib-storage: Fixed listing list=children namespaces...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Aug 31 14:15:06 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/db28fea9b8db
changeset: 15006:db28fea9b8db
user: Timo Sirainen <tss at iki.fi>
date: Fri Aug 31 14:14:50 2012 +0300
description:
lib-storage: Fixed listing list=children namespaces that had child namespaces.
diffstat:
src/lib-storage/mailbox-list-iter.c | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r 1f95d4fe29c7 -r db28fea9b8db src/lib-storage/mailbox-list-iter.c
--- a/src/lib-storage/mailbox-list-iter.c Thu Aug 30 22:05:02 2012 +0300
+++ b/src/lib-storage/mailbox-list-iter.c Fri Aug 31 14:14:50 2012 +0300
@@ -52,6 +52,9 @@
static bool ns_match_next(struct ns_list_iterate_context *ctx,
struct mail_namespace *ns, const char *pattern);
+static int mailbox_list_match_anything(struct ns_list_iterate_context *ctx,
+ struct mail_namespace *ns,
+ const char *prefix);
struct mailbox_list_iterate_context *
mailbox_list_iter_init(struct mailbox_list *list, const char *pattern,
@@ -329,15 +332,29 @@
}
static bool
-ns_prefix_has_child_namespaces(struct mail_namespace *namespaces,
- const char *prefix)
+ns_prefix_is_visible(struct ns_list_iterate_context *ctx,
+ struct mail_namespace *ns)
+{
+ if ((ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0)
+ return TRUE;
+ if ((ns->flags & NAMESPACE_FLAG_LIST_CHILDREN) != 0) {
+ if (mailbox_list_match_anything(ctx, ns, ns->prefix))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool
+ns_prefix_has_visible_child_namespace(struct ns_list_iterate_context *ctx,
+ const char *prefix)
{
struct mail_namespace *ns;
unsigned int prefix_len = strlen(prefix);
- for (ns = namespaces; ns != NULL; ns = ns->next) {
+ for (ns = ctx->namespaces; ns != NULL; ns = ns->next) {
if (ns->prefix_len > prefix_len &&
- strncmp(ns->prefix, prefix, prefix_len) == 0)
+ strncmp(ns->prefix, prefix, prefix_len) == 0 &&
+ ns_prefix_is_visible(ctx, ns))
return TRUE;
}
return FALSE;
@@ -370,7 +387,7 @@
const char *pattern;
int ret;
- if (ns_prefix_has_child_namespaces(ctx->namespaces, prefix))
+ if (ns_prefix_has_visible_child_namespace(ctx, prefix))
return 1;
pattern = t_strconcat(prefix, "%", NULL);
More information about the dovecot-cvs
mailing list