From: Timo Sirainen Date: Thu, 20 Mar 2003 17:38:39 +0000 (+0200) Subject: More kludgy LIST fixes for maildir subfolders X-Git-Tag: 1.1.alpha1~4796 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63bc8e680c583e6108a0adcc8eb871ebfa0b3e2a;p=thirdparty%2Fdovecot%2Fcore.git More kludgy LIST fixes for maildir subfolders --HG-- branch : HEAD --- diff --git a/src/imap/cmd-list.c b/src/imap/cmd-list.c index 6e50c1b3e6..441e0d594c 100644 --- a/src/imap/cmd-list.c +++ b/src/imap/cmd-list.c @@ -24,16 +24,17 @@ struct list_send_context { const char *response_name; const char *sep; struct imap_match_glob *glob; - int listext; + int listext, no_placeholder; }; -static const char *mailbox_flags2str(enum mailbox_flags flags, int listext) +static const char *mailbox_flags2str(enum mailbox_flags flags, + int listext, int no_placeholder) { const char *str; if (flags & MAILBOX_PLACEHOLDER) { - if (flags == MAILBOX_PLACEHOLDER) { - if (!listext) + if ((flags & ~MAILBOX_CHILDREN) == MAILBOX_PLACEHOLDER) { + if (!listext || no_placeholder) flags = MAILBOX_NOSELECT; } else { /* it was at one point, but then we got better specs */ @@ -59,7 +60,6 @@ static const char *mailbox_flags2str(enum mailbox_flags flags, int listext) static void list_node_update(pool_t pool, struct list_node **node, const char *path, char separator, - enum mailbox_flags dir_flags, enum mailbox_flags flags) { const char *name, *parent; @@ -88,7 +88,8 @@ static void list_node_update(pool_t pool, struct list_node **node, /* not found, create it */ *node = p_new(pool, struct list_node, 1); (*node)->name = p_strdup(pool, name); - (*node)->flags = *path == '\0' ? flags : dir_flags; + (*node)->flags = *path == '\0' ? flags : + MAILBOX_PLACEHOLDER; } else { if (*path == '\0') { if (((*node)->flags & MAILBOX_NOSELECT) != 0 && @@ -155,7 +156,8 @@ static void list_send(struct list_send_context *ctx, struct list_node *node, if (match == IMAP_MATCH_YES) { /* node->name should already be escaped */ - flagstr = mailbox_flags2str(node->flags, ctx->listext); + flagstr = mailbox_flags2str(node->flags, ctx->listext, + ctx->no_placeholder); str = t_strdup_printf("* %s (%s) \"%s\" \"%s\"", ctx->response_name, flagstr, ctx->sep, send_name); @@ -178,19 +180,15 @@ static void list_and_sort(struct client *client, struct mailbox_list *list; struct list_node *nodes; struct list_send_context send_ctx; - enum mailbox_flags dir_flags; pool_t pool; - dir_flags = (list_flags & MAILBOX_LIST_SUBSCRIBED) ? - MAILBOX_PLACEHOLDER : MAILBOX_NOSELECT; - pool = pool_alloconly_create("list_mailboxes", 10240); nodes = NULL; while ((list = client->storage->list_mailbox_next(ctx)) != NULL) { list_node_update(pool, &nodes, list->name, client->storage->hierarchy_sep, - dir_flags, list->flags); + list->flags); } send_ctx.client = client; @@ -199,6 +197,7 @@ static void list_and_sort(struct client *client, send_ctx.glob = imap_match_init(data_stack_pool, mask, TRUE, client->storage->hierarchy_sep); send_ctx.listext = listext; + send_ctx.no_placeholder = (list_flags & MAILBOX_LIST_SUBSCRIBED) == 0; list_send(&send_ctx, nodes, NULL); imap_match_deinit(send_ctx.glob); @@ -219,7 +218,8 @@ static void list_unsorted(struct client *client, else name = str_escape(list->name); str = t_strdup_printf("* %s (%s) \"%s\" \"%s\"", reply, - mailbox_flags2str(list->flags, listext), + mailbox_flags2str(list->flags, listext, + FALSE), sep, name); client_send_line(client, str); t_pop(); diff --git a/src/lib-storage/index/maildir/maildir-list.c b/src/lib-storage/index/maildir/maildir-list.c index dac5563389..c2cdca2281 100644 --- a/src/lib-storage/index/maildir/maildir-list.c +++ b/src/lib-storage/index/maildir/maildir-list.c @@ -242,7 +242,8 @@ static struct mailbox_list *maildir_list_next(struct mailbox_list_context *ctx) continue; /* ignore inboxes */ if (match == IMAP_MATCH_PARENT) { - ctx->list.flags = MAILBOX_NOSELECT | MAILBOX_CHILDREN; + ctx->list.flags = + MAILBOX_PLACEHOLDER | MAILBOX_CHILDREN; while ((p = strrchr(fname, '.')) != NULL) { fname = t_strdup_until(fname, p); if (imap_match(ctx->glob, fname) > 0) {