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



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

    Fix SMTP auth errors when using IMAP credentials
    
    Default response for AccountInformation.load_outgoing_credentials (and
    for incoming) should be null in case there's no credentials, but also
    loading ougoing must load incoming when USE_INCOMING is set.
    
    Fixes SMTP side of #301

 src/engine/api/geary-account-information.vala | 28 ++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index 89b83363..48d069f8 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -471,18 +471,24 @@ public class Geary.AccountInformation : BaseObject {
      * 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
-     * credentials are invalid.
+     * Returns true if the credentials were successfully loaded or are
+     * null, or false if the credentials 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;
+        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;
     }
@@ -493,14 +499,14 @@ public class Geary.AccountInformation : BaseObject {
      * 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
-     * credentials are invalid.
+     * Returns true if the credentials were successfully loaded or are
+     * null, or false if the credentials 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]