[evolution-data-server] [IMAPx] Cannot mark-all-read in virtual Junk and Trash folders



commit f20b3dfd198b54bc7c548313ca416a5eaa01ce3e
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 22 14:16:07 2016 +0100

    [IMAPx] Cannot mark-all-read in virtual Junk and Trash folders
    
    The IMAPx provider didn't return any CamelFolderInfo when the top
    folder was either the virtual Junk or the virtual Trash folder, which
    caused no messages being marked are read in any of the both folders.
    
    This had been reported at:
    https://bugzilla.redhat.com/show_bug.cgi?id=1310312

 camel/providers/imapx/camel-imapx-store.c |   34 ++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index f6c731c..8271bc8 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -1025,6 +1025,7 @@ static CamelFolderInfo *
 get_folder_info_offline (CamelStore *store,
                          const gchar *top,
                          CamelStoreGetFolderInfoFlags flags,
+                        GCancellable *cancellable,
                          GError **error)
 {
        CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (store);
@@ -1038,6 +1039,33 @@ get_folder_info_offline (CamelStore *store,
        gint top_len;
        guint ii;
 
+       if (g_strcmp0 (top, CAMEL_VTRASH_NAME) == 0 ||
+           g_strcmp0 (top, CAMEL_VJUNK_NAME) == 0) {
+               CamelFolder *vfolder;
+
+               vfolder = camel_store_get_folder_sync (store, top, 0, cancellable, error);
+               if (!vfolder)
+                       return NULL;
+
+               fi = imapx_store_build_folder_info (imapx_store, top, 0);
+               fi->unread = camel_folder_summary_get_unread_count (vfolder->summary);
+               fi->total = camel_folder_summary_get_saved_count (vfolder->summary);
+
+               if (g_strcmp0 (top, CAMEL_VTRASH_NAME) == 0)
+                       fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) |
+                               CAMEL_FOLDER_VIRTUAL |
+                               CAMEL_FOLDER_VTRASH |
+                               CAMEL_FOLDER_TYPE_TRASH;
+               else
+                       fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) |
+                               CAMEL_FOLDER_VIRTUAL |
+                               CAMEL_FOLDER_TYPE_JUNK;
+
+               g_object_unref (vfolder);
+
+               return fi;
+       }
+
        service = CAMEL_SERVICE (store);
 
        settings = camel_service_ref_settings (service);
@@ -1821,7 +1849,7 @@ imapx_store_get_folder_info_sync (CamelStore *store,
        g_mutex_lock (&imapx_store->priv->get_finfo_lock);
 
        if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) {
-               fi = get_folder_info_offline (store, top, flags, error);
+               fi = get_folder_info_offline (store, top, flags, cancellable, error);
                goto exit;
        }
 
@@ -1861,7 +1889,7 @@ imapx_store_get_folder_info_sync (CamelStore *store,
 
        /* Avoid server interaction if the FAST flag is set. */
        if (!initial_setup && flags & CAMEL_STORE_FOLDER_INFO_FAST) {
-               fi = get_folder_info_offline (store, top, flags, error);
+               fi = get_folder_info_offline (store, top, flags, cancellable, error);
                goto exit;
        }
 
@@ -1874,7 +1902,7 @@ imapx_store_get_folder_info_sync (CamelStore *store,
        if (initial_setup && use_subscriptions)
                discover_inbox (imapx_store, cancellable);
 
-       fi = get_folder_info_offline (store, top, flags, error);
+       fi = get_folder_info_offline (store, top, flags, cancellable, error);
 
 exit:
        g_mutex_unlock (&imapx_store->priv->get_finfo_lock);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]