[geary/mjog/invert-folder-class-hierarchy: 322/362] Geary: Update existing local folders to remove old API




commit 4be52094930547bde60283d5ea569ca4357061a9
Author: Michael Gratton <mike vee net>
Date:   Sat Sep 12 15:14:17 2020 +1000

    Geary: Update existing local folders to remove old API

 src/engine/app/app-search-folder.vala | 20 ++---------------
 src/engine/outbox/outbox-folder.vala  | 41 ++++-------------------------------
 2 files changed, 6 insertions(+), 55 deletions(-)
---
diff --git a/src/engine/app/app-search-folder.vala b/src/engine/app/app-search-folder.vala
index d08e45b73..6ecbbd2b3 100644
--- a/src/engine/app/app-search-folder.vala
+++ b/src/engine/app/app-search-folder.vala
@@ -13,8 +13,7 @@
  * search, then collects search results and presents them via the
  * folder interface.
  */
-public class Geary.App.SearchFolder :
-    AbstractLocalFolder, FolderSupport.Remove {
+public class Geary.App.SearchFolder : Folder, FolderSupport.Remove {
 
 
     /** Number of messages to include in the initial search. */
@@ -360,23 +359,8 @@ public class Geary.App.SearchFolder :
                 FolderSupport.Remove? removable = folder as FolderSupport.Remove;
                 if (removable != null) {
                     Gee.Collection<EmailIdentifier> ids = folders_to_ids.get(path);
-
                     debug("Search folder removing %d emails from %s", ids.size, folder.to_string());
-
-                    bool open = false;
-                    try {
-                        yield folder.open_async(NONE, cancellable);
-                        open = true;
-                        yield removable.remove_email_async(ids, cancellable);
-                    } finally {
-                        if (open) {
-                            try {
-                                yield folder.close_async();
-                            } catch (Error e) {
-                                debug("Error closing folder %s: %s", folder.to_string(), e.message);
-                            }
-                        }
-                    }
+                    yield removable.remove_email_async(ids, cancellable);
                 }
             }
         }
diff --git a/src/engine/outbox/outbox-folder.vala b/src/engine/outbox/outbox-folder.vala
index 71b82ee3d..b1754a2d5 100644
--- a/src/engine/outbox/outbox-folder.vala
+++ b/src/engine/outbox/outbox-folder.vala
@@ -9,8 +9,7 @@
 /**
  * A folder for storing outgoing mail.
  */
-public class Geary.Outbox.Folder :
-    Geary.AbstractLocalFolder,
+public class Geary.Outbox.Folder : Geary.Folder,
     Geary.FolderSupport.Create,
     Geary.FolderSupport.Mark,
     Geary.FolderSupport.Remove {
@@ -75,35 +74,15 @@ public class Geary.Outbox.Folder :
     }
 
     private weak Account _account;
-    private weak ImapDB.Account local;
-    private Db.Database? db = null;
+    private Db.Database db = null;
     private FolderProperties _properties = new FolderProperties(0, 0);
     private int64 next_ordering = 0;
 
 
-    internal Folder(Account account, FolderRoot root, ImapDB.Account local) {
+    internal Folder(Account account, FolderRoot root, Db.Database db) {
         this._account = account;
         this._path = root.get_child(MAGIC_BASENAME, Trillian.TRUE);
-        this.local = local;
-    }
-
-    public override async bool open_async(Geary.Folder.OpenFlags open_flags,
-                                          GLib.Cancellable? cancellable = null)
-        throws GLib.Error {
-        bool opened = yield base.open_async(open_flags, cancellable);
-        if (opened) {
-            this.db = this.local.db;
-        }
-        return opened;
-    }
-
-    public override async bool close_async(GLib.Cancellable? cancellable = null)
-        throws GLib.Error {
-        bool closed = yield base.close_async(cancellable);
-        if (closed) {
-            this.db = null;
-        }
-        return closed;
+        this.db = db;
     }
 
     public virtual async Geary.EmailIdentifier?
@@ -112,8 +91,6 @@ public class Geary.Outbox.Folder :
                            GLib.DateTime? date_received,
                            GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
-
         int email_count = 0;
         OutboxRow? row = null;
         yield db.exec_transaction_async(Db.TransactionType.WR, (cx) => {
@@ -153,7 +130,6 @@ public class Geary.Outbox.Folder :
                          EmailFlags? flags_to_remove,
                          GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
         Gee.Map<Geary.EmailIdentifier,EmailFlags> changed =
             new Gee.HashMap<Geary.EmailIdentifier,EmailFlags>();
 
@@ -176,8 +152,6 @@ public class Geary.Outbox.Folder :
         remove_email_async(Gee.Collection<Geary.EmailIdentifier> email_ids,
                            GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
-
         Gee.List<Geary.EmailIdentifier> removed = new Gee.ArrayList<Geary.EmailIdentifier>();
         int final_count = 0;
         yield db.exec_transaction_async(Db.TransactionType.WR, (cx) => {
@@ -216,7 +190,6 @@ public class Geary.Outbox.Folder :
         Gee.Collection<Geary.EmailIdentifier> ids,
         GLib.Cancellable? cancellable = null)
     throws GLib.Error {
-        check_open();
         var contains = new Gee.HashSet<Geary.EmailIdentifier>();
         yield db.exec_transaction_async(
             RO,
@@ -246,8 +219,6 @@ public class Geary.Outbox.Folder :
                                Geary.Folder.ListFlags flags,
                                GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
-
         EmailIdentifier? initial_id = _initial_id as EmailIdentifier;
         if (_initial_id != null && initial_id == null) {
             throw new EngineError.BAD_PARAMETERS("EmailIdentifier %s not for Outbox",
@@ -332,8 +303,6 @@ public class Geary.Outbox.Folder :
                                       Geary.Folder.ListFlags flags,
                                       GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
-
         Gee.List<Geary.Email> list = new Gee.ArrayList<Geary.Email>();
         yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
             foreach (Geary.EmailIdentifier id in ids) {
@@ -360,8 +329,6 @@ public class Geary.Outbox.Folder :
                           Geary.Folder.ListFlags flags,
                           GLib.Cancellable? cancellable = null)
         throws GLib.Error {
-        check_open();
-
         EmailIdentifier? outbox_id = id as EmailIdentifier;
         if (outbox_id == null)
             throw new EngineError.BAD_PARAMETERS("%s is not outbox EmailIdentifier", id.to_string());


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