]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fixed LIST (SPECIAL-USE RECURSIVEMATCH) to actually return CHILDINFOs.
authorTimo Sirainen <tss@iki.fi>
Tue, 4 Sep 2012 13:22:14 +0000 (16:22 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 4 Sep 2012 13:22:14 +0000 (16:22 +0300)
src/lib-storage/list/mailbox-list-iter.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h
src/lib-storage/mailbox-list.h

index b953a0aa8eb02cade63599de9d9f4cee9d43b2d8..d83ed1dfd0cc3fe92f64a2ee2d0de4fa283cabc1 100644 (file)
@@ -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;
 }
index 043e02724c73d1fcd072d54698f55771e4a8650c..81856c321f2f323afac82bf2791c68621f4a4e67 100644 (file)
@@ -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 ||
index 2715bbf62f89c86a421830b6412a95bb22ab2d2b..146f1a55fd14f343fc12a772d0001ddefce9f328 100644 (file)
@@ -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;
 };
 
index 4268c044e463be8cc31d6399ca18187d65cc5772..5b7c81e79870004f39af7420dcef9a20e09b8a81 100644 (file)
@@ -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,