annotate src/imap/cmd-thread.c @ 7086:7ed926ed7aa4 HEAD

Updated copyright notices to include year 2008.
author Timo Sirainen <tss@iki.fi>
date Tue, 01 Jan 2008 22:05:21 +0200
parents 65c69a53a7be
children 443dcddf9a9a 03146f02403f 34d402399040
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7086
7ed926ed7aa4 Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
1 /* Copyright (c) 2002-2008 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"
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "buffer.h"
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "commands.h"
988
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents: 952
diff changeset
6 #include "imap-search.h"
8028c4dcf38f mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents: 952
diff changeset
7 #include "imap-thread.h"
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
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
9 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
10 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
11 struct client *client = cmd->client;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 enum mail_thread_type threading;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 struct mail_search_arg *sargs;
5835
d59ed6a31b66 Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
14 const struct imap_arg *args;
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 int args_count;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 pool_t pool;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 const char *error, *charset, *str;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4921
diff changeset
19 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
20 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
21 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
22 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
23
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 if (args_count < 3) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
25 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
26 "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
27 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
30 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
31 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 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
34 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
35 "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
36 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 str = IMAP_ARG_STR(args);
952
5c8cd0bf94c1 We support only REFERENCES threading for now - updated capability and trying
Timo Sirainen <tss@iki.fi>
parents: 924
diff changeset
40 if (strcasecmp(str, "REFERENCES") == 0)
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 threading = MAIL_THREAD_REFERENCES;
952
5c8cd0bf94c1 We support only REFERENCES threading for now - updated capability and trying
Timo Sirainen <tss@iki.fi>
parents: 924
diff changeset
42 else if (strcasecmp(str, "ORDEREDSUBJECT") == 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
43 client_send_command_error(cmd,
952
5c8cd0bf94c1 We support only REFERENCES threading for now - updated capability and trying
Timo Sirainen <tss@iki.fi>
parents: 924
diff changeset
44 "ORDEREDSUBJECT threading is currently not supported.");
5c8cd0bf94c1 We support only REFERENCES threading for now - updated capability and trying
Timo Sirainen <tss@iki.fi>
parents: 924
diff changeset
45 return TRUE;
5c8cd0bf94c1 We support only REFERENCES threading for now - updated capability and trying
Timo Sirainen <tss@iki.fi>
parents: 924
diff changeset
46 } else {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
47 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
48 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 args++;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 /* charset */
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 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
54 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
55 "Invalid charset argument.");
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 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
59 args++;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
61 pool = pool_alloconly_create("mail_search_args", 2048);
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1654
diff changeset
63 sargs = imap_search_args_build(pool, client->mailbox, args, &error);
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64 if (sargs == NULL) {
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 /* error in search arguments */
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
66 client_send_tagline(cmd, t_strconcat("NO ", error, NULL));
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
67 } else if (imap_thread(cmd, charset, sargs, threading) == 0) {
6428
7cad076906eb pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents: 6229
diff changeset
68 pool_unref(&pool);
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
69 return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
70 (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
3765
ce76b6b8ff11 UID STORE command must return UID parameter in FETCH replies.
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
71 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
72 } else {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
73 client_send_storage_error(cmd,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1654
diff changeset
74 mailbox_get_storage(client->mailbox));
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 }
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76
6428
7cad076906eb pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents: 6229
diff changeset
77 pool_unref(&pool);
924
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 return TRUE;
4f697dde0fca THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 }