]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
More kludgy LIST fixes for maildir subfolders
authorTimo Sirainen <tss@iki.fi>
Thu, 20 Mar 2003 17:38:39 +0000 (19:38 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 20 Mar 2003 17:38:39 +0000 (19:38 +0200)
--HG--
branch : HEAD

src/imap/cmd-list.c
src/lib-storage/index/maildir/maildir-list.c

index 6e50c1b3e68bd5c5af1a34ca00cb1a849da8a53a..441e0d594ca0b48fa352e90c575edccd1da86c1f 100644 (file)
@@ -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();
index dac5563389725125fd3000653bf6965cefbf156f..c2cdca22810469bed1764b3b4c0c6b0f371eeae4 100644 (file)
@@ -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) {