[geary/wip/fix-error-on-goa-account-disabled] Fix an error being thrown when an active GOA account is disabled



commit a2a31d3816452519aa81e9c5527225ffe0df1cad
Author: Michael Gratton <mike vee net>
Date:   Wed Mar 6 20:37:16 2019 +1100

    Fix an error being thrown when an active GOA account is disabled
    
    When GOA accounts are disabled in Settings, they are updated in Geary.
    This caused an error updating credentials since we were trying to
    update the credentials for a now-disabled account.
    
    This patch makes Geary not do this.

 src/client/accounts/accounts-manager.vala | 22 ++++++++++++++--------
 src/client/application/goa-mediator.vala  | 11 +----------
 2 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/src/client/accounts/accounts-manager.vala b/src/client/accounts/accounts-manager.vala
index b8bbc982..967a2710 100644
--- a/src/client/accounts/accounts-manager.vala
+++ b/src/client/accounts/accounts-manager.vala
@@ -784,11 +784,10 @@ public class Accounts.Manager : GLib.Object {
     }
 
     private bool is_valid_goa_account(Goa.Object handle) {
-        // Goa.Account.mail_disabled doesn't seem to reflect if we get
-        // get a valid mail object here, so just rely on that instead.
         Goa.Mail? mail = handle.get_mail();
         return (
             mail != null &&
+            !handle.get_account().mail_disabled &&
             !Geary.String.is_empty(mail.imap_host) &&
             !Geary.String.is_empty(mail.smtp_host)
         );
@@ -838,15 +837,18 @@ public class Accounts.Manager : GLib.Object {
     }
 
     private async void update_goa_account(Geary.AccountInformation account,
+                                          bool is_available,
                                           GLib.Cancellable? cancellable) {
         GoaMediator mediator = (GoaMediator) account.mediator;
         try {
             yield mediator.update(account, cancellable);
 
-            // Update will clear the creds, so make sure they get
-            // refreshed
-            yield account.load_outgoing_credentials(cancellable);
-            yield account.load_incoming_credentials(cancellable);
+            if (is_available) {
+                // Update will clear the creds, so make sure they get
+                // refreshed
+                yield account.load_outgoing_credentials(cancellable);
+                yield account.load_incoming_credentials(cancellable);
+            }
         } catch (GLib.Error err) {
             report_problem(
                 new Geary.AccountProblemReport(
@@ -858,7 +860,7 @@ public class Accounts.Manager : GLib.Object {
 
         // XXX need to notify the engine that creds may have changed
 
-        set_available(account, mediator.is_available);
+        set_available(account, is_available);
     }
 
 
@@ -929,7 +931,11 @@ public class Accounts.Manager : GLib.Object {
             // We already know about this account, so check that it is
             // still valid. If not, the account should be disabled,
             // not deleted, since it may be re-enabled at some point.
-            this.update_goa_account.begin(state.account, null);
+            this.update_goa_account.begin(
+                state.account,
+                is_valid_goa_account(account),
+                null
+            );
         } else {
             // We haven't created an account for this GOA account
             // before, so try doing so now.
diff --git a/src/client/application/goa-mediator.vala b/src/client/application/goa-mediator.vala
index 09a87c44..40a41078 100644
--- a/src/client/application/goa-mediator.vala
+++ b/src/client/application/goa-mediator.vala
@@ -10,15 +10,6 @@
 public class GoaMediator : Geary.CredentialsMediator, Object {
 
 
-    public bool is_available {
-        get {
-            // Goa.Account.mail_disabled doesn't seem to reflect if we
-            // get can get a valid mail object or not, so just rely on
-            // actually getting one instead.
-            return this.handle.get_mail() != null;
-        }
-    }
-
     private Goa.Object handle;
 
 
@@ -111,7 +102,7 @@ public class GoaMediator : Geary.CredentialsMediator, Object {
         // password" or "GOA credentials need renewing" or
         // something. Connect to the GOA service and wait until we
         // hear that needs attention is no longer true.
-        return this.is_available;
+        return false;
     }
 
     private Geary.Credentials.Method get_auth_method() throws GLib.Error {


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