Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/imap/imap-fetch.c @ 9422:73c4a7d325fe HEAD
QRESYNC: Fixed fallback handling to fetching expunged UIDs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 09 Oct 2009 20:33:27 -0400 |
parents | 51329696ecf5 |
children | 36b8d97d0f58 |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8322
diff
changeset
|
1 /* Copyright (c) 2002-2009 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 { |
168 const uint32_t *seqs, *uids; | |
169 unsigned int i, count; | |
170 | |
171 seqs = array_get(ctx->qresync_sample_seqset, &count); | |
172 uids = array_idx(ctx->qresync_sample_uidset, 0); | |
173 i_assert(array_count(ctx->qresync_sample_uidset) == count); | |
174 i_assert(count > 0); | |
175 | |
176 /* FIXME: we could do removals from the middle as well */ | |
177 for (i = 0; i < count; i++) { | |
178 mail_set_seq(mail, seqs[i]); | |
179 if (uids[i] != mail->uid) | |
180 break; | |
181 } | |
182 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
|
183 seq_range_array_remove_range(expunged_uids, 1, uids[i-1]); |
7629 | 184 } |
185 | |
186 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
|
187 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
|
188 ARRAY_TYPE(seq_range) *expunged_uids) |
7629 | 189 { |
190 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
|
191 struct mail_search_args *search_args; |
7629 | 192 struct mail_search_context *search_ctx; |
193 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
|
194 const struct seq_range *uid_filter; |
7629 | 195 struct mailbox_status status; |
196 unsigned int i, count; | |
197 uint32_t next_uid; | |
198 int ret = 0; | |
199 | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
200 uid_filter = array_get(uid_filter_arr, &count); |
7629 | 201 i_assert(count > 0); |
202 i = 0; | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
203 next_uid = uid_filter[0].seq1; |
7629 | 204 |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
205 /* 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 array_append_array(&search_args->args->value.seqset, uid_filter_arr); |
7629 | 211 |
212 trans = mailbox_transaction_begin(ctx->box, 0); | |
213 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
|
214 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
|
215 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
|
216 |
7629 | 217 while (mailbox_search_next(search_ctx, mail) > 0) { |
218 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
|
219 if (next_uid < uid_filter[i].seq2) |
7629 | 220 next_uid++; |
221 else if (++i < count) | |
9422
73c4a7d325fe
QRESYNC: Fixed fallback handling to fetching expunged UIDs.
Timo Sirainen <tss@iki.fi>
parents:
9421
diff
changeset
|
222 next_uid = uid_filter[i].seq1; |
7629 | 223 else |
224 break; | |
225 } else { | |
226 /* next_uid .. mail->uid-1 are expunged */ | |
227 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
|
228 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
|
229 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
|
230 next_uid, |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
231 uid_filter[i].seq2); |
7629 | 232 i++; |
233 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
|
234 next_uid = uid_filter[i].seq1; |
7629 | 235 } |
236 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
|
237 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
|
238 next_uid, |
7629 | 239 mail->uid - 1); |
240 } | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
241 if (uid_filter[i].seq2 == mail->uid) |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
242 next_uid = uid_filter[++i].seq1; |
7629 | 243 else |
244 next_uid = mail->uid + 1; | |
245 } | |
246 } | |
247 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
|
248 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
|
249 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
|
250 uid_filter[i].seq2); |
7629 | 251 i++; |
252 } | |
253 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
|
254 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
|
255 uid_filter[i].seq2); |
7629 | 256 } |
257 | |
258 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
|
259 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
|
260 (uint32_t)-1); |
7629 | 261 |
262 if (mailbox_search_deinit(&search_ctx) < 0) | |
263 ret = -1; | |
264 | |
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
|
265 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
|
266 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
|
267 expunges_drop_known(ctx, mail, expunged_uids); |
7629 | 268 |
269 mail_free(&mail); | |
270 (void)mailbox_transaction_commit(&trans); | |
271 return ret; | |
272 } | |
273 | |
274 static int | |
275 imap_fetch_send_vanished(struct imap_fetch_context *ctx) | |
276 { | |
7642
077bb84e9e77
Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents:
7639
diff
changeset
|
277 const struct mail_search_arg *uidarg = ctx->search_args->args; |
7629 | 278 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
|
279 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
|
280 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
|
281 ARRAY_TYPE(seq_range) expunged_uids; |
7629 | 282 string_t *str; |
283 int ret = 0; | |
284 | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
285 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
|
286 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
|
287 &expunged_uids)) { |
7629 | 288 /* 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
|
289 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
|
290 &expunged_uids) < 0) { |
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
291 array_clear(&expunged_uids); |
7629 | 292 ret = -1; |
293 } | |
294 } | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
295 if (array_count(&expunged_uids) > 0) { |
7629 | 296 str = str_new(default_pool, 128); |
297 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
|
298 imap_write_seq_range(str, &expunged_uids); |
7629 | 299 str_append(str, "\r\n"); |
300 o_stream_send(ctx->client->output, str_data(str), str_len(str)); | |
301 str_free(&str); | |
302 } | |
9421
51329696ecf5
QRESYNC: Minor code cleanup by renaming variables to be more understandable.
Timo Sirainen <tss@iki.fi>
parents:
9420
diff
changeset
|
303 array_free(&expunged_uids); |
7629 | 304 return ret; |
305 } | |
306 | |
307 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
|
308 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
309 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
|
310 |
7629 | 311 if (ctx->send_vanished) { |
312 if (imap_fetch_send_vanished(ctx) < 0) { | |
313 ctx->failed = TRUE; | |
314 return -1; | |
315 } | |
316 } | |
317 | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 (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
|
324 } |
1638
e95c0e462591
API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents:
1534
diff
changeset
|
325 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
326 |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
327 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
|
328 ((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
|
329 MAIL_FETCH_STREAM_BODY)) == 0)) { |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
330 (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
|
331 |
8813
6431b25959c4
imap: Code cleanup: Changed buffer to an array.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
332 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
|
333 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
|
334 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
|
335 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
336 |
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
|
337 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
|
338 (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
|
339 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
|
340 |
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
|
341 ctx->trans = mailbox_transaction_begin(ctx->box, |
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
|
342 MAILBOX_TRANSACTION_FLAG_HIDE); |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
343 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
|
344 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
|
345 ctx->all_headers_ctx); |
7629 | 346 |
347 /* Delayed uidset -> seqset conversion. VANISHED needs the uidset. */ | |
7639
03146f02403f
Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents:
7629
diff
changeset
|
348 mail_search_args_init(ctx->search_args, ctx->box, TRUE, |
03146f02403f
Implemented SEARCHRES extension.
Timo Sirainen <tss@iki.fi>
parents:
7629
diff
changeset
|
349 &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
|
350 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
|
351 mailbox_search_init(ctx->trans, ctx->search_args, NULL); |
7629 | 352 return 0; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
353 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
354 |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
355 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
|
356 { |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
357 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
|
358 size_t len; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
359 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
360 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
|
361 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
|
362 |
6698 | 363 if (len == 0) |
364 return 0; | |
365 | |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
366 /* 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
|
367 to buffer */ |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
368 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
|
369 len--; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
370 ctx->first = FALSE; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
371 } |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
372 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
373 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
|
374 return -1; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
375 |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
376 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
|
377 return 0; |
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 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
380 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
|
381 { |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
382 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
|
383 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
384 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
|
385 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
|
386 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
387 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
|
388 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
|
389 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
|
390 |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
391 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
|
392 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
|
393 return -1; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
394 } |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
395 return 0; |
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 |
7629 | 398 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
|
399 { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 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
|
404 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
405 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
|
406 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
|
407 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
|
408 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
|
409 |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
410 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
|
411 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
|
412 return -1; |
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
413 |
3156
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
414 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
|
415 /* 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
|
416 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
|
417 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
|
418 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
|
419 } else { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
420 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
|
421 } |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
422 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
423 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
424 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
|
425 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
|
426 ctx->cur_handler++; |
6979
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
427 if (ctx->cur_input != NULL) |
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
428 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
|
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 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
431 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
|
432 for (;;) { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
433 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
439 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
440 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
|
441 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
|
442 return 1; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
443 |
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
|
444 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
|
445 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
|
446 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
|
447 ctx->cur_mail = ctx->mail; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
448 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
449 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
|
450 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
|
451 ctx->first = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
452 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
|
453 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
454 |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
455 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
|
456 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
|
457 !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
|
458 /* 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
|
459 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
|
460 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
|
461 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
|
462 return -1; |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
463 } |
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
464 |
7021 | 465 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
|
466 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
467 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
|
468 &handlers[ctx->cur_handler]; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
469 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6888
diff
changeset
|
470 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
|
471 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
|
472 } T_END; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
473 |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
474 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
|
475 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
|
476 |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
477 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
|
478 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
|
479 /* 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
|
480 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
|
481 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
|
482 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
|
483 } else { |
13dbff915a1a
If UID FETCH notices in the middle of fetching that message is expunged,
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 } |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
488 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
489 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
490 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
|
491 ctx->cur_offset = 0; |
6979
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
492 if (ctx->cur_input != NULL) |
1029b2ffad2d
Fixed memory leak when FETCH command used multiple streams.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
493 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
|
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 |
3216
8632ec8486c6
Send buffered fetch items to client first. Fixes kmail and Thunderbird
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
496 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
|
497 /* 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
|
498 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
|
499 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
|
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 |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
502 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
|
503 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
|
504 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
|
505 return -1; |
7017
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
506 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
|
507 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
508 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
|
509 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
|
510 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
511 |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
512 return 1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
513 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
514 |
7629 | 515 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
|
516 { |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
517 int ret; |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
518 |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
519 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
|
520 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
|
521 |
7629 | 522 ret = imap_fetch_more_int(ctx); |
523 if (ret < 0) | |
524 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
|
525 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
|
526 /* 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
|
527 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
|
528 } |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
529 return ret; |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
530 } |
80d3b8fcec09
When pipelining commands another command could have written output in the
Timo Sirainen <tss@iki.fi>
parents:
6979
diff
changeset
|
531 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
532 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
|
533 { |
4073 | 534 const struct imap_fetch_context_handler *handlers; |
535 unsigned int i, count; | |
536 | |
537 handlers = array_get(&ctx->handlers, &count); | |
538 for (i = 0; i < count; i++) { | |
539 if (handlers[i].want_deinit) | |
540 handlers[i].handler(ctx, NULL, handlers[i].context); | |
541 } | |
542 | |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
543 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
|
544 if (imap_fetch_flush_buffer(ctx) < 0) |
6261 | 545 ctx->failed = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
546 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
|
547 ctx->failed = TRUE; |
2680
48df7f95fa4a
If fetching fails, finish sending the untagged FETCH reply correctly.
Timo Sirainen <tss@iki.fi>
parents:
2675
diff
changeset
|
548 } |
6257
2618805b3d94
If FETCH failed internally, we could have sent broken output (")" lines).
Timo Sirainen <tss@iki.fi>
parents:
5949
diff
changeset
|
549 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
|
550 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
551 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
|
552 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
|
553 |
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
|
554 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
|
555 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
|
556 |
7956 | 557 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
|
558 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
|
559 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
|
560 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
|
561 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
562 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
|
563 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
|
564 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
565 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
|
566 /* 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
572 return ctx->failed ? -1 : 0; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
573 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
574 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
575 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
|
576 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
577 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
578 const char *body; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
579 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
580 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
|
581 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
582 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
583 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
584 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
|
585 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
586 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
|
587 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
588 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
589 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
590 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
|
591 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
|
592 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; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
594 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
|
595 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
596 |
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
|
597 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
|
598 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
|
599 { |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
600 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
|
601 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
|
602 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
|
603 "("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
|
604 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
|
605 } |
2675
60d33cf81c8e
BODY.PEEK[HEADER.FIELDS (...)] list is allowed to contain strings and
Timo Sirainen <tss@iki.fi>
parents:
2640
diff
changeset
|
606 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
|
607 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
608 |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
609 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
|
610 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
|
611 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
612 const char *bodystructure; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
613 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
614 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
|
615 &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
|
616 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
617 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
618 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
619 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
|
620 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
621 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
|
622 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
623 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
624 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
625 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
|
626 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
|
627 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 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
630 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
|
631 } |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
632 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
633 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
634 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
|
635 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
|
636 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
637 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
|
638 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
|
639 "("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
|
640 fetch_bodystructure, NULL); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
641 return TRUE; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
642 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
643 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
644 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
|
645 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
646 { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
647 const char *envelope; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
648 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
649 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
|
650 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
651 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
652 if (ctx->first) |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
653 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
|
654 else { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
655 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
|
656 return -1; |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
657 } |
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
658 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
659 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
|
660 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
|
661 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; |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
663 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
|
664 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
665 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
666 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
667 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
|
668 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
|
669 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
670 ctx->fetch_data |= MAIL_FETCH_IMAP_ENVELOPE; |
6887 | 671 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
|
672 fetch_envelope, NULL); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
673 return TRUE; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
674 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
675 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
676 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
|
677 void *context ATTR_UNUSED) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
678 { |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2742
diff
changeset
|
679 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
|
680 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
|
681 |
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
|
682 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
|
683 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
|
684 /* 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
|
685 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
|
686 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
|
687 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
|
688 } 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
|
689 return 1; |
1638
e95c0e462591
API change for updating message flags.
Timo Sirainen <tss@iki.fi>
parents:
1534
diff
changeset
|
690 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
691 |
7057
81f4c9689c18
FLAGS/PERMENENTFLAGS weren't always sent to client early enough. Also
Timo Sirainen <tss@iki.fi>
parents:
7021
diff
changeset
|
692 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
|
693 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
|
694 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
695 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
|
696 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
|
697 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
|
698 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
|
699 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
700 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
701 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
702 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
|
703 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
|
704 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
705 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
|
706 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
|
707 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
|
708 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
|
709 } |
1764
fbb28b07c60f
Write envelope, body and bodystructure directly into output stream.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
710 |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
711 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
|
712 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
|
713 { |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
714 time_t date; |
1926
982bd89b42fd
BYE if trying to fetch body[] of expunged message.
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
715 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
716 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
|
717 return -1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
718 |
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 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
|
720 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
|
721 return 1; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
722 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
723 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
724 static bool |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
725 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
|
726 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
|
727 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
728 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
|
729 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
|
730 "\"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
|
731 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
|
732 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
|
733 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
734 |
7620 | 735 static int fetch_modseq(struct imap_fetch_context *ctx, struct mail *mail, |
736 void *context ATTR_UNUSED) | |
737 { | |
7817
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
738 uint64_t modseq; |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
739 |
ffaf1ea49704
QRESYNC: Send HIGHESTMODSEQ automatically in all tagged replies whenever it
Timo Sirainen <tss@iki.fi>
parents:
7815
diff
changeset
|
740 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
|
741 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
|
742 ctx->client->highest_fetch_modseq = modseq; |
8274
242e6d47f790
FETCH MODSEQ (n) was missing parenthesis.
Timo Sirainen <tss@iki.fi>
parents:
8077
diff
changeset
|
743 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
|
744 (unsigned long long)modseq); |
7620 | 745 return 1; |
746 } | |
747 | |
748 static bool | |
749 fetch_modseq_init(struct imap_fetch_context *ctx, const char *name, | |
750 const struct imap_arg **args ATTR_UNUSED) | |
751 { | |
752 client_enable(ctx->client, MAILBOX_FEATURE_CONDSTORE); | |
753 imap_fetch_add_handler(ctx, TRUE, FALSE, name, NULL, | |
754 fetch_modseq, NULL); | |
755 return TRUE; | |
756 } | |
757 | |
2421
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
758 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
|
759 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
|
760 { |
d141e1bfdd63
We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
761 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
|
762 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
|
763 } |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
764 |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5760
diff
changeset
|
765 static bool |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
766 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
|
767 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
|
768 { |
4973
ec41129cd0ef
When client fetches message data that has already been expunged, reply with
Timo Sirainen <tss@iki.fi>
parents:
4972
diff
changeset
|
769 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
|
770 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
|
771 } |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1642
diff
changeset
|
772 |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
773 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
|
774 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
|
775 { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
776 const char *value; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
777 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
778 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
|
779 return -1; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
780 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
781 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
|
782 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
|
783 return 1; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
784 } |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
785 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
786 static bool |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
787 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
|
788 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
|
789 { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
790 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
|
791 return TRUE; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
792 } |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
8027
diff
changeset
|
793 |
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
|
794 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
|
795 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
|
796 { |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
797 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
|
798 |
c1bbdc2b262e
FETCH X-MAILBOX and SEARCH X-MAILBOX can be used with virtual mailboxes to
Timo Sirainen <tss@iki.fi>
parents:
7817
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
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 |
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 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
|
807 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
|
808 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
|
809 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
|
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 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
|
812 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
|
813 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
|
814 } |
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 |
9069 | 816 static int fetch_x_savedate(struct imap_fetch_context *ctx, struct mail *mail, |
817 void *context ATTR_UNUSED) | |
818 { | |
819 time_t date; | |
820 | |
821 if (mail_get_save_date(mail, &date) < 0) | |
822 return -1; | |
823 | |
824 str_printfa(ctx->cur_str, "X-SAVEDATE \"%s\" ", | |
825 imap_to_datetime(date)); | |
826 return 1; | |
827 } | |
828 | |
829 static bool | |
830 fetch_x_savedate_init(struct imap_fetch_context *ctx, const char *name, | |
831 const struct imap_arg **args ATTR_UNUSED) | |
832 { | |
833 ctx->fetch_data |= MAIL_FETCH_SAVE_DATE; | |
834 imap_fetch_add_handler(ctx, TRUE, FALSE, name, | |
835 "\"01-Jan-1970 00:00:00 +0000\"", | |
836 fetch_x_savedate, NULL); | |
837 return TRUE; | |
838 } | |
839 | |
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
|
840 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
|
841 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
|
842 { "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
|
843 { "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
|
844 { "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
|
845 { "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
|
846 { "INTERNALDATE", fetch_internaldate_init }, |
7620 | 847 { "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
|
848 { "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
|
849 { "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
|
850 { "X-GUID", fetch_guid_init }, |
9069 | 851 { "X-MAILBOX", fetch_x_mailbox_init }, |
852 { "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
|
853 }; |
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
|
854 |
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
|
855 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
|
856 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
857 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
|
858 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
|
859 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
|
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 |
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 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
|
863 { |
9072
43f15920dbaa
imap code cleanup: Use array instead of buffer for storing fetch handlers.
Timo Sirainen <tss@iki.fi>
parents:
9071
diff
changeset
|
864 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
|
865 } |