#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" : "",
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;
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");
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]);
}
failed = !mailbox_list(client, storage, mask, sep,
- lsub ? "LSUB" : "LIST",
- list_flags, listext);
+ lsub ? "LSUB" : "LIST", list_flags);
}
if (failed)