[geary/wip/save-sent-713263] Move the logic for allowing save_sent_mail to acct info



commit 79b59de2eb49516fdf2c53783fcdf49adca95fdf
Author: Charles Lindsay <chaz yorba org>
Date:   Fri Jan 17 12:37:20 2014 -0800

    Move the logic for allowing save_sent_mail to acct info

 src/engine/api/geary-account-information.vala      |   28 +++++++++++++++++++-
 .../imap-engine/imap-engine-generic-account.vala   |    2 +-
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index b896512..78957ef 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -52,7 +52,20 @@ public class Geary.AccountInformation : BaseObject {
     public string email { get; set; }
     public Geary.ServiceProvider service_provider { get; set; }
     public int prefetch_period_days { get; set; }
-    public bool save_sent_mail { get; set; }
+    
+    /**
+     * Whether the user has requested that sent mail be saved.  Note that Geary
+     * will only actively push sent mail when this AND allow_save_sent_mail()
+     * are both true.
+     */
+    public bool save_sent_mail {
+        // If we aren't allowed to save sent mail due to account type, we want
+        // to return true here on the assumption that the account will save
+        // sent mail for us, and thus the user can't disable sent mail from
+        // being saved.
+        get { return (allow_save_sent_mail() ? _save_sent_mail : true); }
+        set { _save_sent_mail = value; }
+    }
     
     // Order for display purposes.
     public int ordinal { get; set; }
@@ -73,6 +86,8 @@ public class Geary.AccountInformation : BaseObject {
     public Geary.Credentials? smtp_credentials { get; set; default = new Geary.Credentials(null, null); }
     public bool smtp_remember_password { get; set; default = true; }
     
+    private bool _save_sent_mail = true;
+    
     // Used to create temporary AccountInformation objects.  (Note that these cannot be saved.)
     public AccountInformation.temp_copy(AccountInformation copy) {
         copy_from(copy);
@@ -155,6 +170,17 @@ public class Geary.AccountInformation : BaseObject {
     }
     
     /**
+     * Return whether this account allows setting the save_sent_mail option.
+     * If not, save_sent_mail will always be true and setting it will be
+     * ignored.
+     */
+    public bool allow_save_sent_mail() {
+        // We should never push mail to Gmail, since its servers automatically
+        // push sent mail to the sent mail folder.
+        return service_provider != ServiceProvider.GMAIL;
+    }
+    
+    /**
      * Fetch the passwords for the given services.  For each service, if the
      * password is unset, use get_passwords_async() first; if the password is
      * set or it's not in the key store, use prompt_passwords_async().  Return
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index f76c5a2..7cdfd4f 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -551,7 +551,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
     
     private async void handle_sent_email_async(Geary.RFC822.Message rfc822, Cancellable? cancellable)
         throws Error {
-        if (!allow_save_sent_mail || !information.save_sent_mail)
+        if (!information.allow_save_sent_mail() || !information.save_sent_mail)
             return;
         
         Geary.Folder? sent_mail = get_special_folder(Geary.SpecialFolderType.SENT);


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