[geary/wip/conversation-polish: 24/26] Show a problem report when an error occurs loading a message body



commit f2235648296d7d44c5c03a80c6816bd8441b3a07
Author: Michael Gratton <mike vee net>
Date:   Sat Feb 2 12:41:01 2019 +1100

    Show a problem report when an error occurs loading a message body

 src/client/application/geary-controller.vala           | 15 ++++++++++++++-
 src/client/conversation-viewer/conversation-email.vala | 14 +++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index f3ef50fa..bb45ede4 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2579,9 +2579,10 @@ public class GearyController : Geary.BaseObject {
 
     private void on_conversation_viewer_email_added(ConversationEmail view) {
         view.attachments_activated.connect(on_attachments_activated);
+        view.forward_message.connect(on_forward_message);
+        view.load_error.connect(on_email_load_error);
         view.reply_to_message.connect(on_reply_to_message);
         view.reply_all_message.connect(on_reply_all_message);
-        view.forward_message.connect(on_forward_message);
 
         Geary.App.Conversation conversation = main_window.conversation_viewer.current_list.conversation;
         bool in_current_folder = (conversation.is_in_base_folder(view.email.id) &&
@@ -3020,6 +3021,18 @@ public class GearyController : Geary.BaseObject {
         );
     }
 
+    private void on_email_load_error(ConversationEmail view, GLib.Error err) {
+        // XXX determine the problem better here
+        report_problem(
+            new Geary.ServiceProblemReport(
+                Geary.ProblemType.GENERIC_ERROR,
+                this.current_account.information,
+                this.current_account.information.incoming,
+                err
+            )
+        );
+    }
+
     private void on_save_attachments(Gee.Collection<Geary.Attachment> attachments) {
         GLib.Cancellable? cancellable = null;
         if (this.current_account != null) {
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 968ea9a1..875f43ec 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -376,6 +376,9 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
     private bool shift_key_down;
 
 
+    /** Fired when an error occurs loading the message body. */
+    public signal void load_error(GLib.Error err);
+
     /** Fired when the user clicks "reply" in the message menu. */
     public signal void reply_to_message();
 
@@ -610,7 +613,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
                 this.fetch_remote_body.begin();
             } catch (GLib.Error err) {
                 this.body_loading_timeout.reset();
-                handle_load_failure();
+                handle_load_failure(err);
                 throw err;
             }
         }
@@ -619,7 +622,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
             try {
                 yield update_body();
             } catch (GLib.Error err) {
-                handle_load_failure();
+                handle_load_failure(err);
                 throw err;
             }
             yield this.message_bodies_loaded_lock.wait_async(
@@ -776,7 +779,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
                 // All good
             } catch (GLib.Error err) {
                 debug("Remote message download failed: %s", err.message);
-                handle_load_failure();
+                handle_load_failure(err);
             }
 
             this.body_loading_timeout.reset();
@@ -787,7 +790,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
                     yield update_body();
                 } catch (GLib.Error err) {
                     debug("Remote message update failed: %s", err.message);
-                    handle_load_failure();
+                    handle_load_failure(err);
                 }
             }
         } else {
@@ -914,7 +917,8 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
         return selected;
     }
 
-    private void handle_load_failure() {
+    private void handle_load_failure(GLib.Error err) {
+        load_error(err);
         this.message_body_state = FAILED;
         this.primary_message.show_load_error_pane();
     }


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