[geary] Make all account types support archiving. Bug 766912.



commit f8acc74eaa4da1084267053c0fe0e1c77828d191
Author: Michael James Gratton <mike vee net>
Date:   Thu Jun 2 10:35:43 2016 +1000

    Make all account types support archiving. Bug 766912.
    
    Move Geary.FolderSupport.Archive interface and implementation from
    OtherFolder to GenericFolder, so both Y! and Outlook services get archive
    support.
    
    * src/client/components/main-toolbar.vala
      (MainToolbar::update_trash_button): Renamed from
      update_trash_archive_buttons, only bother to update the archive
      state. Update call sites.
    
    * src/engine/api/geary-account.vala (Geary.Account): Remove
      can_support_archive property and constructor arg, update subclasses to
      not pass it through.
    
    * src/engine/imap-engine/imap-engine-generic-folder.vala (GenericFolder):
      Extend Geary.FolderSupport.Archive, copy implementation from
      OtherFolder.
    
    * src/engine/imap-engine/other/imap-engine-other-folder.vala
      (OtherFolder): Remove Geary.FolderSupport.Archive parent class and
      implementation.

 src/client/application/geary-controller.vala       |   18 ++++++------
 src/client/components/main-toolbar.vala            |    9 ++----
 src/engine/api/geary-account.vala                  |   18 +++++--------
 .../gmail/imap-engine-gmail-account.vala           |    4 +-
 .../imap-engine/imap-engine-generic-account.vala   |    4 +-
 .../imap-engine/imap-engine-generic-folder.vala    |   28 +++++++++++++++++--
 .../other/imap-engine-other-account.vala           |    4 +-
 .../other/imap-engine-other-folder.vala            |   19 +------------
 .../outlook/imap-engine-outlook-account.vala       |    6 ++--
 .../yahoo/imap-engine-yahoo-account.vala           |    6 ++--
 10 files changed, 57 insertions(+), 59 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index d3c75f6..98cb728 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1285,16 +1285,17 @@ public class GearyController : Geary.BaseObject {
         
         return num;
     }
-    
+
     // Update widgets and such to match capabilities of the current folder ... sensitivity is handled
     // by other utility methods
     private void update_ui() {
         update_tooltips();
-        main_window.main_toolbar.update_trash_archive_buttons(
-            current_folder_supports_trash() || !(current_folder is Geary.FolderSupport.Remove),
-            current_account.can_support_archive);
+        main_window.main_toolbar.update_trash_button(
+            current_folder_supports_trash() ||
+            !(current_folder is Geary.FolderSupport.Remove)
+        );
     }
