[evolution-data-server] Bug #719806 - [IMAP+] Empty trash doesn't work with a real trash folder



commit 112aae395af70f3941877ee073f05a70563000e1
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 12 11:40:44 2014 +0100

    Bug #719806 - [IMAP+] Empty trash doesn't work with a real trash folder

 camel/providers/imapx/camel-imapx-folder.c |   33 +++++++++++++++++++++++++
 camel/providers/imapx/camel-imapx-store.c  |   36 ++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 638c33c..307e4a1 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -492,6 +492,39 @@ imapx_expunge_sync (CamelFolder *folder,
        if (mailbox == NULL)
                goto exit;
 
+       if ((store->flags & CAMEL_STORE_VTRASH) == 0) {
+               CamelFolder *trash;
+               const gchar *full_name;
+               GError *local_error = NULL;
+
+               full_name = camel_folder_get_full_name (folder);
+
+               trash = camel_store_get_trash_folder_sync (store, cancellable, &local_error);
+
+               if (local_error == NULL && trash && (folder == trash || g_ascii_strcasecmp (full_name, 
camel_folder_get_full_name (trash)) == 0)) {
+                       CamelMessageInfo *info;
+                       GPtrArray *known_uids;
+                       gint ii;
+
+                       camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
+                       known_uids = camel_folder_summary_get_array (folder->summary);
+
+                       /* it's a real trash folder, thus delete all mails from there */
+                       for (ii = 0; known_uids && ii < known_uids->len; ii++) {
+                               info = camel_folder_summary_get (folder->summary, g_ptr_array_index 
(known_uids, ii));
+                               if (info) {
+                                       camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 
CAMEL_MESSAGE_DELETED);
+                                       camel_message_info_unref (info);
+                               }
+                       }
+
+                       camel_folder_summary_free_array (known_uids);
+               }
+
+               g_clear_object (&trash);
+               g_clear_error (&local_error);
+       }
+
        success = camel_imapx_server_expunge (
                imapx_server, mailbox, cancellable, error);
 
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 73809e0..2c38511 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -1913,8 +1913,24 @@ imapx_store_get_junk_folder_sync (CamelStore *store,
                                   GCancellable *cancellable,
                                   GError **error)
 {
-       CamelFolder *folder;
+       CamelFolder *folder = NULL;
        CamelStoreClass *store_class;
+       CamelSettings *settings;
+
+       settings = camel_service_ref_settings (CAMEL_SERVICE (store));
+       if (camel_imapx_settings_get_use_real_junk_path (CAMEL_IMAPX_SETTINGS (settings))) {
+               gchar *real_junk_path;
+
+               real_junk_path = camel_imapx_settings_dup_real_junk_path (CAMEL_IMAPX_SETTINGS (settings));
+               if (real_junk_path) {
+                       folder = camel_store_get_folder_sync (store, real_junk_path, 0, cancellable, NULL);
+                       g_free (real_junk_path);
+               }
+       }
+       g_object_unref (settings);
+
+       if (folder)
+               return folder;
 
        store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
        folder = store_class->get_junk_folder_sync (store, cancellable, error);
@@ -1945,8 +1961,24 @@ imapx_store_get_trash_folder_sync (CamelStore *store,
                                    GCancellable *cancellable,
                                    GError **error)
 {
-       CamelFolder *folder;
+       CamelFolder *folder = NULL;
        CamelStoreClass *store_class;
+       CamelSettings *settings;
+
+       settings = camel_service_ref_settings (CAMEL_SERVICE (store));
+       if (camel_imapx_settings_get_use_real_trash_path (CAMEL_IMAPX_SETTINGS (settings))) {
+               gchar *real_trash_path;
+
+               real_trash_path = camel_imapx_settings_dup_real_trash_path (CAMEL_IMAPX_SETTINGS (settings));
+               if (real_trash_path) {
+                       folder = camel_store_get_folder_sync (store, real_trash_path, 0, cancellable, NULL);
+                       g_free (real_trash_path);
+               }
+       }
+       g_object_unref (settings);
+
+       if (folder)
+               return folder;
 
        store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
        folder = store_class->get_trash_folder_sync (store, cancellable, error);


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