[geary/wip/20-cert-pinning: 24/32] Remove now-unsed validation code from Geary.Engine



commit 45c52cd5e7914b84a59b68187899ef8f41f40b68
Author: Michael Gratton <mike vee net>
Date:   Thu Dec 27 18:50:44 2018 +1100

    Remove now-unsed validation code from Geary.Engine
    
    Also, clean up class doc comment to better reflect reality.

 src/client/application/geary-controller.vala | 88 ----------------------------
 src/engine/api/geary-engine.vala             | 43 +++-----------
 2 files changed, 9 insertions(+), 122 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 70a72c82..df67e1ac 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -797,94 +797,6 @@ public class GearyController : Geary.BaseObject {
         }
     }
 
-    // Returns possibly modified validation results
-    private Geary.Engine.ValidationResult validation_check_endpoint_for_tls_warnings(
-        Geary.AccountInformation account, Geary.ServiceInformation service,
-        Geary.Engine.ValidationResult validation_result, out bool prompted, out bool retry_required) {
-        prompted = false;
-        retry_required = false;
-
-        // use LoginDialog for parent only if available and visible
-        Gtk.Window? parent;
-        //if (login_dialog != null && login_dialog.visible)
-        //    parent = login_dialog;
-        //else
-            parent = main_window;
-
-        Geary.Endpoint endpoint = get_endpoint(account, service);
-
-        // If Endpoint had unresolved TLS issues, prompt user about them
-        if (endpoint.tls_validation_warnings != 0 && endpoint.trust_untrusted_host != Geary.Trillian.TRUE) {
-            prompt_for_untrusted_host(parent, account, service, true);
-            prompted = true;
-        }
-
-        // If there are still TLS connection issues that caused the connection to fail (happens on the
-        // first attempt), clear those errors and retry
-        if (endpoint.tls_validation_warnings != 0 && endpoint.trust_untrusted_host == Geary.Trillian.TRUE) {
-            Geary.Engine.ValidationResult flag = (service.protocol == Geary.Protocol.IMAP)
-                ? Geary.Engine.ValidationResult.IMAP_CONNECTION_FAILED
-                : Geary.Engine.ValidationResult.SMTP_CONNECTION_FAILED;
-
-            if ((validation_result & flag) != 0) {
-                validation_result &= ~flag;
-                retry_required = true;
-            }
-        }
-        
-        return validation_result;
-    }
-    
-    // Use after validating to see if TLS warnings were handled by the user and need to retry the
-    // validation; this will also modify the validation results to better indicate issues to the user
-    //
-    // Returns possibly modified validation results
-    public async Geary.Engine.ValidationResult validation_check_for_tls_warnings_async(
-        Geary.AccountInformation config, Geary.Engine.ValidationResult validation_result,
-        out bool retry_required) {
-        retry_required = false;
-
-        // Because TLS warnings need cycles to process, sleep and give 'em a chance to do their
-        // thing ... note that the signal handler does *not* invoke the user prompt dialog when the
-        // login dialog is in play, so this sleep does not need to worry about user input
-        yield Geary.Scheduler.sleep_ms_async(100);
-
-        // check each service for problems, prompting user each time for verification
-        bool imap_prompted, imap_retry_required;
-        validation_result = validation_check_endpoint_for_tls_warnings(
-            config,
-            config.incoming,
-            validation_result,
-            out imap_prompted,
-            out imap_retry_required
-        );
-
-        bool smtp_prompted, smtp_retry_required;
-        validation_result = validation_check_endpoint_for_tls_warnings(
-            config,
-            config.outgoing,
-            validation_result,
-            out smtp_prompted,
-            out smtp_retry_required
-        );
-
-        // if prompted for user acceptance of bad certificates and
-        // they agreed to both, try again
-        Geary.Account account = this.accounts.get(config).account;
-        if (imap_prompted && smtp_prompted
-            && account.incoming.remote.is_trusted_or_never_connected
-            && account.outgoing.remote.is_trusted_or_never_connected) {
-            retry_required = true;
-        } else if (validation_result == Geary.Engine.ValidationResult.OK) {
-            retry_required = true;
-        } else {
-            // if prompt requires retry or otherwise detected it, retry
-            retry_required = imap_retry_required && smtp_retry_required;
-        }
-
-        return validation_result;
-    }
-
     private void report_problem(Geary.ProblemReport report) {
         debug("Problem reported: %s", report.to_string());
 
diff --git a/src/engine/api/geary-engine.vala b/src/engine/api/geary-engine.vala
index 8d37ce7e..6dea9e7c 100644
--- a/src/engine/api/geary-engine.vala
+++ b/src/engine/api/geary-engine.vala
@@ -7,49 +7,24 @@
  */
 
 /**
- * The Geary email engine initial entry points.
+ * Manages email account instances and their life-cycle.
  *
- * Engine represents and contains interfaces into the rest of the email library.  It's a singleton
- * class (see {@link instance}) with various signals for event notification.  Engine is initialized
- * by calling {@link open_async} and closed with {@link close_async}.
- *
- * Engine can list existing {@link Account} objects and create/delete them.  It can also validate
- * changes to Accounts prior to saving those changes.
+ * An engine represents and contains interfaces into the rest of the
+ * email library. Instances are initialized by calling {@link
+ * open_async} and closed with {@link close_async}. Use this class for
+ * verifying and adding {@link AccountInformation} objects to check
+ * and start using email accounts.
  */
 public class Geary.Engine : BaseObject {
 
-    [Flags]
-    public enum ValidationOption {
-        NONE = 0,
-        CHECK_CONNECTIONS,
-        UPDATING_EXISTING;
-        
-        public inline bool is_all_set(ValidationOption options) {
-            return (options & this) == options;
-        }
-    }
-    
-    [Flags]
-    public enum ValidationResult {
-        OK = 0,
-        INVALID_NICKNAME,
-        EMAIL_EXISTS,
-        IMAP_CONNECTION_FAILED,
-        IMAP_CREDENTIALS_INVALID,
-        SMTP_CONNECTION_FAILED,
-        SMTP_CREDENTIALS_INVALID;
-        
-        public inline bool is_all_set(ValidationResult result) {
-            return (result & this) == result;
-        }
-    }
-    
-    private static Engine? _instance = null;
+
     public static Engine instance {
         get {
             return (_instance != null) ? _instance : (_instance = new Engine());
         }
     }
+    private static Engine? _instance = null;
+
 
     // Workaround for Vala issue #659. See shared_endpoints below.
     private class EndpointWeakRef {


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