[geary/wip/301-auth-errors] Fix SMTP auth errors when using IMAP credentials



commit cd8ed405593db2b7e1ebbe8d2e74e8c9a96d8c3a
Author: Michael Gratton <mike vee net>
Date:   Sat Mar 9 09:50:27 2019 +1100

    Fix SMTP auth errors when using IMAP credentials
    
    AccountInformation.load_outgoing_credentials (and incoming) should be
    true in case there's no credentials, but also loading ougoing must use
    the incoming service and credentials when USE_INCOMING is set.
    
    Fixes SMTP side of #301 at least.

 src/engine/api/geary-account-information.vala | 32 +++++++++++++++++----------
 1 file changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index 89b83363..980ef711 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -466,41 +466,49 @@ public class Geary.AccountInformation : BaseObject {
     }
 
     /**
-     * Loads this account's outgoing service credentials, if needed.
+     * Loads the authentication token for the outgoing service.
      *
      * Credentials are loaded from the mediator, thus it may yield for
      * some time.
      *
-     * Returns true if the credentials were successfully loaded, or
-     * false if the credentials could not be loaded and the service's
+     * Returns true if the credential's token was successfully loaded
+     * or are not needed (that is, if the credentials are null), or
+     * false if the token could not be loaded and the service's
      * credentials are invalid.
      */
     public async bool load_outgoing_credentials(GLib.Cancellable? cancellable)
         throws GLib.Error {
-        Credentials? creds = this.outgoing.credentials;
-        bool loaded = false;
+        Credentials? creds = get_outgoing_credentials();
+        bool loaded = true;
         if (creds != null) {
-            loaded = yield this.mediator.load_token(
-                this, this.outgoing, cancellable
-            );
+            if (this.outgoing.credentials_requirement == USE_INCOMING) {
+                loaded = yield this.mediator.load_token(
+                    this, this.incoming, cancellable
+                );
+            } else {
+                loaded = yield this.mediator.load_token(
+                    this, this.outgoing, cancellable
+                );
+            }
         }
         return loaded;
     }
 
     /**
-     * Loads this account's incoming service credentials, if needed.
+     * Loads the authentication token for the incoming service.
      *
      * Credentials are loaded from the mediator, thus it may yield for
      * some time.
      *
-     * Returns true if the credentials were successfully loaded, or
-     * false if the credentials could not be loaded and the service's
+     * Returns true if the credential's token was successfully loaded
+     * or are not needed (that is, if the credentials are null), or
+     * false if the token could not be loaded and the service's
      * credentials are invalid.
      */
     public async bool load_incoming_credentials(GLib.Cancellable? cancellable)
         throws GLib.Error {
         Credentials? creds = this.incoming.credentials;
-        bool loaded = false;
+        bool loaded = true;
         if (creds != null) {
             loaded = yield this.mediator.load_token(
                 this, this.incoming, cancellable


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