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