Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/imap/imap-fetch.c @ 9658:8ba4253adc9b HEAD tip
*-login: SSL connections didn't get closed when the client got destroyed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 08 May 2014 16:41:29 +0300 |
parents | 70fa6178380e |
children |
rev | line source |
---|---|
9532
00cd9aacd03c
Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents:
9515
diff
changeset
|
1 /* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */ |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "common.h" |
3470
346a494c2feb
Moved array declaration to array-decl.h and include it in lib.h. So array.h
Timo Sirainen <tss@iki.fi>
parents:
3216
diff
changeset
|
4 #include "array.h" |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
5 #include "buffer.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "istream.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "ostream.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "str.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "message-send.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include "message-size.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include "imap-date.h" |
7629 | 12 #include "mail-search-build.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 #include "commands.h" |
7910
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
14 #include "imap-quote.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 #include "imap-fetch.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
16 #include "imap-util.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
18 #include <stdlib.h> |
9116
9ae55b68cf61
IMAP FETCH: Previous change broke fetching RFC822*.
Timo Sirainen <tss@iki.fi>
parents:
9115
diff
changeset
|
19 #include <ctype.h> |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
21 #define BODY_NIL_REPLY \ |
7948
e29ddf600a09
FETCH BODY/BODYSTRUCTURE failures replied with too many NILs.
Timo Sirainen <tss@iki.fi>
parents:
7910
diff
changeset
|
22 "\"text\" \"plain\" NIL NIL NIL \"7bit\" 0 0" |
6887 | 23 #define ENVELOPE_NIL_REPLY \ |
24 "(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)" | |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
25 |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
26 static ARRAY_DEFINE(fetch_handlers, struct imap_fetch_handler); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
27 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
28 static int imap_fetch_handler_cmp(const void *p1, const void *p2) |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
29 { |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
30 const struct imap_fetch_handler *h1 = p1, *h2 = p2; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
31 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
32 return strcmp(h1->name, h2->name); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
33 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
34 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
35 void imap_fetch_handlers_register(const struct imap_fetch_handler *handlers, |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
36 size_t count) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
37 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
38 struct imap_fetch_handler *all_handlers; |
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
39 unsigned int all_count; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
40 |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
41 array_append(&fetch_handlers, handlers, count); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
42 |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
43 all_handlers = array_get_modifiable(&fetch_handlers, &all_count); |
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
44 qsort(all_handlers, all_count, sizeof(*all_handlers), |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
45 imap_fetch_handler_cmp); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
46 } |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
47 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
48 static int imap_fetch_handler_bsearch(const void *name_p, const void *handler_p) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
49 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
50 const char *name = name_p; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
51 const struct imap_fetch_handler *h = handler_p; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
52 |
9115
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
53 return strcmp(name, h->name); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
54 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
55 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3470
diff
changeset
|
56 bool imap_fetch_init_handler(struct imap_fetch_context *ctx, const char *name, |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
57 const struct imap_arg **args) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
58 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
59 const struct imap_fetch_handler *handler, *handlers; |
9115
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
60 const char *lookup_name, *p; |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
61 unsigned int count; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
62 |
9225
f353c5b71097
IMAP: FETCH X-* parameters weren't working.
Timo Sirainen <tss@iki.fi>
parents:
9116
diff
changeset
|
63 for (p = name; i_isalnum(*p) || *p == '-'; p++) ; |
9115
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
64 lookup_name = t_strdup_until(name, p); |
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
65 |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
66 handlers = array_get_modifiable(&fetch_handlers, &count); |
9115
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
67 handler = bsearch(lookup_name, handlers, count, |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
68 sizeof(struct imap_fetch_handler), |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
69 imap_fetch_handler_bsearch); |
2497
5cab421f36be
Don't crash with unknown FETCH commands.
Timo Sirainen <tss@iki.fi>
parents:
2483
diff
changeset
|
70 if (handler == NULL) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
3108
diff
changeset
|
71 client_send_command_error(ctx->cmd, |
9115
4d2b2adfd415
IMAP FETCH: Binary searching fetch handlers was a bit broken.
Timo Sirainen <tss@iki.fi>
parents:
9072
diff
changeset
|
72 t_strconcat("Unknown parameter ", name, NULL)); |
2497
5cab421f36be
Don't crash with unknown FETCH commands.
Timo Sirainen <tss@iki.fi>
parents:
2483
diff
changeset
|
73 return FALSE; |
5cab421f36be
Don't crash with unknown FETCH commands.
Timo Sirainen <tss@iki.fi>
parents:
2483
diff
changeset
|
74 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
75 |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
76 return handler->init(ctx, name, args); |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
77 } |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
78 |
7629 | 79 struct imap_fetch_context * |
80 imap_fetch_init(struct client_command_context *cmd, struct mailbox *box) | |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
3108
diff
changeset
|
82 struct client *client = cmd->client; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
83 struct imap_fetch_context *ctx; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
84 |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
3108
diff
changeset
|
85 ctx = p_new(cmd->pool, struct imap_fetch_context, 1); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
86 ctx->client = client; |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
3108
diff
changeset
|
87 ctx->cmd = cmd; |
7629 | 88 ctx->box = box; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
89 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
90 ctx->cur_str = str_new(default_pool, 8192); |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
91 p_array_init(&ctx->all_headers, cmd->pool, 64); |
4596
bf4e98a0de3f
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
Timo Sirainen <tss@iki.fi>
parents:
4594
diff
changeset
|
92 p_array_init(&ctx->handlers, cmd->pool, 16); |
7057
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
93 p_array_init(&ctx->tmp_keywords, cmd->pool, |
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
94 client->keywords.announce_count + 8); |
2730
eef378c0c07d
Don't send extra ")" line with bad FETCH parameters.
Timo Sirainen <tss@iki.fi>
parents:
2716
diff
changeset
|
95 ctx->line_finished = TRUE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
96 return ctx; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 |
8322
66a792567e59
QRESYNC: FETCH CHANGEDSINCE and SELECT with modseq shouldn't have returned changes with the same modseq.
Timo Sirainen <tss@iki.fi>
parents:
8274
diff
changeset
|
99 bool imap_fetch_add_changed_since(struct imap_fetch_context *ctx, |
66a792567e59
QRESYNC: FETCH CHANGEDSINCE and SELECT with modseq shouldn't have returned changes with the same modseq.
Timo Sirainen <tss@iki.fi>
parents:
8274
diff
changeset
|
100 uint64_t modseq) |
7629 | 101 { |
102 struct mail_search_arg *search_arg; | |
103 | |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
104 search_arg = p_new(ctx->search_args->pool, struct mail_search_arg, 1); |
7629 | 105 search_arg->type = SEARCH_MODSEQ; |
106 search_arg->value.modseq = | |
107 p_new(ctx->cmd->pool, struct mail_search_modseq, 1); | |
8322
66a792567e59
QRESYNC: FETCH CHANGEDSINCE and SELECT with modseq shouldn't have returned changes with the same modseq.
Timo Sirainen <tss@iki.fi>
parents:
8274
diff
changeset
|
108 search_arg->value.modseq->modseq = modseq + 1; |
7629 | 109 |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
110 search_arg->next = ctx->search_args->args->next; |
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
111 ctx->search_args->args->next = search_arg; |
7629 | 112 |
113 return imap_fetch_init_handler(ctx, "MODSEQ", NULL); | |
114 } | |
115 | |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4906
diff
changeset
|
116 #undef imap_fetch_add_handler |
4073 | 117 void imap_fetch_add_handler(struct imap_fetch_context *ctx, |
118 bool buffered, bool want_deinit, | |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
119 const char *name, const char *nil_reply, |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
120 imap_fetch_handler_t *handler, void *context) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 { |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
122 /* partially because of broken clients, but also partially because |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
123 it potentially can make client implementations faster, we have a |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
124 buffered parameter which basically means that the handler promises |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
125 to write the output in ctx->cur_str. The cur_str is then sent to |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
126 client before calling any non-buffered handlers. |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
127 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
128 We try to keep the handler registration order the same as the |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
129 client requested them. This is especially useful to get UID |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
130 returned first, which some clients rely on.. |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
131 */ |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
132 const struct imap_fetch_context_handler *handlers; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
133 struct imap_fetch_context_handler h; |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
134 unsigned int i, size; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
135 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
136 if (context == NULL) { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
137 /* don't allow duplicate handlers */ |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
138 handlers = array_get(&ctx->handlers, &size); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
139 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
140 for (i = 0; i < size; i++) { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
141 if (handlers[i].handler == handler && |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
142 handlers[i].context == NULL) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
143 return; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
144 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
145 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
146 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
147 memset(&h, 0, sizeof(h)); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
148 h.handler = handler; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
149 h.context = context; |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
150 h.buffered = buffered; |
4073 | 151 h.want_deinit = want_deinit; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
152 h.name = p_strdup(ctx->cmd->pool, name); |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
153 h.nil_reply = p_strdup(ctx->cmd->pool, nil_reply); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
154 |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
155 if (!buffered) |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
156 array_append(&ctx->handlers, &h, 1); |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
157 else { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
158 array_insert(&ctx->handlers, ctx->buffered_handlers_count, |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
159 &h, 1); |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
160 ctx->buffered_handlers_count++; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
161 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
162 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
163 |
7629 | 164 static void |
165 expunges_drop_known(struct imap_fetch_context *ctx, struct mail *mail, | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
166 ARRAY_TYPE(seq_range) *expunged_uids) |
7629 | 167 { |
9601
70fa6178380e
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
Timo Sirainen <tss@iki.fi>
parents:
9532
diff
changeset
|
168 struct mailbox_status status; |
7629 | 169 const uint32_t *seqs, *uids; |
170 unsigned int i, count; | |
171 | |
172 seqs = array_get(ctx->qresync_sample_seqset, &count); | |
173 uids = array_idx(ctx->qresync_sample_uidset, 0); | |
174 i_assert(array_count(ctx->qresync_sample_uidset) == count); | |
175 i_assert(count > 0); | |
176 | |
9601
70fa6178380e
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
Timo Sirainen <tss@iki.fi>
parents:
9532
diff
changeset
|
177 mailbox_get_status(ctx->box, STATUS_MESSAGES, &status); |
70fa6178380e
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
Timo Sirainen <tss@iki.fi>
parents:
9532
diff
changeset
|
178 |
7629 | 179 /* FIXME: we could do removals from the middle as well */ |
9601
70fa6178380e
imap: Don't crash with QRESYNC SELECT specifying sequences larger than mailbox's message count.
Timo Sirainen <tss@iki.fi>
parents:
9532
diff
changeset
|
180 for (i = 0; i < count && seqs[i] <= status.messages; i++) { |
7629 | 181 mail_set_seq(mail, seqs[i]); |
182 if (uids[i] != mail->uid) | |
183 break; | |
184 } | |
185 if (i > 0) | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
186 seq_range_array_remove_range(expunged_uids, 1, uids[i-1]); |
7629 | 187 } |
188 | |
189 static int get_expunges_fallback(struct imap_fetch_context *ctx, | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
190 const ARRAY_TYPE(seq_range) *uid_filter_arr, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
191 ARRAY_TYPE(seq_range) *expunged_uids) |
7629 | 192 { |
193 struct mailbox_transaction_context *trans; | |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
194 struct mail_search_args *search_args; |
7629 | 195 struct mail_search_context *search_ctx; |
196 struct mail *mail; | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
197 const struct seq_range *uid_filter; |
7629 | 198 struct mailbox_status status; |
199 unsigned int i, count; | |
200 uint32_t next_uid; | |
201 int ret = 0; | |
202 | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
203 uid_filter = array_get(uid_filter_arr, &count); |
7629 | 204 i_assert(count > 0); |
205 i = 0; | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
206 next_uid = uid_filter[0].seq1; |
7629 | 207 |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
208 /* search UIDs only in given range */ |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
209 search_args = mail_search_build_init(); |
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
210 search_args->args = p_new(search_args->pool, struct mail_search_arg, 1); |
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
211 search_args->args->type = SEARCH_UIDSET; |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
212 i_array_init(&search_args->args->value.seqset, count); |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
213 array_append_array(&search_args->args->value.seqset, uid_filter_arr); |
7629 | 214 |
215 trans = mailbox_transaction_begin(ctx->box, 0); | |
216 mail = mail_alloc(trans, 0, NULL); | |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
217 search_ctx = mailbox_search_init(trans, search_args, NULL); |
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
218 mail_search_args_unref(&search_args); |
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
219 |
7629 | 220 while (mailbox_search_next(search_ctx, mail) > 0) { |
221 if (mail->uid == next_uid) { | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
222 if (next_uid < uid_filter[i].seq2) |
7629 | 223 next_uid++; |
224 else if (++i < count) | |
9422
73c4a7d325fe
QRESYNC: Fixed fallback handling to fetching expunged UIDs.
Timo Sirainen <tss@iki.fi>
parents:
9421
diff
changeset
|
225 next_uid = uid_filter[i].seq1; |
7629 | 226 else |
227 break; | |
228 } else { | |
229 /* next_uid .. mail->uid-1 are expunged */ | |
230 i_assert(mail->uid > next_uid); | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
231 while (mail->uid > uid_filter[i].seq2) { |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
232 seq_range_array_add_range(expunged_uids, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
233 next_uid, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
234 uid_filter[i].seq2); |
7629 | 235 i++; |
236 i_assert(i < count); | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
237 next_uid = uid_filter[i].seq1; |
7629 | 238 } |
239 if (next_uid != mail->uid) { | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
240 seq_range_array_add_range(expunged_uids, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
241 next_uid, |
7629 | 242 mail->uid - 1); |
243 } | |
9447
36b8d97d0f58
QRESYNC: Fixed fallback handling to fetching expunged UIDs (again).
Timo Sirainen <tss@iki.fi>
parents:
9422
diff
changeset
|
244 if (uid_filter[i].seq2 != mail->uid) |
36b8d97d0f58
QRESYNC: Fixed fallback handling to fetching expunged UIDs (again).
Timo Sirainen <tss@iki.fi>
parents:
9422
diff
changeset
|
245 next_uid = mail->uid + 1; |
36b8d97d0f58
QRESYNC: Fixed fallback handling to fetching expunged UIDs (again).
Timo Sirainen <tss@iki.fi>
parents:
9422
diff
changeset
|
246 else if (++i < count) |
36b8d97d0f58
QRESYNC: Fixed fallback handling to fetching expunged UIDs (again).
Timo Sirainen <tss@iki.fi>
parents:
9422
diff
changeset
|
247 next_uid = uid_filter[i].seq1; |
7629 | 248 else |
9447
36b8d97d0f58
QRESYNC: Fixed fallback handling to fetching expunged UIDs (again).
Timo Sirainen <tss@iki.fi>
parents:
9422
diff
changeset
|
249 break; |
7629 | 250 } |
251 } | |
252 if (i < count) { | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
253 i_assert(next_uid <= uid_filter[i].seq2); |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
254 seq_range_array_add_range(expunged_uids, next_uid, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
255 uid_filter[i].seq2); |
7629 | 256 i++; |
257 } | |
258 for (; i < count; i++) { | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
259 seq_range_array_add_range(expunged_uids, uid_filter[i].seq1, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
260 uid_filter[i].seq2); |
7629 | 261 } |
262 | |
263 mailbox_get_status(ctx->box, STATUS_UIDNEXT, &status); | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
264 seq_range_array_remove_range(expunged_uids, status.uidnext, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
265 (uint32_t)-1); |
7629 | 266 |
267 if (mailbox_search_deinit(&search_ctx) < 0) | |
268 ret = -1; | |
269 | |
9420
352eab3d6ade
imap: Don't crash on SELECT .. QRESYNC if it didn't give seq-uid map.
Timo Sirainen <tss@iki.fi>
parents:
9346
diff
changeset
|
270 if (ret == 0 && ctx->qresync_sample_seqset != NULL && |
352eab3d6ade
imap: Don't crash on SELECT .. QRESYNC if it didn't give seq-uid map.
Timo Sirainen <tss@iki.fi>
parents:
9346
diff
changeset
|
271 array_is_created(ctx->qresync_sample_seqset)) |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
272 expunges_drop_known(ctx, mail, expunged_uids); |
7629 | 273 |
274 mail_free(&mail); | |
275 (void)mailbox_transaction_commit(&trans); | |
276 return ret; | |
277 } | |
278 | |
279 static int | |
280 imap_fetch_send_vanished(struct imap_fetch_context *ctx) | |
281 { | |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
282 const struct mail_search_arg *uidarg = ctx->search_args->args; |
7629 | 283 const struct mail_search_arg *modseqarg = uidarg->next; |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
284 const ARRAY_TYPE(seq_range) *uid_filter = &uidarg->value.seqset; |
9346
e0cee10e0f41
qresync: Fixed off-by-one modseq comparison when figuring out what VANISHED replies to send.
Timo Sirainen <tss@iki.fi>
parents:
9345
diff
changeset
|
285 uint64_t modseq = modseqarg->value.modseq->modseq - 1; |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
286 ARRAY_TYPE(seq_range) expunged_uids; |
7629 | 287 string_t *str; |
288 int ret = 0; | |
289 | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
290 i_array_init(&expunged_uids, array_count(uid_filter)); |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
291 if (!mailbox_get_expunged_uids(ctx->box, modseq, uid_filter, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
292 &expunged_uids)) { |
7629 | 293 /* return all expunged UIDs */ |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
294 if (get_expunges_fallback(ctx, uid_filter, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
295 &expunged_uids) < 0) { |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
296 array_clear(&expunged_uids); |
7629 | 297 ret = -1; |
298 } | |
299 } | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
300 if (array_count(&expunged_uids) > 0) { |
7629 | 301 str = str_new(default_pool, 128); |
302 str_append(str, "* VANISHED (EARLIER) "); | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
303 imap_write_seq_range(str, &expunged_uids); |
7629 | 304 str_append(str, "\r\n"); |
305 o_stream_send(ctx->client->output, str_data(str), str_len(str)); | |
306 str_free(&str); | |
307 } | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
308 array_free(&expunged_uids); |
7629 | 309 return ret; |
310 } | |
311 | |
312 int imap_fetch_begin(struct imap_fetch_context *ctx) | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
313 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
314 const void *data; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
315 |
7629 | 316 if (ctx->send_vanished) { |
317 if (imap_fetch_send_vanished(ctx) < 0) { | |
318 ctx->failed = TRUE; | |
319 return -1; | |
320 } | |
321 } | |
322 | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
323 if (ctx->flags_update_seen) { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
324 if (mailbox_is_readonly(ctx->box)) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
325 ctx->flags_update_seen = FALSE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
326 else if (!ctx->flags_have_handler) { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
327 ctx->flags_show_only_seen_changes = TRUE; |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
328 (void)imap_fetch_init_handler(ctx, "FLAGS", NULL); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
329 } |
1638
e95c0e462591
API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents:
1534
diff
changeset
|
330 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
331 |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
332 if (array_count(&ctx->all_headers) > 0 && |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
333 ((ctx->fetch_data & (MAIL_FETCH_STREAM_HEADER | |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
334 MAIL_FETCH_STREAM_BODY)) == 0)) { |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
335 (void)array_append_space(&ctx->all_headers); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
336 |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
337 data = array_idx(&ctx->all_headers, 0); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
338 ctx->all_headers_ctx = |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
339 mailbox_header_lookup_init(ctx->box, data); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
340 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
341 |
5949
1a80f37a4a12
Added MAIL_FETCH_NUL_STATE. Don't try to fetch cached flags now unless it's
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
342 if ((ctx->fetch_data & |
1a80f37a4a12
Added MAIL_FETCH_NUL_STATE. Don't try to fetch cached flags now unless it's
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
343 (MAIL_FETCH_STREAM_HEADER | MAIL_FETCH_STREAM_BODY)) != 0) |
1a80f37a4a12
Added MAIL_FETCH_NUL_STATE. Don't try to fetch cached flags now unless it's
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
344 ctx->fetch_data |= MAIL_FETCH_NUL_STATE; |
1a80f37a4a12
Added MAIL_FETCH_NUL_STATE. Don't try to fetch cached flags now unless it's
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
345 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
346 ctx->trans = mailbox_transaction_begin(ctx->box, |
9515
b934756a3714
imap: Refresh index before starting a FETCH, so it sees updated flags immediately.
Timo Sirainen <tss@iki.fi>
parents:
9447
diff
changeset
|
347 MAILBOX_TRANSACTION_FLAG_HIDE | |
b934756a3714
imap: Refresh index before starting a FETCH, so it sees updated flags immediately.
Timo Sirainen <tss@iki.fi>
parents:
9447
diff
changeset
|
348 MAILBOX_TRANSACTION_FLAG_REFRESH); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
349 ctx->select_counter = ctx->client->select_counter; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
350 ctx->mail = mail_alloc(ctx->trans, ctx->fetch_data, |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
351 ctx->all_headers_ctx); |
7629 | 352 |
353 /* Delayed uidset -> seqset conversion. VANISHED needs the uidset. */ | |
7639
03146f02403f
Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents:
7629
diff
changeset
|
354 mail_search_args_init(ctx->search_args, ctx->box, TRUE, |
03146f02403f
Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents:
7629
diff
changeset
|
355 &ctx->cmd->client->search_saved_uidset); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
356 ctx->search_ctx = |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
357 mailbox_search_init(ctx->trans, ctx->search_args, NULL); |
7629 | 358 return 0; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
359 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
360 |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
361 static int imap_fetch_flush_buffer(struct imap_fetch_context *ctx) |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
362 { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
363 const unsigned char *data; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
364 size_t len; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
365 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
366 data = str_data(ctx->cur_str); |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
367 len = str_len(ctx->cur_str); |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
368 |
6698 | 369 if (len == 0) |
370 return 0; | |
371 | |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
372 /* there's an extra space at the end if we added any fetch items |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
373 to buffer */ |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
374 if (data[len-1] == ' ') { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
375 len--; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
376 ctx->first = FALSE; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
377 } |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
378 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
379 if (o_stream_send(ctx->client->output, data, len) < 0) |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
380 return -1; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
381 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
382 str_truncate(ctx->cur_str, 0); |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
383 return 0; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
384 } |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
385 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
386 static int imap_fetch_send_nil_reply(struct imap_fetch_context *ctx) |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
387 { |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
388 const struct imap_fetch_context_handler *handler; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
389 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
390 if (!ctx->first) |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
391 str_append_c(ctx->cur_str, ' '); |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
392 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
393 handler = array_idx(&ctx->handlers, ctx->cur_handler); |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
394 str_printfa(ctx->cur_str, "%s %s ", |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
395 handler->name, handler->nil_reply); |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
396 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
397 if (!handler->buffered) { |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
398 if (imap_fetch_flush_buffer(ctx) < 0) |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
399 return -1; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
400 } |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
401 return 0; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
402 } |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
403 |
7629 | 404 static int imap_fetch_more_int(struct imap_fetch_context *ctx) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
405 { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
406 struct client *client = ctx->client; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
407 const struct imap_fetch_context_handler *handlers; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
408 unsigned int count; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
409 int ret; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
410 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
411 if (ctx->cont_handler != NULL) { |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
412 ret = ctx->cont_handler(ctx); |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
413 if (ret == 0) |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
414 return 0; |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
415 |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
416 if (ret < 0) { |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
417 if (client->output->closed) |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
418 return -1; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
419 |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
420 if (ctx->cur_mail->expunged) { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
421 /* not an error, just lost it. */ |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
422 ctx->partial_fetch = TRUE; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
423 if (imap_fetch_send_nil_reply(ctx) < 0) |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
424 return -1; |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
425 } else { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
426 return -1; |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
427 } |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
428 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
429 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
430 ctx->cont_handler = NULL; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
431 ctx->cur_offset = 0; |
2483
b0fc9984ddcd
Same FETCH handler could have been executed infinitely if client didn't read
Timo Sirainen <tss@iki.fi>
parents:
2421
diff
changeset
|
432 ctx->cur_handler++; |
6979
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
433 if (ctx->cur_input != NULL) |
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
434 i_stream_unref(&ctx->cur_input); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
435 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
436 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
437 handlers = array_get(&ctx->handlers, &count); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
438 for (;;) { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
439 if (o_stream_get_buffer_used_size(client->output) >= |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
440 CLIENT_OUTPUT_OPTIMAL_SIZE) { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
441 ret = o_stream_flush(client->output); |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
442 if (ret <= 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
443 return ret; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
444 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
445 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
446 if (ctx->cur_mail == NULL) { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
447 if (ctx->cmd->cancel) |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
448 return 1; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
449 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
450 if (mailbox_search_next(ctx->search_ctx, |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
451 ctx->mail) <= 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
452 break; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
453 ctx->cur_mail = ctx->mail; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
454 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
455 str_printfa(ctx->cur_str, "* %u FETCH (", |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
456 ctx->cur_mail->seq); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
457 ctx->first = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
458 ctx->line_finished = FALSE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
459 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
460 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
461 for (; ctx->cur_handler < count; ctx->cur_handler++) { |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
462 if (str_len(ctx->cur_str) > 0 && |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
463 !handlers[ctx->cur_handler].buffered) { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
464 /* first non-buffered handler. |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
465 flush the buffer. */ |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
466 ctx->line_partial = TRUE; |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
467 if (imap_fetch_flush_buffer(ctx) < 0) |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
468 return -1; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
469 } |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
470 |
7021 | 471 i_assert(ctx->cur_input == NULL); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
472 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
473 const struct imap_fetch_context_handler *h = |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
474 &handlers[ctx->cur_handler]; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
475 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
476 ret = h->handler(ctx, ctx->cur_mail, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
477 h->context); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
478 } T_END; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
479 |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
480 if (ret == 0) |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
481 return 0; |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
482 |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
483 if (ret < 0) { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
484 if (ctx->cur_mail->expunged) { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
485 /* not an error, just lost it. */ |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
486 ctx->partial_fetch = TRUE; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
487 if (imap_fetch_send_nil_reply(ctx) < 0) |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
488 return -1; |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
489 } else { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
490 i_assert(ret < 0 || |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
491 ctx->cont_handler != NULL); |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
492 return -1; |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
493 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
494 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
495 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
496 ctx->cont_handler = NULL; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
497 ctx->cur_offset = 0; |
6979
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
498 if (ctx->cur_input != NULL) |
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
499 i_stream_unref(&ctx->cur_input); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
500 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
501 |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
502 if (str_len(ctx->cur_str) > 0) { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
503 /* no non-buffered handlers */ |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
504 if (imap_fetch_flush_buffer(ctx) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
505 return -1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
506 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
507 |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
508 ctx->line_finished = TRUE; |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
509 ctx->line_partial = FALSE; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
510 if (o_stream_send(client->output, ")\r\n", 3) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
511 return -1; |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
512 client->last_output = ioloop_time; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
513 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
514 ctx->cur_mail = NULL; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
515 ctx->cur_handler = 0; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
516 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
517 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
518 return 1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
519 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
520 |
7629 | 521 int imap_fetch_more(struct imap_fetch_context *ctx) |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
522 { |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
523 int ret; |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
524 |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
525 i_assert(ctx->client->output_lock == NULL || |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
526 ctx->client->output_lock == ctx->cmd); |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
527 |
7629 | 528 ret = imap_fetch_more_int(ctx); |
529 if (ret < 0) | |
530 ctx->failed = TRUE; | |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
531 if (ctx->line_partial) { |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
532 /* nothing can be sent until FETCH is finished */ |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
533 ctx->client->output_lock = ctx->cmd; |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
534 } |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
535 return ret; |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
536 } |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
537 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
538 int imap_fetch_deinit(struct imap_fetch_context *ctx) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
539 { |
4073 | 540 const struct imap_fetch_context_handler *handlers; |
541 unsigned int i, count; | |
542 | |
543 handlers = array_get(&ctx->handlers, &count); | |
544 for (i = 0; i < count; i++) { | |
545 if (handlers[i].want_deinit) | |
546 handlers[i].handler(ctx, NULL, handlers[i].context); | |
547 } | |
548 | |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
549 if (!ctx->line_finished) { |
6257
2618805b3d94
If FETCH failed internally, we could have sent broken output (")" lines).
Timo Sirainen <tss@iki.fi>
parents:
5949
diff
changeset
|
550 if (imap_fetch_flush_buffer(ctx) < 0) |
6261 | 551 ctx->failed = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
552 if (o_stream_send(ctx->client->output, ")\r\n", 3) < 0) |
3108
38fa28004689
The actual fix for last commit..
Timo Sirainen <tss@iki.fi>
parents:
3100
diff
changeset
|
553 ctx->failed = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
554 } |
6257
2618805b3d94
If FETCH failed internally, we could have sent broken output (")" lines).
Timo Sirainen <tss@iki.fi>
parents:
5949
diff
changeset
|
555 str_free(&ctx->cur_str); |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
556 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
557 if (ctx->cur_input != NULL) |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
558 i_stream_unref(&ctx->cur_input); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
559 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
560 if (ctx->mail != NULL) |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
561 mail_free(&ctx->mail); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
562 |
7956 | 563 mail_search_args_unref(&ctx->search_args); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
564 if (ctx->search_ctx != NULL) { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
565 if (mailbox_search_deinit(&ctx->search_ctx) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
566 ctx->failed = TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
567 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
568 if (ctx->all_headers_ctx != NULL) |
8011
2d902d1f8bea
struct mailbox_header_lookup_ctx can now be referenced/unreferenced so it
Timo Sirainen <tss@iki.fi>
parents:
7956
diff
changeset
|
569 mailbox_header_lookup_unref(&ctx->all_headers_ctx); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
570 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
571 if (ctx->trans != NULL) { |
5760
7851879631ea
Always commit FETCH transaction to make sure cached data is committed.
Timo Sirainen <tss@iki.fi>
parents:
5759
diff
changeset
|
572 /* even if something failed, we want to commit changes to |
7851879631ea
Always commit FETCH transaction to make sure cached data is committed.
Timo Sirainen <tss@iki.fi>
parents:
5759
diff
changeset
|
573 cache, as well as possible \Seen flag changes for FETCH |
7851879631ea
Always commit FETCH transaction to make sure cached data is committed.
Timo Sirainen <tss@iki.fi>
parents:
5759
diff
changeset
|
574 replies we returned so far. */ |
6512
1a3604c8ee05
mailbox_transaction_commit*() doesn't sync the mailbox anymore, so it
Timo Sirainen <tss@iki.fi>
parents:
6494
diff
changeset
|
575 if (mailbox_transaction_commit(&ctx->trans) < 0) |
5760
7851879631ea
Always commit FETCH transaction to make sure cached data is committed.
Timo Sirainen <tss@iki.fi>
parents:
5759
diff
changeset
|
576 ctx->failed = TRUE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
577 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
578 return ctx->failed ? -1 : 0; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
579 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
580 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
581 static int fetch_body(struct imap_fetch_context *ctx, struct mail *mail, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
582 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
583 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
584 const char *body; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
585 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
586 if (mail_get_special(mail, MAIL_FETCH_IMAP_BODY, &body) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
587 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
588 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
589 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
590 ctx->first = FALSE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
591 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
592 if (o_stream_send(ctx->client->output, " ", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
593 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
594 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
595 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
596 if (o_stream_send(ctx->client->output, "BODY (", 6) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
597 o_stream_send_str(ctx->client->output, body) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
598 o_stream_send(ctx->client->output, ")", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
599 return -1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
600 return 1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
601 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
602 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3470
diff
changeset
|
603 static bool fetch_body_init(struct imap_fetch_context *ctx, const char *name, |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
604 const struct imap_arg **args) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
605 { |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
606 if (name[4] == '\0') { |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
607 ctx->fetch_data |= MAIL_FETCH_IMAP_BODY; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
608 imap_fetch_add_handler(ctx, FALSE, FALSE, name, |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
609 "("BODY_NIL_REPLY")", fetch_body, NULL); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
610 return TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
611 } |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
612 return fetch_body_section_init(ctx, name, args); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
613 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
614 |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
615 static int fetch_bodystructure(struct imap_fetch_context *ctx, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
616 struct mail *mail, void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
617 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
618 const char *bodystructure; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
619 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
620 if (mail_get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
621 &bodystructure) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
622 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
623 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
624 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
625 ctx->first = FALSE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
626 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
627 if (o_stream_send(ctx->client->output, " ", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
628 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
629 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
630 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
631 if (o_stream_send(ctx->client->output, "BODYSTRUCTURE (", 15) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
632 o_stream_send_str(ctx->client->output, bodystructure) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
633 o_stream_send(ctx->client->output, ")", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
634 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
635 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
636 return 1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
637 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
638 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
639 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
640 fetch_bodystructure_init(struct imap_fetch_context *ctx, const char *name, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
641 const struct imap_arg **args ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
642 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
643 ctx->fetch_data |= MAIL_FETCH_IMAP_BODYSTRUCTURE; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
644 imap_fetch_add_handler(ctx, FALSE, FALSE, name, |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
645 "("BODY_NIL_REPLY" NIL NIL NIL NIL)", |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
646 fetch_bodystructure, NULL); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
647 return TRUE; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
648 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
649 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
650 static int fetch_envelope(struct imap_fetch_context *ctx, struct mail *mail, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
651 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
652 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
653 const char *envelope; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
654 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
655 if (mail_get_special(mail, MAIL_FETCH_IMAP_ENVELOPE, &envelope) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
656 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
657 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
658 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
659 ctx->first = FALSE; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
660 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
661 if (o_stream_send(ctx->client->output, " ", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
662 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
663 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
664 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
665 if (o_stream_send(ctx->client->output, "ENVELOPE (", 10) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
666 o_stream_send_str(ctx->client->output, envelope) < 0 || |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
667 o_stream_send(ctx->client->output, ")", 1) < 0) |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
668 return -1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
669 return 1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
670 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
671 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
672 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
673 fetch_envelope_init(struct imap_fetch_context *ctx, const char *name, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
674 const struct imap_arg **args ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
675 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
676 ctx->fetch_data |= MAIL_FETCH_IMAP_ENVELOPE; |
6887 | 677 imap_fetch_add_handler(ctx, FALSE, FALSE, name, ENVELOPE_NIL_REPLY, |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
678 fetch_envelope, NULL); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
679 return TRUE; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
680 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
681 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
682 static int fetch_flags(struct imap_fetch_context *ctx, struct mail *mail, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
683 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
684 { |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
685 enum mail_flags flags; |
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
686 const char *const *keywords; |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
687 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3156
diff
changeset
|
688 flags = mail_get_flags(mail); |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
689 if (ctx->flags_update_seen && (flags & MAIL_SEEN) == 0) { |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
690 /* Add \Seen flag */ |
6454
b5e6543b4385
Make sure we do a mailbox sync after flag updates (STORE, FETCH). Also added
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
691 ctx->seen_flags_changed = TRUE; |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
692 flags |= MAIL_SEEN; |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6261
diff
changeset
|
693 mail_update_flags(mail, MODIFY_ADD, MAIL_SEEN); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
694 } else if (ctx->flags_show_only_seen_changes) { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
695 return 1; |
1638
e95c0e462591
API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents:
1534
diff
changeset
|
696 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
697 |
7057
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
698 keywords = client_get_keyword_names(ctx->client, &ctx->tmp_keywords, |
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
699 mail_get_keyword_indexes(mail)); |
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
700 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
701 str_append(ctx->cur_str, "FLAGS ("); |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
702 imap_write_flags(ctx->cur_str, flags, keywords); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
703 str_append(ctx->cur_str, ") "); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
704 return 1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
705 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
706 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
707 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
708 fetch_flags_init(struct imap_fetch_context *ctx, const char *name, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
709 const struct imap_arg **args ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
710 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
711 ctx->flags_have_handler = TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
712 ctx->fetch_data |= MAIL_FETCH_FLAGS; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
713 imap_fetch_add_handler(ctx, TRUE, FALSE, name, "()", fetch_flags, NULL); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
714 return TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
715 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
716 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
717 static int fetch_internaldate(struct imap_fetch_context *ctx, struct mail *mail, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
718 void *context ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
719 { |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
720 time_t date; |
1926
982bd89b42fd
BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
721 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
722 if (mail_get_received_date(mail, &date) < 0) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
723 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
724 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
725 str_printfa(ctx->cur_str, "INTERNALDATE \"%s\" ", |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
726 imap_to_datetime(date)); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
727 return 1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
728 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
729 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
730 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
731 fetch_internaldate_init(struct imap_fetch_context *ctx, const char *name, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
732 const struct imap_arg **args ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
733 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
734 ctx->fetch_data |= MAIL_FETCH_RECEIVED_DATE; |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
735 imap_fetch_add_handler(ctx, TRUE, FALSE, name, |
6888
51bf40995f0f
When client tried to fetch INTERNALDATE for an expunged message, we sent a
Timo Sirainen <tss@iki.fi>
parents:
6887
diff
changeset
|
736 "\"01-Jan-1970 00:00:00 +0000\"", |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
737 fetch_internaldate, NULL); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
738 return TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
739 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
740 |
7620 | 741 static int fetch_modseq(struct imap_fetch_context *ctx, struct mail *mail, |
742 void *context ATTR_UNUSED) | |
743 { | |
7817
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
744 uint64_t modseq; |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
745 |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
746 modseq = mail_get_modseq(mail); |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
747 if (ctx->client->highest_fetch_modseq < modseq) |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
748 ctx->client->highest_fetch_modseq = modseq; |
8274
242e6d47f790
FETCH MODSEQ (n) was missing parenthesis.
Timo Sirainen <tss@iki.fi>
parents:
8077
diff
changeset
|
749 str_printfa(ctx->cur_str, "MODSEQ (%llu) ", |
7817
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
750 (unsigned long long)modseq); |
7620 | 751 return 1; |
752 } | |
753 | |
754 static bool | |
755 fetch_modseq_init(struct imap_fetch_context *ctx, const char *name, | |
756 const struct imap_arg **args ATTR_UNUSED) | |
757 { | |
758 client_enable(ctx->client, MAILBOX_FEATURE_CONDSTORE); | |
759 imap_fetch_add_handler(ctx, TRUE, FALSE, name, NULL, | |
760 fetch_modseq, NULL); | |
761 return TRUE; | |
762 } | |
763 | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
764 static int fetch_uid(struct imap_fetch_context *ctx, struct mail *mail, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
765 void *context ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
766 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
767 str_printfa(ctx->cur_str, "UID %u ", mail->uid); |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
768 return 1; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
769 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
770 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
771 static bool |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
772 fetch_uid_init(struct imap_fetch_context *ctx ATTR_UNUSED, const char *name, |
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
773 const struct imap_arg **args ATTR_UNUSED) |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
774 { |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
775 imap_fetch_add_handler(ctx, TRUE, FALSE, name, NULL, fetch_uid, NULL); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
776 return TRUE; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
777 } |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
778 |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
779 static int fetch_guid(struct imap_fetch_context *ctx, struct mail *mail, |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
780 void *context ATTR_UNUSED) |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
781 { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
782 const char *value; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
783 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
784 if (mail_get_special(mail, MAIL_FETCH_GUID, &value) < 0) |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
785 return -1; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
786 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
787 str_append(ctx->cur_str, "X-GUID "); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
788 imap_quote_append_string(ctx->cur_str, value, FALSE); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
789 return 1; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
790 } |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
791 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
792 static bool |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
793 fetch_guid_init(struct imap_fetch_context *ctx ATTR_UNUSED, const char *name, |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
794 const struct imap_arg **args ATTR_UNUSED) |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
795 { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
796 imap_fetch_add_handler(ctx, TRUE, FALSE, name, "", fetch_guid, NULL); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
797 return TRUE; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
798 } |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
799 |
7910
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
800 static int fetch_x_mailbox(struct imap_fetch_context *ctx, struct mail *mail, |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
801 void *context ATTR_UNUSED) |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
802 { |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
803 const char *str; |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
804 |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
805 if (mail_get_special(mail, MAIL_FETCH_MAILBOX_NAME, &str) < 0) |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
806 i_panic("mailbox name not returned"); |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
807 str_append(ctx->cur_str, "X-MAILBOX "); |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
808 imap_quote_append_string(ctx->cur_str, str, FALSE); |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
809 return 1; |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
810 } |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
811 |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
812 static bool |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
813 fetch_x_mailbox_init(struct imap_fetch_context *ctx ATTR_UNUSED, |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
814 const char *name, |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
815 const struct imap_arg **args ATTR_UNUSED) |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
816 { |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
817 imap_fetch_add_handler(ctx, TRUE, FALSE, name, NULL, |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
818 fetch_x_mailbox, NULL); |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
819 return TRUE; |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
820 } |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
821 |
9069 | 822 static int fetch_x_savedate(struct imap_fetch_context *ctx, struct mail *mail, |
823 void *context ATTR_UNUSED) | |
824 { | |
825 time_t date; | |
826 | |
827 if (mail_get_save_date(mail, &date) < 0) | |
828 return -1; | |
829 | |
830 str_printfa(ctx->cur_str, "X-SAVEDATE \"%s\" ", | |
831 imap_to_datetime(date)); | |
832 return 1; | |
833 } | |
834 | |
835 static bool | |
836 fetch_x_savedate_init(struct imap_fetch_context *ctx, const char *name, | |
837 const struct imap_arg **args ATTR_UNUSED) | |
838 { | |
839 ctx->fetch_data |= MAIL_FETCH_SAVE_DATE; | |
840 imap_fetch_add_handler(ctx, TRUE, FALSE, name, | |
841 "\"01-Jan-1970 00:00:00 +0000\"", | |
842 fetch_x_savedate, NULL); | |
843 return TRUE; | |
844 } | |
845 | |
9071
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
846 static const struct imap_fetch_handler |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
847 imap_fetch_default_handlers[] = { |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
848 { "BODY", fetch_body_init }, |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
849 { "BODYSTRUCTURE", fetch_bodystructure_init }, |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
850 { "ENVELOPE", fetch_envelope_init }, |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
851 { "FLAGS", fetch_flags_init }, |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
852 { "INTERNALDATE", fetch_internaldate_init }, |
7620 | 853 { "MODSEQ", fetch_modseq_init }, |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
854 { "RFC822", fetch_rfc822_init }, |
7910
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
855 { "UID", fetch_uid_init }, |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
856 { "X-GUID", fetch_guid_init }, |
9069 | 857 { "X-MAILBOX", fetch_x_mailbox_init }, |
858 { "X-SAVEDATE", fetch_x_savedate_init } | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
859 }; |
9071
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
860 |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
861 void imap_fetch_handlers_init(void) |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
862 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
863 i_array_init(&fetch_handlers, 32); |
9071
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
864 imap_fetch_handlers_register(imap_fetch_default_handlers, |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
865 N_ELEMENTS(imap_fetch_default_handlers)); |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
866 } |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
867 |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
868 void imap_fetch_handlers_deinit(void) |
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
869 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
870 array_free(&fetch_handlers); |
9071
106e4e3dccbc
IMAP: Register FETCH handlers at startup so we don't break if plugins add them.
Timo Sirainen <tss@iki.fi>
parents:
9069
diff
changeset
|
871 } |