[geary/wip/20-cert-pinning: 5/5] Add Geary.ProblemType for TLS cert validation errors, clarify login errs



commit 3476749616ac93ad3b0e9a07801109fa40380399
Author: Michael Gratton <mike vee net>
Date:   Thu Dec 27 21:33:14 2018 +1100

    Add Geary.ProblemType for TLS cert validation errors, clarify login errs

 src/client/components/main-window-info-bar.vala        | 18 ++++++++++++++++--
 src/engine/api/geary-problem-report.vala               |  7 +++++--
 .../imap-engine/imap-engine-generic-account.vala       |  4 ++--
 src/engine/smtp/smtp-client-service.vala               |  2 +-
 4 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/client/components/main-window-info-bar.vala b/src/client/components/main-window-info-bar.vala
index 17902e36..4c4032ed 100644
--- a/src/client/components/main-window-info-bar.vala
+++ b/src/client/components/main-window-info-bar.vala
@@ -96,20 +96,34 @@ public class MainWindowInfoBar : Gtk.InfoBar {
                 descr = _("Could not communicate with %s for %s, check the server name and try again in a 
moment").printf(server, account);
                 retry = _("Try reconnecting");
 
-            } else if (report.problem_type == Geary.ProblemType.LOGIN_FAILED &&
+            } else if (report.problem_type == Geary.ProblemType.AUTHENTICATION &&
                        service_report.service.protocol == Geary.Protocol.IMAP) {
                 // Translators: String substitution is the account name
                 title = _("Incoming mail server password required for %s").printf(account);
                 descr = _("Messages cannot be received without the correct password.");
                 retry = _("Retry receiving email, you will be prompted for a password");
 
-            } else if (report.problem_type == Geary.ProblemType.LOGIN_FAILED &&
+            } else if (report.problem_type == Geary.ProblemType.AUTHENTICATION &&
                        service_report.service.protocol == Geary.Protocol.SMTP) {
                 // Translators: String substitution is the account name
                 title = _("Outgoing mail server password required for %s").printf(account);
                 descr = _("Messages cannot be sent without the correct password.");
                 retry = _("Retry sending queued messages, you will be prompted for a password");
 
+            } else if (report.problem_type == Geary.ProblemType.UNTRUSTED &&
+                       service_report.service.protocol == Geary.Protocol.IMAP) {
+                // Translators: String substitution is the account name
+                title = _("Incoming mail server security is not trusted for %s").printf(account);
+                descr = _("Messages will not be received until checked.");
+                retry = _("Check security details");
+
+            } else if (report.problem_type == Geary.ProblemType.UNTRUSTED &&
+                       service_report.service.protocol == Geary.Protocol.SMTP) {
+                // Translators: String substitution is the account name
+                title = _("Outgoing mail server security is not trusted for %s").printf(account);
+                descr = _("Messages cannot be sent until checked.");
+                retry = _("Check security details");
+
             } else if (report.problem_type == Geary.ProblemType.GENERIC_ERROR &&
                        service_report.service.protocol == Geary.Protocol.IMAP) {
                 // Translators: String substitution is the account name
diff --git a/src/engine/api/geary-problem-report.vala b/src/engine/api/geary-problem-report.vala
index 2e550560..3afe72b4 100644
--- a/src/engine/api/geary-problem-report.vala
+++ b/src/engine/api/geary-problem-report.vala
@@ -1,6 +1,6 @@
 /*
  * Copyright 2016 Software Freedom Conservancy Inc.
- * Copyright 2017 Michael Gratton <mike vee net>
+ * Copyright 2017-2018 Michael Gratton <mike vee net>
  *
  * This software is licensed under the GNU Lesser General Public License
  * (version 2.1 or later).  See the COPYING file in this distribution.
@@ -26,7 +26,10 @@ public enum Geary.ProblemType {
     SERVER_ERROR,
 
     /** Indicates credentials supplied for authentication were rejected. */
-    LOGIN_FAILED,
+    AUTHENTICATION,
+
+    /** Indicates a remote TLS certificate failed validation. */
+    UNTRUSTED,
 
     /** Indicates an outgoing message was sent, but not saved. */
     SEND_EMAIL_SAVE_FAILED;
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 5402e9af..f33e71fc 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -1046,7 +1046,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         this.authentication_failures++;
         if (this.authentication_failures >= Geary.Account.AUTH_ATTEMPTS_MAX) {
             // We have tried auth too many times, so bail out
-            notify_imap_problem(ProblemType.LOGIN_FAILED, null);
+            notify_imap_problem(ProblemType.AUTHENTICATION, null);
         } else {
             // login can fail due to an invalid password hence we
             // should re-ask it, but it can also fail due to server
@@ -1084,7 +1084,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
                                 this.restart_incoming_service.begin();
                             } else {
                                 // User cancelled, so indicate a login problem
-                                notify_imap_problem(ProblemType.LOGIN_FAILED, null);
+                                notify_imap_problem(ProblemType.AUTHENTICATION, null);
                             }
                         } catch (Error err) {
                             notify_imap_problem(ProblemType.GENERIC_ERROR, err);
diff --git a/src/engine/smtp/smtp-client-service.vala b/src/engine/smtp/smtp-client-service.vala
index 7ec81245..e0b4095f 100644
--- a/src/engine/smtp/smtp-client-service.vala
+++ b/src/engine/smtp/smtp-client-service.vala
@@ -136,7 +136,7 @@ internal class Geary.Smtp.ClientService : Geary.ClientService {
             } catch (SmtpError err) {
                 ProblemType problem = ProblemType.GENERIC_ERROR;
                 if (err is SmtpError.AUTHENTICATION_FAILED) {
-                    problem = ProblemType.LOGIN_FAILED;
+                    problem = ProblemType.AUTHENTICATION;
                 } else if (err is SmtpError.STARTTLS_FAILED) {
                     problem = ProblemType.CONNECTION_ERROR;
                 } else if (err is SmtpError.NOT_CONNECTED) {


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