[geary/wip/17-noisy-problem-reports: 4/12] Set default account and client service status to something useful



commit 62665bf782655ecbd661e65ef31706c79f32c963
Author: Michael Gratton <mike vee net>
Date:   Sun Dec 30 22:32:41 2018 +1100

    Set default account and client service status to something useful
    
    Set account default to ONLINE, so we don't initially show up as being
    offline before even having checked connectivity. Add an UNKNOWN to
    client service status so that when the initial connectivity check comes
    up offine, the account actually gets notified and hence also the client.

 src/engine/api/geary-account.vala        | 10 ++++++++--
 src/engine/api/geary-client-service.vala | 27 +++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index f54b3cbe..cbce1282 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -79,11 +79,17 @@ public abstract class Geary.Account : BaseObject {
      *
      * This property's value is set based on the {@link
      * ClientService.current_status} of the account's {@link incoming}
-     * and {@link outgoing} services. if
+     * and {@link outgoing} services. See {@link Status} for more
+     * information.
+     *
+     * The initial value for this property is {@link Status.ONLINE},
+     * which may or may not be incorrect. However the once the account
+     * has been opened, its services will begin checking connectivity
+     * and the value will be updated to match in due course.
      *
      * @see ClientService.current_status
      */
-    public Status current_status { get; protected set; default = 0; }
+    public Status current_status { get; protected set; default = ONLINE; }
 
     /**
      * The service manager for the incoming email service.
diff --git a/src/engine/api/geary-client-service.vala b/src/engine/api/geary-client-service.vala
index 1c72df46..1e06faf6 100644
--- a/src/engine/api/geary-client-service.vala
+++ b/src/engine/api/geary-client-service.vala
@@ -29,17 +29,31 @@ public abstract class Geary.ClientService : BaseObject {
      */
     public enum Status {
 
+        /**
+         * The service status is currently unknown.
+         *
+         * This is the initial state, and will only change after the
+         * service has performed initial connectivity testing and/or
+         * successfully connected to the remote host.
+         */
+        UNKNOWN,
+
         /**
          * The service is currently offline.
          *
-         * This is the initial state, and will only change after
+         * This is the initial state, will only change after
          * having successfully connected to the remote service. An
          * attempt to connect will be made when the connectivity
          * manager indicates the network has changed.
          */
         OFFLINE,
 
-        /** A connection has been established and is operating normally. */
+        /**
+         * The service is connected and working normally.
+         *
+         * A connection to the remote host has been established and is
+         * operating normally.
+         */
         CONNECTED,
 
         /**
@@ -104,6 +118,7 @@ public abstract class Geary.ClientService : BaseObject {
          */
         public bool automatically_reconnect() {
             return (
+                this == UNKNOWN ||
                 this == OFFLINE ||
                 this == CONNECTED ||
                 this == CONNECTION_FAILED
@@ -117,6 +132,7 @@ public abstract class Geary.ClientService : BaseObject {
          */
         public bool is_error() {
             return (
+                this != UNKNOWN &&
                 this != OFFLINE &&
                 this != CONNECTED
             );
@@ -156,11 +172,14 @@ public abstract class Geary.ClientService : BaseObject {
      * The current state of certain aspects of the service
      * (e.g. online/offline state may not be fully known, and hence
      * the value of this property reflects the engine's current
-     * understanding of the service's status, not necessarily reality.
+     * understanding of the service's status, not necessarily that of
+     * actual reality.
+     *
+     * The initial value for this property is {@link Status.UNKNOWN}.
      *
      * @see Account.current_status
      */
-    public Status current_status { get; protected set; default = OFFLINE; }
+    public Status current_status { get; protected set; default = UNKNOWN; }
 
     /** The network endpoint the service will connect to. */
     public Endpoint remote { get; private set; }


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