summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/generic/imapdriver_cached.c
Side-by-side diff
Diffstat (limited to 'kmicromail/libetpan/generic/imapdriver_cached.c') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/generic/imapdriver_cached.c16
1 files changed, 16 insertions, 0 deletions
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
@@ -60,156 +60,159 @@
static int imapdriver_cached_initialize(mailsession * session);
static void imapdriver_cached_uninitialize(mailsession * session);
static int imapdriver_cached_parameters(mailsession * session,
int id, void * value);
static int imapdriver_cached_connect_stream(mailsession * session,
mailstream * s);
static int imapdriver_cached_starttls(mailsession * session);
static int imapdriver_cached_login(mailsession * session,
char * userid, char * password);
static int imapdriver_cached_logout(mailsession * session);
static int imapdriver_cached_noop(mailsession * session);
static int imapdriver_cached_build_folder_name(mailsession * session,
char * mb,
char * name, char ** result);
static int imapdriver_cached_create_folder(mailsession * session, char * mb);
static int imapdriver_cached_delete_folder(mailsession * session, char * mb);
static int imapdriver_cached_rename_folder(mailsession * session, char * mb,
char * new_name);
static int imapdriver_cached_check_folder(mailsession * session);
static int imapdriver_cached_examine_folder(mailsession * session,
char * mb);
static int imapdriver_cached_select_folder(mailsession * session, char * mb);
static int imapdriver_cached_expunge_folder(mailsession * session);
static int imapdriver_cached_status_folder(mailsession * session, char * mb,
uint32_t * result_messages,
uint32_t * result_recent,
uint32_t * result_unseen);
static int imapdriver_cached_messages_number(mailsession * session,
char * mb,
uint32_t * result);
static int imapdriver_cached_recent_number(mailsession * session, char * mb,
uint32_t * result);
static int imapdriver_cached_unseen_number(mailsession * session, char * mb,
uint32_t * result);
static int imapdriver_cached_list_folders(mailsession * session, char * mb,
struct mail_list ** result);
static int imapdriver_cached_lsub_folders(mailsession * session, char * mb,
struct mail_list ** result);
static int imapdriver_cached_subscribe_folder(mailsession * session,
char * mb);
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);
static int imapdriver_cached_get_messages_list(mailsession * session,
struct mailmessage_list **
result);
static int
imapdriver_cached_get_envelopes_list(mailsession * session,
struct mailmessage_list * env_list);
static int imapdriver_cached_remove_message(mailsession * session,
uint32_t num);
#if 0
static int imapdriver_cached_search_messages(mailsession * session,
char * charset,
struct mail_search_key * key,
struct mail_search_result **
result);
#endif
static int imapdriver_cached_get_message(mailsession * session,
uint32_t num, mailmessage ** result);
static int imapdriver_cached_get_message_by_uid(mailsession * session,
const char * uid,
mailmessage ** result);
static mailsession_driver local_imap_cached_session_driver = {
.sess_name = "imap-cached",
.sess_initialize = imapdriver_cached_initialize,
.sess_uninitialize = imapdriver_cached_uninitialize,
.sess_parameters = imapdriver_cached_parameters,
.sess_connect_stream = imapdriver_cached_connect_stream,
.sess_connect_path = NULL,
.sess_starttls = imapdriver_cached_starttls,
.sess_login = imapdriver_cached_login,
.sess_logout = imapdriver_cached_logout,
.sess_noop = imapdriver_cached_noop,
.sess_build_folder_name = imapdriver_cached_build_folder_name,
.sess_create_folder = imapdriver_cached_create_folder,
.sess_delete_folder = imapdriver_cached_delete_folder,
.sess_rename_folder = imapdriver_cached_rename_folder,
.sess_check_folder = imapdriver_cached_check_folder,
.sess_examine_folder = imapdriver_cached_examine_folder,
.sess_select_folder = imapdriver_cached_select_folder,
.sess_expunge_folder = imapdriver_cached_expunge_folder,
.sess_status_folder = imapdriver_cached_status_folder,
.sess_messages_number = imapdriver_cached_messages_number,
.sess_recent_number = imapdriver_cached_recent_number,
.sess_unseen_number = imapdriver_cached_unseen_number,
.sess_list_folders = imapdriver_cached_list_folders,
.sess_lsub_folders = imapdriver_cached_lsub_folders,
.sess_subscribe_folder = imapdriver_cached_subscribe_folder,
.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,
.sess_get_messages_list = imapdriver_cached_get_messages_list,
.sess_get_envelopes_list = imapdriver_cached_get_envelopes_list,
.sess_remove_message = imapdriver_cached_remove_message,
#if 0
.sess_search_messages = imapdriver_cached_search_messages,
#endif
.sess_get_message = imapdriver_cached_get_message,
.sess_get_message_by_uid = imapdriver_cached_get_message_by_uid,
};
mailsession_driver * imap_cached_session_driver =
&local_imap_cached_session_driver;
#define CACHE_MESSAGE_LIST
static inline struct imap_cached_session_state_data *
get_cached_data(mailsession * session)
{
return session->sess_data;
}
static inline mailsession * get_ancestor(mailsession * s)
{
return get_cached_data(s)->imap_ancestor;
}
static inline
struct imap_session_state_data * get_ancestor_data(mailsession * s)
{
return get_ancestor(s)->sess_data;
}
static inline mailimap * get_imap_session(mailsession * session)
{
return get_ancestor_data(session)->imap_session;
}
static int imapdriver_cached_initialize(mailsession * session)
{
struct imap_cached_session_state_data * data;
data = malloc(sizeof(* data));
if (data == NULL)
goto err;
@@ -731,96 +734,109 @@ static int imapdriver_cached_list_folders(mailsession * session, char * mb,
static int imapdriver_cached_lsub_folders(mailsession * session, char * mb,
struct mail_list ** result)
{
int r;
r = mailsession_lsub_folders(get_ancestor(session), mb, result);
check_for_uid_cache(session);
return r;
}
static int imapdriver_cached_subscribe_folder(mailsession * session,
char * mb)
{
int r;
r = mailsession_subscribe_folder(get_ancestor(session), mb);
check_for_uid_cache(session);
return r;
}
static int imapdriver_cached_unsubscribe_folder(mailsession * session,
char * mb)
{
int r;
r = mailsession_unsubscribe_folder(get_ancestor(session), mb);
check_for_uid_cache(session);
return r;
}
static int imapdriver_cached_append_message(mailsession * session,
char * message, size_t size)
{
int r;
r = mailsession_append_message(get_ancestor(session), message, size);
check_for_uid_cache(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)
{
int r;
r = mailsession_copy_message(get_ancestor(session), num, mb);
check_for_uid_cache(session);
return r;
}
static int cmp_uid(uint32_t ** pa, uint32_t ** pb)
{
uint32_t * a;
uint32_t * b;
a = * pa;
b = * pb;
return * a - * b;
}
static int imapdriver_cached_get_messages_list(mailsession * session,
struct mailmessage_list **
result)
{
#if 0
mailsession * imap_session;
#endif
mailimap * imap;
uint32_t uid_max;
struct imap_cached_session_state_data * data;
struct mailmessage_list * env_list;
unsigned i;
int r;
int res;
carray * tab;
#if 0
data = session->data;
imap_session = get_ancestor(session);
imap = ((struct imap_session_state_data *) (imap_session->data))->session;
#endif
data = get_cached_data(session);
imap = get_imap_session(session);