[Xfce4-commits] <postler:master> Separate parsing in content from actual display

Christian Dywan noreply at xfce.org
Wed Dec 1 22:50:01 CET 2010


Updating branch refs/heads/master
         to d4a49a02a1b7d04d254d8629a611cf34fa0e415f (commit)
       from 40de7ed60c3cbb7d769e39b05591687d3981f99f (commit)

commit d4a49a02a1b7d04d254d8629a611cf34fa0e415f
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Dec 1 22:48:48 2010 +0100

    Separate parsing in content from actual display
    
    So message parts can be used for replying without having to
    parse it separately.

 postler/postler-content.vala |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index c9331c3..c5095f4 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -495,7 +495,7 @@ public class Postler.Content : WebKit.WebView {
         load_string (body.str, mime_type, charset, "about:blank");
     }
 
-    public bool display (string location) {
+    void parse_message (string location) throws GLib.FileError {
         last_location = location;
         subject = _("(No subject)");
 
@@ -622,10 +622,9 @@ public class Postler.Content : WebKit.WebView {
             else
                 multipart = 0;
             if (!(mime_type_is_text (mime_type) || multipart > 0)) {
-                display_error (_("This message of type \"%s\" can't be displayed.").
-                               printf (mime_type));
-                last_location = location;
-                return false;
+                throw new GLib.FileError.FAILED (
+                    _("This message of type \"%s\" can't be displayed.").
+                    printf (mime_type));
             }
 
             MessagePart? message_part = null;
@@ -771,8 +770,18 @@ public class Postler.Content : WebKit.WebView {
                     message_part.body.append (plain_text ? "<br>" : " ");
                 }
             }
+        } catch (GLib.Error contents_error) {
+            throw new GLib.FileError.FAILED (_("Failed to read message: %s").
+                                             printf (contents_error.message));
+        }
+        notify_property ("message-parts");
+    }
 
-            message_part = null;
+    public bool display (string location) {
+        try {
+            parse_message (location);
+
+            MessagePart message_part = null;
             foreach (var part in message_parts) {
                 /* Ignore empty parts inserted by faulty clients */
                 if (part.body.str.strip () == "")
@@ -785,12 +794,10 @@ public class Postler.Content : WebKit.WebView {
             if (message_part != null)
                 display_part (message_part);
             else
-                throw new GLib.FileError.FAILED (
-                    _("No text in the message that can be displayed"));
-        } catch (GLib.Error contents_error) {
-            display_error (_("Failed to read message: %s").printf (contents_error.message));
+                display_error (_("No text in the message that can be displayed"));
+        } catch (GLib.Error error) {
+            display_error  (error.message);
         }
-        notify_property ("message-parts");
         return false;
     }
 



More information about the Xfce4-commits mailing list