68 files changed, 1025 insertions, 112 deletions
diff --git a/kmicromail/libetpan/generic/imapdriver.c b/kmicromail/libetpan/generic/imapdriver.c index 0d63319..b3e5982 100644 --- a/kmicromail/libetpan/generic/imapdriver.c +++ b/kmicromail/libetpan/generic/imapdriver.c | |||
@@ -97,12 +97,14 @@ static int imapdriver_list_folders(mailsession * session, char * mb, | |||
97 | static int imapdriver_lsub_folders(mailsession * session, char * mb, | 97 | static int imapdriver_lsub_folders(mailsession * session, char * mb, |
98 | struct mail_list ** result); | 98 | struct mail_list ** result); |
99 | static int imapdriver_subscribe_folder(mailsession * session, char * mb); | 99 | static int imapdriver_subscribe_folder(mailsession * session, char * mb); |
100 | static int imapdriver_unsubscribe_folder(mailsession * session, char * mb); | 100 | static int imapdriver_unsubscribe_folder(mailsession * session, char * mb); |
101 | static int imapdriver_append_message(mailsession * session, | 101 | static int imapdriver_append_message(mailsession * session, |
102 | char * message, size_t size); | 102 | char * message, size_t size); |
103 | static int imapdriver_append_message_flags(mailsession * session, | ||
104 | char * message, size_t size, struct mail_flags * flags); | ||
103 | static int imapdriver_copy_message(mailsession * session, | 105 | static int imapdriver_copy_message(mailsession * session, |
104 | uint32_t num, char * mb); | 106 | uint32_t num, char * mb); |
105 | 107 | ||
106 | static int imapdriver_get_messages_list(mailsession * session, | 108 | static int imapdriver_get_messages_list(mailsession * session, |
107 | struct mailmessage_list ** result); | 109 | struct mailmessage_list ** result); |
108 | 110 | ||
@@ -154,12 +156,13 @@ static mailsession_driver local_imap_session_driver = { | |||
154 | .sess_list_folders = imapdriver_list_folders, | 156 | .sess_list_folders = imapdriver_list_folders, |
155 | .sess_lsub_folders = imapdriver_lsub_folders, | 157 | .sess_lsub_folders = imapdriver_lsub_folders, |
156 | .sess_subscribe_folder = imapdriver_subscribe_folder, | 158 | .sess_subscribe_folder = imapdriver_subscribe_folder, |
157 | .sess_unsubscribe_folder = imapdriver_unsubscribe_folder, | 159 | .sess_unsubscribe_folder = imapdriver_unsubscribe_folder, |
158 | 160 | ||
159 | .sess_append_message = imapdriver_append_message, | 161 | .sess_append_message = imapdriver_append_message, |
162 | .sess_append_message_flags = imapdriver_append_message_flags, | ||
160 | .sess_copy_message = imapdriver_copy_message, | 163 | .sess_copy_message = imapdriver_copy_message, |
161 | .sess_move_message = NULL, | 164 | .sess_move_message = NULL, |
162 | 165 | ||
163 | .sess_get_messages_list = imapdriver_get_messages_list, | 166 | .sess_get_messages_list = imapdriver_get_messages_list, |
164 | .sess_get_envelopes_list = imapdriver_get_envelopes_list, | 167 | .sess_get_envelopes_list = imapdriver_get_envelopes_list, |
165 | .sess_remove_message = NULL, | 168 | .sess_remove_message = NULL, |
@@ -768,12 +771,37 @@ static int imapdriver_append_message(mailsession * session, | |||
768 | get_data(session)->imap_mailbox, | 771 | get_data(session)->imap_mailbox, |
769 | message, size); | 772 | message, size); |
770 | 773 | ||
771 | return imap_error_to_mail_error(r); | 774 | return imap_error_to_mail_error(r); |
772 | } | 775 | } |
773 | 776 | ||
777 | static int imapdriver_append_message_flags(mailsession * session, | ||
778 | char * message, size_t size, struct mail_flags * flags) | ||
779 | { | ||
780 | struct mailimap_flag_list * flag_list; | ||
781 | int r; | ||
782 | |||
783 | if (flags != NULL) { | ||
784 | r = imap_flags_to_imap_flags(flags, &flag_list); | ||
785 | if (r != MAIL_NO_ERROR) | ||
786 | return r; | ||
787 | } | ||
788 | else { | ||
789 | flag_list = NULL; | ||
790 | } | ||
791 | |||
792 | r = mailimap_append(get_imap_session(session), | ||
793 | get_data(session)->imap_mailbox, | ||
794 | flag_list, NULL, message, size); | ||
795 | |||
796 | if (flag_list != NULL) | ||
797 | mailimap_flag_list_free(flag_list); | ||
798 | |||
799 | return imap_error_to_mail_error(r); | ||
800 | } | ||
801 | |||
774 | static int imapdriver_copy_message(mailsession * session, | 802 | static int imapdriver_copy_message(mailsession * session, |
775 | uint32_t num, char * mb) | 803 | uint32_t num, char * mb) |
776 | { | 804 | { |
777 | int r; | 805 | int r; |
778 | struct mailimap_set * set; | 806 | struct mailimap_set * set; |
779 | int res; | 807 | int res; |
diff --git a/kmicromail/libetpan/generic/imapdriver_cached.c b/kmicromail/libetpan/generic/imapdriver_cached.c index e6af8e8..04044ae 100644 --- a/kmicromail/libetpan/generic/imapdriver_cached.c +++ b/kmicromail/libetpan/generic/imapdriver_cached.c | |||
@@ -102,12 +102,14 @@ static int imapdriver_cached_lsub_folders(mailsession * session, char * mb, | |||
102 | static int imapdriver_cached_subscribe_folder(mailsession * session, | 102 | static int imapdriver_cached_subscribe_folder(mailsession * session, |
103 | char * mb); | 103 | char * mb); |
104 | static int imapdriver_cached_unsubscribe_folder(mailsession * session, | 104 | static int imapdriver_cached_unsubscribe_folder(mailsession * session, |
105 | char * mb); | 105 | char * mb); |
106 | static int imapdriver_cached_append_message(mailsession * session, | 106 | static int imapdriver_cached_append_message(mailsession * session, |
107 | char * message, size_t size); | 107 | char * message, size_t size); |
108 | static int imapdriver_cached_append_message_flags(mailsession * session, | ||
109 | char * message, size_t size, struct mail_flags * flags); | ||
108 | static int imapdriver_cached_copy_message(mailsession * session, | 110 | static int imapdriver_cached_copy_message(mailsession * session, |
109 | uint32_t num, char * mb); | 111 | uint32_t num, char * mb); |
110 | 112 | ||
111 | static int imapdriver_cached_get_messages_list(mailsession * session, | 113 | static int imapdriver_cached_get_messages_list(mailsession * session, |
112 | struct mailmessage_list ** | 114 | struct mailmessage_list ** |
113 | result); | 115 | result); |
@@ -162,12 +164,13 @@ static mailsession_driver local_imap_cached_session_driver = { | |||
162 | .sess_list_folders = imapdriver_cached_list_folders, | 164 | .sess_list_folders = imapdriver_cached_list_folders, |
163 | .sess_lsub_folders = imapdriver_cached_lsub_folders, | 165 | .sess_lsub_folders = imapdriver_cached_lsub_folders, |
164 | .sess_subscribe_folder = imapdriver_cached_subscribe_folder, | 166 | .sess_subscribe_folder = imapdriver_cached_subscribe_folder, |
165 | .sess_unsubscribe_folder = imapdriver_cached_unsubscribe_folder, | 167 | .sess_unsubscribe_folder = imapdriver_cached_unsubscribe_folder, |
166 | 168 | ||
167 | .sess_append_message = imapdriver_cached_append_message, | 169 | .sess_append_message = imapdriver_cached_append_message, |
170 | .sess_append_message_flags = imapdriver_cached_append_message_flags, | ||
168 | .sess_copy_message = imapdriver_cached_copy_message, | 171 | .sess_copy_message = imapdriver_cached_copy_message, |
169 | .sess_move_message = NULL, | 172 | .sess_move_message = NULL, |
170 | 173 | ||
171 | .sess_get_messages_list = imapdriver_cached_get_messages_list, | 174 | .sess_get_messages_list = imapdriver_cached_get_messages_list, |
172 | .sess_get_envelopes_list = imapdriver_cached_get_envelopes_list, | 175 | .sess_get_envelopes_list = imapdriver_cached_get_envelopes_list, |
173 | .sess_remove_message = imapdriver_cached_remove_message, | 176 | .sess_remove_message = imapdriver_cached_remove_message, |
@@ -773,12 +776,25 @@ static int imapdriver_cached_append_message(mailsession * session, | |||
773 | 776 | ||
774 | check_for_uid_cache(session); | 777 | check_for_uid_cache(session); |
775 | 778 | ||
776 | return r; | 779 | return r; |
777 | } | 780 | } |
778 | 781 | ||
782 | static int imapdriver_cached_append_message_flags(mailsession * session, | ||
783 | char * message, size_t size, struct mail_flags * flags) | ||
784 | { | ||
785 | int r; | ||
786 | |||
787 | r = mailsession_append_message_flags(get_ancestor(session), | ||
788 | message, size, flags); | ||
789 | |||
790 | check_for_uid_cache(session); | ||
791 | |||
792 | return r; | ||
793 | } | ||
794 | |||
779 | static int imapdriver_cached_copy_message(mailsession * session, | 795 | static int imapdriver_cached_copy_message(mailsession * session, |
780 | uint32_t num, char * mb) | 796 | uint32_t num, char * mb) |
781 | { | 797 | { |
782 | int r; | 798 | int r; |
783 | 799 | ||
784 | r = mailsession_copy_message(get_ancestor(session), num, mb); | 800 | r = mailsession_copy_message(get_ancestor(session), num, mb); |
diff --git a/kmicromail/libetpan/generic/imapdriver_cached_message.c b/kmicromail/libetpan/generic/imapdriver_cached_message.c index c0542a3..c4357a3 100644 --- a/kmicromail/libetpan/generic/imapdriver_cached_message.c +++ b/kmicromail/libetpan/generic/imapdriver_cached_message.c | |||
@@ -209,13 +209,13 @@ static void generate_key_from_mime_section(char * key, size_t size, | |||
209 | return; | 209 | return; |
210 | 210 | ||
211 | free_str: | 211 | free_str: |
212 | mmap_string_free(gstr); | 212 | mmap_string_free(gstr); |
213 | free_section: | 213 | free_section: |
214 | mailmime_section_free(part); | 214 | mailmime_section_free(part); |
215 | err: | 215 | err:; |
216 | } | 216 | } |
217 | 217 | ||
218 | static void generate_key_from_section(char * key, size_t size, | 218 | static void generate_key_from_section(char * key, size_t size, |
219 | mailmessage * msg_info, | 219 | mailmessage * msg_info, |
220 | struct mailmime * mime, int type) | 220 | struct mailmime * mime, int type) |
221 | { | 221 | { |
diff --git a/kmicromail/libetpan/generic/imapdriver_tools.c b/kmicromail/libetpan/generic/imapdriver_tools.c index 3d737f3..de4008f 100644 --- a/kmicromail/libetpan/generic/imapdriver_tools.c +++ b/kmicromail/libetpan/generic/imapdriver_tools.c | |||
@@ -3104,22 +3104,21 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn, | |||
3104 | free: | 3104 | free: |
3105 | mail_flags_free(flags); | 3105 | mail_flags_free(flags); |
3106 | err: | 3106 | err: |
3107 | return MAIL_ERROR_MEMORY; | 3107 | return MAIL_ERROR_MEMORY; |
3108 | } | 3108 | } |
3109 | 3109 | ||
3110 | static int flags_to_imap_flags(struct mail_flags * flags, | 3110 | int imap_flags_to_imap_flags(struct mail_flags * flags, |
3111 | struct mailimap_store_att_flags ** result) | 3111 | struct mailimap_flag_list ** result) |
3112 | { | 3112 | { |
3113 | struct mailimap_flag * flag; | 3113 | struct mailimap_flag * flag; |
3114 | struct mailimap_flag_list * flag_list; | 3114 | struct mailimap_flag_list * flag_list; |
3115 | struct mailimap_store_att_flags * att_flags; | ||
3116 | int res; | 3115 | int res; |
3117 | clistiter * cur; | 3116 | clistiter * cur; |
3118 | int r; | 3117 | int r; |
3119 | 3118 | ||
3120 | flag_list = mailimap_flag_list_new_empty(); | 3119 | flag_list = mailimap_flag_list_new_empty(); |
3121 | if (flag_list == NULL) { | 3120 | if (flag_list == NULL) { |
3122 | res = MAIL_ERROR_MEMORY; | 3121 | res = MAIL_ERROR_MEMORY; |
3123 | goto err; | 3122 | goto err; |
3124 | } | 3123 | } |
3125 | 3124 | ||
@@ -3236,23 +3235,48 @@ static int flags_to_imap_flags(struct mail_flags * flags, | |||
3236 | mailimap_flag_free(flag); | 3235 | mailimap_flag_free(flag); |
3237 | res = MAIL_ERROR_MEMORY; | 3236 | res = MAIL_ERROR_MEMORY; |
3238 | goto free_flag_list; | 3237 | goto free_flag_list; |
3239 | } | 3238 | } |
3240 | } | 3239 | } |
3241 | } | 3240 | } |
3241 | |||
3242 | * result = flag_list; | ||
3243 | |||
3244 | return MAIL_NO_ERROR; | ||
3245 | |||
3246 | free_flag_list: | ||
3247 | mailimap_flag_list_free(flag_list); | ||
3248 | err: | ||
3249 | return res; | ||
3250 | } | ||
3242 | 3251 | ||
3252 | static int flags_to_imap_flags(struct mail_flags * flags, | ||
3253 | struct mailimap_store_att_flags ** result) | ||
3254 | { | ||
3255 | struct mailimap_flag_list * flag_list; | ||
3256 | struct mailimap_store_att_flags * att_flags; | ||
3257 | int res; | ||
3258 | int r; | ||
3259 | |||
3260 | r = imap_flags_to_imap_flags(flags, | ||
3261 | &flag_list); | ||
3262 | if (r != MAIL_NO_ERROR) { | ||
3263 | res = r; | ||
3264 | goto err; | ||
3265 | } | ||
3266 | |||
3243 | att_flags = mailimap_store_att_flags_new_set_flags_silent(flag_list); | 3267 | att_flags = mailimap_store_att_flags_new_set_flags_silent(flag_list); |
3244 | if (att_flags == NULL) { | 3268 | if (att_flags == NULL) { |
3245 | res = MAIL_ERROR_MEMORY; | 3269 | res = MAIL_ERROR_MEMORY; |
3246 | goto free_flag_list; | 3270 | goto free_flag_list; |
3247 | } | 3271 | } |
3248 | 3272 | ||
3249 | * result = att_flags; | 3273 | * result = att_flags; |
3250 | 3274 | ||
3251 | return MAIL_NO_ERROR; | 3275 | return MAIL_NO_ERROR; |
3252 | 3276 | ||
3253 | free_flag_list: | 3277 | free_flag_list: |
3254 | mailimap_flag_list_free(flag_list); | 3278 | mailimap_flag_list_free(flag_list); |
3255 | err: | 3279 | err: |
3256 | return res; | 3280 | return res; |
3257 | } | 3281 | } |
3258 | 3282 | ||
diff --git a/kmicromail/libetpan/generic/imapdriver_tools.h b/kmicromail/libetpan/generic/imapdriver_tools.h index 6582a31..59c993e 100644 --- a/kmicromail/libetpan/generic/imapdriver_tools.h +++ b/kmicromail/libetpan/generic/imapdriver_tools.h | |||
@@ -103,11 +103,14 @@ imapdriver_get_cached_envelope(struct mail_cache_db * cache_db, | |||
103 | int | 103 | int |
104 | imapdriver_write_cached_envelope(struct mail_cache_db * cache_db, | 104 | imapdriver_write_cached_envelope(struct mail_cache_db * cache_db, |
105 | MMAPString * mmapstr, | 105 | MMAPString * mmapstr, |
106 | mailsession * session, mailmessage * msg, | 106 | mailsession * session, mailmessage * msg, |
107 | struct mailimf_fields * fields); | 107 | struct mailimf_fields * fields); |
108 | 108 | ||
109 | int imap_flags_to_imap_flags(struct mail_flags * flags, | ||
110 | struct mailimap_flag_list ** result); | ||
111 | |||
109 | #ifdef __cplusplus | 112 | #ifdef __cplusplus |
110 | } | 113 | } |
111 | #endif | 114 | #endif |
112 | 115 | ||
113 | #endif | 116 | #endif |
diff --git a/kmicromail/libetpan/generic/imapstorage.c b/kmicromail/libetpan/generic/imapstorage.c index e8683d8..972b6dd 100644 --- a/kmicromail/libetpan/generic/imapstorage.c +++ b/kmicromail/libetpan/generic/imapstorage.c | |||
@@ -68,13 +68,13 @@ int imap_mailstorage_init(struct mailstorage * storage, | |||
68 | int imap_connection_type, int imap_auth_type, | 68 | int imap_connection_type, int imap_auth_type, |
69 | char * imap_login, char * imap_password, | 69 | char * imap_login, char * imap_password, |
70 | int imap_cached, char * imap_cache_directory) | 70 | int imap_cached, char * imap_cache_directory) |
71 | { | 71 | { |
72 | struct imap_mailstorage * imap_storage; | 72 | struct imap_mailstorage * imap_storage; |
73 | 73 | ||
74 | imap_storage = malloc(sizeof(struct imap_mailstorage)); | 74 | imap_storage = malloc(sizeof(* imap_storage)); |
75 | if (imap_storage == NULL) | 75 | if (imap_storage == NULL) |
76 | goto err; | 76 | goto err; |
77 | 77 | ||
78 | imap_storage->imap_servername = strdup(imap_servername); | 78 | imap_storage->imap_servername = strdup(imap_servername); |
79 | if (imap_storage->imap_servername == NULL) | 79 | if (imap_storage->imap_servername == NULL) |
80 | goto free; | 80 | goto free; |
diff --git a/kmicromail/libetpan/generic/maildirdriver.c b/kmicromail/libetpan/generic/maildirdriver.c index 7830ceb..5f21422 100644 --- a/kmicromail/libetpan/generic/maildirdriver.c +++ b/kmicromail/libetpan/generic/maildirdriver.c | |||
@@ -82,12 +82,15 @@ static int unseen_number(mailsession * session, char * mb, | |||
82 | static int messages_number(mailsession * session, char * mb, | 82 | static int messages_number(mailsession * session, char * mb, |
83 | uint32_t * result); | 83 | uint32_t * result); |
84 | 84 | ||
85 | static int append_message(mailsession * session, | 85 | static int append_message(mailsession * session, |
86 | char * message, size_t size); | 86 | char * message, size_t size); |
87 | 87 | ||
88 | static int append_message_flags(mailsession * session, | ||
89 | char * message, size_t size, struct mail_flags * flags); | ||
90 | |||
88 | static int get_messages_list(mailsession * session, | 91 | static int get_messages_list(mailsession * session, |
89 | struct mailmessage_list ** result); | 92 | struct mailmessage_list ** result); |
90 | 93 | ||
91 | static int get_envelopes_list(mailsession * session, | 94 | static int get_envelopes_list(mailsession * session, |
92 | struct mailmessage_list * env_list); | 95 | struct mailmessage_list * env_list); |
93 | 96 | ||
@@ -126,12 +129,13 @@ static mailsession_driver local_maildir_session_driver = { | |||
126 | .sess_list_folders = NULL, | 129 | .sess_list_folders = NULL, |
127 | .sess_lsub_folders = NULL, | 130 | .sess_lsub_folders = NULL, |
128 | .sess_subscribe_folder = NULL, | 131 | .sess_subscribe_folder = NULL, |
129 | .sess_unsubscribe_folder = NULL, | 132 | .sess_unsubscribe_folder = NULL, |
130 | 133 | ||
131 | .sess_append_message = append_message, | 134 | .sess_append_message = append_message, |
135 | .sess_append_message_flags = append_message_flags, | ||
132 | .sess_copy_message = NULL, | 136 | .sess_copy_message = NULL, |
133 | .sess_move_message = NULL, | 137 | .sess_move_message = NULL, |
134 | 138 | ||
135 | .sess_get_messages_list = get_messages_list, | 139 | .sess_get_messages_list = get_messages_list, |
136 | .sess_get_envelopes_list = get_envelopes_list, | 140 | .sess_get_envelopes_list = get_envelopes_list, |
137 | .sess_remove_message = NULL, | 141 | .sess_remove_message = NULL, |
@@ -352,24 +356,71 @@ static int recent_number(mailsession * session, char * mb, | |||
352 | 356 | ||
353 | /* messages operations */ | 357 | /* messages operations */ |
354 | 358 | ||
355 | static int append_message(mailsession * session, | 359 | static int append_message(mailsession * session, |
356 | char * message, size_t size) | 360 | char * message, size_t size) |
357 | { | 361 | { |
362 | #if 0 | ||
358 | struct maildir * md; | 363 | struct maildir * md; |
359 | int r; | 364 | int r; |
360 | 365 | ||
361 | md = get_maildir_session(session); | 366 | md = get_maildir_session(session); |
362 | if (md == NULL) | 367 | if (md == NULL) |
363 | return MAIL_ERROR_BAD_STATE; | 368 | return MAIL_ERROR_BAD_STATE; |
364 | 369 | ||
365 | r = maildir_message_add(md, message, size); | 370 | r = maildir_message_add(md, message, size); |
366 | if (r != MAILDIR_NO_ERROR) | 371 | if (r != MAILDIR_NO_ERROR) |
367 | return maildirdriver_maildir_error_to_mail_error(r); | 372 | return maildirdriver_maildir_error_to_mail_error(r); |
368 | 373 | ||
369 | return MAIL_NO_ERROR; | 374 | return MAIL_NO_ERROR; |
375 | #endif | ||
376 | |||
377 | return append_message_flags(session, message, size, NULL); | ||
378 | } | ||
379 | |||
380 | static int append_message_flags(mailsession * session, | ||
381 | char * message, size_t size, struct mail_flags * flags) | ||
382 | { | ||
383 | struct maildir * md; | ||
384 | int r; | ||
385 | char uid[PATH_MAX]; | ||
386 | struct maildir_msg * md_msg; | ||
387 | chashdatum key; | ||
388 | chashdatum value; | ||
389 | uint32_t md_flags; | ||
390 | |||
391 | md = get_maildir_session(session); | ||
392 | if (md == NULL) | ||
393 | return MAIL_ERROR_BAD_STATE; | ||
394 | |||
395 | r = maildir_message_add_uid(md, message, size, | ||
396 | uid, sizeof(uid)); | ||
397 | if (r != MAILDIR_NO_ERROR) | ||
398 | return maildirdriver_maildir_error_to_mail_error(r); | ||
399 | |||
400 | if (flags == NULL) | ||
401 | goto exit; | ||
402 | |||
403 | key.data = uid; | ||
404 | key.len = strlen(uid); | ||
405 | r = chash_get(md->mdir_msg_hash, &key, &value); | ||
406 | if (r < 0) | ||
407 | goto exit; | ||
408 | |||
409 | md_msg = value.data; | ||
410 | |||
411 | md_flags = maildirdriver_flags_to_maildir_flags(flags->fl_flags); | ||
412 | |||
413 | r = maildir_message_change_flags(md, uid, md_flags); | ||
414 | if (r != MAILDIR_NO_ERROR) | ||
415 | goto exit; | ||
416 | |||
417 | return MAIL_NO_ERROR; | ||
418 | |||
419 | exit: | ||
420 | return MAIL_NO_ERROR; | ||
370 | } | 421 | } |
371 | 422 | ||
372 | static int get_messages_list(mailsession * session, | 423 | static int get_messages_list(mailsession * session, |
373 | struct mailmessage_list ** result) | 424 | struct mailmessage_list ** result) |
374 | { | 425 | { |
375 | struct maildir * md; | 426 | struct maildir * md; |
diff --git a/kmicromail/libetpan/generic/maildirdriver_cached.c b/kmicromail/libetpan/generic/maildirdriver_cached.c index 503d1c9..8a5e206 100644 --- a/kmicromail/libetpan/generic/maildirdriver_cached.c +++ b/kmicromail/libetpan/generic/maildirdriver_cached.c | |||
@@ -83,12 +83,15 @@ static int unseen_number(mailsession * session, char * mb, | |||
83 | static int messages_number(mailsession * session, char * mb, | 83 | static int messages_number(mailsession * session, char * mb, |
84 | uint32_t * result); | 84 | uint32_t * result); |
85 | 85 | ||
86 | static int append_message(mailsession * session, | 86 | static int append_message(mailsession * session, |
87 | char * message, size_t size); | 87 | char * message, size_t size); |
88 | 88 | ||
89 | static int append_message_flags(mailsession * session, | ||
90 | char * message, size_t size, struct mail_flags * flags); | ||
91 | |||
89 | static int get_messages_list(mailsession * session, | 92 | static int get_messages_list(mailsession * session, |
90 | struct mailmessage_list ** result); | 93 | struct mailmessage_list ** result); |
91 | 94 | ||
92 | static int get_envelopes_list(mailsession * session, | 95 | static int get_envelopes_list(mailsession * session, |
93 | struct mailmessage_list * env_list); | 96 | struct mailmessage_list * env_list); |
94 | 97 | ||
@@ -130,12 +133,13 @@ static mailsession_driver local_maildir_cached_session_driver = { | |||
130 | .sess_list_folders = NULL, | 133 | .sess_list_folders = NULL, |
131 | .sess_lsub_folders = NULL, | 134 | .sess_lsub_folders = NULL, |
132 | .sess_subscribe_folder = NULL, | 135 | .sess_subscribe_folder = NULL, |
133 | .sess_unsubscribe_folder = NULL, | 136 | .sess_unsubscribe_folder = NULL, |
134 | 137 | ||
135 | .sess_append_message = append_message, | 138 | .sess_append_message = append_message, |
139 | .sess_append_message_flags = append_message_flags, | ||
136 | .sess_copy_message = NULL, | 140 | .sess_copy_message = NULL, |
137 | .sess_move_message = NULL, | 141 | .sess_move_message = NULL, |
138 | 142 | ||
139 | .sess_get_messages_list = get_messages_list, | 143 | .sess_get_messages_list = get_messages_list, |
140 | .sess_get_envelopes_list = get_envelopes_list, | 144 | .sess_get_envelopes_list = get_envelopes_list, |
141 | .sess_remove_message = NULL, | 145 | .sess_remove_message = NULL, |
@@ -451,15 +455,89 @@ static int recent_number(mailsession * session, char * mb, | |||
451 | } | 455 | } |
452 | 456 | ||
453 | 457 | ||
454 | static int append_message(mailsession * session, | 458 | static int append_message(mailsession * session, |
455 | char * message, size_t size) | 459 | char * message, size_t size) |
456 | { | 460 | { |
461 | #if 0 | ||
457 | return mailsession_append_message(get_ancestor(session), message, size); | 462 | return mailsession_append_message(get_ancestor(session), message, size); |
463 | #endif | ||
464 | return append_message_flags(session, message, size, NULL); | ||
458 | } | 465 | } |
459 | 466 | ||
467 | static int append_message_flags(mailsession * session, | ||
468 | char * message, size_t size, struct mail_flags * flags) | ||
469 | { | ||
470 | struct maildir * md; | ||
471 | int r; | ||
472 | char uid[PATH_MAX]; | ||
473 | struct maildir_msg * md_msg; | ||
474 | chashdatum key; | ||
475 | chashdatum value; | ||
476 | uint32_t md_flags; | ||
477 | struct mail_cache_db * cache_db_flags; | ||
478 | char filename_flags[PATH_MAX]; | ||
479 | MMAPString * mmapstr; | ||
480 | struct maildir_cached_session_state_data * data; | ||
481 | |||
482 | md = get_maildir_session(session); | ||
483 | if (md == NULL) | ||
484 | return MAIL_ERROR_BAD_STATE; | ||
485 | |||
486 | r = maildir_message_add_uid(md, message, size, | ||
487 | uid, sizeof(uid)); | ||
488 | if (r != MAILDIR_NO_ERROR) | ||
489 | return maildirdriver_maildir_error_to_mail_error(r); | ||
490 | |||
491 | if (flags == NULL) | ||
492 | goto exit; | ||
493 | |||
494 | data = get_cached_data(session); | ||
495 | |||
496 | snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s", | ||
497 | data->md_flags_directory, MAIL_DIR_SEPARATOR, data->md_quoted_mb, | ||
498 | MAIL_DIR_SEPARATOR, FLAGS_NAME); | ||
499 | |||
500 | r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); | ||
501 | if (r < 0) | ||
502 | goto exit; | ||
503 | |||
504 | mmapstr = mmap_string_new(""); | ||
505 | if (mmapstr == NULL) | ||
506 | goto close_db_flags; | ||
507 | |||
508 | r = write_cached_flags(cache_db_flags, mmapstr, | ||
509 | uid, flags); | ||
510 | |||
511 | mmap_string_free(mmapstr); | ||
512 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
513 | |||
514 | if (r != MAIL_NO_ERROR) | ||
515 | goto exit; | ||
516 | |||
517 | key.data = uid; | ||
518 | key.len = strlen(uid); | ||
519 | r = chash_get(md->mdir_msg_hash, &key, &value); | ||
520 | if (r < 0) | ||
521 | goto exit; | ||
522 | |||
523 | md_msg = value.data; | ||
524 | |||
525 | md_flags = maildirdriver_flags_to_maildir_flags(flags->fl_flags); | ||
526 | |||
527 | r = maildir_message_change_flags(md, uid, md_flags); | ||
528 | if (r != MAILDIR_NO_ERROR) | ||
529 | goto exit; | ||
530 | |||
531 | return MAIL_NO_ERROR; | ||
532 | |||
533 | close_db_flags: | ||
534 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
535 | exit: | ||
536 | return MAIL_NO_ERROR; | ||
537 | } | ||
460 | 538 | ||
461 | #define UID_NAME "uid.db" | 539 | #define UID_NAME "uid.db" |
462 | 540 | ||
463 | static int uid_clean_up(struct mail_cache_db * uid_db, | 541 | static int uid_clean_up(struct mail_cache_db * uid_db, |
464 | struct mailmessage_list * env_list) | 542 | struct mailmessage_list * env_list) |
465 | { | 543 | { |
diff --git a/kmicromail/libetpan/generic/maildirdriver_cached_message.c b/kmicromail/libetpan/generic/maildirdriver_cached_message.c index 51866aa..34de351 100644 --- a/kmicromail/libetpan/generic/maildirdriver_cached_message.c +++ b/kmicromail/libetpan/generic/maildirdriver_cached_message.c | |||
@@ -36,21 +36,26 @@ | |||
36 | #include "maildirdriver_message.h" | 36 | #include "maildirdriver_message.h" |
37 | 37 | ||
38 | #include "mailmessage_tools.h" | 38 | #include "mailmessage_tools.h" |
39 | #include "maildirdriver.h" | 39 | #include "maildirdriver.h" |
40 | #include "maildir.h" | 40 | #include "maildir.h" |
41 | #include "generic_cache.h" | 41 | #include "generic_cache.h" |
42 | #include "mail_cache_db.h" | ||
43 | #include "maildirdriver_tools.h" | ||
42 | 44 | ||
43 | #include <unistd.h> | 45 | #include <unistd.h> |
44 | #include <sys/mman.h> | 46 | #include <sys/mman.h> |
45 | #include <sys/types.h> | 47 | #include <sys/types.h> |
46 | #include <sys/stat.h> | 48 | #include <sys/stat.h> |
47 | #include <fcntl.h> | 49 | #include <fcntl.h> |
48 | #include <string.h> | 50 | #include <string.h> |
49 | #include <stdlib.h> | 51 | #include <stdlib.h> |
50 | 52 | ||
53 | static int get_flags(mailmessage * msg_info, | ||
54 | struct mail_flags ** result); | ||
55 | |||
51 | static int prefetch(mailmessage * msg_info); | 56 | static int prefetch(mailmessage * msg_info); |
52 | 57 | ||
53 | static void prefetch_free(struct generic_message_t * msg); | 58 | static void prefetch_free(struct generic_message_t * msg); |
54 | 59 | ||
55 | static int initialize(mailmessage * msg_info); | 60 | static int initialize(mailmessage * msg_info); |
56 | 61 | ||
@@ -75,13 +80,13 @@ static mailmessage_driver local_maildir_cached_message_driver = { | |||
75 | .msg_fetch_section = mailmessage_generic_fetch_section, | 80 | .msg_fetch_section = mailmessage_generic_fetch_section, |
76 | .msg_fetch_section_header = mailmessage_generic_fetch_section_header, | 81 | .msg_fetch_section_header = mailmessage_generic_fetch_section_header, |
77 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, | 82 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, |
78 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, | 83 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, |
79 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, | 84 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, |
80 | 85 | ||
81 | .msg_get_flags = NULL, | 86 | .msg_get_flags = get_flags, |
82 | }; | 87 | }; |
83 | 88 | ||
84 | mailmessage_driver * maildir_cached_message_driver = | 89 | mailmessage_driver * maildir_cached_message_driver = |
85 | &local_maildir_cached_message_driver; | 90 | &local_maildir_cached_message_driver; |
86 | 91 | ||
87 | struct maildir_msg_data { | 92 | struct maildir_msg_data { |
@@ -243,6 +248,87 @@ static void check(mailmessage * msg_info) | |||
243 | r = mail_flags_store_set(get_session_ancestor_data(msg_info)->md_flags_store, msg_info); | 248 | r = mail_flags_store_set(get_session_ancestor_data(msg_info)->md_flags_store, msg_info); |
244 | 249 | ||
245 | r = mail_flags_store_set(get_cached_session_data(msg_info)->md_flags_store, msg_info); | 250 | r = mail_flags_store_set(get_cached_session_data(msg_info)->md_flags_store, msg_info); |
246 | /* ignore errors */ | 251 | /* ignore errors */ |
247 | } | 252 | } |
248 | } | 253 | } |
254 | |||
255 | #define FLAGS_NAME "flags.db" | ||
256 | |||
257 | static int get_flags(mailmessage * msg_info, | ||
258 | struct mail_flags ** result) | ||
259 | { | ||
260 | struct mail_cache_db * cache_db_flags; | ||
261 | chashdatum key; | ||
262 | chashdatum value; | ||
263 | struct maildir * md; | ||
264 | struct mail_flags * flags; | ||
265 | struct maildir_cached_session_state_data * data; | ||
266 | struct maildir_msg * md_msg; | ||
267 | int r; | ||
268 | uint32_t driver_flags; | ||
269 | char filename_flags[PATH_MAX]; | ||
270 | char keyname[PATH_MAX]; | ||
271 | MMAPString * mmapstr; | ||
272 | |||
273 | if (msg_info->msg_flags != NULL) { | ||
274 | * result = msg_info->msg_flags; | ||
275 | return MAIL_NO_ERROR; | ||
276 | } | ||
277 | |||
278 | data = get_cached_session_data(msg_info); | ||
279 | flags = mail_flags_store_get(data->md_flags_store, | ||
280 | msg_info->msg_index); | ||
281 | if (flags != NULL) { | ||
282 | msg_info->msg_flags = flags; | ||
283 | * result = msg_info->msg_flags; | ||
284 | return MAIL_NO_ERROR; | ||
285 | } | ||
286 | |||
287 | snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s", | ||
288 | data->md_flags_directory, MAIL_DIR_SEPARATOR, data->md_quoted_mb, | ||
289 | MAIL_DIR_SEPARATOR, FLAGS_NAME); | ||
290 | |||
291 | r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); | ||
292 | if (r < 0) | ||
293 | return MAIL_ERROR_FILE; | ||
294 | |||
295 | snprintf(keyname, PATH_MAX, "%s-flags", msg_info->msg_uid); | ||
296 | |||
297 | mmapstr = mmap_string_new(""); | ||
298 | if (mmapstr == NULL) { | ||
299 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
300 | return MAIL_ERROR_MEMORY; | ||
301 | } | ||
302 | |||
303 | r = generic_cache_flags_read(cache_db_flags, mmapstr, keyname, &flags); | ||
304 | mmap_string_free(mmapstr); | ||
305 | |||
306 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
307 | |||
308 | if (r != MAIL_NO_ERROR) { | ||
309 | flags = mail_flags_new_empty(); | ||
310 | if (flags == NULL) | ||
311 | return MAIL_ERROR_MEMORY; | ||
312 | } | ||
313 | |||
314 | md = get_maildir_session(msg_info); | ||
315 | if (md == NULL) | ||
316 | return MAIL_ERROR_BAD_STATE; | ||
317 | |||
318 | key.data = msg_info->msg_uid; | ||
319 | key.len = strlen(msg_info->msg_uid); | ||
320 | r = chash_get(md->mdir_msg_hash, &key, &value); | ||
321 | if (r < 0) | ||
322 | return MAIL_ERROR_MSG_NOT_FOUND; | ||
323 | |||
324 | md_msg = value.data; | ||
325 | |||
326 | driver_flags = maildirdriver_maildir_flags_to_flags(md_msg->msg_flags); | ||
327 | |||
328 | flags->fl_flags = driver_flags; | ||
329 | msg_info->msg_flags = flags; | ||
330 | |||
331 | * result = msg_info->msg_flags; | ||
332 | |||
333 | return MAIL_NO_ERROR; | ||
334 | } | ||
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 | ||
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 | ||
55 | static int initialize(mailmessage * msg_info); | 59 | static 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 | ||
84 | mailmessage_driver * maildir_message_driver = &local_maildir_message_driver; | 88 | mailmessage_driver * maildir_message_driver = &local_maildir_message_driver; |
85 | 89 | ||
86 | struct maildir_msg_data { | 90 | struct 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 | |||
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 | } | ||
diff --git a/kmicromail/libetpan/generic/maildirstorage.c b/kmicromail/libetpan/generic/maildirstorage.c index 7e6b461..e37f591 100644 --- a/kmicromail/libetpan/generic/maildirstorage.c +++ b/kmicromail/libetpan/generic/maildirstorage.c | |||
@@ -30,12 +30,13 @@ | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "maildirstorage.h" | ||
36 | #include "mailstorage.h" | 37 | #include "mailstorage.h" |
37 | 38 | ||
38 | #include "mail.h" | 39 | #include "mail.h" |
39 | #include "mailmessage.h" | 40 | #include "mailmessage.h" |
40 | #include "maildirdriver.h" | 41 | #include "maildirdriver.h" |
41 | #include "maildirdriver_cached.h" | 42 | #include "maildirdriver_cached.h" |
@@ -62,13 +63,13 @@ static mailstorage_driver maildir_mailstorage_driver = { | |||
62 | int maildir_mailstorage_init(struct mailstorage * storage, | 63 | int maildir_mailstorage_init(struct mailstorage * storage, |
63 | char * md_pathname, int md_cached, | 64 | char * md_pathname, int md_cached, |
64 | char * md_cache_directory, char * md_flags_directory) | 65 | char * md_cache_directory, char * md_flags_directory) |
65 | { | 66 | { |
66 | struct maildir_mailstorage * maildir_storage; | 67 | struct maildir_mailstorage * maildir_storage; |
67 | 68 | ||
68 | maildir_storage = malloc(sizeof(struct maildir_mailstorage)); | 69 | maildir_storage = malloc(sizeof(* maildir_storage)); |
69 | if (maildir_storage == NULL) | 70 | if (maildir_storage == NULL) |
70 | goto err; | 71 | goto err; |
71 | 72 | ||
72 | maildir_storage->md_pathname = strdup(md_pathname); | 73 | maildir_storage->md_pathname = strdup(md_pathname); |
73 | if (maildir_storage->md_pathname == NULL) | 74 | if (maildir_storage->md_pathname == NULL) |
74 | goto free; | 75 | goto free; |
diff --git a/kmicromail/libetpan/generic/maildirstorage.h b/kmicromail/libetpan/generic/maildirstorage.h index d17ea2c..73d7b20 100644 --- a/kmicromail/libetpan/generic/maildirstorage.h +++ b/kmicromail/libetpan/generic/maildirstorage.h | |||
@@ -41,13 +41,13 @@ | |||
41 | 41 | ||
42 | #ifdef __cplusplus | 42 | #ifdef __cplusplus |
43 | extern "C" { | 43 | extern "C" { |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | /* | 46 | /* |
47 | maildir_mailstorage_init is the constructor for a mbox storage. | 47 | maildir_mailstorage_init is the constructor for a maildir storage. |
48 | 48 | ||
49 | @param storage this is the storage to initialize. | 49 | @param storage this is the storage to initialize. |
50 | 50 | ||
51 | @param pathname is the directory that contains the mailbox. | 51 | @param pathname is the directory that contains the mailbox. |
52 | 52 | ||
53 | @param cached if this value is != 0, a persistant cache will be | 53 | @param cached if this value is != 0, a persistant cache will be |
diff --git a/kmicromail/libetpan/generic/maildriver.c b/kmicromail/libetpan/generic/maildriver.c index 01e3e34..1fc478a 100644 --- a/kmicromail/libetpan/generic/maildriver.c +++ b/kmicromail/libetpan/generic/maildriver.c | |||
@@ -279,12 +279,22 @@ int mailsession_append_message(mailsession * session, | |||
279 | if (session->sess_driver->sess_append_message == NULL) | 279 | if (session->sess_driver->sess_append_message == NULL) |
280 | return MAIL_ERROR_NOT_IMPLEMENTED; | 280 | return MAIL_ERROR_NOT_IMPLEMENTED; |
281 | 281 | ||
282 | return session->sess_driver->sess_append_message(session, message, size); | 282 | return session->sess_driver->sess_append_message(session, message, size); |
283 | } | 283 | } |
284 | 284 | ||
285 | int mailsession_append_message_flags(mailsession * session, | ||
286 | char * message, size_t size, struct mail_flags * flags) | ||
287 | { | ||
288 | if (session->sess_driver->sess_append_message_flags == NULL) | ||
289 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
290 | |||
291 | return session->sess_driver->sess_append_message_flags(session, | ||
292 | message, size, flags); | ||
293 | } | ||
294 | |||
285 | int mailsession_copy_message(mailsession * session, | 295 | int mailsession_copy_message(mailsession * session, |
286 | uint32_t num, char * mb) | 296 | uint32_t num, char * mb) |
287 | { | 297 | { |
288 | if (session->sess_driver->sess_copy_message == NULL) | 298 | if (session->sess_driver->sess_copy_message == NULL) |
289 | return MAIL_ERROR_NOT_IMPLEMENTED; | 299 | return MAIL_ERROR_NOT_IMPLEMENTED; |
290 | 300 | ||
diff --git a/kmicromail/libetpan/generic/maildriver.h b/kmicromail/libetpan/generic/maildriver.h index 7da9aea..c773190 100644 --- a/kmicromail/libetpan/generic/maildriver.h +++ b/kmicromail/libetpan/generic/maildriver.h | |||
@@ -397,12 +397,15 @@ int mailsession_unsubscribe_folder(mailsession * session, char * mb); | |||
397 | on error | 397 | on error |
398 | */ | 398 | */ |
399 | 399 | ||
400 | int mailsession_append_message(mailsession * session, | 400 | int mailsession_append_message(mailsession * session, |
401 | char * message, size_t size); | 401 | char * message, size_t size); |
402 | 402 | ||
403 | int mailsession_append_message_flags(mailsession * session, | ||
404 | char * message, size_t size, struct mail_flags * flags); | ||
405 | |||
403 | /* | 406 | /* |
404 | NOTE: some drivers does not implement this | 407 | NOTE: some drivers does not implement this |
405 | 408 | ||
406 | mailsession_copy_message copies a message whose number is given to | 409 | mailsession_copy_message copies a message whose number is given to |
407 | a given mailbox. The mailbox must be accessible from the same session. | 410 | a given mailbox. The mailbox must be accessible from the same session. |
408 | 411 | ||
diff --git a/kmicromail/libetpan/generic/maildriver_types.h b/kmicromail/libetpan/generic/maildriver_types.h index 3ff9440..9eab4d6 100644 --- a/kmicromail/libetpan/generic/maildriver_types.h +++ b/kmicromail/libetpan/generic/maildriver_types.h | |||
@@ -504,12 +504,14 @@ struct mailsession_driver { | |||
504 | int (* sess_unsubscribe_folder)(mailsession * session, char * mb); | 504 | int (* sess_unsubscribe_folder)(mailsession * session, char * mb); |
505 | 505 | ||
506 | /* messages operations */ | 506 | /* messages operations */ |
507 | 507 | ||
508 | int (* sess_append_message)(mailsession * session, | 508 | int (* sess_append_message)(mailsession * session, |
509 | char * message, size_t size); | 509 | char * message, size_t size); |
510 | int (* sess_append_message_flags)(mailsession * session, | ||
511 | char * message, size_t size, struct mail_flags * flags); | ||
510 | int (* sess_copy_message)(mailsession * session, | 512 | int (* sess_copy_message)(mailsession * session, |
511 | uint32_t num, char * mb); | 513 | uint32_t num, char * mb); |
512 | int (* sess_move_message)(mailsession * session, | 514 | int (* sess_move_message)(mailsession * session, |
513 | uint32_t num, char * mb); | 515 | uint32_t num, char * mb); |
514 | 516 | ||
515 | int (* sess_get_message)(mailsession * session, | 517 | int (* sess_get_message)(mailsession * session, |
diff --git a/kmicromail/libetpan/generic/mailfolder.c b/kmicromail/libetpan/generic/mailfolder.c index 2ddc37d..89ba891 100644 --- a/kmicromail/libetpan/generic/mailfolder.c +++ b/kmicromail/libetpan/generic/mailfolder.c | |||
@@ -29,12 +29,19 @@ int mailfolder_status(struct mailfolder * folder, | |||
29 | int mailfolder_append_message(struct mailfolder * folder, | 29 | int mailfolder_append_message(struct mailfolder * folder, |
30 | char * message, size_t size) | 30 | char * message, size_t size) |
31 | { | 31 | { |
32 | return mailsession_append_message(folder->fld_session, message, size); | 32 | return mailsession_append_message(folder->fld_session, message, size); |
33 | } | 33 | } |
34 | 34 | ||
35 | int mailfolder_append_message_flags(struct mailfolder * folder, | ||
36 | char * message, size_t size, struct mail_flags * flags) | ||
37 | { | ||
38 | return mailsession_append_message_flags(folder->fld_session, message, | ||
39 | size, flags); | ||
40 | } | ||
41 | |||
35 | int mailfolder_get_messages_list(struct mailfolder * folder, | 42 | int mailfolder_get_messages_list(struct mailfolder * folder, |
36 | struct mailmessage_list ** result) | 43 | struct mailmessage_list ** result) |
37 | { | 44 | { |
38 | int r; | 45 | int r; |
39 | struct mailmessage_list * msg_list; | 46 | struct mailmessage_list * msg_list; |
40 | unsigned int i; | 47 | unsigned int i; |
diff --git a/kmicromail/libetpan/generic/mailfolder.h b/kmicromail/libetpan/generic/mailfolder.h index 3ecad23..ff53470 100644 --- a/kmicromail/libetpan/generic/mailfolder.h +++ b/kmicromail/libetpan/generic/mailfolder.h | |||
@@ -14,12 +14,15 @@ int mailfolder_status(struct mailfolder * folder, | |||
14 | uint32_t * result_messages, uint32_t * result_recent, | 14 | uint32_t * result_messages, uint32_t * result_recent, |
15 | uint32_t * result_unseen); | 15 | uint32_t * result_unseen); |
16 | 16 | ||
17 | int mailfolder_append_message(struct mailfolder * folder, | 17 | int mailfolder_append_message(struct mailfolder * folder, |
18 | char * message, size_t size); | 18 | char * message, size_t size); |
19 | 19 | ||
20 | int mailfolder_append_message_flags(struct mailfolder * folder, | ||
21 | char * message, size_t size, struct mail_flags * flags); | ||
22 | |||
20 | int mailfolder_get_messages_list(struct mailfolder * folder, | 23 | int mailfolder_get_messages_list(struct mailfolder * folder, |
21 | struct mailmessage_list ** result); | 24 | struct mailmessage_list ** result); |
22 | 25 | ||
23 | int mailfolder_get_envelopes_list(struct mailfolder * folder, | 26 | int mailfolder_get_envelopes_list(struct mailfolder * folder, |
24 | struct mailmessage_list * result); | 27 | struct mailmessage_list * result); |
25 | 28 | ||
diff --git a/kmicromail/libetpan/generic/mailstorage.c b/kmicromail/libetpan/generic/mailstorage.c index 25e561e..dc91744 100644 --- a/kmicromail/libetpan/generic/mailstorage.c +++ b/kmicromail/libetpan/generic/mailstorage.c | |||
@@ -320,12 +320,19 @@ void mailstorage_disconnect(struct mailstorage * storage) | |||
320 | r = mailsession_logout(storage->sto_session); | 320 | r = mailsession_logout(storage->sto_session); |
321 | 321 | ||
322 | mailsession_free(storage->sto_session); | 322 | mailsession_free(storage->sto_session); |
323 | storage->sto_session = NULL; | 323 | storage->sto_session = NULL; |
324 | } | 324 | } |
325 | 325 | ||
326 | |||
327 | int mailstorage_noop(struct mailstorage * storage) | ||
328 | { | ||
329 | return mailsession_noop(storage->sto_session); | ||
330 | } | ||
331 | |||
332 | |||
326 | static int mailstorage_get_folder(struct mailstorage * storage, | 333 | static int mailstorage_get_folder(struct mailstorage * storage, |
327 | char * pathname, mailsession ** result) | 334 | char * pathname, mailsession ** result) |
328 | { | 335 | { |
329 | if (storage->sto_driver->sto_get_folder_session == NULL) | 336 | if (storage->sto_driver->sto_get_folder_session == NULL) |
330 | return MAIL_ERROR_NOT_IMPLEMENTED; | 337 | return MAIL_ERROR_NOT_IMPLEMENTED; |
331 | 338 | ||
diff --git a/kmicromail/libetpan/generic/mailstorage.h b/kmicromail/libetpan/generic/mailstorage.h index d56aef1..4c57883 100644 --- a/kmicromail/libetpan/generic/mailstorage.h +++ b/kmicromail/libetpan/generic/mailstorage.h | |||
@@ -68,12 +68,14 @@ void mailstorage_free(struct mailstorage * storage); | |||
68 | */ | 68 | */ |
69 | 69 | ||
70 | int mailstorage_connect(struct mailstorage * storage); | 70 | int mailstorage_connect(struct mailstorage * storage); |
71 | 71 | ||
72 | void mailstorage_disconnect(struct mailstorage * storage); | 72 | void mailstorage_disconnect(struct mailstorage * storage); |
73 | 73 | ||
74 | int mailstorage_noop(struct mailstorage * storage); | ||
75 | |||
74 | 76 | ||
75 | /* folder */ | 77 | /* folder */ |
76 | 78 | ||
77 | struct mailfolder * mailfolder_new(struct mailstorage * fld_storage, | 79 | struct mailfolder * mailfolder_new(struct mailstorage * fld_storage, |
78 | char * fld_pathname, char * fld_virtual_name); | 80 | char * fld_pathname, char * fld_virtual_name); |
79 | 81 | ||
@@ -85,13 +87,12 @@ int mailfolder_add_child(struct mailfolder * parent, | |||
85 | int mailfolder_detach_parent(struct mailfolder * folder); | 87 | int mailfolder_detach_parent(struct mailfolder * folder); |
86 | 88 | ||
87 | int mailfolder_connect(struct mailfolder * folder); | 89 | int mailfolder_connect(struct mailfolder * folder); |
88 | 90 | ||
89 | void mailfolder_disconnect(struct mailfolder * folder); | 91 | void mailfolder_disconnect(struct mailfolder * folder); |
90 | 92 | ||
91 | |||
92 | #ifdef __cplusplus | 93 | #ifdef __cplusplus |
93 | } | 94 | } |
94 | #endif | 95 | #endif |
95 | 96 | ||
96 | #endif | 97 | #endif |
97 | 98 | ||
diff --git a/kmicromail/libetpan/generic/mboxdriver.c b/kmicromail/libetpan/generic/mboxdriver.c index fa3e2ea..c19a668 100644 --- a/kmicromail/libetpan/generic/mboxdriver.c +++ b/kmicromail/libetpan/generic/mboxdriver.c | |||
@@ -74,12 +74,15 @@ static int mboxdriver_status_folder(mailsession * session, char * mb, | |||
74 | static int mboxdriver_messages_number(mailsession * session, char * mb, | 74 | static int mboxdriver_messages_number(mailsession * session, char * mb, |
75 | uint32_t * result); | 75 | uint32_t * result); |
76 | 76 | ||
77 | static int mboxdriver_append_message(mailsession * session, | 77 | static int mboxdriver_append_message(mailsession * session, |
78 | char * message, size_t size); | 78 | char * message, size_t size); |
79 | 79 | ||
80 | static int mboxdriver_append_message_flags(mailsession * session, | ||
81 | char * message, size_t size, struct mail_flags * flags); | ||
82 | |||
80 | static int mboxdriver_get_messages_list(mailsession * session, | 83 | static int mboxdriver_get_messages_list(mailsession * session, |
81 | struct mailmessage_list ** result); | 84 | struct mailmessage_list ** result); |
82 | 85 | ||
83 | static int | 86 | static int |
84 | mboxdriver_get_envelopes_list(mailsession * session, | 87 | mboxdriver_get_envelopes_list(mailsession * session, |
85 | struct mailmessage_list * env_list); | 88 | struct mailmessage_list * env_list); |
@@ -123,12 +126,13 @@ static mailsession_driver local_mbox_session_driver = { | |||
123 | .sess_list_folders = NULL, | 126 | .sess_list_folders = NULL, |
124 | .sess_lsub_folders = NULL, | 127 | .sess_lsub_folders = NULL, |
125 | .sess_subscribe_folder = NULL, | 128 | .sess_subscribe_folder = NULL, |
126 | .sess_unsubscribe_folder = NULL, | 129 | .sess_unsubscribe_folder = NULL, |
127 | 130 | ||
128 | .sess_append_message = mboxdriver_append_message, | 131 | .sess_append_message = mboxdriver_append_message, |
132 | .sess_append_message_flags = mboxdriver_append_message_flags, | ||
129 | .sess_copy_message = NULL, | 133 | .sess_copy_message = NULL, |
130 | .sess_move_message = NULL, | 134 | .sess_move_message = NULL, |
131 | 135 | ||
132 | .sess_get_messages_list = mboxdriver_get_messages_list, | 136 | .sess_get_messages_list = mboxdriver_get_messages_list, |
133 | .sess_get_envelopes_list = mboxdriver_get_envelopes_list, | 137 | .sess_get_envelopes_list = mboxdriver_get_envelopes_list, |
134 | .sess_remove_message = mboxdriver_remove_message, | 138 | .sess_remove_message = mboxdriver_remove_message, |
@@ -341,12 +345,18 @@ static int mboxdriver_append_message(mailsession * session, | |||
341 | return MAIL_ERROR_DISKSPACE; | 345 | return MAIL_ERROR_DISKSPACE; |
342 | default: | 346 | default: |
343 | return mboxdriver_mbox_error_to_mail_error(r); | 347 | return mboxdriver_mbox_error_to_mail_error(r); |
344 | } | 348 | } |
345 | } | 349 | } |
346 | 350 | ||
351 | static int mboxdriver_append_message_flags(mailsession * session, | ||
352 | char * message, size_t size, struct mail_flags * flags) | ||
353 | { | ||
354 | return mboxdriver_append_message(session, message, size); | ||
355 | } | ||
356 | |||
347 | static int mboxdriver_get_messages_list(mailsession * session, | 357 | static int mboxdriver_get_messages_list(mailsession * session, |
348 | struct mailmessage_list ** result) | 358 | struct mailmessage_list ** result) |
349 | { | 359 | { |
350 | struct mailmbox_folder * folder; | 360 | struct mailmbox_folder * folder; |
351 | int res; | 361 | int res; |
352 | 362 | ||
diff --git a/kmicromail/libetpan/generic/mboxdriver_cached.c b/kmicromail/libetpan/generic/mboxdriver_cached.c index 07871fa..3af7fb9 100644 --- a/kmicromail/libetpan/generic/mboxdriver_cached.c +++ b/kmicromail/libetpan/generic/mboxdriver_cached.c | |||
@@ -83,12 +83,15 @@ static int mboxdriver_cached_recent_number(mailsession * session, char * mb, | |||
83 | static int mboxdriver_cached_unseen_number(mailsession * session, char * mb, | 83 | static int mboxdriver_cached_unseen_number(mailsession * session, char * mb, |
84 | uint32_t * result); | 84 | uint32_t * result); |
85 | 85 | ||
86 | static int mboxdriver_cached_append_message(mailsession * session, | 86 | static int mboxdriver_cached_append_message(mailsession * session, |
87 | char * message, size_t size); | 87 | char * message, size_t size); |
88 | 88 | ||
89 | static int mboxdriver_cached_append_message_flags(mailsession * session, | ||
90 | char * message, size_t size, struct mail_flags * flags); | ||
91 | |||
89 | static int | 92 | static int |
90 | mboxdriver_cached_get_messages_list(mailsession * session, | 93 | mboxdriver_cached_get_messages_list(mailsession * session, |
91 | struct mailmessage_list ** result); | 94 | struct mailmessage_list ** result); |
92 | 95 | ||
93 | static int | 96 | static int |
94 | mboxdriver_cached_get_envelopes_list(mailsession * session, | 97 | mboxdriver_cached_get_envelopes_list(mailsession * session, |
@@ -134,12 +137,14 @@ static mailsession_driver local_mbox_cached_session_driver = { | |||
134 | .sess_list_folders = NULL, | 137 | .sess_list_folders = NULL, |
135 | .sess_lsub_folders = NULL, | 138 | .sess_lsub_folders = NULL, |
136 | .sess_subscribe_folder = NULL, | 139 | .sess_subscribe_folder = NULL, |
137 | .sess_unsubscribe_folder = NULL, | 140 | .sess_unsubscribe_folder = NULL, |
138 | 141 | ||
139 | .sess_append_message = mboxdriver_cached_append_message, | 142 | .sess_append_message = mboxdriver_cached_append_message, |
143 | .sess_append_message_flags = mboxdriver_cached_append_message_flags, | ||
144 | |||
140 | .sess_copy_message = NULL, | 145 | .sess_copy_message = NULL, |
141 | .sess_move_message = NULL, | 146 | .sess_move_message = NULL, |
142 | 147 | ||
143 | .sess_get_messages_list = mboxdriver_cached_get_messages_list, | 148 | .sess_get_messages_list = mboxdriver_cached_get_messages_list, |
144 | .sess_get_envelopes_list = mboxdriver_cached_get_envelopes_list, | 149 | .sess_get_envelopes_list = mboxdriver_cached_get_envelopes_list, |
145 | .sess_remove_message = mboxdriver_cached_remove_message, | 150 | .sess_remove_message = mboxdriver_cached_remove_message, |
@@ -903,13 +908,90 @@ static int mboxdriver_cached_unseen_number(mailsession * session, char * mb, | |||
903 | 908 | ||
904 | /* messages operations */ | 909 | /* messages operations */ |
905 | 910 | ||
906 | static int mboxdriver_cached_append_message(mailsession * session, | 911 | static int mboxdriver_cached_append_message(mailsession * session, |
907 | char * message, size_t size) | 912 | char * message, size_t size) |
908 | { | 913 | { |
909 | return mailsession_append_message(get_ancestor(session), message, size); | 914 | return mboxdriver_cached_append_message_flags(session, |
915 | message, size, NULL); | ||
916 | } | ||
917 | |||
918 | static int mboxdriver_cached_append_message_flags(mailsession * session, | ||
919 | char * message, size_t size, struct mail_flags * flags) | ||
920 | { | ||
921 | int r; | ||
922 | struct mailmbox_folder * folder; | ||
923 | struct mbox_cached_session_state_data * data; | ||
924 | unsigned int uid; | ||
925 | struct mailmbox_msg_info * msg_info; | ||
926 | chashdatum key; | ||
927 | chashdatum value; | ||
928 | struct mail_cache_db * cache_db_flags; | ||
929 | char filename_flags[PATH_MAX]; | ||
930 | MMAPString * mmapstr; | ||
931 | char keyname[PATH_MAX]; | ||
932 | |||
933 | folder = get_mbox_session(session); | ||
934 | if (folder == NULL) | ||
935 | return MAIL_ERROR_APPEND; | ||
936 | |||
937 | r = mailmbox_append_message_uid(folder, message, size, &uid); | ||
938 | |||
939 | switch (r) { | ||
940 | case MAILMBOX_ERROR_FILE: | ||
941 | return MAIL_ERROR_DISKSPACE; | ||
942 | case MAILMBOX_NO_ERROR: | ||
943 | break; | ||
944 | default: | ||
945 | return mboxdriver_mbox_error_to_mail_error(r); | ||
946 | } | ||
947 | |||
948 | /* could store in flags store instead */ | ||
949 | |||
950 | if (flags == NULL) | ||
951 | goto exit; | ||
952 | |||
953 | key.data = &uid; | ||
954 | key.len = sizeof(uid); | ||
955 | r = chash_get(folder->mb_hash, &key, &value); | ||
956 | if (r < 0) | ||
957 | goto exit; | ||
958 | |||
959 | msg_info = value.data; | ||
960 | |||
961 | data = get_cached_data(session); | ||
962 | |||
963 | snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s", | ||
964 | data->mbox_flags_directory, MAIL_DIR_SEPARATOR, data->mbox_quoted_mb, | ||
965 | MAIL_DIR_SEPARATOR, FLAGS_NAME); | ||
966 | |||
967 | r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); | ||
968 | if (r < 0) | ||
969 | goto exit; | ||
970 | |||
971 | mmapstr = mmap_string_new(""); | ||
972 | if (mmapstr == NULL) | ||
973 | goto close_db_flags; | ||
974 | |||
975 | snprintf(keyname, PATH_MAX, "%u-%lu", uid, | ||
976 | (unsigned long) msg_info->msg_body_len); | ||
977 | |||
978 | r = mboxdriver_write_cached_flags(cache_db_flags, mmapstr, keyname, flags); | ||
979 | |||
980 | mmap_string_free(mmapstr); | ||
981 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
982 | |||
983 | if (r != MAIL_NO_ERROR) | ||
984 | goto exit; | ||
985 | |||
986 | return MAIL_NO_ERROR; | ||
987 | |||
988 | close_db_flags: | ||
989 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
990 | exit: | ||
991 | return MAIL_NO_ERROR; | ||
910 | } | 992 | } |
911 | 993 | ||
912 | static int | 994 | static int |
913 | mboxdriver_cached_get_messages_list(mailsession * session, | 995 | mboxdriver_cached_get_messages_list(mailsession * session, |
914 | struct mailmessage_list ** result) | 996 | struct mailmessage_list ** result) |
915 | { | 997 | { |
@@ -957,13 +1039,14 @@ get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, | |||
957 | res = MAIL_ERROR_MSG_NOT_FOUND; | 1039 | res = MAIL_ERROR_MSG_NOT_FOUND; |
958 | goto err; | 1040 | goto err; |
959 | } | 1041 | } |
960 | 1042 | ||
961 | info = data.data; | 1043 | info = data.data; |
962 | 1044 | ||
963 | snprintf(keyname, PATH_MAX, "%u-%u-envelope", num, info->msg_body_len); | 1045 | snprintf(keyname, PATH_MAX, "%u-%lu-envelope", num, |
1046 | (unsigned long) info->msg_body_len); | ||
964 | 1047 | ||
965 | r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields); | 1048 | r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields); |
966 | if (r != MAIL_NO_ERROR) { | 1049 | if (r != MAIL_NO_ERROR) { |
967 | res = r; | 1050 | res = r; |
968 | goto err; | 1051 | goto err; |
969 | } | 1052 | } |
@@ -1003,13 +1086,14 @@ write_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, | |||
1003 | res = MAIL_ERROR_MSG_NOT_FOUND; | 1086 | res = MAIL_ERROR_MSG_NOT_FOUND; |
1004 | goto err; | 1087 | goto err; |
1005 | } | 1088 | } |
1006 | 1089 | ||
1007 | info = data.data; | 1090 | info = data.data; |
1008 | 1091 | ||
1009 | snprintf(keyname, PATH_MAX, "%u-%u-envelope", num, info->msg_body_len); | 1092 | snprintf(keyname, PATH_MAX, "%u-%lu-envelope", num, |
1093 | (unsigned long) info->msg_body_len); | ||
1010 | 1094 | ||
1011 | r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields); | 1095 | r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields); |
1012 | if (r != MAIL_NO_ERROR) { | 1096 | if (r != MAIL_NO_ERROR) { |
1013 | res = r; | 1097 | res = r; |
1014 | goto err; | 1098 | goto err; |
1015 | } | 1099 | } |
diff --git a/kmicromail/libetpan/generic/mboxdriver_cached_message.c b/kmicromail/libetpan/generic/mboxdriver_cached_message.c index 6d92b22..828396b 100644 --- a/kmicromail/libetpan/generic/mboxdriver_cached_message.c +++ b/kmicromail/libetpan/generic/mboxdriver_cached_message.c | |||
@@ -179,13 +179,14 @@ static int mbox_initialize(mailmessage * msg_info) | |||
179 | res = MAIL_ERROR_MSG_NOT_FOUND; | 179 | res = MAIL_ERROR_MSG_NOT_FOUND; |
180 | goto err; | 180 | goto err; |
181 | } | 181 | } |
182 | 182 | ||
183 | info = (struct mailmbox_msg_info *) data.data; | 183 | info = (struct mailmbox_msg_info *) data.data; |
184 | 184 | ||
185 | snprintf(static_uid, PATH_MAX, "%u-%u", msg_info->msg_index, info->msg_body_len); | 185 | snprintf(static_uid, PATH_MAX, "%u-%lu", |
186 | msg_info->msg_index, (unsigned long) info->msg_body_len); | ||
186 | uid = strdup(static_uid); | 187 | uid = strdup(static_uid); |
187 | if (uid == NULL) { | 188 | if (uid == NULL) { |
188 | res = MAIL_ERROR_MEMORY; | 189 | res = MAIL_ERROR_MEMORY; |
189 | goto err; | 190 | goto err; |
190 | } | 191 | } |
191 | 192 | ||
diff --git a/kmicromail/libetpan/generic/mboxdriver_message.c b/kmicromail/libetpan/generic/mboxdriver_message.c index da9a65d..6922625 100644 --- a/kmicromail/libetpan/generic/mboxdriver_message.c +++ b/kmicromail/libetpan/generic/mboxdriver_message.c | |||
@@ -30,13 +30,13 @@ | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "mhdriver_message.h" | 36 | #include "mboxdriver_message.h" |
37 | 37 | ||
38 | #include "mailmessage_tools.h" | 38 | #include "mailmessage_tools.h" |
39 | #include "mboxdriver_tools.h" | 39 | #include "mboxdriver_tools.h" |
40 | #include "mboxdriver.h" | 40 | #include "mboxdriver.h" |
41 | #include "mailmbox.h" | 41 | #include "mailmbox.h" |
42 | 42 | ||
@@ -153,14 +153,14 @@ static int mbox_initialize(mailmessage * msg_info) | |||
153 | res = MAIL_ERROR_MSG_NOT_FOUND; | 153 | res = MAIL_ERROR_MSG_NOT_FOUND; |
154 | goto err; | 154 | goto err; |
155 | } | 155 | } |
156 | 156 | ||
157 | info = data.data; | 157 | info = data.data; |
158 | 158 | ||
159 | snprintf(static_uid, PATH_MAX, "%u-%u", | 159 | snprintf(static_uid, PATH_MAX, "%u-%lu", |
160 | msg_info->msg_index, info->msg_body_len); | 160 | msg_info->msg_index, (unsigned long) info->msg_body_len); |
161 | uid = strdup(static_uid); | 161 | uid = strdup(static_uid); |
162 | if (uid == NULL) { | 162 | if (uid == NULL) { |
163 | res = MAIL_ERROR_MEMORY; | 163 | res = MAIL_ERROR_MEMORY; |
164 | goto err; | 164 | goto err; |
165 | } | 165 | } |
166 | 166 | ||
diff --git a/kmicromail/libetpan/generic/mboxdriver_tools.c b/kmicromail/libetpan/generic/mboxdriver_tools.c index 1e27798..252a20b 100644 --- a/kmicromail/libetpan/generic/mboxdriver_tools.c +++ b/kmicromail/libetpan/generic/mboxdriver_tools.c | |||
@@ -214,13 +214,14 @@ mboxdriver_get_cached_flags(struct mail_cache_db * cache_db, | |||
214 | res = MAIL_ERROR_MSG_NOT_FOUND; | 214 | res = MAIL_ERROR_MSG_NOT_FOUND; |
215 | goto err; | 215 | goto err; |
216 | } | 216 | } |
217 | 217 | ||
218 | info = data.data; | 218 | info = data.data; |
219 | 219 | ||
220 | snprintf(keyname, PATH_MAX, "%u-%u-flags", num, info->msg_body_len); | 220 | snprintf(keyname, PATH_MAX, "%u-%lu-flags", num, |
221 | (unsigned long) info->msg_body_len); | ||
221 | 222 | ||
222 | r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags); | 223 | r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags); |
223 | if (r != MAIL_NO_ERROR) { | 224 | if (r != MAIL_NO_ERROR) { |
224 | res = r; | 225 | res = r; |
225 | goto err; | 226 | goto err; |
226 | } | 227 | } |
diff --git a/kmicromail/libetpan/generic/mboxstorage.c b/kmicromail/libetpan/generic/mboxstorage.c index 0a7dc93..4b55b2b 100644 --- a/kmicromail/libetpan/generic/mboxstorage.c +++ b/kmicromail/libetpan/generic/mboxstorage.c | |||
@@ -62,13 +62,13 @@ static mailstorage_driver mbox_mailstorage_driver = { | |||
62 | int mbox_mailstorage_init(struct mailstorage * storage, | 62 | int mbox_mailstorage_init(struct mailstorage * storage, |
63 | char * mbox_pathname, int mbox_cached, | 63 | char * mbox_pathname, int mbox_cached, |
64 | char * mbox_cache_directory, char * mbox_flags_directory) | 64 | char * mbox_cache_directory, char * mbox_flags_directory) |
65 | { | 65 | { |
66 | struct mbox_mailstorage * mbox_storage; | 66 | struct mbox_mailstorage * mbox_storage; |
67 | 67 | ||
68 | mbox_storage = malloc(sizeof(struct mbox_mailstorage)); | 68 | mbox_storage = malloc(sizeof(* mbox_storage)); |
69 | if (mbox_storage == NULL) | 69 | if (mbox_storage == NULL) |
70 | goto err; | 70 | goto err; |
71 | 71 | ||
72 | mbox_storage->mbox_pathname = strdup(mbox_pathname); | 72 | mbox_storage->mbox_pathname = strdup(mbox_pathname); |
73 | if (mbox_storage->mbox_pathname == NULL) | 73 | if (mbox_storage->mbox_pathname == NULL) |
74 | goto free; | 74 | goto free; |
diff --git a/kmicromail/libetpan/generic/mhdriver.c b/kmicromail/libetpan/generic/mhdriver.c index af38d27..05a6a4f 100644 --- a/kmicromail/libetpan/generic/mhdriver.c +++ b/kmicromail/libetpan/generic/mhdriver.c | |||
@@ -86,12 +86,14 @@ static int mhdriver_lsub_folders(mailsession * session, char * mb, | |||
86 | static int mhdriver_subscribe_folder(mailsession * session, char * mb); | 86 | static int mhdriver_subscribe_folder(mailsession * session, char * mb); |
87 | 87 | ||
88 | static int mhdriver_unsubscribe_folder(mailsession * session, char * mb); | 88 | static int mhdriver_unsubscribe_folder(mailsession * session, char * mb); |
89 | 89 | ||
90 | static int mhdriver_append_message(mailsession * session, | 90 | static int mhdriver_append_message(mailsession * session, |
91 | char * message, size_t size); | 91 | char * message, size_t size); |
92 | static int mhdriver_append_message_flags(mailsession * session, | ||
93 | char * message, size_t size, struct mail_flags * flags); | ||
92 | static int mhdriver_copy_message(mailsession * session, | 94 | static int mhdriver_copy_message(mailsession * session, |
93 | uint32_t num, char * mb); | 95 | uint32_t num, char * mb); |
94 | 96 | ||
95 | static int mhdriver_remove_message(mailsession * session, uint32_t num); | 97 | static int mhdriver_remove_message(mailsession * session, uint32_t num); |
96 | 98 | ||
97 | static int mhdriver_move_message(mailsession * session, | 99 | static int mhdriver_move_message(mailsession * session, |
@@ -136,13 +138,14 @@ static mailsession_driver local_mh_session_driver = { | |||
136 | .sess_unseen_number = mhdriver_messages_number, | 138 | .sess_unseen_number = mhdriver_messages_number, |
137 | .sess_list_folders = mhdriver_list_folders, | 139 | .sess_list_folders = mhdriver_list_folders, |
138 | .sess_lsub_folders = mhdriver_lsub_folders, | 140 | .sess_lsub_folders = mhdriver_lsub_folders, |
139 | .sess_subscribe_folder = mhdriver_subscribe_folder, | 141 | .sess_subscribe_folder = mhdriver_subscribe_folder, |
140 | .sess_unsubscribe_folder = mhdriver_unsubscribe_folder, | 142 | .sess_unsubscribe_folder = mhdriver_unsubscribe_folder, |
141 | 143 | ||
142 | .sess_append_message = mhdriver_append_message, | 144 | .sess_append_message = mhdriver_append_message, |
145 | .sess_append_message_flags = mhdriver_append_message_flags, | ||
143 | .sess_copy_message = mhdriver_copy_message, | 146 | .sess_copy_message = mhdriver_copy_message, |
144 | .sess_move_message = mhdriver_move_message, | 147 | .sess_move_message = mhdriver_move_message, |
145 | 148 | ||
146 | .sess_get_messages_list = mhdriver_get_messages_list, | 149 | .sess_get_messages_list = mhdriver_get_messages_list, |
147 | .sess_get_envelopes_list = maildriver_generic_get_envelopes_list, | 150 | .sess_get_envelopes_list = maildriver_generic_get_envelopes_list, |
148 | .sess_remove_message = mhdriver_remove_message, | 151 | .sess_remove_message = mhdriver_remove_message, |
@@ -681,12 +684,18 @@ static int mhdriver_append_message(mailsession * session, | |||
681 | 684 | ||
682 | default: | 685 | default: |
683 | return mhdriver_mh_error_to_mail_error(r); | 686 | return mhdriver_mh_error_to_mail_error(r); |
684 | } | 687 | } |
685 | } | 688 | } |
686 | 689 | ||
690 | static int mhdriver_append_message_flags(mailsession * session, | ||
691 | char * message, size_t size, struct mail_flags * flags) | ||
692 | { | ||
693 | return mhdriver_append_message(session, message, size); | ||
694 | } | ||
695 | |||
687 | static int mhdriver_copy_message(mailsession * session, | 696 | static int mhdriver_copy_message(mailsession * session, |
688 | uint32_t num, char * mb) | 697 | uint32_t num, char * mb) |
689 | { | 698 | { |
690 | int fd; | 699 | int fd; |
691 | int r; | 700 | int r; |
692 | struct mailmh_folder * folder; | 701 | struct mailmh_folder * folder; |
diff --git a/kmicromail/libetpan/generic/mhdriver_cached.c b/kmicromail/libetpan/generic/mhdriver_cached.c index 5c35089..04aa523 100644 --- a/kmicromail/libetpan/generic/mhdriver_cached.c +++ b/kmicromail/libetpan/generic/mhdriver_cached.c | |||
@@ -105,12 +105,14 @@ static int mhdriver_cached_subscribe_folder(mailsession * session, char * mb); | |||
105 | 105 | ||
106 | static int mhdriver_cached_unsubscribe_folder(mailsession * session, | 106 | static int mhdriver_cached_unsubscribe_folder(mailsession * session, |
107 | char * mb); | 107 | char * mb); |
108 | 108 | ||
109 | static int mhdriver_cached_append_message(mailsession * session, | 109 | static int mhdriver_cached_append_message(mailsession * session, |
110 | char * message, size_t size); | 110 | char * message, size_t size); |
111 | static int mhdriver_cached_append_message_flags(mailsession * session, | ||
112 | char * message, size_t size, struct mail_flags * flags); | ||
111 | static int mhdriver_cached_copy_message(mailsession * session, | 113 | static int mhdriver_cached_copy_message(mailsession * session, |
112 | uint32_t num, char * mb); | 114 | uint32_t num, char * mb); |
113 | 115 | ||
114 | static int mhdriver_cached_remove_message(mailsession * session, | 116 | static int mhdriver_cached_remove_message(mailsession * session, |
115 | uint32_t num); | 117 | uint32_t num); |
116 | 118 | ||
@@ -162,12 +164,13 @@ static mailsession_driver local_mh_cached_session_driver = { | |||
162 | .sess_list_folders = mhdriver_cached_list_folders, | 164 | .sess_list_folders = mhdriver_cached_list_folders, |
163 | .sess_lsub_folders = mhdriver_cached_lsub_folders, | 165 | .sess_lsub_folders = mhdriver_cached_lsub_folders, |
164 | .sess_subscribe_folder = mhdriver_cached_subscribe_folder, | 166 | .sess_subscribe_folder = mhdriver_cached_subscribe_folder, |
165 | .sess_unsubscribe_folder = mhdriver_cached_unsubscribe_folder, | 167 | .sess_unsubscribe_folder = mhdriver_cached_unsubscribe_folder, |
166 | 168 | ||
167 | .sess_append_message = mhdriver_cached_append_message, | 169 | .sess_append_message = mhdriver_cached_append_message, |
170 | .sess_append_message_flags = mhdriver_cached_append_message_flags, | ||
168 | .sess_copy_message = mhdriver_cached_copy_message, | 171 | .sess_copy_message = mhdriver_cached_copy_message, |
169 | .sess_move_message = mhdriver_cached_move_message, | 172 | .sess_move_message = mhdriver_cached_move_message, |
170 | 173 | ||
171 | .sess_get_messages_list = mhdriver_cached_get_messages_list, | 174 | .sess_get_messages_list = mhdriver_cached_get_messages_list, |
172 | .sess_get_envelopes_list = mhdriver_cached_get_envelopes_list, | 175 | .sess_get_envelopes_list = mhdriver_cached_get_envelopes_list, |
173 | .sess_remove_message = mhdriver_cached_remove_message, | 176 | .sess_remove_message = mhdriver_cached_remove_message, |
@@ -880,13 +883,91 @@ static int mhdriver_cached_unsubscribe_folder(mailsession * session, | |||
880 | 883 | ||
881 | /* messages operations */ | 884 | /* messages operations */ |
882 | 885 | ||
883 | static int mhdriver_cached_append_message(mailsession * session, | 886 | static int mhdriver_cached_append_message(mailsession * session, |
884 | char * message, size_t size) | 887 | char * message, size_t size) |
885 | { | 888 | { |
886 | return mailsession_append_message(get_ancestor(session), message, size); | 889 | return mhdriver_cached_append_message_flags(session, |
890 | message, size, NULL); | ||
891 | } | ||
892 | |||
893 | static int mhdriver_cached_append_message_flags(mailsession * session, | ||
894 | char * message, size_t size, struct mail_flags * flags) | ||
895 | { | ||
896 | int r; | ||
897 | struct mailmh_folder * folder; | ||
898 | struct mailmh_msg_info * msg_info; | ||
899 | chashdatum key; | ||
900 | chashdatum value; | ||
901 | uint32_t uid; | ||
902 | struct mh_cached_session_state_data * data; | ||
903 | char filename_flags[PATH_MAX]; | ||
904 | struct mail_cache_db * cache_db_flags; | ||
905 | MMAPString * mmapstr; | ||
906 | char keyname[PATH_MAX]; | ||
907 | |||
908 | folder = get_mh_cur_folder(session); | ||
909 | if (folder == NULL) | ||
910 | return MAIL_ERROR_BAD_STATE; | ||
911 | |||
912 | r = mailmh_folder_add_message_uid(folder, | ||
913 | message, size, &uid); | ||
914 | |||
915 | switch (r) { | ||
916 | case MAILMH_ERROR_FILE: | ||
917 | return MAIL_ERROR_DISKSPACE; | ||
918 | |||
919 | case MAILMH_NO_ERROR: | ||
920 | break; | ||
921 | |||
922 | default: | ||
923 | return mhdriver_mh_error_to_mail_error(r); | ||
924 | } | ||
925 | |||
926 | if (flags == NULL) | ||
927 | goto exit; | ||
928 | |||
929 | key.data = &uid; | ||
930 | key.len = sizeof(uid); | ||
931 | r = chash_get(folder->fl_msgs_hash, &key, &value); | ||
932 | if (r < 0) | ||
933 | return MAIL_ERROR_CACHE_MISS; | ||
934 | |||
935 | msg_info = value.data; | ||
936 | |||
937 | data = get_cached_data(session); | ||
938 | |||
939 | snprintf(filename_flags, PATH_MAX, "%s/%s/%s", | ||
940 | data->mh_flags_directory, data->mh_quoted_mb, FLAGS_NAME); | ||
941 | |||
942 | r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); | ||
943 | if (r < 0) | ||
944 | goto exit; | ||
945 | |||
946 | mmapstr = mmap_string_new(""); | ||
947 | if (mmapstr == NULL) | ||
948 | goto close_db_flags; | ||
949 | |||
950 | snprintf(keyname, PATH_MAX, "%u-%lu-%lu-flags", | ||
951 | uid, (unsigned long) msg_info->msg_mtime, | ||
952 | (unsigned long) msg_info->msg_size); | ||
953 | |||
954 | r = mhdriver_write_cached_flags(cache_db_flags, mmapstr, keyname, flags); | ||
955 | |||
956 | mmap_string_free(mmapstr); | ||
957 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
958 | |||
959 | if (r != MAIL_NO_ERROR) | ||
960 | goto exit; | ||
961 | |||
962 | return MAIL_NO_ERROR; | ||
963 | |||
964 | close_db_flags: | ||
965 | mail_cache_db_close_unlock(filename_flags, cache_db_flags); | ||
966 | exit: | ||
967 | return MAIL_NO_ERROR; | ||
887 | } | 968 | } |
888 | 969 | ||
889 | static int mhdriver_cached_copy_message(mailsession * session, | 970 | static int mhdriver_cached_copy_message(mailsession * session, |
890 | uint32_t num, char * mb) | 971 | uint32_t num, char * mb) |
891 | { | 972 | { |
892 | return mailsession_copy_message(get_ancestor(session), num, mb); | 973 | return mailsession_copy_message(get_ancestor(session), num, mb); |
@@ -950,14 +1031,15 @@ get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, | |||
950 | key.len = sizeof(num); | 1031 | key.len = sizeof(num); |
951 | r = chash_get(folder->fl_msgs_hash, &key, &data); | 1032 | r = chash_get(folder->fl_msgs_hash, &key, &data); |
952 | if (r < 0) | 1033 | if (r < 0) |
953 | return MAIL_ERROR_CACHE_MISS; | 1034 | return MAIL_ERROR_CACHE_MISS; |
954 | msg_info = data.data; | 1035 | msg_info = data.data; |
955 | 1036 | ||
956 | snprintf(keyname, PATH_MAX, "%u-%u-%u-envelope", | 1037 | snprintf(keyname, PATH_MAX, "%u-%lu-%lu-envelope", |
957 | num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size); | 1038 | num, (unsigned long) msg_info->msg_mtime, |
1039 | (unsigned long) msg_info->msg_size); | ||
958 | 1040 | ||
959 | r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields); | 1041 | r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields); |
960 | if (r != MAIL_NO_ERROR) { | 1042 | if (r != MAIL_NO_ERROR) { |
961 | res = r; | 1043 | res = r; |
962 | goto err; | 1044 | goto err; |
963 | } | 1045 | } |
@@ -995,14 +1077,15 @@ write_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, | |||
995 | key.len = sizeof(num); | 1077 | key.len = sizeof(num); |
996 | r = chash_get(folder->fl_msgs_hash, &key, &data); | 1078 | r = chash_get(folder->fl_msgs_hash, &key, &data); |
997 | if (r < 0) | 1079 | if (r < 0) |
998 | return MAIL_ERROR_CACHE_MISS; | 1080 | return MAIL_ERROR_CACHE_MISS; |
999 | msg_info = data.data; | 1081 | msg_info = data.data; |
1000 | 1082 | ||
1001 | snprintf(keyname, PATH_MAX, "%u-%u-%u-envelope", | 1083 | snprintf(keyname, PATH_MAX, "%u-%lu-%lu-envelope", |
1002 | num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size); | 1084 | num, (unsigned long) msg_info->msg_mtime, |
1085 | (unsigned long) msg_info->msg_size); | ||
1003 | 1086 | ||
1004 | r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields); | 1087 | r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields); |
1005 | if (r != MAIL_NO_ERROR) { | 1088 | if (r != MAIL_NO_ERROR) { |
1006 | res = r; | 1089 | res = r; |
1007 | goto err; | 1090 | goto err; |
1008 | } | 1091 | } |
diff --git a/kmicromail/libetpan/generic/mhdriver_cached_message.c b/kmicromail/libetpan/generic/mhdriver_cached_message.c index f716fb9..f69868d 100644 --- a/kmicromail/libetpan/generic/mhdriver_cached_message.c +++ b/kmicromail/libetpan/generic/mhdriver_cached_message.c | |||
@@ -176,14 +176,14 @@ static int mh_initialize(mailmessage * msg_info) | |||
176 | r = chash_get(folder->fl_msgs_hash, &key, &data); | 176 | r = chash_get(folder->fl_msgs_hash, &key, &data); |
177 | if (r < 0) | 177 | if (r < 0) |
178 | return MAIL_ERROR_INVAL; | 178 | return MAIL_ERROR_INVAL; |
179 | 179 | ||
180 | mh_msg_info = data.data; | 180 | mh_msg_info = data.data; |
181 | 181 | ||
182 | snprintf(static_uid, PATH_MAX, "%u-%lu-%u", msg_info->msg_index, | 182 | snprintf(static_uid, PATH_MAX, "%u-%lu-%lu", msg_info->msg_index, |
183 | mh_msg_info->msg_mtime, mh_msg_info->msg_size); | 183 | mh_msg_info->msg_mtime, (unsigned long) mh_msg_info->msg_size); |
184 | uid = strdup(static_uid); | 184 | uid = strdup(static_uid); |
185 | if (uid == NULL) | 185 | if (uid == NULL) |
186 | return MAIL_ERROR_MEMORY; | 186 | return MAIL_ERROR_MEMORY; |
187 | 187 | ||
188 | r = mailmessage_generic_initialize(msg_info); | 188 | r = mailmessage_generic_initialize(msg_info); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
diff --git a/kmicromail/libetpan/generic/mhdriver_message.c b/kmicromail/libetpan/generic/mhdriver_message.c index 2c023e7..aafd2d9 100644 --- a/kmicromail/libetpan/generic/mhdriver_message.c +++ b/kmicromail/libetpan/generic/mhdriver_message.c | |||
@@ -141,14 +141,15 @@ static int mh_initialize(mailmessage * msg_info) | |||
141 | r = chash_get(get_mh_cur_folder(msg_info)->fl_msgs_hash, &key, &value); | 141 | r = chash_get(get_mh_cur_folder(msg_info)->fl_msgs_hash, &key, &value); |
142 | if (r < 0) | 142 | if (r < 0) |
143 | return MAIL_ERROR_INVAL; | 143 | return MAIL_ERROR_INVAL; |
144 | 144 | ||
145 | mh_msg_info = value.data; | 145 | mh_msg_info = value.data; |
146 | 146 | ||
147 | snprintf(static_uid, PATH_MAX, "%u-%lu-%u", msg_info->msg_index, | 147 | snprintf(static_uid, PATH_MAX, "%u-%lu-%lu", msg_info->msg_index, |
148 | mh_msg_info->msg_mtime, mh_msg_info->msg_size); | 148 | (unsigned long) mh_msg_info->msg_mtime, |
149 | (unsigned long) mh_msg_info->msg_size); | ||
149 | uid = strdup(static_uid); | 150 | uid = strdup(static_uid); |
150 | if (uid == NULL) | 151 | if (uid == NULL) |
151 | return MAIL_ERROR_MEMORY; | 152 | return MAIL_ERROR_MEMORY; |
152 | 153 | ||
153 | r = mailmessage_generic_initialize(msg_info); | 154 | r = mailmessage_generic_initialize(msg_info); |
154 | if (r != MAIL_NO_ERROR) { | 155 | if (r != MAIL_NO_ERROR) { |
diff --git a/kmicromail/libetpan/generic/mhdriver_tools.c b/kmicromail/libetpan/generic/mhdriver_tools.c index cb863fa..c15bb6d 100644 --- a/kmicromail/libetpan/generic/mhdriver_tools.c +++ b/kmicromail/libetpan/generic/mhdriver_tools.c | |||
@@ -366,14 +366,15 @@ mhdriver_get_cached_flags(struct mail_cache_db * cache_db, | |||
366 | key.len = sizeof(num); | 366 | key.len = sizeof(num); |
367 | r = chash_get(folder->fl_msgs_hash, &key, &data); | 367 | r = chash_get(folder->fl_msgs_hash, &key, &data); |
368 | if (r < 0) | 368 | if (r < 0) |
369 | return MAIL_ERROR_CACHE_MISS; | 369 | return MAIL_ERROR_CACHE_MISS; |
370 | msg_info = data.data; | 370 | msg_info = data.data; |
371 | 371 | ||
372 | snprintf(keyname, PATH_MAX, "%u-%u-%u-flags", | 372 | snprintf(keyname, PATH_MAX, "%u-%lu-%lu-flags", |
373 | num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size); | 373 | num, (unsigned long) msg_info->msg_mtime, |
374 | (unsigned long) msg_info->msg_size); | ||
374 | 375 | ||
375 | r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags); | 376 | r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags); |
376 | if (r != MAIL_NO_ERROR) { | 377 | if (r != MAIL_NO_ERROR) { |
377 | res = r; | 378 | res = r; |
378 | goto err; | 379 | goto err; |
379 | } | 380 | } |
diff --git a/kmicromail/libetpan/generic/mhstorage.c b/kmicromail/libetpan/generic/mhstorage.c index 32fc26b..715b961 100644 --- a/kmicromail/libetpan/generic/mhstorage.c +++ b/kmicromail/libetpan/generic/mhstorage.c | |||
@@ -59,13 +59,13 @@ static mailstorage_driver mh_mailstorage_driver = { | |||
59 | int mh_mailstorage_init(struct mailstorage * storage, | 59 | int mh_mailstorage_init(struct mailstorage * storage, |
60 | char * mh_pathname, int mh_cached, | 60 | char * mh_pathname, int mh_cached, |
61 | char * mh_cache_directory, char * mh_flags_directory) | 61 | char * mh_cache_directory, char * mh_flags_directory) |
62 | { | 62 | { |
63 | struct mh_mailstorage * mh_storage; | 63 | struct mh_mailstorage * mh_storage; |
64 | 64 | ||
65 | mh_storage = malloc(sizeof(struct mh_mailstorage)); | 65 | mh_storage = malloc(sizeof(* mh_storage)); |
66 | if (mh_storage == NULL) | 66 | if (mh_storage == NULL) |
67 | goto err; | 67 | goto err; |
68 | 68 | ||
69 | mh_storage->mh_pathname = strdup(mh_pathname); | 69 | mh_storage->mh_pathname = strdup(mh_pathname); |
70 | if (mh_storage->mh_pathname == NULL) | 70 | if (mh_storage->mh_pathname == NULL) |
71 | goto free; | 71 | goto free; |
diff --git a/kmicromail/libetpan/generic/nntpdriver.c b/kmicromail/libetpan/generic/nntpdriver.c index fde5f1a..1b65838 100644 --- a/kmicromail/libetpan/generic/nntpdriver.c +++ b/kmicromail/libetpan/generic/nntpdriver.c | |||
@@ -66,12 +66,15 @@ static int nntpdriver_status_folder(mailsession * session, char * mb, | |||
66 | static int nntpdriver_messages_number(mailsession * session, char * mb, | 66 | static int nntpdriver_messages_number(mailsession * session, char * mb, |
67 | uint32_t * result); | 67 | uint32_t * result); |
68 | 68 | ||
69 | static int nntpdriver_append_message(mailsession * session, | 69 | static int nntpdriver_append_message(mailsession * session, |
70 | char * message, size_t size); | 70 | char * message, size_t size); |
71 | 71 | ||
72 | static int nntpdriver_append_message_flags(mailsession * session, | ||
73 | char * message, size_t size, struct mail_flags * flags); | ||
74 | |||
72 | static int | 75 | static int |
73 | nntpdriver_get_envelopes_list(mailsession * session, | 76 | nntpdriver_get_envelopes_list(mailsession * session, |
74 | struct mailmessage_list * env_list); | 77 | struct mailmessage_list * env_list); |
75 | 78 | ||
76 | 79 | ||
77 | static int nntpdriver_get_messages_list(mailsession * session, | 80 | static int nntpdriver_get_messages_list(mailsession * session, |
@@ -126,12 +129,13 @@ static mailsession_driver local_nntp_session_driver = { | |||
126 | .sess_list_folders = nntpdriver_list_folders, | 129 | .sess_list_folders = nntpdriver_list_folders, |
127 | .sess_lsub_folders = nntpdriver_lsub_folders, | 130 | .sess_lsub_folders = nntpdriver_lsub_folders, |
128 | .sess_subscribe_folder = nntpdriver_subscribe_folder, | 131 | .sess_subscribe_folder = nntpdriver_subscribe_folder, |
129 | .sess_unsubscribe_folder = nntpdriver_unsubscribe_folder, | 132 | .sess_unsubscribe_folder = nntpdriver_unsubscribe_folder, |
130 | 133 | ||
131 | .sess_append_message = nntpdriver_append_message, | 134 | .sess_append_message = nntpdriver_append_message, |
135 | .sess_append_message_flags = nntpdriver_append_message_flags, | ||
132 | .sess_copy_message = NULL, | 136 | .sess_copy_message = NULL, |
133 | .sess_move_message = NULL, | 137 | .sess_move_message = NULL, |
134 | 138 | ||
135 | .sess_get_messages_list = nntpdriver_get_messages_list, | 139 | .sess_get_messages_list = nntpdriver_get_messages_list, |
136 | .sess_get_envelopes_list = nntpdriver_get_envelopes_list, | 140 | .sess_get_envelopes_list = nntpdriver_get_envelopes_list, |
137 | .sess_remove_message = NULL, | 141 | .sess_remove_message = NULL, |
@@ -627,12 +631,18 @@ static int nntpdriver_append_message(mailsession * session, | |||
627 | return nntpdriver_nntp_error_to_mail_error(r); | 631 | return nntpdriver_nntp_error_to_mail_error(r); |
628 | } | 632 | } |
629 | } | 633 | } |
630 | while (1); | 634 | while (1); |
631 | } | 635 | } |
632 | 636 | ||
637 | static int nntpdriver_append_message_flags(mailsession * session, | ||
638 | char * message, size_t size, struct mail_flags * flags) | ||
639 | { | ||
640 | return nntpdriver_append_message(session, message, size); | ||
641 | } | ||
642 | |||
633 | 643 | ||
634 | static int xover_resp_to_fields(struct newsnntp_xover_resp_item * item, | 644 | static int xover_resp_to_fields(struct newsnntp_xover_resp_item * item, |
635 | struct mailimf_fields ** result); | 645 | struct mailimf_fields ** result); |
636 | 646 | ||
637 | 647 | ||
638 | static int | 648 | static int |
diff --git a/kmicromail/libetpan/generic/nntpdriver_cached.c b/kmicromail/libetpan/generic/nntpdriver_cached.c index 1f8a8af..0343a65 100644 --- a/kmicromail/libetpan/generic/nntpdriver_cached.c +++ b/kmicromail/libetpan/generic/nntpdriver_cached.c | |||
@@ -93,12 +93,15 @@ static int nntpdriver_cached_recent_number(mailsession * session, char * mb, | |||
93 | static int nntpdriver_cached_unseen_number(mailsession * session, char * mb, | 93 | static int nntpdriver_cached_unseen_number(mailsession * session, char * mb, |
94 | uint32_t * result); | 94 | uint32_t * result); |
95 | 95 | ||
96 | static int nntpdriver_cached_append_message(mailsession * session, | 96 | static int nntpdriver_cached_append_message(mailsession * session, |
97 | char * message, size_t size); | 97 | char * message, size_t size); |
98 | 98 | ||
99 | static int nntpdriver_cached_append_message_flags(mailsession * session, | ||
100 | char * message, size_t size, struct mail_flags * flags); | ||
101 | |||
99 | static int | 102 | static int |
100 | nntpdriver_cached_get_envelopes_list(mailsession * session, | 103 | nntpdriver_cached_get_envelopes_list(mailsession * session, |
101 | struct mailmessage_list * env_list); | 104 | struct mailmessage_list * env_list); |
102 | 105 | ||
103 | 106 | ||
104 | static int | 107 | static int |
@@ -156,12 +159,13 @@ static mailsession_driver local_nntp_cached_session_driver = { | |||
156 | .sess_list_folders = nntpdriver_cached_list_folders, | 159 | .sess_list_folders = nntpdriver_cached_list_folders, |
157 | .sess_lsub_folders = nntpdriver_cached_lsub_folders, | 160 | .sess_lsub_folders = nntpdriver_cached_lsub_folders, |
158 | .sess_subscribe_folder = nntpdriver_cached_subscribe_folder, | 161 | .sess_subscribe_folder = nntpdriver_cached_subscribe_folder, |
159 | .sess_unsubscribe_folder = nntpdriver_cached_unsubscribe_folder, | 162 | .sess_unsubscribe_folder = nntpdriver_cached_unsubscribe_folder, |
160 | 163 | ||
161 | .sess_append_message = nntpdriver_cached_append_message, | 164 | .sess_append_message = nntpdriver_cached_append_message, |
165 | .sess_append_message_flags = nntpdriver_cached_append_message_flags, | ||
162 | .sess_copy_message = NULL, | 166 | .sess_copy_message = NULL, |
163 | .sess_move_message = NULL, | 167 | .sess_move_message = NULL, |
164 | 168 | ||
165 | .sess_get_messages_list = nntpdriver_cached_get_messages_list, | 169 | .sess_get_messages_list = nntpdriver_cached_get_messages_list, |
166 | .sess_get_envelopes_list = nntpdriver_cached_get_envelopes_list, | 170 | .sess_get_envelopes_list = nntpdriver_cached_get_envelopes_list, |
167 | .sess_remove_message = NULL, | 171 | .sess_remove_message = NULL, |
@@ -628,12 +632,18 @@ static int nntpdriver_cached_unsubscribe_folder(mailsession * session, | |||
628 | static int nntpdriver_cached_append_message(mailsession * session, | 632 | static int nntpdriver_cached_append_message(mailsession * session, |
629 | char * message, size_t size) | 633 | char * message, size_t size) |
630 | { | 634 | { |
631 | return mailsession_append_message(get_ancestor(session), message, size); | 635 | return mailsession_append_message(get_ancestor(session), message, size); |
632 | } | 636 | } |
633 | 637 | ||
638 | static int nntpdriver_cached_append_message_flags(mailsession * session, | ||
639 | char * message, size_t size, struct mail_flags * flags) | ||
640 | { | ||
641 | return nntpdriver_cached_append_message(session, message, size); | ||
642 | } | ||
643 | |||
634 | 644 | ||
635 | 645 | ||
636 | static int | 646 | static int |
637 | get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, | 647 | get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr, |
638 | mailsession * session, uint32_t num, | 648 | mailsession * session, uint32_t num, |
639 | struct mailimf_fields ** result) | 649 | struct mailimf_fields ** result) |
diff --git a/kmicromail/libetpan/generic/nntpstorage.c b/kmicromail/libetpan/generic/nntpstorage.c index 5ba333b..89974cd 100644 --- a/kmicromail/libetpan/generic/nntpstorage.c +++ b/kmicromail/libetpan/generic/nntpstorage.c | |||
@@ -68,13 +68,13 @@ int nntp_mailstorage_init(struct mailstorage * storage, | |||
68 | char * nn_login, char * nn_password, | 68 | char * nn_login, char * nn_password, |
69 | int nn_cached, char * nn_cache_directory, char * nn_flags_directory) | 69 | int nn_cached, char * nn_cache_directory, char * nn_flags_directory) |
70 | { | 70 | { |
71 | struct nntp_mailstorage * nntp_storage; | 71 | struct nntp_mailstorage * nntp_storage; |
72 | int res; | 72 | int res; |
73 | 73 | ||
74 | nntp_storage = malloc(sizeof(struct nntp_mailstorage)); | 74 | nntp_storage = malloc(sizeof(* nntp_storage)); |
75 | if (nntp_storage == NULL) { | 75 | if (nntp_storage == NULL) { |
76 | res = MAIL_ERROR_MEMORY; | 76 | res = MAIL_ERROR_MEMORY; |
77 | goto err; | 77 | goto err; |
78 | } | 78 | } |
79 | 79 | ||
80 | nntp_storage->nntp_servername = strdup(nn_servername); | 80 | nntp_storage->nntp_servername = strdup(nn_servername); |
diff --git a/kmicromail/libetpan/generic/pop3driver.c b/kmicromail/libetpan/generic/pop3driver.c index 20b0fc2..375879e 100644 --- a/kmicromail/libetpan/generic/pop3driver.c +++ b/kmicromail/libetpan/generic/pop3driver.c | |||
@@ -106,12 +106,13 @@ static mailsession_driver local_pop3_session_driver = { | |||
106 | .sess_list_folders = NULL, | 106 | .sess_list_folders = NULL, |
107 | .sess_lsub_folders = NULL, | 107 | .sess_lsub_folders = NULL, |
108 | .sess_subscribe_folder = NULL, | 108 | .sess_subscribe_folder = NULL, |
109 | .sess_unsubscribe_folder = NULL, | 109 | .sess_unsubscribe_folder = NULL, |
110 | 110 | ||
111 | .sess_append_message = NULL, | 111 | .sess_append_message = NULL, |
112 | .sess_append_message_flags = NULL, | ||
112 | .sess_copy_message = NULL, | 113 | .sess_copy_message = NULL, |
113 | .sess_move_message = NULL, | 114 | .sess_move_message = NULL, |
114 | 115 | ||
115 | .sess_get_messages_list = pop3driver_get_messages_list, | 116 | .sess_get_messages_list = pop3driver_get_messages_list, |
116 | .sess_get_envelopes_list = maildriver_generic_get_envelopes_list, | 117 | .sess_get_envelopes_list = maildriver_generic_get_envelopes_list, |
117 | .sess_remove_message = pop3driver_remove_message, | 118 | .sess_remove_message = pop3driver_remove_message, |
diff --git a/kmicromail/libetpan/generic/pop3driver_cached.c b/kmicromail/libetpan/generic/pop3driver_cached.c index 6f97303..24f624b 100644 --- a/kmicromail/libetpan/generic/pop3driver_cached.c +++ b/kmicromail/libetpan/generic/pop3driver_cached.c | |||
@@ -107,12 +107,15 @@ static int | |||
107 | pop3driver_cached_get_envelopes_list(mailsession * session, | 107 | pop3driver_cached_get_envelopes_list(mailsession * session, |
108 | struct mailmessage_list * env_list); | 108 | struct mailmessage_list * env_list); |
109 | 109 | ||
110 | static int pop3driver_cached_get_message(mailsession * session, | 110 | static int pop3driver_cached_get_message(mailsession * session, |
111 | uint32_t num, mailmessage ** result); | 111 | uint32_t num, mailmessage ** result); |
112 | 112 | ||
113 | static int pop3driver_cached_get_message_by_uid(mailsession * session, | ||
114 | const char * uid, mailmessage ** result); | ||
115 | |||
113 | static mailsession_driver local_pop3_cached_session_driver = { | 116 | static mailsession_driver local_pop3_cached_session_driver = { |
114 | .sess_name = "pop3-cached", | 117 | .sess_name = "pop3-cached", |
115 | 118 | ||
116 | .sess_initialize = pop3driver_cached_initialize, | 119 | .sess_initialize = pop3driver_cached_initialize, |
117 | .sess_uninitialize = pop3driver_cached_uninitialize, | 120 | .sess_uninitialize = pop3driver_cached_uninitialize, |
118 | 121 | ||
@@ -140,24 +143,25 @@ static mailsession_driver local_pop3_cached_session_driver = { | |||
140 | .sess_list_folders = NULL, | 143 | .sess_list_folders = NULL, |
141 | .sess_lsub_folders = NULL, | 144 | .sess_lsub_folders = NULL, |
142 | .sess_subscribe_folder = NULL, | 145 | .sess_subscribe_folder = NULL, |
143 | .sess_unsubscribe_folder = NULL, | 146 | .sess_unsubscribe_folder = NULL, |
144 | 147 | ||
145 | .sess_append_message = NULL, | 148 | .sess_append_message = NULL, |
149 | .sess_append_message_flags = NULL, | ||
146 | .sess_copy_message = NULL, | 150 | .sess_copy_message = NULL, |
147 | .sess_move_message = NULL, | 151 | .sess_move_message = NULL, |
148 | 152 | ||
149 | .sess_get_messages_list = pop3driver_cached_get_messages_list, | 153 | .sess_get_messages_list = pop3driver_cached_get_messages_list, |
150 | .sess_get_envelopes_list = pop3driver_cached_get_envelopes_list, | 154 | .sess_get_envelopes_list = pop3driver_cached_get_envelopes_list, |
151 | .sess_remove_message = pop3driver_cached_remove_message, | 155 | .sess_remove_message = pop3driver_cached_remove_message, |
152 | #if 0 | 156 | #if 0 |
153 | .sess_search_messages = maildriver_generic_search_messages, | 157 | .sess_search_messages = maildriver_generic_search_messages, |
154 | #endif | 158 | #endif |
155 | 159 | ||
156 | .sess_get_message = pop3driver_cached_get_message, | 160 | .sess_get_message = pop3driver_cached_get_message, |
157 | .sess_get_message_by_uid = NULL, | 161 | .sess_get_message_by_uid = pop3driver_cached_get_message_by_uid, |
158 | }; | 162 | }; |
159 | 163 | ||
160 | mailsession_driver * pop3_cached_session_driver = | 164 | mailsession_driver * pop3_cached_session_driver = |
161 | &local_pop3_cached_session_driver; | 165 | &local_pop3_cached_session_driver; |
162 | 166 | ||
163 | #define ENV_NAME "env.db" | 167 | #define ENV_NAME "env.db" |
@@ -852,6 +856,44 @@ static int pop3driver_cached_get_message(mailsession * session, | |||
852 | } | 856 | } |
853 | 857 | ||
854 | * result = msg_info; | 858 | * result = msg_info; |
855 | 859 | ||
856 | return MAIL_NO_ERROR; | 860 | return MAIL_NO_ERROR; |
857 | } | 861 | } |
862 | |||
863 | static int pop3driver_cached_get_message_by_uid(mailsession * session, | ||
864 | const char * uid, mailmessage ** result) | ||
865 | { | ||
866 | mailpop3 * pop3; | ||
867 | struct mailpop3_msg_info * msg_info; | ||
868 | int found; | ||
869 | unsigned int i; | ||
870 | |||
871 | if (uid == NULL) | ||
872 | return MAIL_ERROR_INVAL; | ||
873 | |||
874 | pop3 = get_pop3_session(session); | ||
875 | |||
876 | found = 0; | ||
877 | |||
878 | /* iterate all messages and look for uid */ | ||
879 | for(i = 0 ; i < carray_count(pop3->pop3_msg_tab) ; i++) { | ||
880 | msg_info = carray_get(pop3->pop3_msg_tab, i); | ||
881 | |||
882 | if (msg_info == NULL) | ||
883 | continue; | ||
884 | |||
885 | if (msg_info->msg_deleted) | ||
886 | continue; | ||
887 | |||
888 | /* uid found, stop looking */ | ||
889 | if (strcmp(msg_info->msg_uidl, uid) == 0) { | ||
890 | found = 1; | ||
891 | break; | ||
892 | } | ||
893 | } | ||
894 | |||
895 | if (!found) | ||
896 | return MAIL_ERROR_MSG_NOT_FOUND; | ||
897 | |||
898 | return pop3driver_cached_get_message(session, msg_info->msg_index, result); | ||
899 | } | ||
diff --git a/kmicromail/libetpan/generic/pop3driver_message.c b/kmicromail/libetpan/generic/pop3driver_message.c index 77bd94c..357bb2e 100644 --- a/kmicromail/libetpan/generic/pop3driver_message.c +++ b/kmicromail/libetpan/generic/pop3driver_message.c | |||
@@ -36,12 +36,14 @@ | |||
36 | #include "pop3driver_message.h" | 36 | #include "pop3driver_message.h" |
37 | 37 | ||
38 | #include "mailmessage_tools.h" | 38 | #include "mailmessage_tools.h" |
39 | #include "pop3driver_tools.h" | 39 | #include "pop3driver_tools.h" |
40 | #include "pop3driver.h" | 40 | #include "pop3driver.h" |
41 | #include "mailpop3.h" | 41 | #include "mailpop3.h" |
42 | #include <stdlib.h> | ||
43 | #include <string.h> | ||
42 | 44 | ||
43 | static int pop3_prefetch(mailmessage * msg_info); | 45 | static int pop3_prefetch(mailmessage * msg_info); |
44 | 46 | ||
45 | static void pop3_prefetch_free(struct generic_message_t * msg); | 47 | static void pop3_prefetch_free(struct generic_message_t * msg); |
46 | 48 | ||
47 | static int pop3_initialize(mailmessage * msg_info); | 49 | static int pop3_initialize(mailmessage * msg_info); |
@@ -77,12 +79,24 @@ static mailmessage_driver local_pop3_message_driver = { | |||
77 | 79 | ||
78 | .msg_get_flags = NULL, | 80 | .msg_get_flags = NULL, |
79 | }; | 81 | }; |
80 | 82 | ||
81 | mailmessage_driver * pop3_message_driver = &local_pop3_message_driver; | 83 | mailmessage_driver * pop3_message_driver = &local_pop3_message_driver; |
82 | 84 | ||
85 | static inline struct pop3_session_state_data * | ||
86 | get_data(mailsession * session) | ||
87 | { | ||
88 | return session->sess_data; | ||
89 | } | ||
90 | |||
91 | |||
92 | static mailpop3 * get_pop3_session(mailsession * session) | ||
93 | { | ||
94 | return get_data(session)->pop3_session; | ||
95 | } | ||
96 | |||
83 | 97 | ||
84 | static int pop3_prefetch(mailmessage * msg_info) | 98 | static int pop3_prefetch(mailmessage * msg_info) |
85 | { | 99 | { |
86 | char * msg_content; | 100 | char * msg_content; |
87 | size_t msg_length; | 101 | size_t msg_length; |
88 | struct generic_message_t * msg; | 102 | struct generic_message_t * msg; |
@@ -110,20 +124,40 @@ static void pop3_prefetch_free(struct generic_message_t * msg) | |||
110 | } | 124 | } |
111 | 125 | ||
112 | static int pop3_initialize(mailmessage * msg_info) | 126 | static int pop3_initialize(mailmessage * msg_info) |
113 | { | 127 | { |
114 | struct generic_message_t * msg; | 128 | struct generic_message_t * msg; |
115 | int r; | 129 | int r; |
130 | char * uid; | ||
131 | struct mailpop3_msg_info * info; | ||
132 | mailpop3 * pop3; | ||
133 | |||
134 | pop3 = get_pop3_session(msg_info->msg_session); | ||
135 | |||
136 | r = mailpop3_get_msg_info(pop3, msg_info->msg_index, &info); | ||
137 | switch (r) { | ||
138 | case MAILPOP3_NO_ERROR: | ||
139 | break; | ||
140 | default: | ||
141 | return pop3driver_pop3_error_to_mail_error(r); | ||
142 | } | ||
143 | |||
144 | uid = strdup(info->msg_uidl); | ||
145 | if (uid == NULL) | ||
146 | return MAIL_ERROR_MEMORY; | ||
116 | 147 | ||
117 | r = mailmessage_generic_initialize(msg_info); | 148 | r = mailmessage_generic_initialize(msg_info); |
118 | if (r != MAIL_NO_ERROR) | 149 | if (r != MAIL_NO_ERROR) { |
150 | free(uid); | ||
119 | return r; | 151 | return r; |
152 | } | ||
120 | 153 | ||
121 | msg = msg_info->msg_data; | 154 | msg = msg_info->msg_data; |
122 | msg->msg_prefetch = pop3_prefetch; | 155 | msg->msg_prefetch = pop3_prefetch; |
123 | msg->msg_prefetch_free = pop3_prefetch_free; | 156 | msg->msg_prefetch_free = pop3_prefetch_free; |
157 | msg_info->msg_uid = uid; | ||
124 | 158 | ||
125 | return MAIL_NO_ERROR; | 159 | return MAIL_NO_ERROR; |
126 | } | 160 | } |
127 | 161 | ||
128 | 162 | ||
129 | static int pop3_fetch_header(mailmessage * msg_info, | 163 | static int pop3_fetch_header(mailmessage * msg_info, |
diff --git a/kmicromail/libetpan/generic/pop3storage.c b/kmicromail/libetpan/generic/pop3storage.c index 8e7a94e..375aeaf 100644 --- a/kmicromail/libetpan/generic/pop3storage.c +++ b/kmicromail/libetpan/generic/pop3storage.c | |||
@@ -65,13 +65,13 @@ int pop3_mailstorage_init(struct mailstorage * storage, | |||
65 | int pop3_connection_type, int pop3_auth_type, | 65 | int pop3_connection_type, int pop3_auth_type, |
66 | char * pop3_login, char * pop3_password, | 66 | char * pop3_login, char * pop3_password, |
67 | int pop3_cached, char * pop3_cache_directory, char * pop3_flags_directory) | 67 | int pop3_cached, char * pop3_cache_directory, char * pop3_flags_directory) |
68 | { | 68 | { |
69 | struct pop3_mailstorage * pop3_storage; | 69 | struct pop3_mailstorage * pop3_storage; |
70 | 70 | ||
71 | pop3_storage = malloc(sizeof(struct pop3_mailstorage)); | 71 | pop3_storage = malloc(sizeof(* pop3_storage)); |
72 | if (pop3_storage == NULL) | 72 | if (pop3_storage == NULL) |
73 | goto err; | 73 | goto err; |
74 | 74 | ||
75 | pop3_storage->pop3_servername = strdup(pop3_servername); | 75 | pop3_storage->pop3_servername = strdup(pop3_servername); |
76 | if (pop3_storage->pop3_servername == NULL) | 76 | if (pop3_storage->pop3_servername == NULL) |
77 | goto free; | 77 | goto free; |
diff --git a/kmicromail/libetpan/imap/mailimap.c b/kmicromail/libetpan/imap/mailimap.c index c8fbfee..76d9454 100644 --- a/kmicromail/libetpan/imap/mailimap.c +++ b/kmicromail/libetpan/imap/mailimap.c | |||
@@ -1904,13 +1904,13 @@ int mailimap_unsubscribe(mailimap * session, const char * mb) | |||
1904 | return MAILIMAP_ERROR_BAD_STATE; | 1904 | return MAILIMAP_ERROR_BAD_STATE; |
1905 | 1905 | ||
1906 | r = send_current_tag(session); | 1906 | r = send_current_tag(session); |
1907 | if (r != MAILIMAP_NO_ERROR) | 1907 | if (r != MAILIMAP_NO_ERROR) |
1908 | return r; | 1908 | return r; |
1909 | 1909 | ||
1910 | r = mailimap_subscribe_send(session->imap_stream, mb); | 1910 | r = mailimap_unsubscribe_send(session->imap_stream, mb); |
1911 | if (r != MAILIMAP_NO_ERROR) | 1911 | if (r != MAILIMAP_NO_ERROR) |
1912 | return r; | 1912 | return r; |
1913 | 1913 | ||
1914 | r = mailimap_crlf_send(session->imap_stream); | 1914 | r = mailimap_crlf_send(session->imap_stream); |
1915 | if (r != MAILIMAP_NO_ERROR) | 1915 | if (r != MAILIMAP_NO_ERROR) |
1916 | return r; | 1916 | return r; |
diff --git a/kmicromail/libetpan/imap/mailimap_keywords.c b/kmicromail/libetpan/imap/mailimap_keywords.c index b277aed..4ec156e 100644 --- a/kmicromail/libetpan/imap/mailimap_keywords.c +++ b/kmicromail/libetpan/imap/mailimap_keywords.c | |||
@@ -50,13 +50,13 @@ struct mailimap_token_value { | |||
50 | int mailimap_token_case_insensitive_parse(mailstream * fd, | 50 | int mailimap_token_case_insensitive_parse(mailstream * fd, |
51 | MMAPString * buffer, | 51 | MMAPString * buffer, |
52 | size_t * index, | 52 | size_t * index, |
53 | const char * token) | 53 | const char * token) |
54 | { | 54 | { |
55 | int len; | 55 | int len; |
56 | int cur_token; | 56 | size_t cur_token; |
57 | int r; | 57 | int r; |
58 | 58 | ||
59 | cur_token = * index; | 59 | cur_token = * index; |
60 | len = strlen(token); | 60 | len = strlen(token); |
61 | 61 | ||
62 | #ifdef UNSTRICT_SYNTAX | 62 | #ifdef UNSTRICT_SYNTAX |
diff --git a/kmicromail/libetpan/imf/mailimf.c b/kmicromail/libetpan/imf/mailimf.c index 84d81a1..e0164b8 100644 --- a/kmicromail/libetpan/imf/mailimf.c +++ b/kmicromail/libetpan/imf/mailimf.c | |||
@@ -45,13 +45,13 @@ | |||
45 | to the extent needed to determine if Return-path headers are present. | 45 | to the extent needed to determine if Return-path headers are present. |
46 | SMTP servers making final delivery MAY remove Return-path headers | 46 | SMTP servers making final delivery MAY remove Return-path headers |
47 | before adding their own. | 47 | before adding their own. |
48 | */ | 48 | */ |
49 | 49 | ||
50 | #include <ctype.h> | 50 | #include <ctype.h> |
51 | #include <mmapstring.h> | 51 | #include "mmapstring.h" |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <string.h> | 53 | #include <string.h> |
54 | 54 | ||
55 | #ifndef TRUE | 55 | #ifndef TRUE |
56 | #define TRUE 1 | 56 | #define TRUE 1 |
57 | #endif | 57 | #endif |
diff --git a/kmicromail/libetpan/include/libetpan/libetpan.h b/kmicromail/libetpan/include/libetpan/libetpan.h index 3b4a107..fe5637d 100644 --- a/kmicromail/libetpan/include/libetpan/libetpan.h +++ b/kmicromail/libetpan/include/libetpan/libetpan.h | |||
@@ -41,12 +41,13 @@ | |||
41 | extern "C" { | 41 | extern "C" { |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #include <libetpan/libetpan_version.h> | 44 | #include <libetpan/libetpan_version.h> |
45 | #include <libetpan/maildriver.h> | 45 | #include <libetpan/maildriver.h> |
46 | #include <libetpan/mailmessage.h> | 46 | #include <libetpan/mailmessage.h> |
47 | #include <libetpan/mailfolder.h> | ||
47 | #include <libetpan/mailstorage.h> | 48 | #include <libetpan/mailstorage.h> |
48 | #include <libetpan/mailthread.h> | 49 | #include <libetpan/mailthread.h> |
49 | #include <libetpan/mailsmtp.h> | 50 | #include <libetpan/mailsmtp.h> |
50 | #include <libetpan/charconv.h> | 51 | #include <libetpan/charconv.h> |
51 | 52 | ||
52 | /* mbox driver */ | 53 | /* mbox driver */ |
@@ -88,17 +89,28 @@ extern "C" { | |||
88 | #include <libetpan/maildirdriver.h> | 89 | #include <libetpan/maildirdriver.h> |
89 | #include <libetpan/maildirdriver_message.h> | 90 | #include <libetpan/maildirdriver_message.h> |
90 | #include <libetpan/maildirdriver_cached.h> | 91 | #include <libetpan/maildirdriver_cached.h> |
91 | #include <libetpan/maildirdriver_cached_message.h> | 92 | #include <libetpan/maildirdriver_cached_message.h> |
92 | #include <libetpan/maildirstorage.h> | 93 | #include <libetpan/maildirstorage.h> |
93 | 94 | ||
95 | /* db driver */ | ||
96 | #include <libetpan/dbdriver.h> | ||
97 | #include <libetpan/dbdriver_message.h> | ||
98 | #include <libetpan/dbstorage.h> | ||
99 | |||
94 | /* message which content is given by a MIME structure */ | 100 | /* message which content is given by a MIME structure */ |
95 | #include <libetpan/mime_message_driver.h> | 101 | #include <libetpan/mime_message_driver.h> |
96 | 102 | ||
97 | /* message which content given by a string */ | 103 | /* message which content given by a string */ |
98 | #include <libetpan/data_message_driver.h> | 104 | #include <libetpan/data_message_driver.h> |
99 | 105 | ||
106 | /* engine */ | ||
107 | #include <libetpan/mailprivacy.h> | ||
108 | #include <libetpan/mailengine.h> | ||
109 | #include <libetpan/mailprivacy_gnupg.h> | ||
110 | #include <libetpan/mailprivacy_smime.h> | ||
111 | |||
100 | #ifdef __cplusplus | 112 | #ifdef __cplusplus |
101 | } | 113 | } |
102 | #endif | 114 | #endif |
103 | 115 | ||
104 | #endif | 116 | #endif |
diff --git a/kmicromail/libetpan/include/libetpan/maildir.h b/kmicromail/libetpan/include/libetpan/maildir.h index b782484..268dda1 100644 --- a/kmicromail/libetpan/include/libetpan/maildir.h +++ b/kmicromail/libetpan/include/libetpan/maildir.h | |||
@@ -42,15 +42,22 @@ | |||
42 | struct maildir * maildir_new(const char * path); | 42 | struct maildir * maildir_new(const char * path); |
43 | 43 | ||
44 | void maildir_free(struct maildir * md); | 44 | void maildir_free(struct maildir * md); |
45 | 45 | ||
46 | int maildir_update(struct maildir * md); | 46 | int maildir_update(struct maildir * md); |
47 | 47 | ||
48 | int maildir_message_add_uid(struct maildir * md, | ||
49 | const char * message, size_t size, | ||
50 | char * uid, size_t max_uid_len); | ||
51 | |||
48 | int maildir_message_add(struct maildir * md, | 52 | int maildir_message_add(struct maildir * md, |
49 | const char * message, size_t size); | 53 | const char * message, size_t size); |
50 | 54 | ||
55 | int maildir_message_add_file_uid(struct maildir * md, int fd, | ||
56 | char * uid, size_t max_uid_len); | ||
57 | |||
51 | int maildir_message_add_file(struct maildir * md, int fd); | 58 | int maildir_message_add_file(struct maildir * md, int fd); |
52 | 59 | ||
53 | char * maildir_message_get(struct maildir * md, const char * uid); | 60 | char * maildir_message_get(struct maildir * md, const char * uid); |
54 | 61 | ||
55 | int maildir_message_remove(struct maildir * md, const char * uid); | 62 | int maildir_message_remove(struct maildir * md, const char * uid); |
56 | 63 | ||
diff --git a/kmicromail/libetpan/include/libetpan/maildirstorage.h b/kmicromail/libetpan/include/libetpan/maildirstorage.h index d17ea2c..73d7b20 100644 --- a/kmicromail/libetpan/include/libetpan/maildirstorage.h +++ b/kmicromail/libetpan/include/libetpan/maildirstorage.h | |||
@@ -41,13 +41,13 @@ | |||
41 | 41 | ||
42 | #ifdef __cplusplus | 42 | #ifdef __cplusplus |
43 | extern "C" { | 43 | extern "C" { |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | /* | 46 | /* |
47 | maildir_mailstorage_init is the constructor for a mbox storage. | 47 | maildir_mailstorage_init is the constructor for a maildir storage. |
48 | 48 | ||
49 | @param storage this is the storage to initialize. | 49 | @param storage this is the storage to initialize. |
50 | 50 | ||
51 | @param pathname is the directory that contains the mailbox. | 51 | @param pathname is the directory that contains the mailbox. |
52 | 52 | ||
53 | @param cached if this value is != 0, a persistant cache will be | 53 | @param cached if this value is != 0, a persistant cache will be |
diff --git a/kmicromail/libetpan/include/libetpan/maildriver.h b/kmicromail/libetpan/include/libetpan/maildriver.h index 7da9aea..c773190 100644 --- a/kmicromail/libetpan/include/libetpan/maildriver.h +++ b/kmicromail/libetpan/include/libetpan/maildriver.h | |||
@@ -397,12 +397,15 @@ int mailsession_unsubscribe_folder(mailsession * session, char * mb); | |||
397 | on error | 397 | on error |
398 | */ | 398 | */ |
399 | 399 | ||
400 | int mailsession_append_message(mailsession * session, | 400 | int mailsession_append_message(mailsession * session, |
401 | char * message, size_t size); | 401 | char * message, size_t size); |
402 | 402 | ||
403 | int mailsession_append_message_flags(mailsession * session, | ||
404 | char * message, size_t size, struct mail_flags * flags); | ||
405 | |||
403 | /* | 406 | /* |
404 | NOTE: some drivers does not implement this | 407 | NOTE: some drivers does not implement this |
405 | 408 | ||
406 | mailsession_copy_message copies a message whose number is given to | 409 | mailsession_copy_message copies a message whose number is given to |
407 | a given mailbox. The mailbox must be accessible from the same session. | 410 | a given mailbox. The mailbox must be accessible from the same session. |
408 | 411 | ||
diff --git a/kmicromail/libetpan/include/libetpan/maildriver_types.h b/kmicromail/libetpan/include/libetpan/maildriver_types.h index 3ff9440..9eab4d6 100644 --- a/kmicromail/libetpan/include/libetpan/maildriver_types.h +++ b/kmicromail/libetpan/include/libetpan/maildriver_types.h | |||
@@ -504,12 +504,14 @@ struct mailsession_driver { | |||
504 | int (* sess_unsubscribe_folder)(mailsession * session, char * mb); | 504 | int (* sess_unsubscribe_folder)(mailsession * session, char * mb); |
505 | 505 | ||
506 | /* messages operations */ | 506 | /* messages operations */ |
507 | 507 | ||
508 | int (* sess_append_message)(mailsession * session, | 508 | int (* sess_append_message)(mailsession * session, |
509 | char * message, size_t size); | 509 | char * message, size_t size); |
510 | int (* sess_append_message_flags)(mailsession * session, | ||
511 | char * message, size_t size, struct mail_flags * flags); | ||
510 | int (* sess_copy_message)(mailsession * session, | 512 | int (* sess_copy_message)(mailsession * session, |
511 | uint32_t num, char * mb); | 513 | uint32_t num, char * mb); |
512 | int (* sess_move_message)(mailsession * session, | 514 | int (* sess_move_message)(mailsession * session, |
513 | uint32_t num, char * mb); | 515 | uint32_t num, char * mb); |
514 | 516 | ||
515 | int (* sess_get_message)(mailsession * session, | 517 | int (* sess_get_message)(mailsession * session, |
diff --git a/kmicromail/libetpan/include/libetpan/mailfolder.h b/kmicromail/libetpan/include/libetpan/mailfolder.h index 3ecad23..ff53470 100644 --- a/kmicromail/libetpan/include/libetpan/mailfolder.h +++ b/kmicromail/libetpan/include/libetpan/mailfolder.h | |||
@@ -14,12 +14,15 @@ int mailfolder_status(struct mailfolder * folder, | |||
14 | uint32_t * result_messages, uint32_t * result_recent, | 14 | uint32_t * result_messages, uint32_t * result_recent, |
15 | uint32_t * result_unseen); | 15 | uint32_t * result_unseen); |
16 | 16 | ||
17 | int mailfolder_append_message(struct mailfolder * folder, | 17 | int mailfolder_append_message(struct mailfolder * folder, |
18 | char * message, size_t size); | 18 | char * message, size_t size); |
19 | 19 | ||
20 | int mailfolder_append_message_flags(struct mailfolder * folder, | ||
21 | char * message, size_t size, struct mail_flags * flags); | ||
22 | |||
20 | int mailfolder_get_messages_list(struct mailfolder * folder, | 23 | int mailfolder_get_messages_list(struct mailfolder * folder, |
21 | struct mailmessage_list ** result); | 24 | struct mailmessage_list ** result); |
22 | 25 | ||
23 | int mailfolder_get_envelopes_list(struct mailfolder * folder, | 26 | int mailfolder_get_envelopes_list(struct mailfolder * folder, |
24 | struct mailmessage_list * result); | 27 | struct mailmessage_list * result); |
25 | 28 | ||
diff --git a/kmicromail/libetpan/include/libetpan/mailmbox.h b/kmicromail/libetpan/include/libetpan/mailmbox.h index 8be086c..0427f1f 100644 --- a/kmicromail/libetpan/include/libetpan/mailmbox.h +++ b/kmicromail/libetpan/include/libetpan/mailmbox.h | |||
@@ -48,12 +48,16 @@ mailmbox_append_message_list(struct mailmbox_folder * folder, | |||
48 | carray * append_tab); | 48 | carray * append_tab); |
49 | 49 | ||
50 | int | 50 | int |
51 | mailmbox_append_message(struct mailmbox_folder * folder, | 51 | mailmbox_append_message(struct mailmbox_folder * folder, |
52 | const char * data, size_t len); | 52 | const char * data, size_t len); |
53 | 53 | ||
54 | int | ||
55 | mailmbox_append_message_uid(struct mailmbox_folder * folder, | ||
56 | const char * data, size_t len, unsigned int * puid); | ||
57 | |||
54 | int mailmbox_fetch_msg(struct mailmbox_folder * folder, | 58 | int mailmbox_fetch_msg(struct mailmbox_folder * folder, |
55 | uint32_t num, char ** result, | 59 | uint32_t num, char ** result, |
56 | size_t * result_len); | 60 | size_t * result_len); |
57 | 61 | ||
58 | int mailmbox_fetch_msg_headers(struct mailmbox_folder * folder, | 62 | int mailmbox_fetch_msg_headers(struct mailmbox_folder * folder, |
59 | uint32_t num, char ** result, | 63 | uint32_t num, char ** result, |
diff --git a/kmicromail/libetpan/include/libetpan/mailmbox_types.h b/kmicromail/libetpan/include/libetpan/mailmbox_types.h index dd6758c..bd6ee30 100644 --- a/kmicromail/libetpan/include/libetpan/mailmbox_types.h +++ b/kmicromail/libetpan/include/libetpan/mailmbox_types.h | |||
@@ -125,12 +125,13 @@ mailmbox_msg_info_new(size_t msg_start, size_t msg_start_len, | |||
125 | 125 | ||
126 | void mailmbox_msg_info_free(struct mailmbox_msg_info * info); | 126 | void mailmbox_msg_info_free(struct mailmbox_msg_info * info); |
127 | 127 | ||
128 | struct mailmbox_append_info { | 128 | struct mailmbox_append_info { |
129 | const char * ai_message; | 129 | const char * ai_message; |
130 | size_t ai_size; | 130 | size_t ai_size; |
131 | unsigned int ai_uid; | ||
131 | }; | 132 | }; |
132 | 133 | ||
133 | struct mailmbox_append_info * | 134 | struct mailmbox_append_info * |
134 | mailmbox_append_info_new(const char * ai_message, size_t ai_size); | 135 | mailmbox_append_info_new(const char * ai_message, size_t ai_size); |
135 | 136 | ||
136 | void mailmbox_append_info_free(struct mailmbox_append_info * info); | 137 | void mailmbox_append_info_free(struct mailmbox_append_info * info); |
diff --git a/kmicromail/libetpan/include/libetpan/mailmh.h b/kmicromail/libetpan/include/libetpan/mailmh.h index 40432cb..00199b8 100644 --- a/kmicromail/libetpan/include/libetpan/mailmh.h +++ b/kmicromail/libetpan/include/libetpan/mailmh.h | |||
@@ -116,15 +116,22 @@ int mailmh_folder_get_message_filename(struct mailmh_folder * folder, | |||
116 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, | 116 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, |
117 | uint32_t index, int flags, int * result); | 117 | uint32_t index, int flags, int * result); |
118 | 118 | ||
119 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, | 119 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, |
120 | uint32_t index, size_t * result); | 120 | uint32_t index, size_t * result); |
121 | 121 | ||
122 | int mailmh_folder_add_message_uid(struct mailmh_folder * folder, | ||
123 | const char * message, size_t size, | ||
124 | uint32_t * pindex); | ||
125 | |||
122 | int mailmh_folder_add_message(struct mailmh_folder * folder, | 126 | int mailmh_folder_add_message(struct mailmh_folder * folder, |
123 | const char * message, size_t size); | 127 | const char * message, size_t size); |
124 | 128 | ||
129 | int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, | ||
130 | int fd, uint32_t * pindex); | ||
131 | |||
125 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, | 132 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, |
126 | int fd); | 133 | int fd); |
127 | 134 | ||
128 | int mailmh_folder_remove_message(struct mailmh_folder * folder, | 135 | int mailmh_folder_remove_message(struct mailmh_folder * folder, |
129 | uint32_t index); | 136 | uint32_t index); |
130 | 137 | ||
diff --git a/kmicromail/libetpan/include/libetpan/mailstorage.h b/kmicromail/libetpan/include/libetpan/mailstorage.h index d56aef1..4c57883 100644 --- a/kmicromail/libetpan/include/libetpan/mailstorage.h +++ b/kmicromail/libetpan/include/libetpan/mailstorage.h | |||
@@ -68,12 +68,14 @@ void mailstorage_free(struct mailstorage * storage); | |||
68 | */ | 68 | */ |
69 | 69 | ||
70 | int mailstorage_connect(struct mailstorage * storage); | 70 | int mailstorage_connect(struct mailstorage * storage); |
71 | 71 | ||
72 | void mailstorage_disconnect(struct mailstorage * storage); | 72 | void mailstorage_disconnect(struct mailstorage * storage); |
73 | 73 | ||
74 | int mailstorage_noop(struct mailstorage * storage); | ||
75 | |||
74 | 76 | ||
75 | /* folder */ | 77 | /* folder */ |
76 | 78 | ||
77 | struct mailfolder * mailfolder_new(struct mailstorage * fld_storage, | 79 | struct mailfolder * mailfolder_new(struct mailstorage * fld_storage, |
78 | char * fld_pathname, char * fld_virtual_name); | 80 | char * fld_pathname, char * fld_virtual_name); |
79 | 81 | ||
@@ -85,13 +87,12 @@ int mailfolder_add_child(struct mailfolder * parent, | |||
85 | int mailfolder_detach_parent(struct mailfolder * folder); | 87 | int mailfolder_detach_parent(struct mailfolder * folder); |
86 | 88 | ||
87 | int mailfolder_connect(struct mailfolder * folder); | 89 | int mailfolder_connect(struct mailfolder * folder); |
88 | 90 | ||
89 | void mailfolder_disconnect(struct mailfolder * folder); | 91 | void mailfolder_disconnect(struct mailfolder * folder); |
90 | 92 | ||
91 | |||
92 | #ifdef __cplusplus | 93 | #ifdef __cplusplus |
93 | } | 94 | } |
94 | #endif | 95 | #endif |
95 | 96 | ||
96 | #endif | 97 | #endif |
97 | 98 | ||
diff --git a/kmicromail/libetpan/maildir/maildir.c b/kmicromail/libetpan/maildir/maildir.c index 320ef81..0e038b1 100644 --- a/kmicromail/libetpan/maildir/maildir.c +++ b/kmicromail/libetpan/maildir/maildir.c | |||
@@ -427,14 +427,15 @@ static char * libetpan_basename(char * filename) | |||
427 | return p + 1; | 427 | return p + 1; |
428 | } | 428 | } |
429 | #else | 429 | #else |
430 | #define libetpan_basename(a) basename(a) | 430 | #define libetpan_basename(a) basename(a) |
431 | #endif | 431 | #endif |
432 | 432 | ||
433 | int maildir_message_add(struct maildir * md, | 433 | int maildir_message_add_uid(struct maildir * md, |
434 | const char * message, size_t size) | 434 | const char * message, size_t size, |
435 | char * uid, size_t max_uid_len) | ||
435 | { | 436 | { |
436 | char path_new[PATH_MAX]; | 437 | char path_new[PATH_MAX]; |
437 | char tmpname[PATH_MAX]; | 438 | char tmpname[PATH_MAX]; |
438 | int fd; | 439 | int fd; |
439 | int r; | 440 | int r; |
440 | char * mapping; | 441 | char * mapping; |
@@ -450,13 +451,14 @@ int maildir_message_add(struct maildir * md, | |||
450 | res = r; | 451 | res = r; |
451 | goto err; | 452 | goto err; |
452 | } | 453 | } |
453 | 454 | ||
454 | /* write to tmp/ with a classic temporary file */ | 455 | /* write to tmp/ with a classic temporary file */ |
455 | 456 | ||
456 | snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX", md->mdir_path); | 457 | snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX", |
458 | md->mdir_path); | ||
457 | fd = mkstemp(tmpname); | 459 | fd = mkstemp(tmpname); |
458 | if (fd < 0) { | 460 | if (fd < 0) { |
459 | res = MAILDIR_ERROR_FILE; | 461 | res = MAILDIR_ERROR_FILE; |
460 | goto err; | 462 | goto err; |
461 | } | 463 | } |
462 | 464 | ||
@@ -518,13 +520,16 @@ int maildir_message_add(struct maildir * md, | |||
518 | r = add_message(md, delivery_new_basename, 1); | 520 | r = add_message(md, delivery_new_basename, 1); |
519 | if (r != MAILDIR_NO_ERROR) { | 521 | if (r != MAILDIR_NO_ERROR) { |
520 | unlink(delivery_new_name); | 522 | unlink(delivery_new_name); |
521 | res = MAILDIR_ERROR_FILE; | 523 | res = MAILDIR_ERROR_FILE; |
522 | goto unlink_tmp; | 524 | goto unlink_tmp; |
523 | } | 525 | } |
524 | 526 | ||
527 | if (uid != NULL) | ||
528 | strncpy(uid, delivery_new_basename, max_uid_len); | ||
529 | |||
525 | unlink(delivery_tmp_name); | 530 | unlink(delivery_tmp_name); |
526 | free(delivery_tmp_name); | 531 | free(delivery_tmp_name); |
527 | 532 | ||
528 | return MAILDIR_NO_ERROR; | 533 | return MAILDIR_NO_ERROR; |
529 | 534 | ||
530 | unlink_tmp: | 535 | unlink_tmp: |
@@ -536,32 +541,46 @@ int maildir_message_add(struct maildir * md, | |||
536 | unlink: | 541 | unlink: |
537 | unlink(tmpname); | 542 | unlink(tmpname); |
538 | err: | 543 | err: |
539 | return res; | 544 | return res; |
540 | } | 545 | } |
541 | 546 | ||
542 | int maildir_message_add_file(struct maildir * md, int fd) | 547 | int maildir_message_add(struct maildir * md, |
548 | const char * message, size_t size) | ||
549 | { | ||
550 | return maildir_message_add_uid(md, message, size, | ||
551 | NULL, 0); | ||
552 | } | ||
553 | |||
554 | int maildir_message_add_file_uid(struct maildir * md, int fd, | ||
555 | char * uid, size_t max_uid_len) | ||
543 | { | 556 | { |
544 | char * message; | 557 | char * message; |
545 | struct stat buf; | 558 | struct stat buf; |
546 | int r; | 559 | int r; |
547 | 560 | ||
548 | if (fstat(fd, &buf) == -1) | 561 | if (fstat(fd, &buf) == -1) |
549 | return MAILDIR_ERROR_FILE; | 562 | return MAILDIR_ERROR_FILE; |
550 | 563 | ||
551 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 564 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
552 | if (message == MAP_FAILED) | 565 | if (message == MAP_FAILED) |
553 | return MAILDIR_ERROR_FILE; | 566 | return MAILDIR_ERROR_FILE; |
554 | 567 | ||
555 | r = maildir_message_add(md, message, buf.st_size); | 568 | r = maildir_message_add_uid(md, message, buf.st_size, uid, max_uid_len); |
556 | 569 | ||
557 | munmap(message, buf.st_size); | 570 | munmap(message, buf.st_size); |
558 | 571 | ||
559 | return r; | 572 | return r; |
560 | } | 573 | } |
561 | 574 | ||
575 | int maildir_message_add_file(struct maildir * md, int fd) | ||
576 | { | ||
577 | return maildir_message_add_file_uid(md, fd, | ||
578 | NULL, 0); | ||
579 | } | ||
580 | |||
562 | char * maildir_message_get(struct maildir * md, const char * uid) | 581 | char * maildir_message_get(struct maildir * md, const char * uid) |
563 | { | 582 | { |
564 | chashdatum key; | 583 | chashdatum key; |
565 | chashdatum value; | 584 | chashdatum value; |
566 | char filename[PATH_MAX]; | 585 | char filename[PATH_MAX]; |
567 | char * dup_filename; | 586 | char * dup_filename; |
diff --git a/kmicromail/libetpan/maildir/maildir.h b/kmicromail/libetpan/maildir/maildir.h index b782484..268dda1 100644 --- a/kmicromail/libetpan/maildir/maildir.h +++ b/kmicromail/libetpan/maildir/maildir.h | |||
@@ -42,15 +42,22 @@ | |||
42 | struct maildir * maildir_new(const char * path); | 42 | struct maildir * maildir_new(const char * path); |
43 | 43 | ||
44 | void maildir_free(struct maildir * md); | 44 | void maildir_free(struct maildir * md); |
45 | 45 | ||
46 | int maildir_update(struct maildir * md); | 46 | int maildir_update(struct maildir * md); |
47 | 47 | ||
48 | int maildir_message_add_uid(struct maildir * md, | ||
49 | const char * message, size_t size, | ||
50 | char * uid, size_t max_uid_len); | ||
51 | |||
48 | int maildir_message_add(struct maildir * md, | 52 | int maildir_message_add(struct maildir * md, |
49 | const char * message, size_t size); | 53 | const char * message, size_t size); |
50 | 54 | ||
55 | int maildir_message_add_file_uid(struct maildir * md, int fd, | ||
56 | char * uid, size_t max_uid_len); | ||
57 | |||
51 | int maildir_message_add_file(struct maildir * md, int fd); | 58 | int maildir_message_add_file(struct maildir * md, int fd); |
52 | 59 | ||
53 | char * maildir_message_get(struct maildir * md, const char * uid); | 60 | char * maildir_message_get(struct maildir * md, const char * uid); |
54 | 61 | ||
55 | int maildir_message_remove(struct maildir * md, const char * uid); | 62 | int maildir_message_remove(struct maildir * md, const char * uid); |
56 | 63 | ||
diff --git a/kmicromail/libetpan/mbox/mailmbox.c b/kmicromail/libetpan/mbox/mailmbox.c index 280c313..b3fce02 100644 --- a/kmicromail/libetpan/mbox/mailmbox.c +++ b/kmicromail/libetpan/mbox/mailmbox.c | |||
@@ -194,12 +194,15 @@ void mailmbox_timestamp(struct mailmbox_folder * folder) | |||
194 | 194 | ||
195 | int mailmbox_open(struct mailmbox_folder * folder) | 195 | int mailmbox_open(struct mailmbox_folder * folder) |
196 | { | 196 | { |
197 | int fd; | 197 | int fd; |
198 | int read_only; | 198 | int read_only; |
199 | 199 | ||
200 | fd = -1; | ||
201 | read_only = TRUE; | ||
202 | |||
200 | if (!folder->mb_read_only) { | 203 | if (!folder->mb_read_only) { |
201 | read_only = FALSE; | 204 | read_only = FALSE; |
202 | fd = open(folder->mb_filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); | 205 | fd = open(folder->mb_filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); |
203 | } | 206 | } |
204 | 207 | ||
205 | if (folder->mb_read_only || (fd < 0)) { | 208 | if (folder->mb_read_only || (fd < 0)) { |
@@ -614,12 +617,14 @@ mailmbox_append_message_list_no_lock(struct mailmbox_folder * folder, | |||
614 | info = carray_get(append_tab, i); | 617 | info = carray_get(append_tab, i); |
615 | extra_size += from_size; | 618 | extra_size += from_size; |
616 | extra_size += get_fixed_message_size(info->ai_message, info->ai_size, | 619 | extra_size += get_fixed_message_size(info->ai_message, info->ai_size, |
617 | folder->mb_max_uid + i + 1, | 620 | folder->mb_max_uid + i + 1, |
618 | folder->mb_no_uid); | 621 | folder->mb_no_uid); |
619 | extra_size += 2; /* CR LF */ | 622 | extra_size += 2; /* CR LF */ |
623 | |||
624 | info->ai_uid = folder->mb_max_uid + i + 1; | ||
620 | } | 625 | } |
621 | 626 | ||
622 | left = folder->mb_mapping_size; | 627 | left = folder->mb_mapping_size; |
623 | crlf_count = 0; | 628 | crlf_count = 0; |
624 | while (left >= 1) { | 629 | while (left >= 1) { |
625 | if (folder->mb_mapping[left - 1] == '\n') { | 630 | if (folder->mb_mapping[left - 1] == '\n') { |
@@ -741,14 +746,14 @@ mailmbox_append_message_list(struct mailmbox_folder * folder, | |||
741 | mailmbox_write_unlock(folder); | 746 | mailmbox_write_unlock(folder); |
742 | err: | 747 | err: |
743 | return res; | 748 | return res; |
744 | } | 749 | } |
745 | 750 | ||
746 | int | 751 | int |
747 | mailmbox_append_message(struct mailmbox_folder * folder, | 752 | mailmbox_append_message_uid(struct mailmbox_folder * folder, |
748 | const char * data, size_t len) | 753 | const char * data, size_t len, unsigned int * puid) |
749 | { | 754 | { |
750 | carray * tab; | 755 | carray * tab; |
751 | struct mailmbox_append_info * append_info; | 756 | struct mailmbox_append_info * append_info; |
752 | int res; | 757 | int res; |
753 | int r; | 758 | int r; |
754 | 759 | ||
@@ -768,13 +773,16 @@ mailmbox_append_message(struct mailmbox_folder * folder, | |||
768 | if (r < 0) { | 773 | if (r < 0) { |
769 | res = MAILMBOX_ERROR_MEMORY; | 774 | res = MAILMBOX_ERROR_MEMORY; |
770 | goto free_append_info; | 775 | goto free_append_info; |
771 | } | 776 | } |
772 | 777 | ||
773 | r = mailmbox_append_message_list(folder, tab); | 778 | r = mailmbox_append_message_list(folder, tab); |
774 | 779 | ||
780 | if (puid != NULL) | ||
781 | * puid = append_info->ai_uid; | ||
782 | |||
775 | mailmbox_append_info_free(append_info); | 783 | mailmbox_append_info_free(append_info); |
776 | carray_free(tab); | 784 | carray_free(tab); |
777 | 785 | ||
778 | return r; | 786 | return r; |
779 | 787 | ||
780 | free_append_info: | 788 | free_append_info: |
@@ -782,12 +790,19 @@ mailmbox_append_message(struct mailmbox_folder * folder, | |||
782 | free_list: | 790 | free_list: |
783 | carray_free(tab); | 791 | carray_free(tab); |
784 | err: | 792 | err: |
785 | return res; | 793 | return res; |
786 | } | 794 | } |
787 | 795 | ||
796 | int | ||
797 | mailmbox_append_message(struct mailmbox_folder * folder, | ||
798 | const char * data, size_t len) | ||
799 | { | ||
800 | return mailmbox_append_message_uid(folder, data, len, NULL); | ||
801 | } | ||
802 | |||
788 | /* ********************************************************************** */ | 803 | /* ********************************************************************** */ |
789 | 804 | ||
790 | int mailmbox_fetch_msg_no_lock(struct mailmbox_folder * folder, | 805 | int mailmbox_fetch_msg_no_lock(struct mailmbox_folder * folder, |
791 | uint32_t num, char ** result, | 806 | uint32_t num, char ** result, |
792 | size_t * result_len) | 807 | size_t * result_len) |
793 | { | 808 | { |
diff --git a/kmicromail/libetpan/mbox/mailmbox.h b/kmicromail/libetpan/mbox/mailmbox.h index 8be086c..0427f1f 100644 --- a/kmicromail/libetpan/mbox/mailmbox.h +++ b/kmicromail/libetpan/mbox/mailmbox.h | |||
@@ -48,12 +48,16 @@ mailmbox_append_message_list(struct mailmbox_folder * folder, | |||
48 | carray * append_tab); | 48 | carray * append_tab); |
49 | 49 | ||
50 | int | 50 | int |
51 | mailmbox_append_message(struct mailmbox_folder * folder, | 51 | mailmbox_append_message(struct mailmbox_folder * folder, |
52 | const char * data, size_t len); | 52 | const char * data, size_t len); |
53 | 53 | ||
54 | int | ||
55 | mailmbox_append_message_uid(struct mailmbox_folder * folder, | ||
56 | const char * data, size_t len, unsigned int * puid); | ||
57 | |||
54 | int mailmbox_fetch_msg(struct mailmbox_folder * folder, | 58 | int mailmbox_fetch_msg(struct mailmbox_folder * folder, |
55 | uint32_t num, char ** result, | 59 | uint32_t num, char ** result, |
56 | size_t * result_len); | 60 | size_t * result_len); |
57 | 61 | ||
58 | int mailmbox_fetch_msg_headers(struct mailmbox_folder * folder, | 62 | int mailmbox_fetch_msg_headers(struct mailmbox_folder * folder, |
59 | uint32_t num, char ** result, | 63 | uint32_t num, char ** result, |
diff --git a/kmicromail/libetpan/mbox/mailmbox_types.c b/kmicromail/libetpan/mbox/mailmbox_types.c index 1986182..4e3e521 100644 --- a/kmicromail/libetpan/mbox/mailmbox_types.c +++ b/kmicromail/libetpan/mbox/mailmbox_types.c | |||
@@ -175,13 +175,14 @@ mailmbox_append_info_new(const char * ai_message, size_t ai_size) | |||
175 | info = malloc(sizeof(* info)); | 175 | info = malloc(sizeof(* info)); |
176 | if (info == NULL) | 176 | if (info == NULL) |
177 | return NULL; | 177 | return NULL; |
178 | 178 | ||
179 | info->ai_message = ai_message; | 179 | info->ai_message = ai_message; |
180 | info->ai_size = ai_size; | 180 | info->ai_size = ai_size; |
181 | 181 | info->ai_uid = 0; | |
182 | |||
182 | return info; | 183 | return info; |
183 | } | 184 | } |
184 | 185 | ||
185 | void mailmbox_append_info_free(struct mailmbox_append_info * info) | 186 | void mailmbox_append_info_free(struct mailmbox_append_info * info) |
186 | { | 187 | { |
187 | free(info); | 188 | free(info); |
diff --git a/kmicromail/libetpan/mbox/mailmbox_types.h b/kmicromail/libetpan/mbox/mailmbox_types.h index dd6758c..bd6ee30 100644 --- a/kmicromail/libetpan/mbox/mailmbox_types.h +++ b/kmicromail/libetpan/mbox/mailmbox_types.h | |||
@@ -125,12 +125,13 @@ mailmbox_msg_info_new(size_t msg_start, size_t msg_start_len, | |||
125 | 125 | ||
126 | void mailmbox_msg_info_free(struct mailmbox_msg_info * info); | 126 | void mailmbox_msg_info_free(struct mailmbox_msg_info * info); |
127 | 127 | ||
128 | struct mailmbox_append_info { | 128 | struct mailmbox_append_info { |
129 | const char * ai_message; | 129 | const char * ai_message; |
130 | size_t ai_size; | 130 | size_t ai_size; |
131 | unsigned int ai_uid; | ||
131 | }; | 132 | }; |
132 | 133 | ||
133 | struct mailmbox_append_info * | 134 | struct mailmbox_append_info * |
134 | mailmbox_append_info_new(const char * ai_message, size_t ai_size); | 135 | mailmbox_append_info_new(const char * ai_message, size_t ai_size); |
135 | 136 | ||
136 | void mailmbox_append_info_free(struct mailmbox_append_info * info); | 137 | void mailmbox_append_info_free(struct mailmbox_append_info * info); |
diff --git a/kmicromail/libetpan/mh/mailmh.c b/kmicromail/libetpan/mh/mailmh.c index d6ff950..119f217 100644 --- a/kmicromail/libetpan/mh/mailmh.c +++ b/kmicromail/libetpan/mh/mailmh.c | |||
@@ -720,14 +720,15 @@ int mailmh_folder_get_message_size(struct mailmh_folder * folder, | |||
720 | 720 | ||
721 | * result = buf.st_size; | 721 | * result = buf.st_size; |
722 | 722 | ||
723 | return MAILMH_NO_ERROR; | 723 | return MAILMH_NO_ERROR; |
724 | } | 724 | } |
725 | 725 | ||
726 | int mailmh_folder_add_message(struct mailmh_folder * folder, | 726 | int mailmh_folder_add_message_uid(struct mailmh_folder * folder, |
727 | const char * message, size_t size) | 727 | const char * message, size_t size, |
728 | uint32_t * pindex) | ||
728 | { | 729 | { |
729 | char * tmpname; | 730 | char * tmpname; |
730 | int fd; | 731 | int fd; |
731 | size_t namesize; | 732 | size_t namesize; |
732 | size_t left; | 733 | size_t left; |
733 | ssize_t res; | 734 | ssize_t res; |
@@ -806,12 +807,15 @@ int mailmh_folder_add_message(struct mailmh_folder * folder, | |||
806 | #endif | 807 | #endif |
807 | key.data = &index; | 808 | key.data = &index; |
808 | key.len = sizeof(index); | 809 | key.len = sizeof(index); |
809 | data.data = msg_info; | 810 | data.data = msg_info; |
810 | data.len = 0; | 811 | data.len = 0; |
811 | 812 | ||
813 | if (pindex != NULL) | ||
814 | * pindex = index; | ||
815 | |||
812 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); | 816 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); |
813 | if (r < 0) { | 817 | if (r < 0) { |
814 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); | 818 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); |
815 | mailmh_msg_info_free(msg_info); | 819 | mailmh_msg_info_free(msg_info); |
816 | error = MAILMH_ERROR_MEMORY; | 820 | error = MAILMH_ERROR_MEMORY; |
817 | goto err; | 821 | goto err; |
@@ -822,14 +826,20 @@ int mailmh_folder_add_message(struct mailmh_folder * folder, | |||
822 | free: | 826 | free: |
823 | free(tmpname); | 827 | free(tmpname); |
824 | err: | 828 | err: |
825 | return error; | 829 | return error; |
826 | } | 830 | } |
827 | 831 | ||
828 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, | 832 | int mailmh_folder_add_message(struct mailmh_folder * folder, |
829 | int fd) | 833 | const char * message, size_t size) |
834 | { | ||
835 | return mailmh_folder_add_message_uid(folder, message, size, NULL); | ||
836 | } | ||
837 | |||
838 | int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, | ||
839 | int fd, uint32_t * pindex) | ||
830 | { | 840 | { |
831 | char * message; | 841 | char * message; |
832 | struct stat buf; | 842 | struct stat buf; |
833 | int r; | 843 | int r; |
834 | 844 | ||
835 | #if 0 | 845 | #if 0 |
@@ -842,19 +852,25 @@ int mailmh_folder_add_message_file(struct mailmh_folder * folder, | |||
842 | return MAILMH_ERROR_FILE; | 852 | return MAILMH_ERROR_FILE; |
843 | 853 | ||
844 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 854 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
845 | if (message == MAP_FAILED) | 855 | if (message == MAP_FAILED) |
846 | return MAILMH_ERROR_FILE; | 856 | return MAILMH_ERROR_FILE; |
847 | 857 | ||
848 | r = mailmh_folder_add_message(folder, message, buf.st_size); | 858 | r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex); |
849 | 859 | ||
850 | munmap(message, buf.st_size); | 860 | munmap(message, buf.st_size); |
851 | 861 | ||
852 | return r; | 862 | return r; |
853 | } | 863 | } |
854 | 864 | ||
865 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, | ||
866 | int fd) | ||
867 | { | ||
868 | return mailmh_folder_add_message_file_uid(folder, fd, NULL); | ||
869 | } | ||
870 | |||
855 | int mailmh_folder_remove_message(struct mailmh_folder * folder, | 871 | int mailmh_folder_remove_message(struct mailmh_folder * folder, |
856 | uint32_t index) | 872 | uint32_t index) |
857 | { | 873 | { |
858 | char * filename; | 874 | char * filename; |
859 | struct mailmh_msg_info * msg_info; | 875 | struct mailmh_msg_info * msg_info; |
860 | int res; | 876 | int res; |
diff --git a/kmicromail/libetpan/mh/mailmh.h b/kmicromail/libetpan/mh/mailmh.h index 40432cb..00199b8 100644 --- a/kmicromail/libetpan/mh/mailmh.h +++ b/kmicromail/libetpan/mh/mailmh.h | |||
@@ -116,15 +116,22 @@ int mailmh_folder_get_message_filename(struct mailmh_folder * folder, | |||
116 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, | 116 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, |
117 | uint32_t index, int flags, int * result); | 117 | uint32_t index, int flags, int * result); |
118 | 118 | ||
119 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, | 119 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, |
120 | uint32_t index, size_t * result); | 120 | uint32_t index, size_t * result); |
121 | 121 | ||
122 | int mailmh_folder_add_message_uid(struct mailmh_folder * folder, | ||
123 | const char * message, size_t size, | ||
124 | uint32_t * pindex); | ||
125 | |||
122 | int mailmh_folder_add_message(struct mailmh_folder * folder, | 126 | int mailmh_folder_add_message(struct mailmh_folder * folder, |
123 | const char * message, size_t size); | 127 | const char * message, size_t size); |
124 | 128 | ||
129 | int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, | ||
130 | int fd, uint32_t * pindex); | ||
131 | |||
125 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, | 132 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, |
126 | int fd); | 133 | int fd); |
127 | 134 | ||
128 | int mailmh_folder_remove_message(struct mailmh_folder * folder, | 135 | int mailmh_folder_remove_message(struct mailmh_folder * folder, |
129 | uint32_t index); | 136 | uint32_t index); |
130 | 137 | ||
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c index 3025dcb..e48ec19 100644 --- a/kmicromail/libetpan/mime/mailmime_decode.c +++ b/kmicromail/libetpan/mime/mailmime_decode.c | |||
@@ -184,22 +184,32 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, | |||
184 | type = TYPE_WORD; | 184 | type = TYPE_WORD; |
185 | 185 | ||
186 | wordutf8 = NULL; | 186 | wordutf8 = NULL; |
187 | r = charconv(tocode, default_fromcode, raw_word, | 187 | r = charconv(tocode, default_fromcode, raw_word, |
188 | strlen(raw_word), &wordutf8); | 188 | strlen(raw_word), &wordutf8); |
189 | 189 | ||
190 | if (wordutf8 != NULL) { | 190 | switch (r) { |
191 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 191 | case MAIL_CHARCONV_ERROR_MEMORY: |
192 | free(wordutf8); | 192 | free(raw_word); |
193 | free(raw_word); | 193 | res = MAILIMF_ERROR_MEMORY; |
194 | res = MAILIMF_ERROR_MEMORY; | 194 | goto free; |
195 | goto free; | ||
196 | } | ||
197 | 195 | ||
196 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | ||
197 | case MAIL_CHARCONV_ERROR_CONV: | ||
198 | free(raw_word); | ||
199 | res = MAILIMF_ERROR_PARSE; | ||
200 | goto free; | ||
201 | } | ||
202 | |||
203 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | ||
198 | free(wordutf8); | 204 | free(wordutf8); |
205 | free(raw_word); | ||
206 | res = MAILIMF_ERROR_MEMORY; | ||
207 | goto free; | ||
199 | } | 208 | } |
209 | |||
200 | free(raw_word); | 210 | free(raw_word); |
201 | first = FALSE; | 211 | first = FALSE; |
202 | } | 212 | } |
203 | else if (r == MAILIMF_ERROR_PARSE) { | 213 | else if (r == MAILIMF_ERROR_PARSE) { |
204 | break; | 214 | break; |
205 | } | 215 | } |
diff --git a/kmicromail/libetpan/mime/mailmime_write.c b/kmicromail/libetpan/mime/mailmime_write.c index 5c3b1f7..208e3ba 100644 --- a/kmicromail/libetpan/mime/mailmime_write.c +++ b/kmicromail/libetpan/mime/mailmime_write.c | |||
@@ -438,13 +438,13 @@ mailmime_disposition_param_write(FILE * f, int * col, | |||
438 | 438 | ||
439 | case MAILMIME_DISPOSITION_PARM_READ_DATE: | 439 | case MAILMIME_DISPOSITION_PARM_READ_DATE: |
440 | len = strlen("read-date=") + strlen(param->pa_data.pa_read_date); | 440 | len = strlen("read-date=") + strlen(param->pa_data.pa_read_date); |
441 | break; | 441 | break; |
442 | 442 | ||
443 | case MAILMIME_DISPOSITION_PARM_SIZE: | 443 | case MAILMIME_DISPOSITION_PARM_SIZE: |
444 | snprintf(sizestr, 20, "%u", param->pa_data.pa_size); | 444 | snprintf(sizestr, 20, "%lu", (unsigned long) param->pa_data.pa_size); |
445 | len = strlen("size=") + strlen(sizestr); | 445 | len = strlen("size=") + strlen(sizestr); |
446 | break; | 446 | break; |
447 | 447 | ||
448 | case MAILMIME_DISPOSITION_PARM_PARAMETER: | 448 | case MAILMIME_DISPOSITION_PARM_PARAMETER: |
449 | len = strlen(param->pa_data.pa_parameter->pa_name) + 1 + | 449 | len = strlen(param->pa_data.pa_parameter->pa_name) + 1 + |
450 | strlen(param->pa_data.pa_parameter->pa_value); | 450 | strlen(param->pa_data.pa_parameter->pa_value); |
diff --git a/kmicromail/libetpan/smtp/mailsmtp.c b/kmicromail/libetpan/smtp/mailsmtp.c index b3be432..3ab1d11 100644 --- a/kmicromail/libetpan/smtp/mailsmtp.c +++ b/kmicromail/libetpan/smtp/mailsmtp.c | |||
@@ -189,12 +189,14 @@ int mailsmtp_helo(mailsmtp * session) | |||
189 | if (r == -1) | 189 | if (r == -1) |
190 | return MAILSMTP_ERROR_STREAM; | 190 | return MAILSMTP_ERROR_STREAM; |
191 | r = read_response(session); | 191 | r = read_response(session); |
192 | 192 | ||
193 | switch (r) { | 193 | switch (r) { |
194 | case 250: | 194 | case 250: |
195 | session->esmtp = 0; | ||
196 | session->auth = MAILSMTP_AUTH_NOT_CHECKED; | ||
195 | return MAILSMTP_NO_ERROR; | 197 | return MAILSMTP_NO_ERROR; |
196 | 198 | ||
197 | case 504: | 199 | case 504: |
198 | return MAILSMTP_ERROR_NOT_IMPLEMENTED; | 200 | return MAILSMTP_ERROR_NOT_IMPLEMENTED; |
199 | 201 | ||
200 | case 550: | 202 | case 550: |
diff --git a/kmicromail/libetpan/smtp/mailsmtp_helper.c b/kmicromail/libetpan/smtp/mailsmtp_helper.c index 32d6564..7995377 100644 --- a/kmicromail/libetpan/smtp/mailsmtp_helper.c +++ b/kmicromail/libetpan/smtp/mailsmtp_helper.c | |||
@@ -38,25 +38,21 @@ | |||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include "mail.h" | 39 | #include "mail.h" |
40 | 40 | ||
41 | int mailsmtp_init(mailsmtp * session) | 41 | int mailsmtp_init(mailsmtp * session) |
42 | { | 42 | { |
43 | int r; | 43 | int r; |
44 | session->esmtp = 0; | 44 | |
45 | r = mailesmtp_ehlo(session); | 45 | r = mailesmtp_ehlo(session); |
46 | 46 | ||
47 | if (r == MAILSMTP_NO_ERROR) { | 47 | if (r == MAILSMTP_NO_ERROR) |
48 | // session->esmtp = TRUE; | ||
49 | return MAILSMTP_NO_ERROR; | 48 | return MAILSMTP_NO_ERROR; |
50 | } | ||
51 | 49 | ||
52 | r = mailsmtp_helo(session); | 50 | r = mailsmtp_helo(session); |
53 | /* if (r == MAILSMTP_NO_ERROR) { */ | 51 | if (r == MAILSMTP_NO_ERROR) |
54 | /* session->esmtp = FALSE; */ | 52 | return MAILSMTP_NO_ERROR; |
55 | /* return MAILSMTP_NO_ERROR; */ | ||
56 | /* } */ | ||
57 | 53 | ||
58 | return r; | 54 | return r; |
59 | } | 55 | } |
60 | 56 | ||
61 | 57 | ||
62 | 58 | ||
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 3998abd..3b0ca1f 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -4,12 +4,14 @@ | |||
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | 8 | ||
9 | 9 | ||
10 | #include <qprogressbar.h> | ||
11 | #include <qapplication.h> | ||
10 | 12 | ||
11 | #include <kdecore/kstandarddirs.h> | 13 | #include <kdecore/kstandarddirs.h> |
12 | #include <qfile.h> | 14 | #include <qfile.h> |
13 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
14 | #include <stdlib.h> | 16 | #include <stdlib.h> |
15 | #include <libetpan/mailmime_content.h> | 17 | #include <libetpan/mailmime_content.h> |
@@ -137,39 +139,87 @@ QString AbstractMail::draftFolder() | |||
137 | /* temporary - will be removed when implemented in all classes */ | 139 | /* temporary - will be removed when implemented in all classes */ |
138 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 140 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
139 | { | 141 | { |
140 | } | 142 | } |
141 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 143 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
142 | { | 144 | { |
143 | qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 145 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
144 | 146 | // this is currently re-implemented in pop3wrapper and imapwrapper | |
147 | int iii = 0; | ||
148 | int count = target.count(); | ||
149 | QProgressBar bar( count,0 ); | ||
150 | bar.setCaption (("Removing mails - close to abort!") ); | ||
151 | int w = 300; | ||
152 | if ( QApplication::desktop()->width() < 320 ) | ||
153 | w = 220; | ||
154 | int h = bar.sizeHint().height() ; | ||
155 | int dw = QApplication::desktop()->width(); | ||
156 | int dh = QApplication::desktop()->height(); | ||
157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
158 | bar.show(); | ||
159 | int modulo = (count/10)+1; | ||
160 | int incCounter = 0; | ||
161 | while (iii < count ) { | ||
162 | if ( ! bar.isVisible() ) | ||
163 | return ; | ||
164 | if ( incCounter % modulo == 0 ) | ||
165 | bar.setProgress( incCounter ); | ||
166 | ++incCounter; | ||
167 | qApp->processEvents(); | ||
168 | RecMailP mail = (*target.at( iii )); | ||
169 | deleteMail(mail); | ||
170 | ++iii; | ||
171 | } | ||
145 | } | 172 | } |
146 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 173 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
147 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 174 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
148 | { | 175 | { |
149 | QValueList<RecMailP> t; | 176 | QValueList<RecMailP> t; |
150 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 177 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
151 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 178 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
152 | 179 | ||
153 | } | 180 | } |
154 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 181 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
155 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 182 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
156 | { | 183 | { |
157 | |||
158 | encodedString*st = 0; | 184 | encodedString*st = 0; |
159 | int iii = 0; | 185 | int iii = 0; |
160 | int count = t.count(); | 186 | int count = t.count(); |
187 | if ( count == 0 ) | ||
188 | return; | ||
189 | |||
190 | QProgressBar bar( count,0 ); | ||
191 | bar.setCaption (("Copying mails - close to abort!") ); | ||
192 | int w = 300; | ||
193 | if ( QApplication::desktop()->width() < 320 ) | ||
194 | w = 220; | ||
195 | int h = bar.sizeHint().height() ; | ||
196 | int dw = QApplication::desktop()->width(); | ||
197 | int dh = QApplication::desktop()->height(); | ||
198 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
199 | bar.show(); | ||
200 | int modulo = (count/10)+1; | ||
201 | int incCounter = 0; | ||
161 | while (iii < count ) { | 202 | while (iii < count ) { |
203 | if ( ! bar.isVisible() ) | ||
204 | return ; | ||
205 | if ( incCounter % modulo == 0 ) | ||
206 | bar.setProgress( incCounter ); | ||
207 | ++incCounter; | ||
208 | bar.raise(); | ||
209 | qApp->processEvents(); | ||
210 | //qDebug("copy "); | ||
162 | RecMailP r = (*t.at( iii )); | 211 | RecMailP r = (*t.at( iii )); |
163 | st = fetchRawBody(r); | 212 | st = fetchRawBody(r); |
164 | if (st) { | 213 | if (st) { |
165 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 214 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
166 | delete st; | 215 | delete st; |
167 | } | 216 | } |
168 | ++iii; | 217 | ++iii; |
169 | } | 218 | } |
219 | bar.hide(); | ||
170 | if (moveit) { | 220 | if (moveit) { |
171 | deleteMailList( t ); | 221 | deleteMailList( t ); |
172 | //deleteAllMail(fromFolder); | 222 | //deleteAllMail(fromFolder); |
173 | } | 223 | } |
174 | } | 224 | } |
175 | 225 | ||
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index bb8bbfc..11d3343 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -3,12 +3,13 @@ | |||
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | ||
9 | 10 | ||
10 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
11 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
12 | : AbstractMail() | 13 | : AbstractMail() |
13 | { | 14 | { |
14 | account = a; | 15 | account = a; |
@@ -868,27 +869,49 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which | |||
868 | } | 869 | } |
869 | target_part->setEncoding(encoding); | 870 | target_part->setEncoding(encoding); |
870 | target_part->setSize(which->bd_size); | 871 | target_part->setSize(which->bd_size); |
871 | } | 872 | } |
872 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 873 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
873 | { | 874 | { |
875 | //#if 0 | ||
874 | mailimap_flag_list*flist; | 876 | mailimap_flag_list*flist; |
875 | mailimap_set *set; | 877 | mailimap_set *set; |
876 | mailimap_store_att_flags * store_flags; | 878 | mailimap_store_att_flags * store_flags; |
877 | int err; | 879 | int err; |
878 | login(); | 880 | login(); |
881 | //#endif | ||
879 | if (!m_imap) { | 882 | if (!m_imap) { |
880 | return; | 883 | return; |
881 | } | 884 | } |
882 | int iii = 0; | 885 | int iii = 0; |
883 | int count = target.count(); | 886 | int count = target.count(); |
884 | qDebug("imap remove count %d ", count); | 887 | // qDebug("imap remove count %d ", count); |
888 | |||
889 | QProgressBar bar( count,0 ); | ||
890 | bar.setCaption (("Removing mails - close to abort!") ); | ||
891 | int w = 300; | ||
892 | if ( QApplication::desktop()->width() < 320 ) | ||
893 | w = 220; | ||
894 | int h = bar.sizeHint().height() ; | ||
895 | int dw = QApplication::desktop()->width(); | ||
896 | int dh = QApplication::desktop()->height(); | ||
897 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
898 | bar.show(); | ||
899 | int modulo = (count/10)+1; | ||
900 | int incCounter = 0; | ||
901 | |||
885 | while (iii < count ) { | 902 | while (iii < count ) { |
886 | qDebug("IMAP remove %d ", iii); | 903 | if ( ! bar.isVisible() ) |
904 | return ; | ||
905 | if ( incCounter % modulo == 0 ) | ||
906 | bar.setProgress( incCounter ); | ||
907 | ++incCounter; | ||
908 | qApp->processEvents(); | ||
887 | RecMailP mail = (*target.at( iii )); | 909 | RecMailP mail = (*target.at( iii )); |
888 | 910 | //#if 0 | |
911 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | ||
889 | err = selectMbox(mail->getMbox()); | 912 | err = selectMbox(mail->getMbox()); |
890 | if ( err != MAILIMAP_NO_ERROR ) { | 913 | if ( err != MAILIMAP_NO_ERROR ) { |
891 | return; | 914 | return; |
892 | } | 915 | } |
893 | flist = mailimap_flag_list_new_empty(); | 916 | flist = mailimap_flag_list_new_empty(); |
894 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 917 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
@@ -902,18 +925,25 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | |||
902 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 925 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
903 | return; | 926 | return; |
904 | } | 927 | } |
905 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 928 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
906 | /* should we realy do that at this moment? */ | 929 | /* should we realy do that at this moment? */ |
907 | 930 | ||
931 | // err = mailimap_expunge(m_imap); | ||
932 | //if (err != MAILIMAP_NO_ERROR) { | ||
933 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | ||
934 | // } | ||
935 | //#endif | ||
936 | //deleteMail( mail); | ||
937 | ++iii; | ||
938 | } | ||
939 | //qDebug("Deleting imap mails... "); | ||
908 | err = mailimap_expunge(m_imap); | 940 | err = mailimap_expunge(m_imap); |
909 | if (err != MAILIMAP_NO_ERROR) { | 941 | if (err != MAILIMAP_NO_ERROR) { |
910 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 942 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
911 | } | 943 | } |
912 | ++iii; | ||
913 | } | ||
914 | } | 944 | } |
915 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 945 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
916 | { | 946 | { |
917 | mailimap_flag_list*flist; | 947 | mailimap_flag_list*flist; |
918 | mailimap_set *set; | 948 | mailimap_set *set; |
919 | mailimap_store_att_flags * store_flags; | 949 | mailimap_store_att_flags * store_flags; |
@@ -942,13 +972,13 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) | |||
942 | /* should we realy do that at this moment? */ | 972 | /* should we realy do that at this moment? */ |
943 | 973 | ||
944 | err = mailimap_expunge(m_imap); | 974 | err = mailimap_expunge(m_imap); |
945 | if (err != MAILIMAP_NO_ERROR) { | 975 | if (err != MAILIMAP_NO_ERROR) { |
946 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 976 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
947 | } | 977 | } |
948 | qDebug("IMAPwrapper::deleteMail "); | 978 | //qDebug("IMAPwrapper::deleteMail 2"); |
949 | 979 | ||
950 | } | 980 | } |
951 | 981 | ||
952 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 982 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
953 | { | 983 | { |
954 | mailimap_flag_list*flist; | 984 | mailimap_flag_list*flist; |
@@ -1186,13 +1216,13 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1186 | } | 1216 | } |
1187 | int last = m_imap->imap_selection_info->sel_exists; | 1217 | int last = m_imap->imap_selection_info->sel_exists; |
1188 | set = mailimap_set_new_interval( 1, last ); | 1218 | set = mailimap_set_new_interval( 1, last ); |
1189 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1219 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1190 | mailimap_set_free( set ); | 1220 | mailimap_set_free( set ); |
1191 | if ( err != MAILIMAP_NO_ERROR ) { | 1221 | if ( err != MAILIMAP_NO_ERROR ) { |
1192 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1222 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); |
1193 | Global::statusMessage(error_msg); | 1223 | Global::statusMessage(error_msg); |
1194 | // odebug << error_msg << oendl; | 1224 | // odebug << error_msg << oendl; |
1195 | return; | 1225 | return; |
1196 | } | 1226 | } |
1197 | if (moveit) { | 1227 | if (moveit) { |
1198 | deleteAllMail(fromFolder); | 1228 | deleteAllMail(fromFolder); |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 7a84b30..0e6612c 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -5,12 +5,14 @@ | |||
5 | #include "logindialog.h" | 5 | #include "logindialog.h" |
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | 8 | ||
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qprogressbar.h> | ||
12 | #include <qapplication.h> | ||
11 | 13 | ||
12 | /* we don't fetch messages larger than 5 MB */ | 14 | /* we don't fetch messages larger than 5 MB */ |
13 | #define HARD_MSG_SIZE_LIMIT 5242880 | 15 | #define HARD_MSG_SIZE_LIMIT 5242880 |
14 | 16 | ||
15 | using namespace Opie::Core; | 17 | using namespace Opie::Core; |
16 | POP3wrapper::POP3wrapper( POP3account *a ) | 18 | POP3wrapper::POP3wrapper( POP3account *a ) |
@@ -190,24 +192,43 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | |||
190 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 192 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
191 | FolderP inb=new Folder("INBOX","/"); | 193 | FolderP inb=new Folder("INBOX","/"); |
192 | folders->append(inb); | 194 | folders->append(inb); |
193 | return folders; | 195 | return folders; |
194 | } | 196 | } |
195 | 197 | ||
196 | void POP3wrapper::deleteMailList(QValueList<RecMailP>&target) | 198 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 199 | { |
198 | login(); | 200 | login(); |
199 | if (!m_pop3) | 201 | if (!m_pop3) |
200 | return; | 202 | return; |
201 | int iii = 0; | 203 | int iii = 0; |
202 | int count = target.count(); | 204 | int count = target.count(); |
203 | while (iii < count ) { | 205 | QProgressBar bar( count,0 ); |
206 | bar.setCaption (("Removing mails - close to abort!") ); | ||
207 | int w = 300; | ||
208 | if ( QApplication::desktop()->width() < 320 ) | ||
209 | w = 220; | ||
210 | int h = bar.sizeHint().height() ; | ||
211 | int dw = QApplication::desktop()->width(); | ||
212 | int dh = QApplication::desktop()->height(); | ||
213 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
214 | bar.show(); | ||
215 | int modulo = (count/10)+1; | ||
216 | int incCounter = 0; | ||
217 | while (iii < count ) { | ||
218 | if ( ! bar.isVisible() ) | ||
219 | return ; | ||
220 | if ( incCounter % modulo == 0 ) | ||
221 | bar.setProgress( incCounter ); | ||
222 | ++incCounter; | ||
223 | qApp->processEvents(); | ||
224 | //qDebug("delete "); | ||
204 | RecMailP mail = (*target.at( iii )); | 225 | RecMailP mail = (*target.at( iii )); |
205 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 226 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
206 | if (err != MAIL_NO_ERROR) { | 227 | if (err != MAIL_NO_ERROR) { |
207 | Global::statusMessage(tr("error deleting mail")); | 228 | Global::statusMessage(tr("Error deleting mail")); |
208 | } | 229 | } |
209 | ++iii; | 230 | ++iii; |
210 | } | 231 | } |
211 | } | 232 | } |
212 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 233 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
213 | login(); | 234 | login(); |
@@ -230,13 +251,31 @@ int POP3wrapper::deleteAllMail(const FolderP&) { | |||
230 | uint32_t result = 0; | 251 | uint32_t result = 0; |
231 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 252 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
232 | if (err != MAIL_NO_ERROR) { | 253 | if (err != MAIL_NO_ERROR) { |
233 | Global::statusMessage(tr("Error getting folder info")); | 254 | Global::statusMessage(tr("Error getting folder info")); |
234 | return 0; | 255 | return 0; |
235 | } | 256 | } |
257 | QProgressBar bar( result,0 ); | ||
258 | bar.setCaption (("Deleting mails - close to abort!") ); | ||
259 | int w = 300; | ||
260 | if ( QApplication::desktop()->width() < 320 ) | ||
261 | w = 220; | ||
262 | int h = bar.sizeHint().height() ; | ||
263 | int dw = QApplication::desktop()->width(); | ||
264 | int dh = QApplication::desktop()->height(); | ||
265 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
266 | bar.show(); | ||
267 | int modulo = (result/10)+1; | ||
268 | int incCounter = 0; | ||
236 | for (unsigned int i = 0; i < result; ++i) { | 269 | for (unsigned int i = 0; i < result; ++i) { |
270 | if ( ! bar.isVisible() ) | ||
271 | return 0; | ||
272 | if ( incCounter % modulo == 0 ) | ||
273 | bar.setProgress( incCounter ); | ||
274 | ++incCounter; | ||
275 | qApp->processEvents(); | ||
237 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 276 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
238 | if (err != MAIL_NO_ERROR) { | 277 | if (err != MAIL_NO_ERROR) { |
239 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 278 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
240 | res=0; | 279 | res=0; |
241 | } | 280 | } |
242 | break; | 281 | break; |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index ee754a4..7c70942 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h | |||
@@ -21,14 +21,14 @@ public: | |||
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | /* mailbox will be ignored */ | 23 | /* mailbox will be ignored */ |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 25 | ||
26 | virtual void deleteMail(const RecMailP&mail); | 26 | virtual void deleteMail(const RecMailP&mail); |
27 | virtual void deleteMailList(const QValueList<RecMailP>&target); | ||
27 | virtual void answeredMail(const RecMailP&mail); | 28 | virtual void answeredMail(const RecMailP&mail); |
28 | virtual void deleteMailList(QValueList<RecMailP>&target); | ||
29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
30 | 30 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 31 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 32 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
33 | virtual void logout(); | 33 | virtual void logout(); |
34 | virtual MAILLIB::ATYPE getType()const; | 34 | virtual MAILLIB::ATYPE getType()const; |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 3fbdcec..251f15a 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -15,13 +15,13 @@ | |||
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <libmailwrapper/smtpwrapper.h> | 16 | #include <libmailwrapper/smtpwrapper.h> |
17 | #include <libmailwrapper/mailtypes.h> | 17 | #include <libmailwrapper/mailtypes.h> |
18 | #include <libmailwrapper/abstractmail.h> | 18 | #include <libmailwrapper/abstractmail.h> |
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | //#include <qpe/resource.h> | 20 | //#include <qpe/resource.h> |
21 | #include <qpe/qpeapplication.h> | 21 | //#include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | /* QT */ | 23 | /* QT */ |
24 | 24 | ||
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 27 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
@@ -234,26 +234,33 @@ void OpieMail::slotDeleteMail() | |||
234 | mail->Wrapper()->deleteMail( mail ); | 234 | mail->Wrapper()->deleteMail( mail ); |
235 | folderView->refreshCurrent(); | 235 | folderView->refreshCurrent(); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | void OpieMail::slotDeleteAllMail() | 238 | void OpieMail::slotDeleteAllMail() |
239 | { | 239 | { |
240 | if (!mailView->currentItem()) return; | 240 | |
241 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 241 | QValueList<RecMailP> t; |
242 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 242 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
243 | { | 243 | { |
244 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 244 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
245 | while ( item ) { | 245 | while ( item ) { |
246 | if ( item->isSelected() ) { | 246 | if ( item->isSelected() ) { |
247 | RecMailP mail = item->data(); | 247 | t.append( item->data() ); |
248 | mail->Wrapper()->deleteMail( mail ); | 248 | } |
249 | item = (MailListViewItem*)item->nextSibling(); | ||
249 | } | 250 | } |
250 | item = (MailListViewItem*)item->nextSibling(); | ||
251 | } | 251 | } |
252 | folderView->refreshCurrent(); | 252 | else |
253 | } | 253 | return; |
254 | if ( t.count() == 0 ) | ||
255 | return; | ||
256 | RecMailP mail = t.first(); | ||
257 | mail->Wrapper()->deleteMailList(t); | ||
258 | folderView->refreshCurrent(); | ||
259 | |||
260 | |||
254 | } | 261 | } |
255 | void OpieMail::clearSelection() | 262 | void OpieMail::clearSelection() |
256 | { | 263 | { |
257 | mailView->clearSelection(); | 264 | mailView->clearSelection(); |
258 | 265 | ||
259 | } | 266 | } |
@@ -273,16 +280,16 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | |||
273 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 280 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
274 | } else { | 281 | } else { |
275 | if (folderView->currentisDraft()) { | 282 | if (folderView->currentisDraft()) { |
276 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 283 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
277 | } | 284 | } |
278 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 285 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
279 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 286 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
280 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 287 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
281 | m->insertSeparator(); | 288 | m->insertSeparator(); |
282 | m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 289 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
283 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 290 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
284 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); | 291 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); |
285 | } | 292 | } |
286 | m->setFocus(); | 293 | m->setFocus(); |
287 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 294 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
288 | delete m; | 295 | delete m; |
@@ -347,33 +354,36 @@ void OpieMail::slotMoveCopyMail() | |||
347 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 354 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
348 | { | 355 | { |
349 | QMessageBox::critical(0,tr("Error creating new Folder"), | 356 | QMessageBox::critical(0,tr("Error creating new Folder"), |
350 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 357 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
351 | return; | 358 | return; |
352 | } | 359 | } |
360 | sels.hide(); | ||
361 | qApp->processEvents(); | ||
362 | // qDebug("hiding sels "); | ||
353 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 363 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
354 | folderView->refreshCurrent(); | 364 | folderView->refreshCurrent(); |
355 | } | 365 | } |
356 | 366 | ||
357 | void OpieMail::slotMoveCopyAllMail() | 367 | void OpieMail::slotMoveCopyAllMail() |
358 | { | 368 | { |
359 | 369 | ||
360 | if (!mailView->currentItem()) return; | 370 | if (!mailView->currentItem()) return; |
361 | QValueList<RecMailP> t; | 371 | QValueList<RecMailP> t; |
362 | if ( QMessageBox::warning(this, tr("Copy/Move all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 372 | // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
363 | { | 373 | { |
364 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 374 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
365 | while ( item ) { | 375 | while ( item ) { |
366 | if ( item->isSelected() ) { | 376 | if ( item->isSelected() ) { |
367 | t.append( item->data() ); | 377 | t.append( item->data() ); |
368 | } | 378 | } |
369 | item = (MailListViewItem*)item->nextSibling(); | 379 | item = (MailListViewItem*)item->nextSibling(); |
370 | } | 380 | } |
371 | } | 381 | } |
372 | else | 382 | // else |
373 | return; | 383 | // return; |
374 | if ( t.count() == 0 ) | 384 | if ( t.count() == 0 ) |
375 | return; | 385 | return; |
376 | RecMailP mail = t.first(); | 386 | RecMailP mail = t.first(); |
377 | AbstractMail*targetMail = 0; | 387 | AbstractMail*targetMail = 0; |
378 | QString targetFolder = ""; | 388 | QString targetFolder = ""; |
379 | Selectstore sels; | 389 | Selectstore sels; |
@@ -389,12 +399,15 @@ void OpieMail::slotMoveCopyAllMail() | |||
389 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 399 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
390 | { | 400 | { |
391 | QMessageBox::critical(0,tr("Error creating new Folder"), | 401 | QMessageBox::critical(0,tr("Error creating new Folder"), |
392 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 402 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
393 | return; | 403 | return; |
394 | } | 404 | } |
405 | sels.hide(); | ||
406 | qApp->processEvents(); | ||
407 | //qDebug("hiding sels "); | ||
395 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 408 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
396 | folderView->refreshCurrent(); | 409 | folderView->refreshCurrent(); |
397 | } | 410 | } |
398 | 411 | ||
399 | void OpieMail::reEditMail() | 412 | void OpieMail::reEditMail() |
400 | { | 413 | { |