cmd-list.c revision 2b619d427addefb7d1660b23a528259d162a5f67
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainentypedef struct {
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainenstatic const char *mailbox_flags2str(MailboxFlags flags)
1128c114416bdc4df0b41d3e15429a1522e5cfe4Timo Sirainen const char *str;
1128c114416bdc4df0b41d3e15429a1522e5cfe4Timo Sirainen str = t_strconcat((flags & MAILBOX_NOSELECT) ? " \\Noselect" : "",
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen (flags & MAILBOX_NOINFERIORS) ? " \\NoInferiors" : "",
4db61af2cfe2b206113bcc4b6153521679702bb4Timo Sirainen (flags & MAILBOX_UNMARKED) ? " \\UnMarked" : "",
1128c114416bdc4df0b41d3e15429a1522e5cfe4Timo Sirainenstatic ListNode *list_node_get(Pool pool, ListNode **node,
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen /* escaping is done here to make sure we don't try to escape
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen the separator char */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen name = imap_escape(t_strdup_until(name, path));
4db61af2cfe2b206113bcc4b6153521679702bb4Timo Sirainen /* find the node */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen /* not found, create it */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainenstatic void list_func(MailStorage *storage __attr_unused__, const char *name,
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen node = list_node_get(ctx->pool, &ctx->nodes, name,
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen /* set the flags, this also nicely overrides the NOSELECT flag
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen set by list_node_get() */
37e8420b32a0fa3442c405616980e45beb494104Timo Sirainenstatic void list_send(Client *client, ListNode *node, const char *cmd,
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen const char *path, const char *sep, ImapMatchGlob *glob)
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen /* Send INBOX always uppercased */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen name = t_strconcat(path, sep, node->name, NULL);
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen else if (strcasecmp(node->name, "INBOX") == 0)
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen list_send(client, node->children, cmd, name, sep, glob);
e22ec7998afd426c53c658483ce66b6e404e27c6Timo Sirainen /* node->name should already be escaped */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen str = t_strdup_printf("* %s (%s) \"%s\" \"%s\"", cmd,
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainenint _cmd_list_full(Client *client, int subscribed)
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen /* <reference> <mailbox wildcards> */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen if (!client_read_string_args(client, 2, &ref, &pattern))
a1044a46a8f3512173f4ea2684ef1fc3e61645c7Timo Sirainen /* special request to return the hierarchy delimiter */
a1044a46a8f3512173f4ea2684ef1fc3e61645c7Timo Sirainen "* LIST (\\Noselect) \"", sep, "\" \"\"", NULL));
a1044a46a8f3512173f4ea2684ef1fc3e61645c7Timo Sirainen /* join reference + pattern */
1128c114416bdc4df0b41d3e15429a1522e5cfe4Timo Sirainen /* LIST A. .B -> A.B */
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen ctx.pool = pool_alloconly_create("ListContext", 10240);
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen "OK Lsub completed." :
b772ddf3cfb606dddaa465b317a0dc01bf06c6e4Timo Sirainen "OK List completed.");