summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/generic/maildirdriver_message.c
authorzautrix <zautrix>2004-09-01 10:23:29 (UTC)
committer zautrix <zautrix>2004-09-01 10:23:29 (UTC)
commit6cefbdc9c8f3f3001373f10715361e2740c45395 (patch) (unidiff)
treecb2c36f57620e698913c27ca4ebe59e4a7c9d46e /kmicromail/libetpan/generic/maildirdriver_message.c
parentb9257cb225cd29bab5d96fcdaf557926603ee587 (diff)
downloadkdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.zip
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.gz
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.bz2
Mail fixes and libetpan updated
Diffstat (limited to 'kmicromail/libetpan/generic/maildirdriver_message.c') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/generic/maildirdriver_message.c58
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
@@ -31,12 +31,13 @@
31 31
32/* 32/*
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"
41#include "generic_cache.h" 42#include "generic_cache.h"
42 43
@@ -45,12 +46,15 @@
45#include <sys/types.h> 46#include <sys/types.h>
46#include <sys/stat.h> 47#include <sys/stat.h>
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
52static int get_flags(mailmessage * msg_info,
53 struct mail_flags ** result);
54
51static int prefetch(mailmessage * msg_info); 55static int prefetch(mailmessage * msg_info);
52 56
53static void prefetch_free(struct generic_message_t * msg); 57static void prefetch_free(struct generic_message_t * msg);
54 58
55static int initialize(mailmessage * msg_info); 59static int initialize(mailmessage * msg_info);
56 60
@@ -75,13 +79,13 @@ static mailmessage_driver local_maildir_message_driver = {
75 .msg_fetch_section = mailmessage_generic_fetch_section, 79 .msg_fetch_section = mailmessage_generic_fetch_section,
76 .msg_fetch_section_header = mailmessage_generic_fetch_section_header, 80 .msg_fetch_section_header = mailmessage_generic_fetch_section_header,
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
84mailmessage_driver * maildir_message_driver = &local_maildir_message_driver; 88mailmessage_driver * maildir_message_driver = &local_maildir_message_driver;
85 89
86struct maildir_msg_data { 90struct maildir_msg_data {
87 int fd; 91 int fd;
@@ -194,6 +198,58 @@ static void check(mailmessage * msg_info)
194 if (msg_info->msg_flags != NULL) { 198 if (msg_info->msg_flags != NULL) {
195 r = mail_flags_store_set(get_session_data(msg_info)->md_flags_store, 199 r = mail_flags_store_set(get_session_data(msg_info)->md_flags_store,
196 msg_info); 200 msg_info);
197 /* ignore errors */ 201 /* ignore errors */
198 } 202 }
199} 203}
204
205static 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}