summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libetpan/generic/imapdriver.c28
-rw-r--r--kmicromail/libetpan/generic/imapdriver_cached.c16
-rw-r--r--kmicromail/libetpan/generic/imapdriver_cached_message.c2
-rw-r--r--kmicromail/libetpan/generic/imapdriver_tools.c30
-rw-r--r--kmicromail/libetpan/generic/imapdriver_tools.h3
-rw-r--r--kmicromail/libetpan/generic/imapstorage.c2
-rw-r--r--kmicromail/libetpan/generic/maildirdriver.c51
-rw-r--r--kmicromail/libetpan/generic/maildirdriver_cached.c78
-rw-r--r--kmicromail/libetpan/generic/maildirdriver_cached_message.c88
-rw-r--r--kmicromail/libetpan/generic/maildirdriver_message.c58
-rw-r--r--kmicromail/libetpan/generic/maildirstorage.c3
-rw-r--r--kmicromail/libetpan/generic/maildirstorage.h2
-rw-r--r--kmicromail/libetpan/generic/maildriver.c10
-rw-r--r--kmicromail/libetpan/generic/maildriver.h3
-rw-r--r--kmicromail/libetpan/generic/maildriver_types.h2
-rw-r--r--kmicromail/libetpan/generic/mailfolder.c7
-rw-r--r--kmicromail/libetpan/generic/mailfolder.h3
-rw-r--r--kmicromail/libetpan/generic/mailstorage.c7
-rw-r--r--kmicromail/libetpan/generic/mailstorage.h3
-rw-r--r--kmicromail/libetpan/generic/mboxdriver.c10
-rw-r--r--kmicromail/libetpan/generic/mboxdriver_cached.c90
-rw-r--r--kmicromail/libetpan/generic/mboxdriver_cached_message.c3
-rw-r--r--kmicromail/libetpan/generic/mboxdriver_message.c6
-rw-r--r--kmicromail/libetpan/generic/mboxdriver_tools.c3
-rw-r--r--kmicromail/libetpan/generic/mboxstorage.c2
-rw-r--r--kmicromail/libetpan/generic/mhdriver.c9
-rw-r--r--kmicromail/libetpan/generic/mhdriver_cached.c93
-rw-r--r--kmicromail/libetpan/generic/mhdriver_cached_message.c4
-rw-r--r--kmicromail/libetpan/generic/mhdriver_message.c5
-rw-r--r--kmicromail/libetpan/generic/mhdriver_tools.c5
-rw-r--r--kmicromail/libetpan/generic/mhstorage.c2
-rw-r--r--kmicromail/libetpan/generic/nntpdriver.c10
-rw-r--r--kmicromail/libetpan/generic/nntpdriver_cached.c10
-rw-r--r--kmicromail/libetpan/generic/nntpstorage.c2
-rw-r--r--kmicromail/libetpan/generic/pop3driver.c1
-rw-r--r--kmicromail/libetpan/generic/pop3driver_cached.c44
-rw-r--r--kmicromail/libetpan/generic/pop3driver_message.c36
-rw-r--r--kmicromail/libetpan/generic/pop3storage.c2
-rw-r--r--kmicromail/libetpan/imap/mailimap.c2
-rw-r--r--kmicromail/libetpan/imap/mailimap_keywords.c2
-rw-r--r--kmicromail/libetpan/imf/mailimf.c2
-rw-r--r--kmicromail/libetpan/include/libetpan/libetpan.h12
-rw-r--r--kmicromail/libetpan/include/libetpan/maildir.h7
-rw-r--r--kmicromail/libetpan/include/libetpan/maildirstorage.h2
-rw-r--r--kmicromail/libetpan/include/libetpan/maildriver.h3
-rw-r--r--kmicromail/libetpan/include/libetpan/maildriver_types.h2
-rw-r--r--kmicromail/libetpan/include/libetpan/mailfolder.h3
-rw-r--r--kmicromail/libetpan/include/libetpan/mailmbox.h4
-rw-r--r--kmicromail/libetpan/include/libetpan/mailmbox_types.h1
-rw-r--r--kmicromail/libetpan/include/libetpan/mailmh.h7
-rw-r--r--kmicromail/libetpan/include/libetpan/mailstorage.h3
-rw-r--r--kmicromail/libetpan/maildir/maildir.c29
-rw-r--r--kmicromail/libetpan/maildir/maildir.h7
-rw-r--r--kmicromail/libetpan/mbox/mailmbox.c19
-rw-r--r--kmicromail/libetpan/mbox/mailmbox.h4
-rw-r--r--kmicromail/libetpan/mbox/mailmbox_types.c1
-rw-r--r--kmicromail/libetpan/mbox/mailmbox_types.h1
-rw-r--r--kmicromail/libetpan/mh/mailmh.c26
-rw-r--r--kmicromail/libetpan/mh/mailmh.h7
-rw-r--r--kmicromail/libetpan/mime/mailmime_decode.c16
-rw-r--r--kmicromail/libetpan/mime/mailmime_write.c2
-rw-r--r--kmicromail/libetpan/smtp/mailsmtp.c2
-rw-r--r--kmicromail/libetpan/smtp/mailsmtp_helper.c12
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp56
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp46
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp43
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.h2
-rw-r--r--kmicromail/opiemail.cpp35
68 files changed, 1002 insertions, 89 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
@@ -100,6 +100,8 @@ static int imapdriver_subscribe_folder(mailsession * session, char * mb);
static int imapdriver_unsubscribe_folder(mailsession * session, char * mb);
static int imapdriver_append_message(mailsession * session,
char * message, size_t size);
+static int imapdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
static int imapdriver_copy_message(mailsession * session,
uint32_t num, char * mb);
@@ -157,6 +159,7 @@ static mailsession_driver local_imap_session_driver = {
.sess_unsubscribe_folder = imapdriver_unsubscribe_folder,
.sess_append_message = imapdriver_append_message,
+ .sess_append_message_flags = imapdriver_append_message_flags,
.sess_copy_message = imapdriver_copy_message,
.sess_move_message = NULL,
@@ -771,6 +774,31 @@ static int imapdriver_append_message(mailsession * session,
return imap_error_to_mail_error(r);
}
+static int imapdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ struct mailimap_flag_list * flag_list;
+ int r;
+
+ if (flags != NULL) {
+ r = imap_flags_to_imap_flags(flags, &flag_list);
+ if (r != MAIL_NO_ERROR)
+ return r;
+ }
+ else {
+ flag_list = NULL;
+ }
+
+ r = mailimap_append(get_imap_session(session),
+ get_data(session)->imap_mailbox,
+ flag_list, NULL, message, size);
+
+ if (flag_list != NULL)
+ mailimap_flag_list_free(flag_list);
+
+ return imap_error_to_mail_error(r);
+}
+
static int imapdriver_copy_message(mailsession * session,
uint32_t num, char * mb)
{
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
@@ -105,6 +105,8 @@ static int imapdriver_cached_unsubscribe_folder(mailsession * session,
char * mb);
static int imapdriver_cached_append_message(mailsession * session,
char * message, size_t size);
+static int imapdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
static int imapdriver_cached_copy_message(mailsession * session,
uint32_t num, char * mb);
@@ -165,6 +167,7 @@ static mailsession_driver local_imap_cached_session_driver = {
.sess_unsubscribe_folder = imapdriver_cached_unsubscribe_folder,
.sess_append_message = imapdriver_cached_append_message,
+ .sess_append_message_flags = imapdriver_cached_append_message_flags,
.sess_copy_message = imapdriver_cached_copy_message,
.sess_move_message = NULL,
@@ -776,6 +779,19 @@ static int imapdriver_cached_append_message(mailsession * session,
return r;
}
+static int imapdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ int r;
+
+ r = mailsession_append_message_flags(get_ancestor(session),
+ message, size, flags);
+
+ check_for_uid_cache(session);
+
+ return r;
+}
+
static int imapdriver_cached_copy_message(mailsession * session,
uint32_t num, char * 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
@@ -212,7 +212,7 @@ static void generate_key_from_mime_section(char * key, size_t size,
mmap_string_free(gstr);
free_section:
mailmime_section_free(part);
- err:
+ err:;
}
static void generate_key_from_section(char * key, size_t size,
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
@@ -3107,12 +3107,11 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn,
return MAIL_ERROR_MEMORY;
}
-static int flags_to_imap_flags(struct mail_flags * flags,
- struct mailimap_store_att_flags ** result)
+int imap_flags_to_imap_flags(struct mail_flags * flags,
+ struct mailimap_flag_list ** result)
{
struct mailimap_flag * flag;
struct mailimap_flag_list * flag_list;
- struct mailimap_store_att_flags * att_flags;
int res;
clistiter * cur;
int r;
@@ -3240,6 +3239,31 @@ static int flags_to_imap_flags(struct mail_flags * flags,
}
}
+ * result = flag_list;
+
+ return MAIL_NO_ERROR;
+
+ free_flag_list:
+ mailimap_flag_list_free(flag_list);
+ err:
+ return res;
+}
+
+static int flags_to_imap_flags(struct mail_flags * flags,
+ struct mailimap_store_att_flags ** result)
+{
+ struct mailimap_flag_list * flag_list;
+ struct mailimap_store_att_flags * att_flags;
+ int res;
+ int r;
+
+ r = imap_flags_to_imap_flags(flags,
+ &flag_list);
+ if (r != MAIL_NO_ERROR) {
+ res = r;
+ goto err;
+ }
+
att_flags = mailimap_store_att_flags_new_set_flags_silent(flag_list);
if (att_flags == NULL) {
res = MAIL_ERROR_MEMORY;
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
@@ -106,6 +106,9 @@ imapdriver_write_cached_envelope(struct mail_cache_db * cache_db,
mailsession * session, mailmessage * msg,
struct mailimf_fields * fields);
+int imap_flags_to_imap_flags(struct mail_flags * flags,
+ struct mailimap_flag_list ** result);
+
#ifdef __cplusplus
}
#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
@@ -71,7 +71,7 @@ int imap_mailstorage_init(struct mailstorage * storage,
{
struct imap_mailstorage * imap_storage;
- imap_storage = malloc(sizeof(struct imap_mailstorage));
+ imap_storage = malloc(sizeof(* imap_storage));
if (imap_storage == NULL)
goto err;
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
@@ -85,6 +85,9 @@ static int messages_number(mailsession * session, char * mb,
static int append_message(mailsession * session,
char * message, size_t size);
+static int append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int get_messages_list(mailsession * session,
struct mailmessage_list ** result);
@@ -129,6 +132,7 @@ static mailsession_driver local_maildir_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = append_message,
+ .sess_append_message_flags = append_message_flags,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -355,6 +359,7 @@ static int recent_number(mailsession * session, char * mb,
static int append_message(mailsession * session,
char * message, size_t size)
{
+#if 0
struct maildir * md;
int r;
@@ -367,6 +372,52 @@ static int append_message(mailsession * session,
return maildirdriver_maildir_error_to_mail_error(r);
return MAIL_NO_ERROR;
+#endif
+
+ return append_message_flags(session, message, size, NULL);
+}
+
+static int append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ struct maildir * md;
+ int r;
+ char uid[PATH_MAX];
+ struct maildir_msg * md_msg;
+ chashdatum key;
+ chashdatum value;
+ uint32_t md_flags;
+
+ md = get_maildir_session(session);
+ if (md == NULL)
+ return MAIL_ERROR_BAD_STATE;
+
+ r = maildir_message_add_uid(md, message, size,
+ uid, sizeof(uid));
+ if (r != MAILDIR_NO_ERROR)
+ return maildirdriver_maildir_error_to_mail_error(r);
+
+ if (flags == NULL)
+ goto exit;
+
+ key.data = uid;
+ key.len = strlen(uid);
+ r = chash_get(md->mdir_msg_hash, &key, &value);
+ if (r < 0)
+ goto exit;
+
+ md_msg = value.data;
+
+ md_flags = maildirdriver_flags_to_maildir_flags(flags->fl_flags);
+
+ r = maildir_message_change_flags(md, uid, md_flags);
+ if (r != MAILDIR_NO_ERROR)
+ goto exit;
+
+ return MAIL_NO_ERROR;
+
+ exit:
+ return MAIL_NO_ERROR;
}
static int get_messages_list(mailsession * session,
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
@@ -86,6 +86,9 @@ static int messages_number(mailsession * session, char * mb,
static int append_message(mailsession * session,
char * message, size_t size);
+static int append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int get_messages_list(mailsession * session,
struct mailmessage_list ** result);
@@ -133,6 +136,7 @@ static mailsession_driver local_maildir_cached_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = append_message,
+ .sess_append_message_flags = append_message_flags,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -454,9 +458,83 @@ static int recent_number(mailsession * session, char * mb,
static int append_message(mailsession * session,
char * message, size_t size)
{
+#if 0
return mailsession_append_message(get_ancestor(session), message, size);
+#endif
+ return append_message_flags(session, message, size, NULL);
}
+static int append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ struct maildir * md;
+ int r;
+ char uid[PATH_MAX];
+ struct maildir_msg * md_msg;
+ chashdatum key;
+ chashdatum value;
+ uint32_t md_flags;
+ struct mail_cache_db * cache_db_flags;
+ char filename_flags[PATH_MAX];
+ MMAPString * mmapstr;
+ struct maildir_cached_session_state_data * data;
+
+ md = get_maildir_session(session);
+ if (md == NULL)
+ return MAIL_ERROR_BAD_STATE;
+
+ r = maildir_message_add_uid(md, message, size,
+ uid, sizeof(uid));
+ if (r != MAILDIR_NO_ERROR)
+ return maildirdriver_maildir_error_to_mail_error(r);
+
+ if (flags == NULL)
+ goto exit;
+
+ data = get_cached_data(session);
+
+ snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s",
+ data->md_flags_directory, MAIL_DIR_SEPARATOR, data->md_quoted_mb,
+ MAIL_DIR_SEPARATOR, FLAGS_NAME);
+
+ r = mail_cache_db_open_lock(filename_flags, &cache_db_flags);
+ if (r < 0)
+ goto exit;
+
+ mmapstr = mmap_string_new("");
+ if (mmapstr == NULL)
+ goto close_db_flags;
+
+ r = write_cached_flags(cache_db_flags, mmapstr,
+ uid, flags);
+
+ mmap_string_free(mmapstr);
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+
+ if (r != MAIL_NO_ERROR)
+ goto exit;
+
+ key.data = uid;
+ key.len = strlen(uid);
+ r = chash_get(md->mdir_msg_hash, &key, &value);
+ if (r < 0)
+ goto exit;
+
+ md_msg = value.data;
+
+ md_flags = maildirdriver_flags_to_maildir_flags(flags->fl_flags);
+
+ r = maildir_message_change_flags(md, uid, md_flags);
+ if (r != MAILDIR_NO_ERROR)
+ goto exit;
+
+ return MAIL_NO_ERROR;
+
+ close_db_flags:
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+ exit:
+ return MAIL_NO_ERROR;
+}
#define UID_NAME "uid.db"
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
@@ -39,6 +39,8 @@
#include "maildirdriver.h"
#include "maildir.h"
#include "generic_cache.h"
+#include "mail_cache_db.h"
+#include "maildirdriver_tools.h"
#include <unistd.h>
#include <sys/mman.h>
@@ -48,6 +50,9 @@
#include <string.h>
#include <stdlib.h>
+static int get_flags(mailmessage * msg_info,
+ struct mail_flags ** result);
+
static int prefetch(mailmessage * msg_info);
static void prefetch_free(struct generic_message_t * msg);
@@ -78,7 +83,7 @@ static mailmessage_driver local_maildir_cached_message_driver = {
.msg_fetch_section_body = mailmessage_generic_fetch_section_body,
.msg_fetch_envelope = mailmessage_generic_fetch_envelope,
- .msg_get_flags = NULL,
+ .msg_get_flags = get_flags,
};
mailmessage_driver * maildir_cached_message_driver =
@@ -246,3 +251,84 @@ static void check(mailmessage * msg_info)
/* ignore errors */
}
}
+
+#define FLAGS_NAME "flags.db"
+
+static int get_flags(mailmessage * msg_info,
+ struct mail_flags ** result)
+{
+ struct mail_cache_db * cache_db_flags;
+ chashdatum key;
+ chashdatum value;
+ struct maildir * md;
+ struct mail_flags * flags;
+ struct maildir_cached_session_state_data * data;
+ struct maildir_msg * md_msg;
+ int r;
+ uint32_t driver_flags;
+ char filename_flags[PATH_MAX];
+ char keyname[PATH_MAX];
+ MMAPString * mmapstr;
+
+ if (msg_info->msg_flags != NULL) {
+ * result = msg_info->msg_flags;
+ return MAIL_NO_ERROR;
+ }
+
+ data = get_cached_session_data(msg_info);
+ flags = mail_flags_store_get(data->md_flags_store,
+ msg_info->msg_index);
+ if (flags != NULL) {
+ msg_info->msg_flags = flags;
+ * result = msg_info->msg_flags;
+ return MAIL_NO_ERROR;
+ }
+
+ snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s",
+ data->md_flags_directory, MAIL_DIR_SEPARATOR, data->md_quoted_mb,
+ MAIL_DIR_SEPARATOR, FLAGS_NAME);
+
+ r = mail_cache_db_open_lock(filename_flags, &cache_db_flags);
+ if (r < 0)
+ return MAIL_ERROR_FILE;
+
+ snprintf(keyname, PATH_MAX, "%s-flags", msg_info->msg_uid);
+
+ mmapstr = mmap_string_new("");
+ if (mmapstr == NULL) {
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+ return MAIL_ERROR_MEMORY;
+ }
+
+ r = generic_cache_flags_read(cache_db_flags, mmapstr, keyname, &flags);
+ mmap_string_free(mmapstr);
+
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+
+ if (r != MAIL_NO_ERROR) {
+ flags = mail_flags_new_empty();
+ if (flags == NULL)
+ return MAIL_ERROR_MEMORY;
+ }
+
+ md = get_maildir_session(msg_info);
+ if (md == NULL)
+ return MAIL_ERROR_BAD_STATE;
+
+ key.data = msg_info->msg_uid;
+ key.len = strlen(msg_info->msg_uid);
+ r = chash_get(md->mdir_msg_hash, &key, &value);
+ if (r < 0)
+ return MAIL_ERROR_MSG_NOT_FOUND;
+
+ md_msg = value.data;
+
+ driver_flags = maildirdriver_maildir_flags_to_flags(md_msg->msg_flags);
+
+ flags->fl_flags = driver_flags;
+ msg_info->msg_flags = flags;
+
+ * result = msg_info->msg_flags;
+
+ return MAIL_NO_ERROR;
+}
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
@@ -34,6 +34,7 @@
*/
#include "maildirdriver_message.h"
+#include "maildirdriver_tools.h"
#include "mailmessage_tools.h"
#include "maildirdriver.h"
@@ -48,6 +49,9 @@
#include <string.h>
#include <stdlib.h>
+static int get_flags(mailmessage * msg_info,
+ struct mail_flags ** result);
+
static int prefetch(mailmessage * msg_info);
static void prefetch_free(struct generic_message_t * msg);
@@ -78,7 +82,7 @@ static mailmessage_driver local_maildir_message_driver = {
.msg_fetch_section_body = mailmessage_generic_fetch_section_body,
.msg_fetch_envelope = mailmessage_generic_fetch_envelope,
- .msg_get_flags = NULL,
+ .msg_get_flags = get_flags,
};
mailmessage_driver * maildir_message_driver = &local_maildir_message_driver;
@@ -197,3 +201,55 @@ static void check(mailmessage * msg_info)
/* ignore errors */
}
}
+
+static int get_flags(mailmessage * msg_info,
+ struct mail_flags ** result)
+{
+ chashdatum key;
+ chashdatum value;
+ struct maildir * md;
+ struct mail_flags * flags;
+ struct maildir_session_state_data * data;
+ struct maildir_msg * md_msg;
+ int r;
+ uint32_t driver_flags;
+ clist * ext;
+
+ if (msg_info->msg_flags != NULL) {
+ * result = msg_info->msg_flags;
+ return MAIL_NO_ERROR;
+ }
+
+ data = get_session_data(msg_info);
+ flags = mail_flags_store_get(data->md_flags_store,
+ msg_info->msg_index);
+ if (flags != NULL) {
+ msg_info->msg_flags = flags;
+ * result = msg_info->msg_flags;
+ return MAIL_NO_ERROR;
+ }
+
+ md = get_maildir_session(msg_info);
+ if (md == NULL)
+ return MAIL_ERROR_BAD_STATE;
+
+ key.data = msg_info->msg_uid;
+ key.len = strlen(msg_info->msg_uid);
+ r = chash_get(md->mdir_msg_hash, &key, &value);
+ if (r < 0)
+ return MAIL_ERROR_MSG_NOT_FOUND;
+
+ md_msg = value.data;
+
+ driver_flags = maildirdriver_maildir_flags_to_flags(md_msg->msg_flags);
+
+ ext = clist_new();
+ if (ext == NULL)
+ return MAIL_ERROR_MEMORY;
+
+ msg_info->msg_flags = mail_flags_new(driver_flags, ext);
+
+ * result = msg_info->msg_flags;
+
+ return MAIL_NO_ERROR;
+}
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
@@ -33,6 +33,7 @@
* $Id$
*/
+#include "maildirstorage.h"
#include "mailstorage.h"
#include "mail.h"
@@ -65,7 +66,7 @@ int maildir_mailstorage_init(struct mailstorage * storage,
{
struct maildir_mailstorage * maildir_storage;
- maildir_storage = malloc(sizeof(struct maildir_mailstorage));
+ maildir_storage = malloc(sizeof(* maildir_storage));
if (maildir_storage == NULL)
goto err;
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
@@ -44,7 +44,7 @@ extern "C" {
#endif
/*
- maildir_mailstorage_init is the constructor for a mbox storage.
+ maildir_mailstorage_init is the constructor for a maildir storage.
@param storage this is the storage to initialize.
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
@@ -282,6 +282,16 @@ int mailsession_append_message(mailsession * session,
return session->sess_driver->sess_append_message(session, message, size);
}
+int mailsession_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ if (session->sess_driver->sess_append_message_flags == NULL)
+ return MAIL_ERROR_NOT_IMPLEMENTED;
+
+ return session->sess_driver->sess_append_message_flags(session,
+ message, size, flags);
+}
+
int mailsession_copy_message(mailsession * session,
uint32_t num, char * mb)
{
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
@@ -400,6 +400,9 @@ int mailsession_unsubscribe_folder(mailsession * session, char * mb);
int mailsession_append_message(mailsession * session,
char * message, size_t size);
+int mailsession_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
/*
NOTE: some drivers does not implement this
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
@@ -507,6 +507,8 @@ struct mailsession_driver {
int (* sess_append_message)(mailsession * session,
char * message, size_t size);
+ int (* sess_append_message_flags)(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
int (* sess_copy_message)(mailsession * session,
uint32_t num, char * mb);
int (* sess_move_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
@@ -32,6 +32,13 @@ int mailfolder_append_message(struct mailfolder * folder,
return mailsession_append_message(folder->fld_session, message, size);
}
+int mailfolder_append_message_flags(struct mailfolder * folder,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ return mailsession_append_message_flags(folder->fld_session, message,
+ size, flags);
+}
+
int mailfolder_get_messages_list(struct mailfolder * folder,
struct mailmessage_list ** result)
{
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
@@ -17,6 +17,9 @@ int mailfolder_status(struct mailfolder * folder,
int mailfolder_append_message(struct mailfolder * folder,
char * message, size_t size);
+int mailfolder_append_message_flags(struct mailfolder * folder,
+ char * message, size_t size, struct mail_flags * flags);
+
int mailfolder_get_messages_list(struct mailfolder * folder,
struct mailmessage_list ** result);
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
@@ -323,6 +323,13 @@ void mailstorage_disconnect(struct mailstorage * storage)
storage->sto_session = NULL;
}
+
+int mailstorage_noop(struct mailstorage * storage)
+{
+ return mailsession_noop(storage->sto_session);
+}
+
+
static int mailstorage_get_folder(struct mailstorage * storage,
char * pathname, mailsession ** result)
{
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
@@ -71,6 +71,8 @@ int mailstorage_connect(struct mailstorage * storage);
void mailstorage_disconnect(struct mailstorage * storage);
+int mailstorage_noop(struct mailstorage * storage);
+
/* folder */
@@ -88,7 +90,6 @@ int mailfolder_connect(struct mailfolder * folder);
void mailfolder_disconnect(struct mailfolder * folder);
-
#ifdef __cplusplus
}
#endif
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
@@ -77,6 +77,9 @@ static int mboxdriver_messages_number(mailsession * session, char * mb,
static int mboxdriver_append_message(mailsession * session,
char * message, size_t size);
+static int mboxdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int mboxdriver_get_messages_list(mailsession * session,
struct mailmessage_list ** result);
@@ -126,6 +129,7 @@ static mailsession_driver local_mbox_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = mboxdriver_append_message,
+ .sess_append_message_flags = mboxdriver_append_message_flags,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -344,6 +348,12 @@ static int mboxdriver_append_message(mailsession * session,
}
}
+static int mboxdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ return mboxdriver_append_message(session, message, size);
+}
+
static int mboxdriver_get_messages_list(mailsession * session,
struct mailmessage_list ** result)
{
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
@@ -86,6 +86,9 @@ static int mboxdriver_cached_unseen_number(mailsession * session, char * mb,
static int mboxdriver_cached_append_message(mailsession * session,
char * message, size_t size);
+static int mboxdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int
mboxdriver_cached_get_messages_list(mailsession * session,
struct mailmessage_list ** result);
@@ -137,6 +140,8 @@ static mailsession_driver local_mbox_cached_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = mboxdriver_cached_append_message,
+ .sess_append_message_flags = mboxdriver_cached_append_message_flags,
+
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -906,7 +911,84 @@ static int mboxdriver_cached_unseen_number(mailsession * session, char * mb,
static int mboxdriver_cached_append_message(mailsession * session,
char * message, size_t size)
{
- return mailsession_append_message(get_ancestor(session), message, size);
+ return mboxdriver_cached_append_message_flags(session,
+ message, size, NULL);
+}
+
+static int mboxdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ int r;
+ struct mailmbox_folder * folder;
+ struct mbox_cached_session_state_data * data;
+ unsigned int uid;
+ struct mailmbox_msg_info * msg_info;
+ chashdatum key;
+ chashdatum value;
+ struct mail_cache_db * cache_db_flags;
+ char filename_flags[PATH_MAX];
+ MMAPString * mmapstr;
+ char keyname[PATH_MAX];
+
+ folder = get_mbox_session(session);
+ if (folder == NULL)
+ return MAIL_ERROR_APPEND;
+
+ r = mailmbox_append_message_uid(folder, message, size, &uid);
+
+ switch (r) {
+ case MAILMBOX_ERROR_FILE:
+ return MAIL_ERROR_DISKSPACE;
+ case MAILMBOX_NO_ERROR:
+ break;
+ default:
+ return mboxdriver_mbox_error_to_mail_error(r);
+ }
+
+ /* could store in flags store instead */
+
+ if (flags == NULL)
+ goto exit;
+
+ key.data = &uid;
+ key.len = sizeof(uid);
+ r = chash_get(folder->mb_hash, &key, &value);
+ if (r < 0)
+ goto exit;
+
+ msg_info = value.data;
+
+ data = get_cached_data(session);
+
+ snprintf(filename_flags, PATH_MAX, "%s%c%s%c%s",
+ data->mbox_flags_directory, MAIL_DIR_SEPARATOR, data->mbox_quoted_mb,
+ MAIL_DIR_SEPARATOR, FLAGS_NAME);
+
+ r = mail_cache_db_open_lock(filename_flags, &cache_db_flags);
+ if (r < 0)
+ goto exit;
+
+ mmapstr = mmap_string_new("");
+ if (mmapstr == NULL)
+ goto close_db_flags;
+
+ snprintf(keyname, PATH_MAX, "%u-%lu", uid,
+ (unsigned long) msg_info->msg_body_len);
+
+ r = mboxdriver_write_cached_flags(cache_db_flags, mmapstr, keyname, flags);
+
+ mmap_string_free(mmapstr);
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+
+ if (r != MAIL_NO_ERROR)
+ goto exit;
+
+ return MAIL_NO_ERROR;
+
+ close_db_flags:
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+ exit:
+ return MAIL_NO_ERROR;
}
static int
@@ -960,7 +1042,8 @@ get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr,
info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-envelope", num, info->msg_body_len);
+ snprintf(keyname, PATH_MAX, "%u-%lu-envelope", num,
+ (unsigned long) info->msg_body_len);
r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields);
if (r != MAIL_NO_ERROR) {
@@ -1006,7 +1089,8 @@ write_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr,
info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-envelope", num, info->msg_body_len);
+ snprintf(keyname, PATH_MAX, "%u-%lu-envelope", num,
+ (unsigned long) info->msg_body_len);
r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields);
if (r != MAIL_NO_ERROR) {
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
@@ -182,7 +182,8 @@ static int mbox_initialize(mailmessage * msg_info)
info = (struct mailmbox_msg_info *) data.data;
- snprintf(static_uid, PATH_MAX, "%u-%u", msg_info->msg_index, info->msg_body_len);
+ snprintf(static_uid, PATH_MAX, "%u-%lu",
+ msg_info->msg_index, (unsigned long) info->msg_body_len);
uid = strdup(static_uid);
if (uid == NULL) {
res = MAIL_ERROR_MEMORY;
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
@@ -33,7 +33,7 @@
* $Id$
*/
-#include "mhdriver_message.h"
+#include "mboxdriver_message.h"
#include "mailmessage_tools.h"
#include "mboxdriver_tools.h"
@@ -156,8 +156,8 @@ static int mbox_initialize(mailmessage * msg_info)
info = data.data;
- snprintf(static_uid, PATH_MAX, "%u-%u",
- msg_info->msg_index, info->msg_body_len);
+ snprintf(static_uid, PATH_MAX, "%u-%lu",
+ msg_info->msg_index, (unsigned long) info->msg_body_len);
uid = strdup(static_uid);
if (uid == NULL) {
res = MAIL_ERROR_MEMORY;
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
@@ -217,7 +217,8 @@ mboxdriver_get_cached_flags(struct mail_cache_db * cache_db,
info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-flags", num, info->msg_body_len);
+ snprintf(keyname, PATH_MAX, "%u-%lu-flags", num,
+ (unsigned long) info->msg_body_len);
r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags);
if (r != MAIL_NO_ERROR) {
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
@@ -65,7 +65,7 @@ int mbox_mailstorage_init(struct mailstorage * storage,
{
struct mbox_mailstorage * mbox_storage;
- mbox_storage = malloc(sizeof(struct mbox_mailstorage));
+ mbox_storage = malloc(sizeof(* mbox_storage));
if (mbox_storage == NULL)
goto err;
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
@@ -89,6 +89,8 @@ static int mhdriver_unsubscribe_folder(mailsession * session, char * mb);
static int mhdriver_append_message(mailsession * session,
char * message, size_t size);
+static int mhdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
static int mhdriver_copy_message(mailsession * session,
uint32_t num, char * mb);
@@ -140,6 +142,7 @@ static mailsession_driver local_mh_session_driver = {
.sess_unsubscribe_folder = mhdriver_unsubscribe_folder,
.sess_append_message = mhdriver_append_message,
+ .sess_append_message_flags = mhdriver_append_message_flags,
.sess_copy_message = mhdriver_copy_message,
.sess_move_message = mhdriver_move_message,
@@ -684,6 +687,12 @@ static int mhdriver_append_message(mailsession * session,
}
}
+static int mhdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ return mhdriver_append_message(session, message, size);
+}
+
static int mhdriver_copy_message(mailsession * session,
uint32_t num, char * mb)
{
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
@@ -108,6 +108,8 @@ static int mhdriver_cached_unsubscribe_folder(mailsession * session,
static int mhdriver_cached_append_message(mailsession * session,
char * message, size_t size);
+static int mhdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
static int mhdriver_cached_copy_message(mailsession * session,
uint32_t num, char * mb);
@@ -165,6 +167,7 @@ static mailsession_driver local_mh_cached_session_driver = {
.sess_unsubscribe_folder = mhdriver_cached_unsubscribe_folder,
.sess_append_message = mhdriver_cached_append_message,
+ .sess_append_message_flags = mhdriver_cached_append_message_flags,
.sess_copy_message = mhdriver_cached_copy_message,
.sess_move_message = mhdriver_cached_move_message,
@@ -883,7 +886,85 @@ static int mhdriver_cached_unsubscribe_folder(mailsession * session,
static int mhdriver_cached_append_message(mailsession * session,
char * message, size_t size)
{
- return mailsession_append_message(get_ancestor(session), message, size);
+ return mhdriver_cached_append_message_flags(session,
+ message, size, NULL);
+}
+
+static int mhdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ int r;
+ struct mailmh_folder * folder;
+ struct mailmh_msg_info * msg_info;
+ chashdatum key;
+ chashdatum value;
+ uint32_t uid;
+ struct mh_cached_session_state_data * data;
+ char filename_flags[PATH_MAX];
+ struct mail_cache_db * cache_db_flags;
+ MMAPString * mmapstr;
+ char keyname[PATH_MAX];
+
+ folder = get_mh_cur_folder(session);
+ if (folder == NULL)
+ return MAIL_ERROR_BAD_STATE;
+
+ r = mailmh_folder_add_message_uid(folder,
+ message, size, &uid);
+
+ switch (r) {
+ case MAILMH_ERROR_FILE:
+ return MAIL_ERROR_DISKSPACE;
+
+ case MAILMH_NO_ERROR:
+ break;
+
+ default:
+ return mhdriver_mh_error_to_mail_error(r);
+ }
+
+ if (flags == NULL)
+ goto exit;
+
+ key.data = &uid;
+ key.len = sizeof(uid);
+ r = chash_get(folder->fl_msgs_hash, &key, &value);
+ if (r < 0)
+ return MAIL_ERROR_CACHE_MISS;
+
+ msg_info = value.data;
+
+ data = get_cached_data(session);
+
+ snprintf(filename_flags, PATH_MAX, "%s/%s/%s",
+ data->mh_flags_directory, data->mh_quoted_mb, FLAGS_NAME);
+
+ r = mail_cache_db_open_lock(filename_flags, &cache_db_flags);
+ if (r < 0)
+ goto exit;
+
+ mmapstr = mmap_string_new("");
+ if (mmapstr == NULL)
+ goto close_db_flags;
+
+ snprintf(keyname, PATH_MAX, "%u-%lu-%lu-flags",
+ uid, (unsigned long) msg_info->msg_mtime,
+ (unsigned long) msg_info->msg_size);
+
+ r = mhdriver_write_cached_flags(cache_db_flags, mmapstr, keyname, flags);
+
+ mmap_string_free(mmapstr);
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+
+ if (r != MAIL_NO_ERROR)
+ goto exit;
+
+ return MAIL_NO_ERROR;
+
+ close_db_flags:
+ mail_cache_db_close_unlock(filename_flags, cache_db_flags);
+ exit:
+ return MAIL_NO_ERROR;
}
static int mhdriver_cached_copy_message(mailsession * session,
@@ -953,8 +1034,9 @@ get_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr,
return MAIL_ERROR_CACHE_MISS;
msg_info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-%u-envelope",
- num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size);
+ snprintf(keyname, PATH_MAX, "%u-%lu-%lu-envelope",
+ num, (unsigned long) msg_info->msg_mtime,
+ (unsigned long) msg_info->msg_size);
r = generic_cache_fields_read(cache_db, mmapstr, keyname, &fields);
if (r != MAIL_NO_ERROR) {
@@ -998,8 +1080,9 @@ write_cached_envelope(struct mail_cache_db * cache_db, MMAPString * mmapstr,
return MAIL_ERROR_CACHE_MISS;
msg_info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-%u-envelope",
- num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size);
+ snprintf(keyname, PATH_MAX, "%u-%lu-%lu-envelope",
+ num, (unsigned long) msg_info->msg_mtime,
+ (unsigned long) msg_info->msg_size);
r = generic_cache_fields_write(cache_db, mmapstr, keyname, fields);
if (r != MAIL_NO_ERROR) {
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
@@ -179,8 +179,8 @@ static int mh_initialize(mailmessage * msg_info)
mh_msg_info = data.data;
- snprintf(static_uid, PATH_MAX, "%u-%lu-%u", msg_info->msg_index,
- mh_msg_info->msg_mtime, mh_msg_info->msg_size);
+ snprintf(static_uid, PATH_MAX, "%u-%lu-%lu", msg_info->msg_index,
+ mh_msg_info->msg_mtime, (unsigned long) mh_msg_info->msg_size);
uid = strdup(static_uid);
if (uid == NULL)
return MAIL_ERROR_MEMORY;
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
@@ -144,8 +144,9 @@ static int mh_initialize(mailmessage * msg_info)
mh_msg_info = value.data;
- snprintf(static_uid, PATH_MAX, "%u-%lu-%u", msg_info->msg_index,
- mh_msg_info->msg_mtime, mh_msg_info->msg_size);
+ snprintf(static_uid, PATH_MAX, "%u-%lu-%lu", msg_info->msg_index,
+ (unsigned long) mh_msg_info->msg_mtime,
+ (unsigned long) mh_msg_info->msg_size);
uid = strdup(static_uid);
if (uid == NULL)
return MAIL_ERROR_MEMORY;
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
@@ -369,8 +369,9 @@ mhdriver_get_cached_flags(struct mail_cache_db * cache_db,
return MAIL_ERROR_CACHE_MISS;
msg_info = data.data;
- snprintf(keyname, PATH_MAX, "%u-%u-%u-flags",
- num, (uint32_t) msg_info->msg_mtime, msg_info->msg_size);
+ snprintf(keyname, PATH_MAX, "%u-%lu-%lu-flags",
+ num, (unsigned long) msg_info->msg_mtime,
+ (unsigned long) msg_info->msg_size);
r = generic_cache_flags_read(cache_db, mmapstr, keyname, &flags);
if (r != MAIL_NO_ERROR) {
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
@@ -62,7 +62,7 @@ int mh_mailstorage_init(struct mailstorage * storage,
{
struct mh_mailstorage * mh_storage;
- mh_storage = malloc(sizeof(struct mh_mailstorage));
+ mh_storage = malloc(sizeof(* mh_storage));
if (mh_storage == NULL)
goto err;
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
@@ -69,6 +69,9 @@ static int nntpdriver_messages_number(mailsession * session, char * mb,
static int nntpdriver_append_message(mailsession * session,
char * message, size_t size);
+static int nntpdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int
nntpdriver_get_envelopes_list(mailsession * session,
struct mailmessage_list * env_list);
@@ -129,6 +132,7 @@ static mailsession_driver local_nntp_session_driver = {
.sess_unsubscribe_folder = nntpdriver_unsubscribe_folder,
.sess_append_message = nntpdriver_append_message,
+ .sess_append_message_flags = nntpdriver_append_message_flags,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -630,6 +634,12 @@ static int nntpdriver_append_message(mailsession * session,
while (1);
}
+static int nntpdriver_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ return nntpdriver_append_message(session, message, size);
+}
+
static int xover_resp_to_fields(struct newsnntp_xover_resp_item * item,
struct mailimf_fields ** result);
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
@@ -96,6 +96,9 @@ static int nntpdriver_cached_unseen_number(mailsession * session, char * mb,
static int nntpdriver_cached_append_message(mailsession * session,
char * message, size_t size);
+static int nntpdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
static int
nntpdriver_cached_get_envelopes_list(mailsession * session,
struct mailmessage_list * env_list);
@@ -159,6 +162,7 @@ static mailsession_driver local_nntp_cached_session_driver = {
.sess_unsubscribe_folder = nntpdriver_cached_unsubscribe_folder,
.sess_append_message = nntpdriver_cached_append_message,
+ .sess_append_message_flags = nntpdriver_cached_append_message_flags,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -631,6 +635,12 @@ static int nntpdriver_cached_append_message(mailsession * session,
return mailsession_append_message(get_ancestor(session), message, size);
}
+static int nntpdriver_cached_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags)
+{
+ return nntpdriver_cached_append_message(session, message, size);
+}
+
static int
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
@@ -71,7 +71,7 @@ int nntp_mailstorage_init(struct mailstorage * storage,
struct nntp_mailstorage * nntp_storage;
int res;
- nntp_storage = malloc(sizeof(struct nntp_mailstorage));
+ nntp_storage = malloc(sizeof(* nntp_storage));
if (nntp_storage == NULL) {
res = MAIL_ERROR_MEMORY;
goto err;
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
@@ -109,6 +109,7 @@ static mailsession_driver local_pop3_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = NULL,
+ .sess_append_message_flags = NULL,
.sess_copy_message = NULL,
.sess_move_message = NULL,
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
@@ -110,6 +110,9 @@ pop3driver_cached_get_envelopes_list(mailsession * session,
static int pop3driver_cached_get_message(mailsession * session,
uint32_t num, mailmessage ** result);
+static int pop3driver_cached_get_message_by_uid(mailsession * session,
+ const char * uid, mailmessage ** result);
+
static mailsession_driver local_pop3_cached_session_driver = {
.sess_name = "pop3-cached",
@@ -143,6 +146,7 @@ static mailsession_driver local_pop3_cached_session_driver = {
.sess_unsubscribe_folder = NULL,
.sess_append_message = NULL,
+ .sess_append_message_flags = NULL,
.sess_copy_message = NULL,
.sess_move_message = NULL,
@@ -154,7 +158,7 @@ static mailsession_driver local_pop3_cached_session_driver = {
#endif
.sess_get_message = pop3driver_cached_get_message,
- .sess_get_message_by_uid = NULL,
+ .sess_get_message_by_uid = pop3driver_cached_get_message_by_uid,
};
mailsession_driver * pop3_cached_session_driver =
@@ -855,3 +859,41 @@ static int pop3driver_cached_get_message(mailsession * session,
return MAIL_NO_ERROR;
}
+
+static int pop3driver_cached_get_message_by_uid(mailsession * session,
+ const char * uid, mailmessage ** result)
+{
+ mailpop3 * pop3;
+ struct mailpop3_msg_info * msg_info;
+ int found;
+ unsigned int i;
+
+ if (uid == NULL)
+ return MAIL_ERROR_INVAL;
+
+ pop3 = get_pop3_session(session);
+
+ found = 0;
+
+ /* iterate all messages and look for uid */
+ for(i = 0 ; i < carray_count(pop3->pop3_msg_tab) ; i++) {
+ msg_info = carray_get(pop3->pop3_msg_tab, i);
+
+ if (msg_info == NULL)
+ continue;
+
+ if (msg_info->msg_deleted)
+ continue;
+
+ /* uid found, stop looking */
+ if (strcmp(msg_info->msg_uidl, uid) == 0) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return MAIL_ERROR_MSG_NOT_FOUND;
+
+ return pop3driver_cached_get_message(session, msg_info->msg_index, result);
+}
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
@@ -39,6 +39,8 @@
#include "pop3driver_tools.h"
#include "pop3driver.h"
#include "mailpop3.h"
+#include <stdlib.h>
+#include <string.h>
static int pop3_prefetch(mailmessage * msg_info);
@@ -80,6 +82,18 @@ static mailmessage_driver local_pop3_message_driver = {
mailmessage_driver * pop3_message_driver = &local_pop3_message_driver;
+static inline struct pop3_session_state_data *
+get_data(mailsession * session)
+{
+ return session->sess_data;
+}
+
+
+static mailpop3 * get_pop3_session(mailsession * session)
+{
+ return get_data(session)->pop3_session;
+}
+
static int pop3_prefetch(mailmessage * msg_info)
{
@@ -113,14 +127,34 @@ static int pop3_initialize(mailmessage * msg_info)
{
struct generic_message_t * msg;
int r;
+ char * uid;
+ struct mailpop3_msg_info * info;
+ mailpop3 * pop3;
+
+ pop3 = get_pop3_session(msg_info->msg_session);
+
+ r = mailpop3_get_msg_info(pop3, msg_info->msg_index, &info);
+ switch (r) {
+ case MAILPOP3_NO_ERROR:
+ break;
+ default:
+ return pop3driver_pop3_error_to_mail_error(r);
+ }
+
+ uid = strdup(info->msg_uidl);
+ if (uid == NULL)
+ return MAIL_ERROR_MEMORY;
r = mailmessage_generic_initialize(msg_info);
- if (r != MAIL_NO_ERROR)
+ if (r != MAIL_NO_ERROR) {
+ free(uid);
return r;
+ }
msg = msg_info->msg_data;
msg->msg_prefetch = pop3_prefetch;
msg->msg_prefetch_free = pop3_prefetch_free;
+ msg_info->msg_uid = uid;
return MAIL_NO_ERROR;
}
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
@@ -68,7 +68,7 @@ int pop3_mailstorage_init(struct mailstorage * storage,
{
struct pop3_mailstorage * pop3_storage;
- pop3_storage = malloc(sizeof(struct pop3_mailstorage));
+ pop3_storage = malloc(sizeof(* pop3_storage));
if (pop3_storage == NULL)
goto err;
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
@@ -1907,7 +1907,7 @@ int mailimap_unsubscribe(mailimap * session, const char * mb)
if (r != MAILIMAP_NO_ERROR)
return r;
- r = mailimap_subscribe_send(session->imap_stream, mb);
+ r = mailimap_unsubscribe_send(session->imap_stream, mb);
if (r != MAILIMAP_NO_ERROR)
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
@@ -53,7 +53,7 @@ int mailimap_token_case_insensitive_parse(mailstream * fd,
const char * token)
{
int len;
- int cur_token;
+ size_t cur_token;
int r;
cur_token = * index;
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
@@ -48,7 +48,7 @@
*/
#include <ctype.h>
-#include <mmapstring.h>
+#include "mmapstring.h"
#include <stdlib.h>
#include <string.h>
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
@@ -44,6 +44,7 @@ extern "C" {
#include <libetpan/libetpan_version.h>
#include <libetpan/maildriver.h>
#include <libetpan/mailmessage.h>
+#include <libetpan/mailfolder.h>
#include <libetpan/mailstorage.h>
#include <libetpan/mailthread.h>
#include <libetpan/mailsmtp.h>
@@ -91,12 +92,23 @@ extern "C" {
#include <libetpan/maildirdriver_cached_message.h>
#include <libetpan/maildirstorage.h>
+/* db driver */
+#include <libetpan/dbdriver.h>
+#include <libetpan/dbdriver_message.h>
+#include <libetpan/dbstorage.h>
+
/* message which content is given by a MIME structure */
#include <libetpan/mime_message_driver.h>
/* message which content given by a string */
#include <libetpan/data_message_driver.h>
+/* engine */
+#include <libetpan/mailprivacy.h>
+#include <libetpan/mailengine.h>
+#include <libetpan/mailprivacy_gnupg.h>
+#include <libetpan/mailprivacy_smime.h>
+
#ifdef __cplusplus
}
#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
@@ -45,9 +45,16 @@ void maildir_free(struct maildir * md);
int maildir_update(struct maildir * md);
+int maildir_message_add_uid(struct maildir * md,
+ const char * message, size_t size,
+ char * uid, size_t max_uid_len);
+
int maildir_message_add(struct maildir * md,
const char * message, size_t size);
+int maildir_message_add_file_uid(struct maildir * md, int fd,
+ char * uid, size_t max_uid_len);
+
int maildir_message_add_file(struct maildir * md, int fd);
char * maildir_message_get(struct maildir * md, const char * uid);
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
@@ -44,7 +44,7 @@ extern "C" {
#endif
/*
- maildir_mailstorage_init is the constructor for a mbox storage.
+ maildir_mailstorage_init is the constructor for a maildir storage.
@param storage this is the storage to initialize.
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
@@ -400,6 +400,9 @@ int mailsession_unsubscribe_folder(mailsession * session, char * mb);
int mailsession_append_message(mailsession * session,
char * message, size_t size);
+int mailsession_append_message_flags(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
+
/*
NOTE: some drivers does not implement this
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
@@ -507,6 +507,8 @@ struct mailsession_driver {
int (* sess_append_message)(mailsession * session,
char * message, size_t size);
+ int (* sess_append_message_flags)(mailsession * session,
+ char * message, size_t size, struct mail_flags * flags);
int (* sess_copy_message)(mailsession * session,
uint32_t num, char * mb);
int (* sess_move_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
@@ -17,6 +17,9 @@ int mailfolder_status(struct mailfolder * folder,
int mailfolder_append_message(struct mailfolder * folder,
char * message, size_t size);
+int mailfolder_append_message_flags(struct mailfolder * folder,
+ char * message, size_t size, struct mail_flags * flags);
+
int mailfolder_get_messages_list(struct mailfolder * folder,
struct mailmessage_list ** result);
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
@@ -51,6 +51,10 @@ int
mailmbox_append_message(struct mailmbox_folder * folder,
const char * data, size_t len);
+int
+mailmbox_append_message_uid(struct mailmbox_folder * folder,
+ const char * data, size_t len, unsigned int * puid);
+
int mailmbox_fetch_msg(struct mailmbox_folder * folder,
uint32_t num, char ** result,
size_t * result_len);
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
@@ -128,6 +128,7 @@ void mailmbox_msg_info_free(struct mailmbox_msg_info * info);
struct mailmbox_append_info {
const char * ai_message;
size_t ai_size;
+ unsigned int ai_uid;
};
struct mailmbox_append_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
@@ -119,9 +119,16 @@ int mailmh_folder_get_message_fd(struct mailmh_folder * folder,
int mailmh_folder_get_message_size(struct mailmh_folder * folder,
uint32_t index, size_t * result);
+int mailmh_folder_add_message_uid(struct mailmh_folder * folder,
+ const char * message, size_t size,
+ uint32_t * pindex);
+
int mailmh_folder_add_message(struct mailmh_folder * folder,
const char * message, size_t size);
+int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder,
+ int fd, uint32_t * pindex);
+
int mailmh_folder_add_message_file(struct mailmh_folder * folder,
int fd);
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
@@ -71,6 +71,8 @@ int mailstorage_connect(struct mailstorage * storage);
void mailstorage_disconnect(struct mailstorage * storage);
+int mailstorage_noop(struct mailstorage * storage);
+
/* folder */
@@ -88,7 +90,6 @@ int mailfolder_connect(struct mailfolder * folder);
void mailfolder_disconnect(struct mailfolder * folder);
-
#ifdef __cplusplus
}
#endif
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
@@ -430,8 +430,9 @@ static char * libetpan_basename(char * filename)
#define libetpan_basename(a) basename(a)
#endif
-int maildir_message_add(struct maildir * md,
- const char * message, size_t size)
+int maildir_message_add_uid(struct maildir * md,
+ const char * message, size_t size,
+ char * uid, size_t max_uid_len)
{
char path_new[PATH_MAX];
char tmpname[PATH_MAX];
@@ -453,7 +454,8 @@ int maildir_message_add(struct maildir * md,
/* write to tmp/ with a classic temporary file */
- snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX", md->mdir_path);
+ snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX",
+ md->mdir_path);
fd = mkstemp(tmpname);
if (fd < 0) {
res = MAILDIR_ERROR_FILE;
@@ -522,6 +524,9 @@ int maildir_message_add(struct maildir * md,
goto unlink_tmp;
}
+ if (uid != NULL)
+ strncpy(uid, delivery_new_basename, max_uid_len);
+
unlink(delivery_tmp_name);
free(delivery_tmp_name);
@@ -539,7 +544,15 @@ int maildir_message_add(struct maildir * md,
return res;
}
-int maildir_message_add_file(struct maildir * md, int fd)
+int maildir_message_add(struct maildir * md,
+ const char * message, size_t size)
+{
+ return maildir_message_add_uid(md, message, size,
+ NULL, 0);
+}
+
+int maildir_message_add_file_uid(struct maildir * md, int fd,
+ char * uid, size_t max_uid_len)
{
char * message;
struct stat buf;
@@ -552,13 +565,19 @@ int maildir_message_add_file(struct maildir * md, int fd)
if (message == MAP_FAILED)
return MAILDIR_ERROR_FILE;
- r = maildir_message_add(md, message, buf.st_size);
+ r = maildir_message_add_uid(md, message, buf.st_size, uid, max_uid_len);
munmap(message, buf.st_size);
return r;
}
+int maildir_message_add_file(struct maildir * md, int fd)
+{
+ return maildir_message_add_file_uid(md, fd,
+ NULL, 0);
+}
+
char * maildir_message_get(struct maildir * md, const char * uid)
{
chashdatum key;
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
@@ -45,9 +45,16 @@ void maildir_free(struct maildir * md);
int maildir_update(struct maildir * md);
+int maildir_message_add_uid(struct maildir * md,
+ const char * message, size_t size,
+ char * uid, size_t max_uid_len);
+
int maildir_message_add(struct maildir * md,
const char * message, size_t size);
+int maildir_message_add_file_uid(struct maildir * md, int fd,
+ char * uid, size_t max_uid_len);
+
int maildir_message_add_file(struct maildir * md, int fd);
char * maildir_message_get(struct maildir * md, const char * uid);
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
@@ -197,6 +197,9 @@ int mailmbox_open(struct mailmbox_folder * folder)
int fd;
int read_only;
+ fd = -1;
+ read_only = TRUE;
+
if (!folder->mb_read_only) {
read_only = FALSE;
fd = open(folder->mb_filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
@@ -617,6 +620,8 @@ mailmbox_append_message_list_no_lock(struct mailmbox_folder * folder,
folder->mb_max_uid + i + 1,
folder->mb_no_uid);
extra_size += 2; /* CR LF */
+
+ info->ai_uid = folder->mb_max_uid + i + 1;
}
left = folder->mb_mapping_size;
@@ -744,8 +749,8 @@ mailmbox_append_message_list(struct mailmbox_folder * folder,
}
int
-mailmbox_append_message(struct mailmbox_folder * folder,
- const char * data, size_t len)
+mailmbox_append_message_uid(struct mailmbox_folder * folder,
+ const char * data, size_t len, unsigned int * puid)
{
carray * tab;
struct mailmbox_append_info * append_info;
@@ -772,6 +777,9 @@ mailmbox_append_message(struct mailmbox_folder * folder,
r = mailmbox_append_message_list(folder, tab);
+ if (puid != NULL)
+ * puid = append_info->ai_uid;
+
mailmbox_append_info_free(append_info);
carray_free(tab);
@@ -785,6 +793,13 @@ mailmbox_append_message(struct mailmbox_folder * folder,
return res;
}
+int
+mailmbox_append_message(struct mailmbox_folder * folder,
+ const char * data, size_t len)
+{
+ return mailmbox_append_message_uid(folder, data, len, NULL);
+}
+
/* ********************************************************************** */
int mailmbox_fetch_msg_no_lock(struct mailmbox_folder * folder,
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
@@ -51,6 +51,10 @@ int
mailmbox_append_message(struct mailmbox_folder * folder,
const char * data, size_t len);
+int
+mailmbox_append_message_uid(struct mailmbox_folder * folder,
+ const char * data, size_t len, unsigned int * puid);
+
int mailmbox_fetch_msg(struct mailmbox_folder * folder,
uint32_t num, char ** result,
size_t * result_len);
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
@@ -178,6 +178,7 @@ mailmbox_append_info_new(const char * ai_message, size_t ai_size)
info->ai_message = ai_message;
info->ai_size = ai_size;
+ info->ai_uid = 0;
return 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
@@ -128,6 +128,7 @@ void mailmbox_msg_info_free(struct mailmbox_msg_info * info);
struct mailmbox_append_info {
const char * ai_message;
size_t ai_size;
+ unsigned int ai_uid;
};
struct mailmbox_append_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
@@ -723,8 +723,9 @@ int mailmh_folder_get_message_size(struct mailmh_folder * folder,
return MAILMH_NO_ERROR;
}
-int mailmh_folder_add_message(struct mailmh_folder * folder,
- const char * message, size_t size)
+int mailmh_folder_add_message_uid(struct mailmh_folder * folder,
+ const char * message, size_t size,
+ uint32_t * pindex)
{
char * tmpname;
int fd;
@@ -809,6 +810,9 @@ int mailmh_folder_add_message(struct mailmh_folder * folder,
data.data = msg_info;
data.len = 0;
+ if (pindex != NULL)
+ * pindex = index;
+
r = chash_set(folder->fl_msgs_hash, &key, &data, NULL);
if (r < 0) {
carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index);
@@ -825,8 +829,14 @@ int mailmh_folder_add_message(struct mailmh_folder * folder,
return error;
}
-int mailmh_folder_add_message_file(struct mailmh_folder * folder,
- int fd)
+int mailmh_folder_add_message(struct mailmh_folder * folder,
+ const char * message, size_t size)
+{
+ return mailmh_folder_add_message_uid(folder, message, size, NULL);
+}
+
+int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder,
+ int fd, uint32_t * pindex)
{
char * message;
struct stat buf;
@@ -845,13 +855,19 @@ int mailmh_folder_add_message_file(struct mailmh_folder * folder,
if (message == MAP_FAILED)
return MAILMH_ERROR_FILE;
- r = mailmh_folder_add_message(folder, message, buf.st_size);
+ r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex);
munmap(message, buf.st_size);
return r;
}
+int mailmh_folder_add_message_file(struct mailmh_folder * folder,
+ int fd)
+{
+ return mailmh_folder_add_message_file_uid(folder, fd, NULL);
+}
+
int mailmh_folder_remove_message(struct mailmh_folder * folder,
uint32_t index)
{
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
@@ -119,9 +119,16 @@ int mailmh_folder_get_message_fd(struct mailmh_folder * folder,
int mailmh_folder_get_message_size(struct mailmh_folder * folder,
uint32_t index, size_t * result);
+int mailmh_folder_add_message_uid(struct mailmh_folder * folder,
+ const char * message, size_t size,
+ uint32_t * pindex);
+
int mailmh_folder_add_message(struct mailmh_folder * folder,
const char * message, size_t size);
+int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder,
+ int fd, uint32_t * pindex);
+
int mailmh_folder_add_message_file(struct mailmh_folder * folder,
int fd);
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
@@ -187,16 +187,26 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
r = charconv(tocode, default_fromcode, raw_word,
strlen(raw_word), &wordutf8);
- if (wordutf8 != NULL) {
- if (mmap_string_append(gphrase, wordutf8) == NULL) {
- free(wordutf8);
+ switch (r) {
+ case MAIL_CHARCONV_ERROR_MEMORY:
free(raw_word);
res = MAILIMF_ERROR_MEMORY;
goto free;
+
+ case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
+ case MAIL_CHARCONV_ERROR_CONV:
+ free(raw_word);
+ res = MAILIMF_ERROR_PARSE;
+ goto free;
}
+ if (mmap_string_append(gphrase, wordutf8) == NULL) {
free(wordutf8);
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
}
+
free(raw_word);
first = FALSE;
}
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
@@ -441,7 +441,7 @@ mailmime_disposition_param_write(FILE * f, int * col,
break;
case MAILMIME_DISPOSITION_PARM_SIZE:
- snprintf(sizestr, 20, "%u", param->pa_data.pa_size);
+ snprintf(sizestr, 20, "%lu", (unsigned long) param->pa_data.pa_size);
len = strlen("size=") + strlen(sizestr);
break;
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
@@ -192,6 +192,8 @@ int mailsmtp_helo(mailsmtp * session)
switch (r) {
case 250:
+ session->esmtp = 0;
+ session->auth = MAILSMTP_AUTH_NOT_CHECKED;
return MAILSMTP_NO_ERROR;
case 504:
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
@@ -41,19 +41,15 @@
int mailsmtp_init(mailsmtp * session)
{
int r;
- session->esmtp = 0;
+
r = mailesmtp_ehlo(session);
- if (r == MAILSMTP_NO_ERROR) {
- // session->esmtp = TRUE;
+ if (r == MAILSMTP_NO_ERROR)
return MAILSMTP_NO_ERROR;
- }
r = mailsmtp_helo(session);
- /* if (r == MAILSMTP_NO_ERROR) { */
-/* session->esmtp = FALSE; */
-/* return MAILSMTP_NO_ERROR; */
-/* } */
+ if (r == MAILSMTP_NO_ERROR)
+ return MAILSMTP_NO_ERROR;
return r;
}
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
@@ -7,6 +7,8 @@
#include "mailtypes.h"
+#include <qprogressbar.h>
+#include <qapplication.h>
#include <kdecore/kstandarddirs.h>
#include <qfile.h>
@@ -140,8 +142,33 @@ void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSma
}
void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
{
- qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
-
+ //qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
+ // this is currently re-implemented in pop3wrapper and imapwrapper
+ int iii = 0;
+ int count = target.count();
+ QProgressBar bar( count,0 );
+ bar.setCaption (("Removing mails - close to abort!") );
+ int w = 300;
+ if ( QApplication::desktop()->width() < 320 )
+ w = 220;
+ int h = bar.sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ int modulo = (count/10)+1;
+ int incCounter = 0;
+ while (iii < count ) {
+ if ( ! bar.isVisible() )
+ return ;
+ if ( incCounter % modulo == 0 )
+ bar.setProgress( incCounter );
+ ++incCounter;
+ qApp->processEvents();
+ RecMailP mail = (*target.at( iii ));
+ deleteMail(mail);
+ ++iii;
+ }
}
void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
@@ -154,11 +181,33 @@ void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
-
encodedString*st = 0;
int iii = 0;
int count = t.count();
+ if ( count == 0 )
+ return;
+
+ QProgressBar bar( count,0 );
+ bar.setCaption (("Copying mails - close to abort!") );
+ int w = 300;
+ if ( QApplication::desktop()->width() < 320 )
+ w = 220;
+ int h = bar.sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ int modulo = (count/10)+1;
+ int incCounter = 0;
while (iii < count ) {
+ if ( ! bar.isVisible() )
+ return ;
+ if ( incCounter % modulo == 0 )
+ bar.setProgress( incCounter );
+ ++incCounter;
+ bar.raise();
+ qApp->processEvents();
+ //qDebug("copy ");
RecMailP r = (*t.at( iii ));
st = fetchRawBody(r);
if (st) {
@@ -167,6 +216,7 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
}
++iii;
}
+ bar.hide();
if (moveit) {
deleteMailList( t );
//deleteAllMail(fromFolder);
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
@@ -6,6 +6,7 @@
#include "imapwrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
+#include <qprogressbar.h>
using namespace Opie::Core;
IMAPwrapper::IMAPwrapper( IMAPaccount *a )
@@ -871,21 +872,43 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
}
void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
{
+ //#if 0
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
login();
+ //#endif
if (!m_imap) {
return;
}
int iii = 0;
int count = target.count();
- qDebug("imap remove count %d ", count);
+ // qDebug("imap remove count %d ", count);
+
+ QProgressBar bar( count,0 );
+ bar.setCaption (("Removing mails - close to abort!") );
+ int w = 300;
+ if ( QApplication::desktop()->width() < 320 )
+ w = 220;
+ int h = bar.sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ int modulo = (count/10)+1;
+ int incCounter = 0;
+
while (iii < count ) {
- qDebug("IMAP remove %d ", iii);
+ if ( ! bar.isVisible() )
+ return ;
+ if ( incCounter % modulo == 0 )
+ bar.setProgress( incCounter );
+ ++incCounter;
+ qApp->processEvents();
RecMailP mail = (*target.at( iii ));
-
+ //#if 0
+ //qDebug("IMAP remove %d %d ", iii, mail->getNumber() );
err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return;
@@ -905,11 +928,18 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
// odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
/* should we realy do that at this moment? */
+ // err = mailimap_expunge(m_imap);
+ //if (err != MAILIMAP_NO_ERROR) {
+ // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
+ // }
+ //#endif
+ //deleteMail( mail);
+ ++iii;
+ }
+ //qDebug("Deleting imap mails... ");
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
- Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
- }
- ++iii;
+ Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
}
}
void IMAPwrapper::deleteMail(const RecMailP&mail)
@@ -945,7 +975,7 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
}
- qDebug("IMAPwrapper::deleteMail ");
+ //qDebug("IMAPwrapper::deleteMail 2");
}
@@ -1189,7 +1219,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
err = mailimap_copy(m_imap,set,targetFolder.latin1());
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
- QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
+ QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
// odebug << error_msg << oendl;
return;
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
@@ -8,6 +8,8 @@
#include <qpe/global.h>
#include <qfile.h>
+#include <qprogressbar.h>
+#include <qapplication.h>
/* we don't fetch messages larger than 5 MB */
#define HARD_MSG_SIZE_LIMIT 5242880
@@ -193,18 +195,37 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
return folders;
}
-void POP3wrapper::deleteMailList(QValueList<RecMailP>&target)
+void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
{
login();
if (!m_pop3)
return;
int iii = 0;
int count = target.count();
+ QProgressBar bar( count,0 );
+ bar.setCaption (("Removing mails - close to abort!") );
+ int w = 300;
+ if ( QApplication::desktop()->width() < 320 )
+ w = 220;
+ int h = bar.sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ int modulo = (count/10)+1;
+ int incCounter = 0;
while (iii < count ) {
+ if ( ! bar.isVisible() )
+ return ;
+ if ( incCounter % modulo == 0 )
+ bar.setProgress( incCounter );
+ ++incCounter;
+ qApp->processEvents();
+ //qDebug("delete ");
RecMailP mail = (*target.at( iii ));
int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
if (err != MAIL_NO_ERROR) {
- Global::statusMessage(tr("error deleting mail"));
+ Global::statusMessage(tr("Error deleting mail"));
}
++iii;
}
@@ -233,7 +254,25 @@ int POP3wrapper::deleteAllMail(const FolderP&) {
Global::statusMessage(tr("Error getting folder info"));
return 0;
}
+ QProgressBar bar( result,0 );
+ bar.setCaption (("Deleting mails - close to abort!") );
+ int w = 300;
+ if ( QApplication::desktop()->width() < 320 )
+ w = 220;
+ int h = bar.sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ int modulo = (result/10)+1;
+ int incCounter = 0;
for (unsigned int i = 0; i < result; ++i) {
+ if ( ! bar.isVisible() )
+ return 0;
+ if ( incCounter % modulo == 0 )
+ bar.setProgress( incCounter );
+ ++incCounter;
+ qApp->processEvents();
err = mailsession_remove_message(m_pop3->sto_session,i+1);
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
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
@@ -24,8 +24,8 @@ public:
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMailP&mail);
+ virtual void deleteMailList(const QValueList<RecMailP>&target);
virtual void answeredMail(const RecMailP&mail);
- virtual void deleteMailList(QValueList<RecMailP>&target);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual RecBodyP fetchBody( const RecMailP &mail );
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 3fbdcec..251f15a 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -18,7 +18,7 @@
#include <libmailwrapper/abstractmail.h>
/* OPIE */
//#include <qpe/resource.h>
-#include <qpe/qpeapplication.h>
+//#include <qpe/qpeapplication.h>
/* QT */
@@ -237,20 +237,27 @@ void OpieMail::slotDeleteMail()
}
void OpieMail::slotDeleteAllMail()
{
- if (!mailView->currentItem()) return;
- RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
+
+ QValueList<RecMailP> t;
if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
{
MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
- RecMailP mail = item->data();
- mail->Wrapper()->deleteMail( mail );
+ t.append( item->data() );
}
item = (MailListViewItem*)item->nextSibling();
}
- folderView->refreshCurrent();
}
+ else
+ return;
+ if ( t.count() == 0 )
+ return;
+ RecMailP mail = t.first();
+ mail->Wrapper()->deleteMailList(t);
+ folderView->refreshCurrent();
+
+
}
void OpieMail::clearSelection()
{
@@ -276,10 +283,10 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
}
m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
- m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
+ m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
m->insertSeparator();
- m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail()));
+ m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
}
@@ -350,6 +357,9 @@ void OpieMail::slotMoveCopyMail()
tr("<center>Error while creating<br>new folder - breaking.</center>"));
return;
}
+ sels.hide();
+ qApp->processEvents();
+ // qDebug("hiding sels ");
mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
folderView->refreshCurrent();
}
@@ -359,7 +369,7 @@ void OpieMail::slotMoveCopyAllMail()
if (!mailView->currentItem()) return;
QValueList<RecMailP> t;
- 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 )
+ // 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 )
{
MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
while ( item ) {
@@ -369,8 +379,8 @@ void OpieMail::slotMoveCopyAllMail()
item = (MailListViewItem*)item->nextSibling();
}
}
- else
- return;
+ // else
+ // return;
if ( t.count() == 0 )
return;
RecMailP mail = t.first();
@@ -392,6 +402,9 @@ void OpieMail::slotMoveCopyAllMail()
tr("<center>Error while creating<br>new folder - breaking.</center>"));
return;
}
+ sels.hide();
+ qApp->processEvents();
+ //qDebug("hiding sels ");
mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
folderView->refreshCurrent();
}