[geary/wip/create-folders-713492: 20/26] Use required trash folder



commit 591bd7efcfd4f82f37cfdbdee0e5583e16f9c83a
Author: Charles Lindsay <chaz yorba org>
Date:   Thu Feb 6 14:24:00 2014 -0800

    Use required trash folder

 src/client/application/geary-controller.vala       |   43 +++++++------------
 .../gmail/imap-engine-gmail-search-folder.vala     |    2 +-
 2 files changed, 17 insertions(+), 28 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 6f8b5e0..075483e 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1894,26 +1894,10 @@ public class GearyController : Geary.BaseObject {
             on_archive_or_delete_selection_finished);
     }
     
-    private bool current_folder_supports_trash(out Geary.FolderSupport.Move? move = null,
-        out Geary.FolderPath? trash_path = null) {
-        try {
-            if (current_folder != null && current_folder.special_folder_type != Geary.SpecialFolderType.TRASH
-                && !current_folder.properties.is_local_only && current_account != null) {
-                Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
-                Geary.Folder? trash_folder = 
current_account.get_special_folder(Geary.SpecialFolderType.TRASH);
-                if (supports_move != null && trash_folder != null) {
-                    move = supports_move;
-                    trash_path = trash_folder.path;
-                    return true;
-                }
-            }
-        } catch (Error e) {
-            debug("Error finding trash folder: %s", e.message);
-        }
-        
-        move = null;
-        trash_path = null;
-        return false;
+    private bool current_folder_supports_trash() {
+        return (current_folder != null && current_folder.special_folder_type != Geary.SpecialFolderType.TRASH
+            && !current_folder.properties.is_local_only && current_account != null
+            && (current_folder as Geary.FolderSupport.Move) != null);
     }
     
     private async void archive_or_delete_selection_async(bool archive, bool trash,
@@ -1945,13 +1929,18 @@ public class GearyController : Geary.BaseObject {
         if (trash) {
             debug("Trashing selected messages");
             
-            Geary.FolderPath? trash_path;
-            Geary.FolderSupport.Move? supports_move;
-            if (!current_folder_supports_trash(out supports_move, out trash_path))
-                debug("Folder %s doesn't support move or account %s doesn't have a trash folder",
-                    current_folder.to_string(), current_account.to_string());
-            else
-                yield supports_move.move_email_async(ids, trash_path, cancellable);
+            if (current_folder_supports_trash()) {
+                Geary.FolderPath trash_path = (yield current_account.get_required_special_folder_async(
+                    Geary.SpecialFolderType.TRASH, cancellable)).path;
+                Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
+                if (supports_move != null) {
+                    yield supports_move.move_email_async(ids, trash_path, cancellable);
+                    return;
+                }
+            }
+            
+            debug("Folder %s doesn't support move or account %s doesn't have a trash folder",
+                current_folder.to_string(), current_account.to_string());
             return;
         }
         
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala 
b/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
index ca0b75f..4540e8d 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
@@ -21,7 +21,7 @@ public class Geary.ImapEngine.GmailSearchFolder : Geary.SearchFolder {
         Cancellable? cancellable = null) throws Error {
         Geary.Folder? trash_folder = null;
         try {
-            trash_folder = account.get_special_folder(Geary.SpecialFolderType.TRASH);
+            trash_folder = yield account.get_required_special_folder_async(Geary.SpecialFolderType.TRASH, 
cancellable);
         } catch (Error e) {
             debug("Error looking up trash folder in %s: %s", account.to_string(), e.message);
         }


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