Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/mail.c @ 9354:687ac828b964 HEAD
lib-index: modseqs weren't tracked properly within session when changes were done.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 01 Sep 2009 13:05:03 -0400 |
parents | 3eacb6bbd227 |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8077
diff
changeset
|
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "ioloop.h" |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
5 #include "hostpid.h" |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "mail-storage-private.h" |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
8 #include <time.h> |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
9 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 struct mail *mail_alloc(struct mailbox_transaction_context *t, |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 enum mail_fetch_field wanted_fields, |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 struct mailbox_header_lookup_ctx *wanted_headers) |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 return t->box->v.mail_alloc(t, wanted_fields, wanted_headers); |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3290
diff
changeset
|
17 void mail_free(struct mail **mail) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3290
diff
changeset
|
19 struct mail_private *p = (struct mail_private *)*mail; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3290
diff
changeset
|
21 p->v.free(*mail); |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3290
diff
changeset
|
22 *mail = NULL; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
25 void mail_set_seq(struct mail *mail, uint32_t seq) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
29 p->v.set_seq(mail, seq); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
32 bool mail_set_uid(struct mail *mail, uint32_t uid) |
4274
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
33 { |
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
34 struct mail_private *p = (struct mail_private *)mail; |
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
35 |
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
36 return p->v.set_uid(mail, uid); |
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
37 } |
bd519db7f6e5
Added mail_set_uid() to select a mail by UID.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
38 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 enum mail_flags mail_get_flags(struct mail *mail) |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 return p->v.get_flags(mail); |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
7620 | 46 uint64_t mail_get_modseq(struct mail *mail) |
47 { | |
48 struct mail_private *p = (struct mail_private *)mail; | |
49 | |
50 return p->v.get_modseq(mail); | |
51 } | |
52 | |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 const char *const *mail_get_keywords(struct mail *mail) |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 return p->v.get_keywords(mail); |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 |
6985
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
60 const ARRAY_TYPE(keyword_indexes) *mail_get_keyword_indexes(struct mail *mail) |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
61 { |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
62 struct mail_private *p = (struct mail_private *)mail; |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
63 |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
64 return p->v.get_keyword_indexes(mail); |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
65 } |
58b8daf695bf
Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents:
6495
diff
changeset
|
66 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
67 int mail_get_parts(struct mail *mail, const struct message_part **parts_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
71 return p->v.get_parts(mail, parts_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
74 int mail_get_date(struct mail *mail, time_t *date_r, int *timezone_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 struct mail_private *p = (struct mail_private *)mail; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
77 int tz; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
79 if (timezone_r == NULL) |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
80 timezone_r = &tz; |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
81 |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
82 return p->v.get_date(mail, date_r, timezone_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
85 int mail_get_received_date(struct mail *mail, time_t *date_r) |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4274
diff
changeset
|
86 { |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4274
diff
changeset
|
87 struct mail_private *p = (struct mail_private *)mail; |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4274
diff
changeset
|
88 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
89 return p->v.get_received_date(mail, date_r); |
4455
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4274
diff
changeset
|
90 } |
fce5140fbe0b
Added mail_get_save_date() and some cleanups.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4274
diff
changeset
|
91 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
92 int mail_get_save_date(struct mail *mail, time_t *date_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
95 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
96 return p->v.get_save_date(mail, date_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
99 int mail_get_virtual_size(struct mail *mail, uoff_t *size_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
102 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
103 return p->v.get_virtual_size(mail, size_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
106 int mail_get_physical_size(struct mail *mail, uoff_t *size_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
110 return p->v.get_physical_size(mail, size_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
113 int mail_get_first_header(struct mail *mail, const char *field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
114 const char **value_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 { |
3248
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
116 struct mail_private *p = (struct mail_private *)mail; |
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
117 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
118 return p->v.get_first_header(mail, field, FALSE, value_r); |
6120
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
119 } |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
120 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
121 int mail_get_first_header_utf8(struct mail *mail, const char *field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
122 const char **value_r) |
6120
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
123 { |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
124 struct mail_private *p = (struct mail_private *)mail; |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
125 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
126 return p->v.get_first_header(mail, field, TRUE, value_r); |
3248
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
127 } |
ff47e78ad717
Renamed mail_get_header() to mail_get_first_header() and mail_gets_headers()
Timo Sirainen <tss@iki.fi>
parents:
3209
diff
changeset
|
128 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
129 int mail_get_headers(struct mail *mail, const char *field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
130 const char *const **value_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
131 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
132 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
133 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
134 return p->v.get_headers(mail, field, FALSE, value_r); |
6120
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
135 } |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
136 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
137 int mail_get_headers_utf8(struct mail *mail, const char *field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
138 const char *const **value_r) |
6120
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
139 { |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
140 struct mail_private *p = (struct mail_private *)mail; |
00d1a94a94c6
Added mail_get_first_header_utf8() and mail_get_headers_utf8().
Timo Sirainen <tss@iki.fi>
parents:
5614
diff
changeset
|
141 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
142 return p->v.get_headers(mail, field, TRUE, value_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
143 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
145 int mail_get_header_stream(struct mail *mail, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
146 struct mailbox_header_lookup_ctx *headers, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
147 struct istream **stream_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
148 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
149 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
151 return p->v.get_header_stream(mail, headers, stream_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
152 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 |
8981
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
154 int mail_set_aborted(struct mail *mail) |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
155 { |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
156 mail_storage_set_error(mail->box->storage, MAIL_ERROR_NOTPOSSIBLE, |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
157 "Mail field not cached"); |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
158 return -1; |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
159 } |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
160 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
161 int mail_get_stream(struct mail *mail, struct message_size *hdr_size, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
162 struct message_size *body_size, struct istream **stream_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
163 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
164 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
165 |
8981
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
166 if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) |
5611bba3548b
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
167 return mail_set_aborted(mail); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
168 return p->v.get_stream(mail, hdr_size, body_size, stream_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
169 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
170 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
171 int mail_get_special(struct mail *mail, enum mail_fetch_field field, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
172 const char **value_r) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
174 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
176 return p->v.get_special(mail, field, value_r); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
179 void mail_update_flags(struct mail *mail, enum modify_type modify_type, |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
180 enum mail_flags flags) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
181 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 |
6495
94501a17dcd0
Don't return void values from void functions.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
184 p->v.update_flags(mail, modify_type, flags); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
185 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
186 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
187 void mail_update_keywords(struct mail *mail, enum modify_type modify_type, |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
188 struct mail_keywords *keywords) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
189 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
190 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
191 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
192 p->v.update_keywords(mail, modify_type, keywords); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
193 } |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
194 |
9348 | 195 void mail_update_pop3_uidl(struct mail *mail, const char *uidl) |
196 { | |
197 struct mail_private *p = (struct mail_private *)mail; | |
198 | |
199 if (p->v.update_pop3_uidl != NULL) | |
200 p->v.update_pop3_uidl(mail, uidl); | |
201 } | |
202 | |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
203 void mail_expunge(struct mail *mail) |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
204 { |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
205 struct mail_private *p = (struct mail_private *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
206 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6120
diff
changeset
|
207 p->v.expunge(mail); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
208 } |
5614
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
209 |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
210 void mail_set_expunged(struct mail *mail) |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
211 { |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
212 mail_storage_set_error(mail->box->storage, MAIL_ERROR_EXPUNGED, |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
213 "Message was expunged"); |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
214 mail->expunged = TRUE; |
a4e5053fb31a
Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents:
4455
diff
changeset
|
215 } |
7241
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
216 |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
217 void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field) |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
218 { |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
219 struct mail_private *p = (struct mail_private *)mail; |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
220 |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
221 p->v.set_cache_corrupted(mail, field); |
a6c066f50877
Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
222 } |
8077
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
223 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
224 const char *mail_generate_guid_string(void) |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
225 { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
226 static struct timespec ts = { 0, 0 }; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
227 static unsigned int pid = 0; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
228 |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
229 /* we'll use the current time in nanoseconds as the initial 64bit |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
230 counter. */ |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
231 if (ts.tv_sec == 0) { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
232 if (clock_gettime(CLOCK_REALTIME, &ts) < 0) |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
233 i_fatal("clock_gettime() failed: %m"); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
234 pid = getpid(); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
235 } else if ((uint32_t)ts.tv_nsec < (uint32_t)-1) { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
236 ts.tv_nsec++; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
237 } else { |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
238 ts.tv_sec++; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
239 ts.tv_nsec = 0; |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
240 } |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
241 return t_strdup_printf("%04x%04lx%04x%s", |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
242 (unsigned int)ts.tv_nsec, |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
243 (unsigned long)ts.tv_sec, |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
244 pid, my_hostname); |
6d51328896d6
Added the concept of Global UIDs that are preserved across copies.
Timo Sirainen <tss@iki.fi>
parents:
7620
diff
changeset
|
245 } |