[geary/wip/778276-better-flag-updates: 9/25] Allow reporting problems to the client from Geary.Imap.MinimalFolder.



commit 3b025b3d41658195c7cf450128edea4b8ceaa74a
Author: Michael James Gratton <mike vee net>
Date:   Mon Nov 20 19:17:01 2017 +1100

    Allow reporting problems to the client from Geary.Imap.MinimalFolder.
    
    * src/engine/api/geary-account.vala (Account): Add a doc comment for the
      report_problem signal.
    
    * src/engine/imap-engine/imap-engine-minimal-folder.vala (Folder): Add
      problem_report signal and notify_service_problem method for firting it.
    
    * src/engine/imap-engine/imap-engine-generic-account.vala
      (Account::build_folders): Connect problem_report from folder through to
      the account.

 src/engine/api/geary-account.vala                  |    8 ++++++++
 .../imap-engine/imap-engine-generic-account.vala   |    1 +
 .../imap-engine/imap-engine-minimal-folder.vala    |   12 ++++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index a7fd343..b21d3e1 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -41,6 +41,14 @@ public abstract class Geary.Account : BaseObject {
     
     public signal void email_sent(Geary.RFC822.Message rfc822);
 
+    /**
+     * Emitted to notify the client that some problem has occurred.
+     *
+     * The engine uses this signal to report internal errors and other
+     * issues that the client should notify the user about. The {@link
+     * ProblemReport} class provides context about the nature of the
+     * problem itself.
+     */
     public signal void report_problem(Geary.ProblemReport problem);
 
     public signal void contacts_loaded();
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 2ac8e73..f56faaf 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -337,6 +337,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         
         foreach(ImapDB.Folder folder_to_build in folders_to_build) {
             MinimalFolder folder = new_folder(folder_to_build.get_path(), remote, local, folder_to_build);
+            folder.report_problem.connect(notify_report_problem);
             folder_map.set(folder.path, folder);
             built_folders.add(folder);
             return_folders.add(folder);
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 6522803..5afd866 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -93,6 +93,10 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
      */
     public signal void marked_email_removed(Gee.Collection<Geary.EmailIdentifier> removed);
     
+    /** Emitted to notify the account that some problem has occurred. */
+    internal signal void report_problem(Geary.ProblemReport problem);
+
+
     public MinimalFolder(GenericAccount account, Imap.Account remote, ImapDB.Account local,
         ImapDB.Folder local_folder, SpecialFolderType special_folder_type) {
         this._account = account;
@@ -1548,6 +1552,13 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
         return ret;
     }
 
+    /** Fires a {@link report_problem}} signal for a service for this folder. */
+    protected virtual void notify_service_problem(ProblemType type, Service service_type, Error? err) {
+        report_problem(new ServiceProblemReport(
+                           type, this._account.information, service_type, err
+                       ));
+    }
+
     public override string to_string() {
         return "%s (open_count=%d remote_opened=%s)".printf(base.to_string(), open_count,
             remote_opened.to_string());
@@ -1556,4 +1567,5 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
     private void on_remote_ready() {
         start_open_remote();
     }
+
 }


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