annotate src/imap/cmd-list.c @ 5314:ce59b45431fb HEAD

Use less memory when listing lots of mailboxes
author Timo Sirainen <tss@iki.fi>
date Thu, 15 Mar 2007 03:25:03 +0200
parents 1e2b2b3f18e3
children 469799904802
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
1 /* Copyright (C) 2002-2004 Timo Sirainen */
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
1329
ae229b7acb4c Mailbox names are now sent through imap-quoter instead of just escaping it.
Timo Sirainen <tss@iki.fi>
parents: 1310
diff changeset
4 #include "str.h"
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents: 886
diff changeset
5 #include "strescape.h"
1329
ae229b7acb4c Mailbox names are now sent through imap-quoter instead of just escaping it.
Timo Sirainen <tss@iki.fi>
parents: 1310
diff changeset
6 #include "imap-quote.h"
1218
a70ebd3a59e2 Removed list-sort workarounds. It's pretty much needed for maildir listing.
Timo Sirainen <tss@iki.fi>
parents: 1198
diff changeset
7 #include "imap-match.h"
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "commands.h"
1655
Timo Sirainen <tss@iki.fi>
parents: 1654
diff changeset
9 #include "namespace.h"
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
11 enum {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
12 _MAILBOX_LIST_ITER_HIDE_CHILDREN = 0x1000000,
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
13 _MAILBOX_LIST_ITER_LISTEXT = 0x0800000
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
14 };
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
15
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
16 struct cmd_list_context {
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
17 const char *ref;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
18 const char *mask;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
19 enum mailbox_list_flags list_flags;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
20
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
21 struct namespace *ns;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
22 struct mailbox_list_iterate_context *list_iter;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
23 struct imap_match_glob *glob;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
24
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
25 unsigned int lsub:1;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
26 unsigned int inbox_found:1;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
27 unsigned int match_inbox:1;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
28 };
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
29
5314
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
30 static void
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
31 mailbox_flags2str(string_t *str, enum mailbox_info_flags flags,
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
32 enum mailbox_list_flags list_flags)
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 {
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
34 if ((flags & MAILBOX_NONEXISTENT) != 0 &&
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
35 (list_flags & _MAILBOX_LIST_ITER_LISTEXT) == 0) {
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
36 flags |= MAILBOX_NOSELECT;
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
37 flags &= ~MAILBOX_NONEXISTENT;
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
38 }
1218
a70ebd3a59e2 Removed list-sort workarounds. It's pretty much needed for maildir listing.
Timo Sirainen <tss@iki.fi>
parents: 1198
diff changeset
39
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
40 if ((list_flags & _MAILBOX_LIST_ITER_HIDE_CHILDREN) != 0)
1748
588326f1cd84 If LISTEXT is used and CHILDREN info isn't wanted, don't send it.
Timo Sirainen <tss@iki.fi>
parents: 1657
diff changeset
41 flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN);
588326f1cd84 If LISTEXT is used and CHILDREN info isn't wanted, don't send it.
Timo Sirainen <tss@iki.fi>
parents: 1657
diff changeset
42
5314
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
43 if ((flags & MAILBOX_NOSELECT) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
44 str_append(str, " \\Noselect");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
45 if ((flags & MAILBOX_NONEXISTENT) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
46 str_append(str, " \\NonExistent");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
47 if ((flags & MAILBOX_CHILDREN) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
48 str_append(str, " \\HasChildren");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
49 if ((flags & MAILBOX_NOCHILDREN) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
50 str_append(str, " \\HasNoChildren");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
51 if ((flags & MAILBOX_NOINFERIORS) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
52 str_append(str, " \\NoInferiors");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
53 if ((flags & MAILBOX_MARKED) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
54 str_append(str, " \\Marked");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
55 if ((flags & MAILBOX_UNMARKED) != 0)
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
56 str_append(str, " \\UnMarked");
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3856
diff changeset
59 static bool
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
60 parse_list_flags(struct client_command_context *cmd, struct imap_arg *args,
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
61 enum mailbox_list_flags *list_flags)
1198
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
62 {
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
63 const char *atom;
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
64
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
65 while (args->type != IMAP_ARG_EOL) {
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
66 if (args->type != IMAP_ARG_ATOM) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
67 client_send_command_error(cmd,
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
68 "List options contains non-atoms.");
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
69 return FALSE;
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
70 }
1198
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
71
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
72 atom = IMAP_ARG_STR(args);
1198
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
73
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
74 if (strcasecmp(atom, "SUBSCRIBED") == 0)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
75 *list_flags |= MAILBOX_LIST_ITER_SUBSCRIBED;
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
76 else if (strcasecmp(atom, "CHILDREN") == 0)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
77 *list_flags |= MAILBOX_LIST_ITER_CHILDREN;
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
78 else {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
79 client_send_tagline(cmd, t_strconcat(
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
80 "BAD Invalid list option ", atom, NULL));
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
81 return FALSE;
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
82 }
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
83 args++;
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
84 }
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
85 return TRUE;
1198
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
86 }
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
87
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
88 static void
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
89 list_namespace_inbox(struct client *client, struct cmd_list_context *ctx)
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
90 {
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
91 const char *str;
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
92
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
93 if (!ctx->inbox_found && ctx->ns->inbox && ctx->match_inbox &&
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
94 (ctx->list_flags & MAILBOX_LIST_ITER_SUBSCRIBED) == 0) {
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
95 /* INBOX always exists */
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
96 str = t_strdup_printf("* LIST (\\Unmarked) \"%s\" \"INBOX\"",
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
97 ctx->ns->sep_str);
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
98 client_send_line(client, str);
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
99 }
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
100 }
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
101
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
102 static int
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
103 list_namespace_mailboxes(struct client *client, struct cmd_list_context *ctx)
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
104 {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
105 struct mailbox_info *info;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
106 const char *name;
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
107 string_t *str, *name_str;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
108 int ret = 0;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
109
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
110 if (ctx->list_iter == NULL) {
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
111 list_namespace_inbox(client, ctx);
2537
5c95f17f6f25 Fix for having INBOX/ namespace.
Timo Sirainen <tss@iki.fi>
parents: 2425
diff changeset
112 return 1;
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
113 }
2537
5c95f17f6f25 Fix for having INBOX/ namespace.
Timo Sirainen <tss@iki.fi>
parents: 2425
diff changeset
114
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
115 t_push();
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
116 str = t_str_new(256);
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
117 name_str = t_str_new(256);
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
118 while ((info = mailbox_list_iter_next(ctx->list_iter)) != NULL) {
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
119 str_truncate(name_str, 0);
5221
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
120 if (ctx->ns->inbox && strcasecmp(info->name, "INBOX") == 0) {
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
121 /* Listing INBOX from inbox=yes namespace.
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
122 Don't insert the namespace prefix. */
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
123 if (!ctx->match_inbox) {
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
124 /* The mask doesn't match INBOX (eg. prefix.%).
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
125 We still want to list prefix.INBOX if it has
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
126 children. Otherwise we don't want to list
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
127 this INBOX at all. */
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
128 if ((info->flags & MAILBOX_CHILDREN) == 0)
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
129 continue;
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
130 str_append(name_str, ctx->ns->prefix);
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
131 }
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
132 } else {
4546
ca9eaace800a When listing INBOX from inbox=yes namespace, don't insert the
Timo Sirainen <tss@iki.fi>
parents: 4545
diff changeset
133 str_append(name_str, ctx->ns->prefix);
5221
c8a82d0fb443 With namespace prefixes LSUB prefix.* listed INBOX.INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5198
diff changeset
134 }
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
135 str_append(name_str, info->name);
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
136
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
137 if (ctx->ns->sep != ctx->ns->real_sep) {
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
138 char *p = str_c_modifiable(name_str);
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
139 for (; *p != '\0'; p++) {
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
140 if (*p == ctx->ns->real_sep)
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
141 *p = ctx->ns->sep;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
142 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
143 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
144 name = str_c(name_str);
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
145
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
146 if (*ctx->ns->prefix != '\0') {
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
147 /* With masks containing '*' we do the checks here
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
148 so prefix is included in matching */
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
149 if (ctx->glob != NULL &&
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
150 imap_match(ctx->glob, name) != IMAP_MATCH_YES)
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
151 continue;
4639
47531abcf691 Handle INBOX-prefixed namespaces better. Avoid duplicate INBOX replies if
Timo Sirainen <tss@iki.fi>
parents: 4546
diff changeset
152 }
47531abcf691 Handle INBOX-prefixed namespaces better. Avoid duplicate INBOX replies if
Timo Sirainen <tss@iki.fi>
parents: 4546
diff changeset
153 if (strcasecmp(name, "INBOX") == 0) {
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
154 if (!ctx->ns->inbox)
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
155 continue;
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
156
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
157 name = "INBOX";
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
158 ctx->inbox_found = TRUE;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
159 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
160
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
161 str_truncate(str, 0);
5314
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
162 str_printfa(str, "* %s (", ctx->lsub ? "LSUB" : "LIST");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
163 mailbox_flags2str(str, info->flags, ctx->list_flags);
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
164 str_printfa(str, ") \"%s\" ", ctx->ns->sep_str);
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
165 imap_quote_append_string(str, name, FALSE);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
166 if (client_send_line(client, str_c(str)) == 0) {
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
167 /* buffer is full, continue later */
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
168 t_pop();
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
169 return 0;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
170 }
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
171 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
172
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
173 if (mailbox_list_iter_deinit(&ctx->list_iter) < 0) {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
174 mail_storage_set_list_error(ctx->ns->storage);
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
175 ret = -1;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
176 }
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
177
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
178 if (ret == 0)
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
179 list_namespace_inbox(client, ctx);
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
180
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
181 t_pop();
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
182 return ret < 0 ? -1 : 1;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
183 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
184
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
185 static bool list_mask_has_wildcards(const char *mask)
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
186 {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
187 for (; *mask != '\0'; mask++) {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
188 if (*mask == '%' || *mask == '*')
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
189 return TRUE;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
190 }
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
191 return FALSE;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
192 }
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
193
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
194 static void
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
195 skip_namespace_prefix(const char **prefix, const char **mask,
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
196 bool inbox_check, char sep)
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
197 {
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
198 size_t mask_len, prefix_len;
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3856
diff changeset
199 bool match;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
200
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
201 prefix_len = strlen(*prefix);
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
202 mask_len = strlen(*mask);
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
203
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
204 if (mask_len < prefix_len) {
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
205 /* eg. namespace prefix = "INBOX.", mask = "INBOX" */
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
206 return;
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
207 }
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
208
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
209 match = strncmp(*prefix, *mask, prefix_len) == 0;
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
210 if (!match && inbox_check) {
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
211 /* try INBOX check. */
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
212 match = prefix_len >= 5 &&
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
213 strncasecmp(*prefix, *mask, 5) == 0 &&
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
214 strncmp(*prefix + 5, *mask + 5, prefix_len - 5) == 0 &&
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
215 strncasecmp(*prefix, "INBOX", 5) == 0 &&
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
216 ((*prefix)[5] == sep || (*prefix)[5] == '\0');
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
217 }
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
218
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
219 if (match) {
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
220 *prefix += prefix_len;
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
221 *mask += prefix_len;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
222 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
223 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
224
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
225 static void
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
226 list_namespace_init(struct client_command_context *cmd,
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
227 struct cmd_list_context *ctx)
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
228 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
229 struct client *client = cmd->client;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
230 struct namespace *ns = ctx->ns;
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
231 const char *cur_ns_prefix, *cur_ref, *cur_mask;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
232 enum imap_match_result match;
4545
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
233 enum imap_match_result inbox_match;
5104
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
234 enum mailbox_list_flags list_flags;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
235 struct mailbox_list *list;
4545
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
236 struct imap_match_glob *inbox_glob;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
237 unsigned int count;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
238 size_t len;
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
239
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
240 cur_ns_prefix = ns->prefix;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
241 cur_ref = ctx->ref;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
242 cur_mask = ctx->mask;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
243
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
244 if (*cur_ref != '\0' && *cur_ns_prefix != '\0') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
245 /* reference argument given. skip namespace prefix using it.
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
246
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
247 cur_ns_prefix = foo/bar/
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
248 cur_ref = foo/
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
249 -> cur_ns_prefix=bar/, cur_ref=""
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
250 cur_ref = foo/bar/baz
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
251 -> cur_ns_prefix="", cur_ref="baz"
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
252 */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
253 skip_namespace_prefix(&cur_ns_prefix, &cur_ref, TRUE, ns->sep);
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
254
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
255 if (*cur_ref != '\0' && *cur_ns_prefix != '\0') {
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
256 /* reference parameter didn't match with
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
257 namespace prefix. skip this. */
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
258 return;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
259 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
260 }
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
261
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
262 if (*cur_ns_prefix != '\0') {
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
263 /* no reference parameter. skip namespace prefix from mask. */
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
264 const char *old_ns_prefix = cur_ns_prefix;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
265 const char *old_mask = cur_mask;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
266
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
267 i_assert(*cur_ref == '\0');
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
268
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
269 skip_namespace_prefix(&cur_ns_prefix, &cur_mask,
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
270 cur_ref == ctx->ref, ns->sep);
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
271
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
272 if (*cur_mask == '\0' && *cur_ns_prefix == '\0') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
273 /* trying to list the namespace prefix itself. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
274 cur_ns_prefix = old_ns_prefix;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
275 cur_mask = old_mask;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
276 }
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
277 }
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
278
4545
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
279 /* if the original reference and mask combined produces something
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
280 that matches INBOX, the INBOX casing is on. */
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
281 inbox_glob = imap_match_init(cmd->pool,
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
282 t_strconcat(ctx->ref, ctx->mask, NULL),
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
283 TRUE, ns->sep);
5104
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
284 inbox_match = *ns->prefix == '\0' || ns->inbox ?
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
285 imap_match(inbox_glob, "INBOX") : FALSE;
4545
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
286 ctx->match_inbox = inbox_match == IMAP_MATCH_YES;
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
287
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
288 ctx->glob = imap_match_init(cmd->pool, ctx->mask,
4545
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
289 (inbox_match == IMAP_MATCH_YES ||
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
290 inbox_match == IMAP_MATCH_PARENT) &&
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
291 cur_mask == ctx->mask,
5ab638aafc7b Fixes to handling INBOX in LIST.
Timo Sirainen <tss@iki.fi>
parents: 4542
diff changeset
292 ns->sep);
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
293
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
294 if (*cur_ns_prefix != '\0') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
295 /* namespace prefix still wasn't completely skipped over.
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
296 for example cur_ns_prefix=INBOX/, mask=%/% or mask=IN%.
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
297 Check that mask matches namespace prefix. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
298 bool skip_trailing_sep = FALSE;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
299 i_assert(*cur_ref == '\0');
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
300
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
301 /* drop the trailing separator in namespace prefix.
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
302 don't do it if we're listing only the prefix itself. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
303 len = strlen(cur_ns_prefix);
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
304 if (cur_ns_prefix[len-1] == ns->sep &&
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
305 strcmp(cur_mask, cur_ns_prefix) != 0) {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
306 skip_trailing_sep = TRUE;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
307 cur_ns_prefix = t_strndup(cur_ns_prefix, len-1);
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
308 }
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
309
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
310 /* hidden namespaces should still be seen without wildcards.
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
311 some clients rely on this. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
312 match = (ns->hidden && list_mask_has_wildcards(cur_mask)) ?
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
313 IMAP_MATCH_NO : imap_match(ctx->glob, cur_ns_prefix);
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
314 if (match < 0)
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
315 return;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
316
4639
47531abcf691 Handle INBOX-prefixed namespaces better. Avoid duplicate INBOX replies if
Timo Sirainen <tss@iki.fi>
parents: 4546
diff changeset
317 len = strlen(ns->prefix);
3305
cccb5c6ba946 LSUB was returning namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3217
diff changeset
318 if (match == IMAP_MATCH_YES &&
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
319 (ctx->list_flags & MAILBOX_LIST_ITER_SUBSCRIBED) == 0 &&
4639
47531abcf691 Handle INBOX-prefixed namespaces better. Avoid duplicate INBOX replies if
Timo Sirainen <tss@iki.fi>
parents: 4546
diff changeset
320 (!ctx->ns->inbox ||
47531abcf691 Handle INBOX-prefixed namespaces better. Avoid duplicate INBOX replies if
Timo Sirainen <tss@iki.fi>
parents: 4546
diff changeset
321 strncmp(ns->prefix, "INBOX", len-1) != 0)) {
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
322 /* The prefix itself matches */
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
323 enum mailbox_info_flags flags;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
324 string_t *str = t_str_new(128);
2537
5c95f17f6f25 Fix for having INBOX/ namespace.
Timo Sirainen <tss@iki.fi>
parents: 2425
diff changeset
325
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4808
diff changeset
326 flags = MAILBOX_NONEXISTENT | MAILBOX_CHILDREN;
5314
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
327 str_append(str, "* LIST (");
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
328 mailbox_flags2str(str, flags, ctx->list_flags);
ce59b45431fb Use less memory when listing lots of mailboxes
Timo Sirainen <tss@iki.fi>
parents: 5307
diff changeset
329 str_printfa(str, ") \"%s\" ", ns->sep_str);
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
330 imap_quote_append_string(str, skip_trailing_sep ?
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
331 t_strndup(ns->prefix, len-1) : ns->prefix,
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
332 FALSE);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
333 client_send_line(client, str_c(str));
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
334 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
335 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
336
3856
b97de2e354bd Fixes to handling namespace prefixes.
Timo Sirainen <tss@iki.fi>
parents: 3305
diff changeset
337
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
338 if (*cur_ns_prefix != '\0') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
339 /* We didn't skip over the whole namespace prefix. For example
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
340 cur_ns_prefix=INBOX/ and mask=%/% or IN*.
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
341
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
342 We have already verified that the mask matches the namespace
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
343 prefix, so we'll just have to skip over as many hierarchies
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
344 from mask as there exists in namespace prefix.
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
345
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
346 The "INBOX" namespace match reply was already sent. We're
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
347 only listing the actual mailboxes now. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
348 i_assert(*cur_ref == '\0');
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
349
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
350 for (count = 1; *cur_ns_prefix != '\0'; cur_ns_prefix++) {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
351 if (*cur_ns_prefix == ns->sep)
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
352 count++;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
353 }
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
354
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
355 for (; count > 0; count--) {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
356 /* skip over one hierarchy */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
357 while (*cur_mask != '\0' && *cur_mask != '*' &&
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
358 *cur_mask != ns->sep)
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
359 cur_mask++;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
360
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
361 if (*cur_mask == '*') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
362 /* we'll just request "*" and filter it
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
363 ourself. otherwise this gets too complex. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
364 cur_mask = "*";
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
365 break;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
366 }
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
367 if (*cur_mask == '\0') {
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
368 /* mask ended too early. we won't be listing
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
369 any mailboxes. */
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
370 break;
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
371 }
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
372 cur_mask++;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
373 }
4729
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
374
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
375 if (*cur_mask == '\0' && ctx->match_inbox) {
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
376 /* oh what a horrible hack. ns_prefix="INBOX/" and
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
377 we wanted to list "%". INBOX should match. */
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
378 cur_mask = "INBOX";
5ac887e3a53d If we had only prefixed namespaces and we listed for "%", INBOX's flags
Timo Sirainen <tss@iki.fi>
parents: 4639
diff changeset
379 }
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
380 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
381
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
382 if (*cur_mask != '*' || strcmp(ctx->mask, "*") == 0) {
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
383 /* a) we don't have '*' in mask
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
384 b) we want to display everything
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
385
3875
e5abc07d843f Cleaned up and added comments. Also added some kludging so that listing
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
386 we don't need to do separate filtering ourself */
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
387 ctx->glob = NULL;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
388 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
389
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
390 cur_ref = namespace_fix_sep(ns, cur_ref);
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
391 cur_mask = namespace_fix_sep(ns, cur_mask);
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
392
5104
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
393 list_flags = ctx->list_flags;
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
394 if (ctx->match_inbox)
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
395 list_flags |= MAILBOX_LIST_FLAG_INBOX;
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
396
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
397 list = mail_storage_get_list(ns->storage);
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4808
diff changeset
398 cur_mask = mailbox_list_join_refmask(list, cur_ref, cur_mask);
5104
ffd9df333232 If namespace has a prefix and inbox=no, don't list prefix.inbox if it
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
399 ctx->list_iter = mailbox_list_iter_init(list, cur_mask, list_flags);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
400 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
401
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3856
diff changeset
402 static bool cmd_list_continue(struct client_command_context *cmd)
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
403 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
404 struct client *client = cmd->client;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
405 struct cmd_list_context *ctx = cmd->context;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
406 int ret;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
407
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
408 if (cmd->cancel) {
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
409 if (ctx->list_iter != NULL) {
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
410 if (mailbox_list_iter_deinit(&ctx->list_iter) < 0)
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
411 mail_storage_set_list_error(ctx->ns->storage);
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
412 }
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
413 return TRUE;
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
414 }
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
415 for (; ctx->ns != NULL; ctx->ns = ctx->ns->next) {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
416 if (ctx->list_iter == NULL)
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
417 list_namespace_init(cmd, ctx);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
418
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
419 if ((ret = list_namespace_mailboxes(client, ctx)) < 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
420 client_send_storage_error(cmd, ctx->ns->storage);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
421 return TRUE;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
422 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
423 if (ret == 0)
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
424 return FALSE;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
425 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
426
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
427 client_send_tagline(cmd, !ctx->lsub ?
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
428 "OK List completed." :
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
429 "OK Lsub completed.");
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
430 return TRUE;
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
431 }
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
432
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3856
diff changeset
433 bool _cmd_list_full(struct client_command_context *cmd, bool lsub)
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
435 struct client *client = cmd->client;
1657
a85af58a363c A bit more temporary kludging
Timo Sirainen <tss@iki.fi>
parents: 1655
diff changeset
436 struct namespace *ns;
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
437 struct imap_arg *args;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
438 enum mailbox_list_flags list_flags;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
439 struct cmd_list_context *ctx;
1198
d28571e8c810 Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
Timo Sirainen <tss@iki.fi>
parents: 1183
diff changeset
440 const char *ref, *mask;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
441
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
442 /* [(<options>)] <reference> <mailbox wildcards> */
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
443 if (!client_read_args(cmd, 0, 0, &args))
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
444 return FALSE;
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
445
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
446 if (lsub) {
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
447 /* LSUB - we don't care about flags */
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
448 list_flags = MAILBOX_LIST_ITER_SUBSCRIBED |
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
449 MAILBOX_LIST_ITER_FAST_FLAGS |
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
450 _MAILBOX_LIST_ITER_HIDE_CHILDREN;
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
451 } else if (args[0].type != IMAP_ARG_LIST) {
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
452 /* LIST - allow children flags, but don't require them */
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
453 list_flags = 0;
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
454 } else {
5307
1e2b2b3f18e3 Added casts to some enums to avoid compiler warnings.
Timo Sirainen <tss@iki.fi>
parents: 5221
diff changeset
455 list_flags =
1e2b2b3f18e3 Added casts to some enums to avoid compiler warnings.
Timo Sirainen <tss@iki.fi>
parents: 5221
diff changeset
456 (enum mailbox_list_flags)_MAILBOX_LIST_ITER_LISTEXT;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
457 if (!parse_list_flags(cmd, IMAP_ARG_LIST(&args[0])->args,
1895
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
458 &list_flags))
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
459 return TRUE;
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
460 args++;
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
461
bbdce1697239 LSUB should never show \HasChildren flags.
Timo Sirainen <tss@iki.fi>
parents: 1890
diff changeset
462 /* don't show children flags unless explicitly specified */
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
463 if ((list_flags & MAILBOX_LIST_ITER_CHILDREN) == 0)
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4729
diff changeset
464 list_flags |= _MAILBOX_LIST_ITER_HIDE_CHILDREN;
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
465 }
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
466
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
467 ref = imap_arg_string(&args[0]);
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
468 mask = imap_arg_string(&args[1]);
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
469
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
470 if (ref == NULL || mask == NULL) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
471 client_send_command_error(cmd, "Invalid arguments.");
1244
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
472 return TRUE;
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
473 }
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
474
40bae47bdba1 Added support for CHILDREN and LISTEXT extensions.
Timo Sirainen <tss@iki.fi>
parents: 1218
diff changeset
475 if (*mask == '\0' && !lsub) {
3217
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
476 /* special request to return the hierarchy delimiter and
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
477 mailbox root name. Mailbox root name is somewhat strange
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
478 concept which probably no other client uses than Pine.
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
479 Just try our best to emulate UW-IMAP behavior and hopefully
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
480 we're fine. */
3876
a291d41bc50d Fixes to returning namespace root with "" mask.
Timo Sirainen <tss@iki.fi>
parents: 3875
diff changeset
481 ns = namespace_find_visible(client->namespaces, &ref);
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
482 if (ns == NULL) {
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
483 const char *empty = "";
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
484 ns = namespace_find(client->namespaces, &empty);
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
485 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
486
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
487 if (ns != NULL) {
3217
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
488 string_t *str = t_str_new(64);
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
489
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
490 str_printfa(str, "* LIST (\\Noselect) \"%s\" ",
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
491 ns->sep_str);
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
492 if (*ns->prefix != '\0' && !ns->hidden) {
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
493 /* public namespace, use it as the root name */
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
494 imap_quote_append_string(str, ns->prefix,
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
495 FALSE);
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
496 } else {
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
497 /* private namespace, or empty namespace
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
498 prefix. use the mailbox name's first part
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
499 as the root. */
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
500 const char *p = strchr(ref, ns->sep);
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
501
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
502 if (p == NULL)
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
503 str_append(str, "\"\"");
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
504 else {
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
505 imap_quote_append_string(str,
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
506 t_strdup_until(ref, p + 1),
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
507 FALSE);
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
508 }
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
509 }
23e5925c48dd We weren't returning "root name" properly with LIST <ref> "".
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
510 client_send_line(client, str_c(str));
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
511 }
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
512 client_send_tagline(cmd, "OK List completed.");
2350
1371d41c375f Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
513 } else {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
514 ctx = p_new(cmd->pool, struct cmd_list_context, 1);
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
515 ctx->ref = ref;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
516 ctx->mask = mask;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
517 ctx->list_flags = list_flags;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
518 ctx->lsub = lsub;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
519 ctx->ns = client->namespaces;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
520
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
521 cmd->context = ctx;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
522 if (!cmd_list_continue(cmd)) {
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
523 /* unfinished */
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
524 cmd->output_pending = TRUE;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
525 cmd->func = cmd_list_continue;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
526 return FALSE;
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
527 }
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
528
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
529 cmd->context = NULL;
2425
8267d11cacfb LIST command interrupts itself when output buffer gets full and continues
Timo Sirainen <tss@iki.fi>
parents: 2374
diff changeset
530 return TRUE;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
531 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
532 return TRUE;
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
533 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
534
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3856
diff changeset
535 bool cmd_list(struct client_command_context *cmd)
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
536 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2590
diff changeset
537 return _cmd_list_full(cmd, FALSE);
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
538 }