[geary/mjog/misc-fixes: 3/5] Report when account operations are being executed



commit dfc6be2b17d1def5740fc877a5fa76092d325e1b
Author: Michael Gratton <mike vee net>
Date:   Mon Dec 2 19:08:01 2019 +0800

    Report when account operations are being executed
    
    Replace the Geary.Account::opening_monitor with a more generic
    ::background_progress, and pass that to
    Geary.ImapEngine.AccountProcessor so it can keep it updated when ops
    are being execited.

 src/client/application/application-main-window.vala       |  4 ++--
 src/engine/api/geary-account.vala                         |  8 ++++----
 src/engine/imap-engine/imap-engine-account-processor.vala | 13 ++++++++++++-
 src/engine/imap-engine/imap-engine-generic-account.vala   |  8 ++++----
 4 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/client/application/application-main-window.vala 
b/src/client/application/application-main-window.vala
index 13a1cd48..812e3961 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -949,7 +949,7 @@ public class Application.MainWindow :
                 to_add.account, _("Labels")
             );
 
-            this.progress_monitor.add(to_add.account.opening_monitor);
+            this.progress_monitor.add(to_add.account.background_progress);
             Geary.Smtp.ClientService? smtp = (
                 to_add.account.outgoing as Geary.Smtp.ClientService
             );
@@ -1010,7 +1010,7 @@ public class Application.MainWindow :
             to_remove.commands.undone.disconnect(on_command_undo);
             to_remove.commands.redone.disconnect(on_command_redo);
 
-            this.progress_monitor.remove(to_remove.account.opening_monitor);
+            this.progress_monitor.remove(to_remove.account.background_progress);
             Geary.Smtp.ClientService? smtp = (
                 to_remove.account.outgoing as Geary.Smtp.ClientService
             );
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index 4d5d6aad..aad174bd 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -131,10 +131,10 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
      */
     public Geary.ContactStore contact_store { get; protected set; }
 
-    public Geary.ProgressMonitor search_upgrade_monitor { get; protected set; }
-    public Geary.ProgressMonitor db_upgrade_monitor { get; protected set; }
-    public Geary.ProgressMonitor db_vacuum_monitor { get; protected set; }
-    public Geary.ProgressMonitor opening_monitor { get; protected set; }
+    public ProgressMonitor background_progress { get; protected set; }
+    public ProgressMonitor search_upgrade_monitor { get; protected set; }
+    public ProgressMonitor db_upgrade_monitor { get; protected set; }
+    public ProgressMonitor db_vacuum_monitor { get; protected set; }
 
 
     public signal void opened();
diff --git a/src/engine/imap-engine/imap-engine-account-processor.vala 
b/src/engine/imap-engine/imap-engine-account-processor.vala
index 561c9c62..9375cf2c 100644
--- a/src/engine/imap-engine/imap-engine-account-processor.vala
+++ b/src/engine/imap-engine/imap-engine-account-processor.vala
@@ -57,10 +57,13 @@ internal class Geary.ImapEngine.AccountProcessor :
     private AccountOperation? current_op = null;
     private GLib.Cancellable? op_cancellable = null;
 
+    private ProgressMonitor? progress;
 
-    public AccountProcessor() {
+
+    public AccountProcessor(ProgressMonitor? progress = null) {
         this.queue.allow_duplicates = false;
         this.is_running = true;
+        this.progress = progress;
         this.run.begin();
     }
 
@@ -109,6 +112,10 @@ internal class Geary.ImapEngine.AccountProcessor :
                 debug("Executing operation: %s", op.to_string());
                 this.current_op = op;
 
+                if (this.progress != null) {
+                    this.progress.notify_start();
+                }
+
                 Error? op_error = null;
                 int network_errors = 0;
                 while (op_error == null) {
@@ -139,6 +146,10 @@ internal class Geary.ImapEngine.AccountProcessor :
 
                 this.current_op = null;
                 this.op_cancellable = null;
+
+                if (this.progress != null) {
+                    this.progress.notify_finish();
+                }
             }
         }
     }
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index c6c0b54b..c0394112 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -106,7 +106,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             () => { this.update_remote_folders(); }
          );
 
-        this.opening_monitor = new ReentrantProgressMonitor(Geary.ProgressType.ACTIVITY);
+        this.background_progress = new ReentrantProgressMonitor(ACTIVITY);
         this.search_upgrade_monitor = local.search_index_monitor;
         this.db_upgrade_monitor = local.upgrade_monitor;
         this.db_vacuum_monitor = local.vacuum_monitor;
@@ -119,11 +119,11 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         if (open)
             throw new EngineError.ALREADY_OPEN("Account %s already opened", to_string());
 
-        opening_monitor.notify_start();
+        this.background_progress.notify_start();
         try {
             yield internal_open_async(cancellable);
         } finally {
-            opening_monitor.notify_finish();
+            this.background_progress.notify_finish();
         }
     }
 
@@ -131,7 +131,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         this.open_cancellable = new Cancellable();
         this.remote_ready_lock = new Nonblocking.Semaphore(this.open_cancellable);
 
-        this.processor = new AccountProcessor();
+        this.processor = new AccountProcessor(this.background_progress);
         this.processor.operation_error.connect(on_operation_error);
         this.processor.set_logging_parent(this);
 


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