From: Timo Sirainen Date: Tue, 25 Nov 2003 12:50:28 +0000 (+0200) Subject: LSUB should never show \HasChildren flags. X-Git-Tag: 1.1.alpha1~4211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=218ad257435470e78869d20e3dc8f15d51610953;p=thirdparty%2Fdovecot%2Fcore.git LSUB should never show \HasChildren flags. --HG-- branch : HEAD --- diff --git a/src/imap/cmd-list.c b/src/imap/cmd-list.c index fa0950ed5d..0948aa7d63 100644 --- a/src/imap/cmd-list.c +++ b/src/imap/cmd-list.c @@ -8,26 +8,31 @@ #include "commands.h" #include "namespace.h" +enum { + _MAILBOX_LIST_HIDE_CHILDREN = 0x1000000, + _MAILBOX_LIST_LISTEXT = 0x0800000 +}; + static const char * -mailbox_flags2str(enum mailbox_flags flags, enum mailbox_list_flags list_flags, - int listext) +mailbox_flags2str(enum mailbox_flags flags, enum mailbox_list_flags list_flags) { const char *str; if (flags & MAILBOX_PLACEHOLDER) { i_assert((flags & ~MAILBOX_CHILDREN) == MAILBOX_PLACEHOLDER); - if (!listext) + if ((list_flags & _MAILBOX_LIST_LISTEXT) == 0) flags = MAILBOX_NOSELECT; flags |= MAILBOX_CHILDREN; } - if ((flags & MAILBOX_NONEXISTENT) != 0 && !listext) + if ((flags & MAILBOX_NONEXISTENT) != 0 && + (list_flags & _MAILBOX_LIST_LISTEXT) == 0) { flags |= MAILBOX_NOSELECT; + flags &= ~MAILBOX_NONEXISTENT; + } - if (listext && (list_flags & MAILBOX_LIST_CHILDREN) == 0) { - /* LISTEXT used and we didn't want children info */ + if ((list_flags & _MAILBOX_LIST_HIDE_CHILDREN) != 0) flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN); - } str = t_strconcat( (flags & MAILBOX_NOSELECT) ? " \\Noselect" : "", @@ -45,7 +50,7 @@ mailbox_flags2str(enum mailbox_flags flags, enum mailbox_list_flags list_flags, static int mailbox_list(struct client *client, struct mail_storage *storage, const char *mask, const char *sep, const char *reply, - enum mailbox_list_flags list_flags, int listext) + enum mailbox_list_flags list_flags) { struct mailbox_list_context *ctx; struct mailbox_list *list; @@ -59,7 +64,7 @@ static int mailbox_list(struct client *client, struct mail_storage *storage, while ((list = storage->list_mailbox_next(ctx)) != NULL) { str_truncate(str, 0); str_printfa(str, "* %s (%s) \"%s\" ", reply, - mailbox_flags2str(list->flags, list_flags, listext), + mailbox_flags2str(list->flags, list_flags), sep); if (strcasecmp(list->name, "INBOX") == 0) str_append(str, "INBOX"); @@ -107,25 +112,29 @@ int _cmd_list_full(struct client *client, int lsub) enum mailbox_list_flags list_flags; const char *ref, *mask; char sep_chr, sep[3]; - int failed, listext; + int failed; /* [()] */ if (!client_read_args(client, 0, 0, &args)) return FALSE; - listext = FALSE; - if (lsub) - list_flags = MAILBOX_LIST_SUBSCRIBED | MAILBOX_LIST_FAST_FLAGS; - else { + if (lsub) { + /* LSUB - we don't care about flags */ + list_flags = MAILBOX_LIST_SUBSCRIBED | MAILBOX_LIST_FAST_FLAGS | + _MAILBOX_LIST_HIDE_CHILDREN; + } else if (args[0].type != IMAP_ARG_LIST) { + /* LIST - allow children flags, but don't require them */ list_flags = 0; - if (args[0].type == IMAP_ARG_LIST) { - listext = TRUE; - if (!parse_list_flags(client, - IMAP_ARG_LIST(&args[0])->args, - &list_flags)) - return TRUE; - args++; - } + } else { + list_flags = _MAILBOX_LIST_LISTEXT; + if (!parse_list_flags(client, IMAP_ARG_LIST(&args[0])->args, + &list_flags)) + return TRUE; + args++; + + /* don't show children flags unless explicitly specified */ + if ((list_flags & MAILBOX_LIST_CHILDREN) == 0) + list_flags |= _MAILBOX_LIST_HIDE_CHILDREN; } ref = imap_arg_string(&args[0]); @@ -176,8 +185,7 @@ int _cmd_list_full(struct client *client, int lsub) } failed = !mailbox_list(client, storage, mask, sep, - lsub ? "LSUB" : "LIST", - list_flags, listext); + lsub ? "LSUB" : "LIST", list_flags); } if (failed)