-    
+
     private void on_folder_selected(Geary.Folder? folder) {
         debug("Folder %s selected", folder != null ? folder.to_string() : "(null)");
         
@@ -1704,12 +1705,11 @@ public class GearyController : Geary.BaseObject {
     private void on_shift_key(bool pressed) {
         if (main_window != null && main_window.main_toolbar != null
             && current_account != null && current_folder != null) {
-            main_window.main_toolbar.update_trash_archive_buttons(
-                (!pressed && current_folder_supports_trash()) || !(current_folder is 
Geary.FolderSupport.Remove),
-                current_account.can_support_archive);
+            main_window.main_toolbar.update_trash_button(
+                (!pressed && current_folder_supports_trash()) || !(current_folder is 
Geary.FolderSupport.Remove));
         }
     }
-    
+
     // this signal does not necessarily indicate that the application previously didn't have
     // focus and now it does
     private void on_has_toplevel_focus() {
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 9fa0d3a..01eb8c4 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -128,14 +128,11 @@ public class MainToolbar : Gtk.Box {
         Gtk.Settings.get_default().notify["gtk-decoration-layout"].connect(set_window_buttons);
         realize.connect(set_window_buttons);
     }
-    
-    /// Updates the trash button as trash or delete, and shows or hides the archive button.
-    public void update_trash_archive_buttons(bool trash, bool archive) {
-        string action_name = (trash ? GearyController.ACTION_TRASH_MESSAGE
+
+    public void update_trash_button(bool is_trash) {
+        string action_name = (is_trash ? GearyController.ACTION_TRASH_MESSAGE
             : GearyController.ACTION_DELETE_MESSAGE);
         conversation_header.setup_button(trash_delete_button, null, action_name, false);
-        
-        archive_button.visible = archive;
     }
 
     public void set_conversation_header(Gtk.HeaderBar header) {
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index 33effd3..05ec03a 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -38,15 +38,7 @@ public abstract class Geary.Account : BaseObject {
     public Geary.ProgressMonitor db_vacuum_monitor { get; protected set; }
     public Geary.ProgressMonitor opening_monitor { get; protected set; }
     public Geary.ProgressMonitor sending_monitor { get; protected set; }
-    
-    /**
-     * HACK: for now, only certain account types support folders with
-     * FolderSupport.Archive.  It's useful to know whether an account supports
-     * archive because the button is hidden for accounts that will never
-     * support it.
-     */
-    public bool can_support_archive { get; protected set; }
-    
+
     public signal void opened();
     
     public signal void closed();
@@ -89,6 +81,11 @@ public abstract class Geary.Account : BaseObject {
     public signal void folders_contents_altered(Gee.Collection<Geary.Folder> altered);
     
     /**
+     * Fired when a Folder's contents is detected having changed.
+     */
+    public signal void folders_special_type(Gee.Collection<Geary.Folder> altered);
+    
+    /**
      * Fired when emails are appended to a folder in this account.
      */
     public signal void email_appended(Geary.Folder folder, Gee.Collection<Geary.EmailIdentifier> ids);
@@ -126,10 +123,9 @@ public abstract class Geary.Account : BaseObject {
     
     private string name;
     
-    protected Account(string name, AccountInformation information, bool can_support_archive) {
+    protected Account(string name, AccountInformation information) {
         this.name = name;
         this.information = information;
-        this.can_support_archive = can_support_archive;
     }
     
     protected virtual void notify_folders_available_unavailable(Gee.List<Geary.Folder>? available,
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala 
b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
index 8607637..6f292cb 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
@@ -36,9 +36,9 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
 
     public GmailAccount(string name, Geary.AccountInformation account_information,
         Imap.Account remote, ImapDB.Account local) {
-        base (name, account_information, true, remote, local);
+        base (name, account_information, remote, local);
     }
-    
+
     protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
         ImapDB.Account local_account, ImapDB.Folder local_folder) {
         SpecialFolderType special_folder_type;
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 1e99263..9a67cfa 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -37,9 +37,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
     private Cancellable refresh_cancellable = new Cancellable();
     private bool awaiting_credentials = false;
     
-    public GenericAccount(string name, Geary.AccountInformation information, bool can_support_archive,
+    public GenericAccount(string name, Geary.AccountInformation information,
         Imap.Account remote, ImapDB.Account local) {
-        base (name, information, can_support_archive);
+        base (name, information);
         
         this.remote = remote;
         this.local = local;
diff --git a/src/engine/imap-engine/imap-engine-generic-folder.vala 
b/src/engine/imap-engine/imap-engine-generic-folder.vala
index 176df06..889d9bf 100644
--- a/src/engine/imap-engine/imap-engine-generic-folder.vala
+++ b/src/engine/imap-engine/imap-engine-generic-folder.vala
@@ -4,13 +4,35 @@
  * (version 2.1 or later).  See the COPYING file in this distribution.
  */
 
-private class Geary.ImapEngine.GenericFolder : MinimalFolder, Geary.FolderSupport.Remove,
-    Geary.FolderSupport.Create, Geary.FolderSupport.Empty {
+private class Geary.ImapEngine.GenericFolder : MinimalFolder,
+    Geary.FolderSupport.Archive,
+    Geary.FolderSupport.Remove,
+    Geary.FolderSupport.Create,
+    Geary.FolderSupport.Empty {
+
     public GenericFolder(GenericAccount account, Imap.Account remote, ImapDB.Account local,
         ImapDB.Folder local_folder, SpecialFolderType special_folder_type) {
         base (account, remote, local, local_folder, special_folder_type);
     }
-    
+
+    public async Geary.Revokable? archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+        Cancellable? cancellable = null) throws Error {
+        Geary.Folder? archive_folder = null;
+        try {
+            archive_folder = yield 
account.get_required_special_folder_async(Geary.SpecialFolderType.ARCHIVE, cancellable);
+        } catch (Error e) {
+            debug("Error looking up archive folder in %s: %s", account.to_string(), e.message);
+        }
+
+        if (archive_folder == null) {
+            debug("Can't archive email because no archive folder was found in %s", account.to_string());
+        } else {
+            return yield move_email_async(email_ids, archive_folder.path, cancellable);
+        }
+
+        return null;
+    }
+
     public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
         Cancellable? cancellable = null) throws Error {
         yield expunge_email_async(email_ids, cancellable);
diff --git a/src/engine/imap-engine/other/imap-engine-other-account.vala 
b/src/engine/imap-engine/other/imap-engine-other-account.vala
index 934e0ca..3ff0cef 100644
--- a/src/engine/imap-engine/other/imap-engine-other-account.vala
+++ b/src/engine/imap-engine/other/imap-engine-other-account.vala
@@ -7,9 +7,9 @@
 private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount {
     public OtherAccount(string name, AccountInformation account_information,
         Imap.Account remote, ImapDB.Account local) {
-        base (name, account_information, true, remote, local);
+        base (name, account_information, remote, local);
     }
-    
+
     protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
         ImapDB.Account local_account, ImapDB.Folder local_folder) {
         SpecialFolderType type;
diff --git a/src/engine/imap-engine/other/imap-engine-other-folder.vala 
b/src/engine/imap-engine/other/imap-engine-other-folder.vala
index 882131f..e966603 100644
--- a/src/engine/imap-engine/other/imap-engine-other-folder.vala
+++ b/src/engine/imap-engine/other/imap-engine-other-folder.vala
@@ -4,27 +4,10 @@
  * (version 2.1 or later).  See the COPYING file in this distribution.
  */
 
-private class Geary.ImapEngine.OtherFolder : GenericFolder, FolderSupport.Archive {
+private class Geary.ImapEngine.OtherFolder : GenericFolder {
     public OtherFolder(OtherAccount account, Imap.Account remote, ImapDB.Account local,
         ImapDB.Folder local_folder, SpecialFolderType special_folder_type) {
         base (account, remote, local, local_folder, special_folder_type);
     }
 
-    public async Geary.Revokable? archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
-        Cancellable? cancellable = null) throws Error {
-        Geary.Folder? archive_folder = null;
-        try {
-            archive_folder = yield 
account.get_required_special_folder_async(Geary.SpecialFolderType.ARCHIVE, cancellable);
-        } catch (Error e) {
-            debug("Error looking up archive folder in %s: %s", account.to_string(), e.message);
-        }
-
-        if (archive_folder == null) {
-            debug("Can't archive email because no archive folder was found in %s", account.to_string());
-        } else {
-            return yield move_email_async(email_ids, archive_folder.path, cancellable);
-        }
-
-        return null;
-    }
 }
diff --git a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala 
b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
index 1ac43bf..3ca4acd 100644
--- a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
+++ b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
@@ -20,12 +20,12 @@ private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount
             Geary.Endpoint.Flags.STARTTLS,
             Smtp.ClientConnection.DEFAULT_TIMEOUT_SEC);
     }
-    
+
     public OutlookAccount(string name, AccountInformation account_information, Imap.Account remote,
         ImapDB.Account local) {
-        base (name, account_information, false, remote, local);
+        base (name, account_information, remote, local);
     }
-    
+
     protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
         ImapDB.Account local_account, ImapDB.Folder local_folder) {
         // use the Folder's attributes to determine if it's a special folder type, unless it's
diff --git a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala 
b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
index db83f5c..651a693 100644
--- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
+++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
@@ -22,11 +22,11 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
     }
     
     private static Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>? special_map = null;
-    
+
     public YahooAccount(string name, AccountInformation account_information,
         Imap.Account remote, ImapDB.Account local) {
-        base (name, account_information, false, remote, local);
-        
+        base (name, account_information, remote, local);
+
         if (special_map == null) {
             special_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>();
             


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