From: Timo Sirainen Date: Tue, 4 Sep 2012 13:22:14 +0000 (+0300) Subject: imap: Fixed LIST (SPECIAL-USE RECURSIVEMATCH) to actually return CHILDINFOs. X-Git-Tag: 2.2.alpha1~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abed24374d7e1a57bec8d8a108acfcaffd52d4f9;p=thirdparty%2Fdovecot%2Fcore.git imap: Fixed LIST (SPECIAL-USE RECURSIVEMATCH) to actually return CHILDINFOs. --- diff --git a/src/lib-storage/list/mailbox-list-iter.c b/src/lib-storage/list/mailbox-list-iter.c index b953a0aa8e..d83ed1dfd0 100644 --- a/src/lib-storage/list/mailbox-list-iter.c +++ b/src/lib-storage/list/mailbox-list-iter.c @@ -444,6 +444,8 @@ mailbox_list_ns_prefix_return(struct ns_list_iterate_context *ctx, ctx->ns_info.ns = ns; ctx->ns_info.vname = p_strndup(ctx->pool, ns->prefix, ns->prefix_len-1); + if (ns->special_use_mailboxes) + ctx->ns_info.flags |= MAILBOX_CHILD_SPECIALUSE; if (strcasecmp(ctx->ns_info.vname, "INBOX") == 0) { i_assert(!ctx->inbox_listed); @@ -972,6 +974,13 @@ static bool special_use_selection(struct mailbox_list_iterate_context *ctx, const struct mailbox_info *info) { + if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0 && + (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) != 0) { + /* LIST (SPECIAL-USE RECURSIVEMATCH) used. for now we support + this only for namespace prefixes */ + if ((info->flags & MAILBOX_CHILD_SPECIALUSE) != 0) + return TRUE; + } return (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) == 0 || info->special_use != NULL; } diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index 043e02724c..81856c321f 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -44,6 +44,21 @@ static void mail_namespace_free(struct mail_namespace *ns) i_free(ns); } +static bool +namespace_has_special_use_mailboxes(struct mail_namespace_settings *ns_set) +{ + struct mailbox_settings *const *box_set; + + if (!array_is_created(&ns_set->mailboxes)) + return FALSE; + + array_foreach(&ns_set->mailboxes, box_set) { + if ((*box_set)->special_use[0] != '\0') + return TRUE; + } + return FALSE; +} + static int namespace_add(struct mail_user *user, struct mail_namespace_settings *ns_set, @@ -110,6 +125,7 @@ namespace_add(struct mail_user *user, ns->unexpanded_set = unexpanded_ns_set; ns->mail_set = mail_set; ns->prefix = i_strdup(ns_set->prefix); + ns->special_use_mailboxes = namespace_has_special_use_mailboxes(ns_set); if (ns->type == MAIL_NAMESPACE_TYPE_SHARED && (strchr(ns->prefix, '%') != NULL || diff --git a/src/lib-storage/mail-namespace.h b/src/lib-storage/mail-namespace.h index 2715bbf62f..146f1a55fd 100644 --- a/src/lib-storage/mail-namespace.h +++ b/src/lib-storage/mail-namespace.h @@ -73,6 +73,7 @@ struct mail_namespace { struct mail_namespace_settings *set, *unexpanded_set; const struct mail_storage_settings *mail_set; + unsigned int special_use_mailboxes:1; unsigned int destroyed:1; }; diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index 4268c044e4..5b7c81e798 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -47,6 +47,7 @@ enum mailbox_info_flags { MAILBOX_UNMARKED = 0x040, MAILBOX_SUBSCRIBED = 0x080, MAILBOX_CHILD_SUBSCRIBED = 0x100, + MAILBOX_CHILD_SPECIALUSE = 0x200, /* Internally used by lib-storage */ MAILBOX_SELECT = 0x20000000,