From 785515dcbd70d041ce3da2e7ea2283e1e7d87a31 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 19 Apr 2012 13:46:56 +0200 Subject: Bug #465076 - INBOX confusion with outbox --- libemail-engine/e-mail-utils.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'libemail-engine/e-mail-utils.c') diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c index e60e08aa3f..fcf24a8c57 100644 --- a/libemail-engine/e-mail-utils.c +++ b/libemail-engine/e-mail-utils.c @@ -128,6 +128,9 @@ em_utils_folder_is_drafts (CamelFolder *folder) CamelFolder *local_drafts_folder; CamelSession *session; CamelStore *store; + MailFolderCache *cache; + EMailSession *mail_session; + CamelFolderInfoFlags flags = 0; EAccountList *account_list; EIterator *iterator; gchar *folder_uri; @@ -137,14 +140,22 @@ em_utils_folder_is_drafts (CamelFolder *folder) store = camel_folder_get_parent_store (folder); session = camel_service_get_session (CAMEL_SERVICE (store)); + mail_session = E_MAIL_SESSION (session); local_drafts_folder = e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS); + mail_session, E_MAIL_LOCAL_FOLDER_DRAFTS); if (folder == local_drafts_folder) return TRUE; + cache = e_mail_session_get_folder_cache (mail_session); + + /* user can select Inbox as his Draft folder - in that case prefer Inbox type */ + if (mail_folder_cache_get_folder_info_flags (cache, folder, &flags) && + (flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX) + return FALSE; + folder_uri = e_mail_folder_uri_from_folder (folder); account_list = e_get_account_list (); @@ -184,6 +195,9 @@ em_utils_folder_is_sent (CamelFolder *folder) CamelFolder *local_sent_folder; CamelSession *session; CamelStore *store; + MailFolderCache *cache; + EMailSession *mail_session; + CamelFolderInfoFlags flags = 0; EAccountList *account_list; EIterator *iterator; gchar *folder_uri; @@ -193,14 +207,22 @@ em_utils_folder_is_sent (CamelFolder *folder) store = camel_folder_get_parent_store (folder); session = camel_service_get_session (CAMEL_SERVICE (store)); + mail_session = E_MAIL_SESSION (session); local_sent_folder = e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_SENT); + mail_session, E_MAIL_LOCAL_FOLDER_SENT); if (folder == local_sent_folder) return TRUE; + cache = e_mail_session_get_folder_cache (mail_session); + + /* user can select Inbox as his Sent folder - in that case prefer Inbox type */ + if (mail_folder_cache_get_folder_info_flags (cache, folder, &flags) && + (flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX) + return FALSE; + folder_uri = e_mail_folder_uri_from_folder (folder); account_list = e_get_account_list (); -- cgit