Mercurial > dovecot > core-2.2
changeset 1895:bbdce1697239 HEAD
LSUB should never show \HasChildren flags.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 25 Nov 2003 14:50:28 +0200 |
parents | 07324c0d1d0a |
children | 0613ad9d5034 |
files | src/imap/cmd-list.c |
diffstat | 1 files changed, 32 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-list.c Tue Nov 25 03:26:26 2003 +0200 +++ b/src/imap/cmd-list.c Tue Nov 25 14:50:28 2003 +0200 @@ -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 @@ 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 @@ 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 @@ enum mailbox_list_flags list_flags; const char *ref, *mask; char sep_chr, sep[3]; - int failed, listext; + int failed; /* [(<options>)] <reference> <mailbox wildcards> */ 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 @@ } failed = !mailbox_list(client, storage, mask, sep, - lsub ? "LSUB" : "LIST", - list_flags, listext); + lsub ? "LSUB" : "LIST", list_flags); } if (failed)