annotate src/imap/cmd-thread.c @ 8590:b9faf4db2a9f HEAD

Updated copyright notices to include year 2009.
author Timo Sirainen <tss@iki.fi>
date Tue, 06 Jan 2009 09:25:38 -0500
parents 70b53e9b232e
children bd2bb6ff0a83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8590
b9faf4db2a9f Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents: 8146
diff changeset
1 /* Copyright (c) 2002-2009 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"
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents: 952
diff changeset
7 #include "imap-search.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 ||
b2fefe24b849 Moved code around so that cmd-thread.c can do the THREAD reply writing.
Timo Sirainen <tss@iki.fi>
parents: 7790
diff changeset
86 thread_type == MAIL_THREAD_REFERENCES2);
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 int ret, args_count;
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
112 const char *charset, *str;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
113
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4921
diff changeset
114 args_count = imap_parser_read_args(cmd->parser, 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 if (args_count == -2)
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 return FALSE;
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4921
diff changeset
117 client->input_lock = NULL;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
118
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119 if (args_count < 3) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
120 client_send_command_error(cmd, args_count < 0 ? NULL :
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 "Missing or invalid arguments.");
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
125 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
126 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
127
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
128 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
129 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
130 "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
131 return TRUE;
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
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
134 str = IMAP_ARG_STR(args);
7906
d987e018483b Thread code cleanups + fixes
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
135 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
136 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
137 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 }
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
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141 /* charset */
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 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
143 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
144 "Invalid charset argument.");
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
145 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147 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
148 args++;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
149
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7639
diff changeset
150 ret = imap_search_args_build(cmd, args, charset, &sargs);
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
151 if (ret <= 0)
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
152 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
153
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
154 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
155 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
156 if (ret < 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
157 client_send_storage_error(cmd,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1654
diff changeset
158 mailbox_get_storage(client->mailbox));
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
159 return TRUE;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
160 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
161
7639
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
162 return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
163 (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
03146f02403f Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
164 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
165 }