]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir++ LIST (subscribed): If listing finds a non-subscribed mailbox under
authorTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 20:43:18 +0000 (23:43 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 20:43:18 +0000 (23:43 +0300)
a subscribed one, mark the subscribed one as having children.

--HG--
branch : HEAD

src/lib-storage/list/mailbox-list-maildir-iter.c

index 6ba60ca550c77d5cc4e9dc7a3f22cb67ec055362..255769289da6e16d73020d2e08b6634ce3951c81 100644 (file)
@@ -89,6 +89,33 @@ maildir_fill_parents(struct maildir_list_iterate_context *ctx,
        }
 }
 
+static void maildir_set_children(struct maildir_list_iterate_context *ctx,
+                                string_t *mailbox)
+{
+       struct mailbox_node *node;
+       const char *p, *mailbox_c;
+       char hierarchy_sep;
+
+       if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
+               hierarchy_sep = ctx->ctx.list->ns->sep;
+       else
+               hierarchy_sep = ctx->ctx.list->ns->real_sep;
+
+       /* mark the first existing parent as containing children */
+       mailbox_c = str_c(mailbox);
+       while ((p = strrchr(mailbox_c, hierarchy_sep)) != NULL) {
+               str_truncate(mailbox, (size_t) (p-mailbox_c));
+               mailbox_c = str_c(mailbox);
+
+               node = mailbox_tree_lookup(ctx->tree_ctx, mailbox_c);
+               if (node != NULL) {
+                       node->flags &= ~MAILBOX_NOCHILDREN;
+                       node->flags |= MAILBOX_CHILDREN;
+                       break;
+               }
+       }
+}
+
 static int
 maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
                     struct imap_match_glob *glob, bool update_only)
@@ -191,6 +218,9 @@ maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
                                        node->flags |= MAILBOX_MATCHED;
                                node->flags |= flags;
                                node_fix_parents(node);
+                       } else {
+                               i_assert(update_only);
+                               maildir_set_children(ctx, mailbox);
                        }
                }
        }