annotate src/imap/cmd-thread.c @ 9575:0a00dcc4f0ea HEAD

lib-storage: Allow shared namespace prefix to use %variable modifiers.
author Timo Sirainen <tss@iki.fi>
date Wed, 26 May 2010 17:07:51 +0100
parents 00cd9aacd03c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9532
00cd9aacd03c Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents: 8903
diff changeset
1 /* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
4 #include "str.h"
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
5 #include "ostream.h"
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "commands.h"
8711
bd2bb6ff0a83 Renamed imap-search.[ch] to imap-search-args.[ch]
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
7 #include "imap-search-args.h"
7796
37f23e0476e2 Moved threading code to lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 7794
diff changeset
8 #include "mail-thread.h"
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
10 static int imap_thread_write(struct mail_thread_iterate_context *iter,
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
11 string_t *str, bool root)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
12 {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
13 const struct mail_thread_child_node *node;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
14 struct mail_thread_iterate_context *child_iter;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
15 unsigned int count;
7796
37f23e0476e2 Moved threading code to lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 7794
diff changeset
16 int ret = 0;
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
17
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
18 count = mail_thread_iterate_count(iter);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
19 if (count == 0)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
20 return 0;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
21
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
22 if (count == 1 && !root) {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
23 /* only one child - special case to avoid extra paranthesis */
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
24 node = mail_thread_iterate_next(iter, &child_iter);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
25 str_printfa(str, "%u", node->uid);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
26 if (child_iter != NULL) {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
27 str_append_c(str, ' ');
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
28 T_BEGIN {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
29 ret = imap_thread_write(child_iter, str, FALSE);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
30 } T_END;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
31 if (mail_thread_iterate_deinit(&child_iter) < 0)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
32 return -1;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
33 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
34 return ret;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
35 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
36
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
37 while ((node = mail_thread_iterate_next(iter, &child_iter)) != NULL) {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
38 if (child_iter == NULL) {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
39 /* no children */
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
40 str_printfa(str, "(%u)", node->uid);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
41 } else {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
42 /* node with children */
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
43 str_append_c(str, '(');
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
44 if (node->uid != 0)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
45 str_printfa(str, "%u ", node->uid);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
46 T_BEGIN {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
47 ret = imap_thread_write(child_iter, str, FALSE);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
48 } T_END;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
49 if (mail_thread_iterate_deinit(&child_iter) < 0 ||
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
50 ret < 0)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
51 return -1;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
52 str_append_c(str, ')');
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
53 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
54 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
55 return 0;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
56 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
57
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
58 static int
7796
37f23e0476e2 Moved threading code to lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 7794
diff changeset
59 imap_thread_write_reply(struct mail_thread_context *ctx, string_t *str,
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
60 enum mail_thread_type thread_type, bool write_seqs)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
61 {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
62 struct mail_thread_iterate_context *iter;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
63 int ret;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
64
7796
37f23e0476e2 Moved threading code to lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 7794
diff changeset
65 iter = mail_thread_iterate_init(ctx, thread_type, write_seqs);
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
66 str_append(str, "* THREAD ");
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
67 T_BEGIN {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
68 ret = imap_thread_write(iter, str, TRUE);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
69 } T_END;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
70 if (mail_thread_iterate_deinit(&iter) < 0)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
71 ret = -1;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
72
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
73 str_append(str, "\r\n");
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
74 return ret;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
75 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
76
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
77 static int imap_thread(struct client_command_context *cmd,
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
78 struct mail_search_args *search_args,
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
79 enum mail_thread_type thread_type)
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
80 {
7796
37f23e0476e2 Moved threading code to lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 7794
diff changeset
81 struct mail_thread_context *ctx;
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
82 string_t *str;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
83 int ret;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
84
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
85 i_assert(thread_type == MAIL_THREAD_REFERENCES ||
8903
20e6fa42d081 Renamed THREAD X-REFERENCES2 to THREAD REFS (from INTHREAD draft).
Timo Sirainen <tss@iki.fi>
parents: 8727
diff changeset
86 thread_type == MAIL_THREAD_REFS);
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
87
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
88 str = str_new(default_pool, 1024);
8146
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
89 ret = mail_thread_init(cmd->client->mailbox,
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
90 search_args, &ctx);
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
91 if (ret == 0) {
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
92 ret = imap_thread_write_reply(ctx, str, thread_type,
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
93 !cmd->uid);
70b53e9b232e Rewrote thread indexing code. It's a lot simpler and takes less disk space.
Timo Sirainen <tss@iki.fi>
parents: 7906
diff changeset
94 mail_thread_deinit(&ctx);
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
95 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
96
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
97 if (ret == 0) {
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
98 (void)o_stream_send(cmd->client->output,
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
99 str_data(str), str_len(str));
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
100 }
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
101 str_free(&str);
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
102 return ret;
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
103 }
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3765
diff changeset
105 bool cmd_thread(struct client_command_context *cmd)
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
106 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
107 struct client *client = cmd->client;
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
108 enum mail_thread_type thread_type;
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7639
diff changeset
109 struct mail_search_args *sargs;
5835
d59ed6a31b66 Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
110 const struct imap_arg *args;
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
111 const char *charset, *str;
8727
d2c357625ef2 Avoid calling imap_parser_*() directly. It's not required.
Timo Sirainen <tss@iki.fi>
parents: 8711
diff changeset
112 int ret;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
113
8727
d2c357625ef2 Avoid calling imap_parser_*() directly. It's not required.
Timo Sirainen <tss@iki.fi>
parents: 8711
diff changeset
114 if (!client_read_args(cmd, 0, 0, &args))
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 return FALSE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
117 if (!client_verify_open_mailbox(cmd))
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
118 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
120 if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
121 client_send_command_error(cmd,
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122 "Invalid thread algorithm argument.");
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
125
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
126 str = IMAP_ARG_STR(args);
7906
d987e018483b Thread code cleanups + fixes
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
127 if (!mail_thread_type_parse(str, &thread_type)) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
128 client_send_command_error(cmd, "Unknown thread algorithm.");
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
129 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
130 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
131 args++;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
132
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 /* charset */
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
134 if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) {
8727
d2c357625ef2 Avoid calling imap_parser_*() directly. It's not required.
Timo Sirainen <tss@iki.fi>
parents: 8711
diff changeset
135 client_send_command_error(cmd, "Invalid charset argument.");
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
136 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 charset = IMAP_ARG_STR(args);
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
139 args++;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7639
diff changeset
141 ret = imap_search_args_build(cmd, args, charset, &sargs);
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
142 if (ret <= 0)
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
143 return ret < 0;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
144
7794
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
145 ret = imap_thread(cmd, sargs, thread_type);
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7639
diff changeset
146 mail_search_args_unref(&sargs);
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7639
diff changeset
147 if (ret < 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
148 client_send_storage_error(cmd,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1654
diff changeset
149 mailbox_get_storage(client->mailbox));
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
150 return TRUE;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
151 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
152
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
153 return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
154 (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
155 0, "OK Thread completed.");
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
156 }