[geary/wip/problem-report-cleanup: 1/2] Clean up problem report types and UI



commit 207eb07baeff054d0013abe132e770f6f4a36f26
Author: Michael Gratton <mike vee net>
Date:   Sat Mar 23 14:05:59 2019 +1100

    Clean up problem report types and UI
    
    With the new account status work, many of the existing problem report
    types don't actually get used any more. Remove all but one of the types
    and related UI.

 src/client/application/geary-controller.vala       |   2 +-
 src/client/components/main-window-info-bar.vala    | 143 +++++----------------
 src/engine/api/geary-problem-report.vala           |  43 +------
 .../imap-engine/imap-engine-generic-account.vala   |  15 +--
 4 files changed, 38 insertions(+), 165 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index a0b9f789..3164ce4d 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -882,7 +882,7 @@ public class GearyController : Geary.BaseObject {
             context.tls_validation_failed = false;
             report_problem(
                 new Geary.ServiceProblemReport(
-                    Geary.ProblemType.UNTRUSTED,
+                    Geary.ProblemType.GENERIC_ERROR,
                     context.account.information,
                     service,
                     err
diff --git a/src/client/components/main-window-info-bar.vala b/src/client/components/main-window-info-bar.vala
index d8dc148b..1084c71e 100644
--- a/src/client/components/main-window-info-bar.vala
+++ b/src/client/components/main-window-info-bar.vala
@@ -39,135 +39,50 @@ public class MainWindowInfoBar : Gtk.InfoBar {
         if (report is Geary.ServiceProblemReport) {
             Geary.ServiceProblemReport service_report = (Geary.ServiceProblemReport) report;
             string account = service_report.account.display_name;
-            string server = service_report.service.host;
-
-            if (report.problem_type == Geary.ProblemType.CONNECTION_ERROR &&
-                service_report.service.protocol == Geary.Protocol.IMAP) {
-                // Translators: String substitution is the account name
-                title = _("Problem connecting to incoming server for %s".printf(account));
-                // Translators: String substitution is the server name
-                descr = _("Could not connect to %s, check your Internet access and the server name and try 
again").printf(server);
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
-
-            } else if (report.problem_type == Geary.ProblemType.CONNECTION_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.SMTP) {
-                // Translators: String substitution is the account name
-                title = _("Problem connecting to outgoing server for %s".printf(account));
-                // Translators: String substitution is the server name
-                descr = _("Could not connect to %s, check your Internet access and the server name and try 
again").printf(server);
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
-
-            } else if (report.problem_type == Geary.ProblemType.NETWORK_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.IMAP) {
-                // Translators: String substitution is the account name
-                title = _("Problem communicating with incoming server for %s").printf(account);
-                // Translators: String substitution is the server name
-                descr = _("Network error talking to %s, check your Internet access and try 
again").printf(server);
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
-
-            } else if (report.problem_type == Geary.ProblemType.NETWORK_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.SMTP) {
-                // Translators: String substitution is the account name
-                title = _("Problem communicating with outgoing mail server");
-                // Translators: String substitution is the server name
-                descr = _("Network error talking to %s, check your Internet access and try 
again").printf(server);
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
-
-            } else if (report.problem_type == Geary.ProblemType.SERVER_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.IMAP) {
-                // Translators: String substitution is the account name
-                title = _("Problem communicating with incoming server for %s").printf(account);
-                // Translators: String substitution is the server name
-                descr = _("Geary did not understand a message from %s or vice versa, please file a bug 
report").printf(server);
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
 
-            } else if (report.problem_type == Geary.ProblemType.SERVER_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.SMTP) {
-                title = _("Problem communicating with outgoing mail server");
-                // Translators: First string substitution is the server
-                // name, second is the account name
-                descr = _("Could not communicate with %s for %s, check the server name and try again in a 
moment").printf(server, account);
+            if (service_report.service.protocol == Geary.Protocol.IMAP) {
+                // Translators: Info bar title for an incoming account
+                // problem. String substitution is the account name
+                title = _("A problem occurred checking email for %s").printf(account);
+                // Translators: Info bar sub-title for an incoming account
+                // problem.
+                descr = _("Email will not be received until re-connected");
                 // Translators: Tooltip label for Retry button
                 retry = _("Try reconnecting");
 
-            } 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.");
-                // Translators: Tooltip label for Retry button
-                retry = _("Retry receiving email, you will be prompted for a password");
-
-            } 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.");
-                // Translators: Tooltip label for Retry button
-                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.");
-                // Translators: Tooltip label for Retry button
-                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.");
-                // Translators: Tooltip label for Retry button
-                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
-                title = _("A problem occurred checking mail for %s").printf(account);
-                descr = _("Something went wrong, please file a bug report if the problem persists");
-                // Translators: Tooltip label for Retry button
-                retry = _("Try reconnecting");
-
-            } else if (report.problem_type == Geary.ProblemType.GENERIC_ERROR &&
-                       service_report.service.protocol == Geary.Protocol.SMTP) {
-                // Translators: String substitution is the account name
-                title = _("A problem occurred sending mail for %s").printf(account);
-                descr = _("Something went wrong, please file a bug report if the problem persists");
+            } else if (service_report.service.protocol == Geary.Protocol.SMTP) {
+                // Translators: Info bar title for an outgoing account
+                // problem. String substitution is the account name
+                title = _("A problem occurred sending email for %s").printf(account);
+                // Translators: Info bar sub-title for an outgoing
+                // account problem.
+                descr = _("Email will not be sent until re-connected");
                 // Translators: Tooltip label for Retry button
                 retry = _("Retry sending queued messages");
 
-            } else {
-                debug("Un-handled service problem report: %s".printf(report.to_string()));
-                show_generic = true;
             }
         } else if (report is Geary.AccountProblemReport) {
             Geary.AccountProblemReport account_report = (Geary.AccountProblemReport) report;
             string account = account_report.account.display_name;
-            if (report.problem_type == Geary.ProblemType.DATABASE_FAILURE) {
-                type = Gtk.MessageType.ERROR;
-                title = _("A database problem has occurred");
-                // Translators: String substitution is the account name
-                descr = _("Messages for %s must be downloaded again.").printf(account);
-                show_close = true;
-
-            } else {
-                debug("Un-handled account problem report: %s".printf(report.to_string()));
-                show_generic = true;
-            }
+
+            // Translators: Info bar title for a generic account
+            // problem. String substitution is the account name
+            title = _("A problem occurred with account %s").printf(account);
+            // Translators: Info bar sub-title for a generic account
+            // problem.
+            descr = _("Something went wrong, please file a bug report if the problem persists");
+
         } else {
             debug("Un-handled generic problem report: %s".printf(report.to_string()));
             show_generic = true;
         }
 
         if (show_generic) {
+            // Translators: Info bar title for a generic application
+            // problem.
             title = _("Geary has encountered a problem");
+            // Translators: Info bar sub-title for a generic
+            // application problem.
             descr = _("Please check the technical details and report the problem if it persists.");
             show_close = true;
         }
@@ -176,11 +91,17 @@ public class MainWindowInfoBar : Gtk.InfoBar {
         this.report = report;
 
         if (this.report.error != null) {
+            // Translators: Button label for viewing technical details
+            // for a problem report.
             Gtk.Button details = add_button(_("_Details"), ResponseType.DETAILS);
+            // Translators: Tooltip for viewing technical details for
+            // a problem report.
             details.tooltip_text = _("View technical details about the error");
         }
 
         if (retry != null) {
+            // Translators: Button label for retrying a server
+            // connection
             Gtk.Button retry_btn = add_button(_("_Retry"), ResponseType.RETRY);
             retry_btn.tooltip_text = retry;
         }
diff --git a/src/engine/api/geary-problem-report.vala b/src/engine/api/geary-problem-report.vala
index 35353562..1d3789d2 100644
--- a/src/engine/api/geary-problem-report.vala
+++ b/src/engine/api/geary-problem-report.vala
@@ -10,47 +10,8 @@
 public enum Geary.ProblemType {
 
 
-    /** Indicates an engine problem not covered by one of the other types. */
-    GENERIC_ERROR,
-
-    /** Indicates an error opening, using or closing the account database. */
-    DATABASE_FAILURE,
-
-    /** Indicates a problem establishing a connection. */
-    CONNECTION_ERROR,
-
-    /** Indicates a problem caused by a network operation. */
-    NETWORK_ERROR,
-
-    /** Indicates a non-network related server error. */
-    SERVER_ERROR,
-
-    /** Indicates credentials supplied for authentication were rejected. */
-    AUTHENTICATION,
-
-    /** Indicates a remote TLS certificate failed validation. */
-    UNTRUSTED,
-
-    /** Indicates an outgoing message was sent, but not saved. */
-    SEND_EMAIL_SAVE_FAILED;
-
-
-    /** Determines the appropriate problem type for an IOError. */
-    public static ProblemType for_ioerror(IOError error) {
-        if (error is IOError.CONNECTION_REFUSED ||
-            error is IOError.HOST_NOT_FOUND ||
-            error is IOError.HOST_UNREACHABLE ||
-            error is IOError.NETWORK_UNREACHABLE) {
-            return ProblemType.CONNECTION_ERROR;
-        }
-
-        if (error is IOError.CONNECTION_CLOSED ||
-            error is IOError.NOT_CONNECTED) {
-            return ProblemType.NETWORK_ERROR;
-        }
-
-        return ProblemType.GENERIC_ERROR;
-    }
+    /** Indicates an engine problem not covered by another type. */
+    GENERIC_ERROR;
 
 }
 
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index cb7f54af..0dd764e7 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -999,18 +999,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
     }
 
     private void on_operation_error(AccountOperation op, Error error) {
-        if (error is ImapError) {
-            notify_service_problem(
-                ProblemType.SERVER_ERROR, this.information.incoming, error
-            );
-        } else if (error is IOError) {
-            // IOErrors could be network related or disk related, need
-            // to work out the difference and send a service problem
-            // if definitely network related
-            notify_account_problem(ProblemType.for_ioerror((IOError) error), error);
-        } else {
-            notify_account_problem(ProblemType.GENERIC_ERROR, error);
-        }
+        notify_service_problem(
+            ProblemType.GENERIC_ERROR, this.information.incoming, error
+        );
     }
 
     private void on_imap_status_notify() {


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