Diffstat (limited to 'kmicromail/libetpan/generic/maildirdriver_message.c') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/maildirdriver_message.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/kmicromail/libetpan/generic/maildirdriver_message.c b/kmicromail/libetpan/generic/maildirdriver_message.c index 7cf9dd1..613fc39 100644 --- a/kmicromail/libetpan/generic/maildirdriver_message.c +++ b/kmicromail/libetpan/generic/maildirdriver_message.c | |||
@@ -33,8 +33,9 @@ | |||
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "maildirdriver_message.h" | 36 | #include "maildirdriver_message.h" |
37 | #include "maildirdriver_tools.h" | ||
37 | 38 | ||
38 | #include "mailmessage_tools.h" | 39 | #include "mailmessage_tools.h" |
39 | #include "maildirdriver.h" | 40 | #include "maildirdriver.h" |
40 | #include "maildir.h" | 41 | #include "maildir.h" |
@@ -47,8 +48,11 @@ | |||
47 | #include <fcntl.h> | 48 | #include <fcntl.h> |
48 | #include <string.h> | 49 | #include <string.h> |
49 | #include <stdlib.h> | 50 | #include <stdlib.h> |
50 | 51 | ||
52 | static int get_flags(mailmessage * msg_info, | ||
53 | struct mail_flags ** result); | ||
54 | |||
51 | static int prefetch(mailmessage * msg_info); | 55 | static int prefetch(mailmessage * msg_info); |
52 | 56 | ||
53 | static void prefetch_free(struct generic_message_t * msg); | 57 | static void prefetch_free(struct generic_message_t * msg); |
54 | 58 | ||
@@ -77,9 +81,9 @@ static mailmessage_driver local_maildir_message_driver = { | |||
77 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, | 81 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, |
78 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, | 82 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, |
79 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, | 83 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, |
80 | 84 | ||
81 | .msg_get_flags = NULL, | 85 | .msg_get_flags = get_flags, |
82 | }; | 86 | }; |
83 | 87 | ||
84 | mailmessage_driver * maildir_message_driver = &local_maildir_message_driver; | 88 | mailmessage_driver * maildir_message_driver = &local_maildir_message_driver; |
85 | 89 | ||
@@ -196,4 +200,56 @@ static void check(mailmessage * msg_info) | |||
196 | msg_info); | 200 | msg_info); |
197 | /* ignore errors */ | 201 | /* ignore errors */ |
198 | } | 202 | } |
199 | } | 203 | } |
204 | |||
205 | static int get_flags(mailmessage * msg_info, | ||
206 | struct mail_flags ** result) | ||
207 | { | ||
208 | chashdatum key; | ||
209 | chashdatum value; | ||
210 | struct maildir * md; | ||
211 | struct mail_flags * flags; | ||
212 | struct maildir_session_state_data * data; | ||
213 | struct maildir_msg * md_msg; | ||
214 | int r; | ||
215 | uint32_t driver_flags; | ||
216 | clist * ext; | ||
217 | |||
218 | if (msg_info->msg_flags != NULL) { | ||
219 | * result = msg_info->msg_flags; | ||
220 | return MAIL_NO_ERROR; | ||
221 | } | ||
222 | |||
223 | data = get_session_data(msg_info); | ||
224 | flags = mail_flags_store_get(data->md_flags_store, | ||
225 | msg_info->msg_index); | ||
226 | if (flags != NULL) { | ||
227 | msg_info->msg_flags = flags; | ||
228 | * result = msg_info->msg_flags; | ||
229 | return MAIL_NO_ERROR; | ||
230 | } | ||
231 | |||
232 | md = get_maildir_session(msg_info); | ||
233 | if (md == NULL) | ||
234 | return MAIL_ERROR_BAD_STATE; | ||
235 | |||
236 | key.data = msg_info->msg_uid; | ||
237 | key.len = strlen(msg_info->msg_uid); | ||
238 | r = chash_get(md->mdir_msg_hash, &key, &value); | ||
239 | if (r < 0) | ||
240 | return MAIL_ERROR_MSG_NOT_FOUND; | ||
241 | |||
242 | md_msg = value.data; | ||
243 | |||
244 | driver_flags = maildirdriver_maildir_flags_to_flags(md_msg->msg_flags); | ||
245 | |||
246 | ext = clist_new(); | ||
247 | if (ext == NULL) | ||
248 | return MAIL_ERROR_MEMORY; | ||
249 | |||
250 | msg_info->msg_flags = mail_flags_new(driver_flags, ext); | ||
251 | |||
252 | * result = msg_info->msg_flags; | ||
253 | |||
254 | return MAIL_NO_ERROR; | ||
255 | } | ||