[Xfce4-commits] <postler:master> Parse errors and render messages in one place each

Christian Dywan noreply at xfce.org
Sat Feb 19 00:18:01 CET 2011


Updating branch refs/heads/master
         to 0930baa144a3c991d63de237e02e3a1db79bde33 (commit)
       from 23bb97203677c52bc4256527a30fee218e723b2a (commit)

commit 0930baa144a3c991d63de237e02e3a1db79bde33
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Feb 18 23:53:38 2011 +0100

    Parse errors and render messages in one place each
    
    So known errors are parsed into PSTL/FOO/folder/message
    and rendered readably in the interface.

 postler/postler-bureau.vala  |   23 ++++++++++++-----------
 postler/postler-service.vala |   30 ++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 9600662..223d20e 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -467,7 +467,7 @@ public class Postler.Bureau : Gtk.Window {
         if (error_message == null)
             return;
 
-        if ("can't verify certificate" in error_message) {
+        if (error_message.has_prefix ("PSTL/CERT/")) {
             var infobar = show_fetch_error_infobar (account,
         _("Can't verify mail server authenticity."));
             infobar.add_button (_("Fetch Without Verifying"), Gtk.ResponseType.OK);
@@ -483,19 +483,20 @@ public class Postler.Bureau : Gtk.Window {
                 GLib.critical (_("Account \"%s\" doesn't exist"), account);
             });
         }
-        else if ("NO Login failed" in error_message)
+        else if (error_message.has_prefix ("PSTL/LOGIN/"))
             show_fetch_error_infobar (account, _("Wrong username or password."));
-        else if (error_message.has_prefix ("UIDVALIDITY/")) {
-            string folder = error_message.split ("/")[1];
-            var infobar = show_fetch_error_infobar (account,
-                _("Folder \"%s\" is in invalid state.").printf (folder));
+        else if (error_message.has_prefix ("PSTL/")) {
+            string[] parts = error_message.split ("/");
+            string error_id = parts[1];
+            string folder = parts[2];
+            string error_text = error_message;
+            if (error_id == "UIDVAL")
+                error_text = _("Folder \"%s\" is in invalid state.").printf (folder);
+            else if (error_id == "BADUID")
+                error_text = _("Failed to update folder \"%s\".").printf (folder);
+            var infobar = show_fetch_error_infobar (account, error_text);
             infobar.set_message_type (Gtk.MessageType.WARNING);
         }
-        else if (error_message.has_prefix ("BADUID/")) {
-            string folder = error_message.split ("/")[1];
-            show_fetch_error_infobar (account,
-                _("Failed to update folder \"%s\".").printf (folder));
-        }
         else
             show_fetch_error_infobar (account, error_message);
     }
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index b96a5cd..e5e3b21 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -181,12 +181,23 @@ namespace Postler {
 #endif
 
         void display_status (HelperProcess helper, ref string line) {
-            if ("UIDVALIDITY of slave changed" in line) {
-                line = "UIDVALIDITY/" + helper.folder;
-                return;
-            }
-            else if ("Invalid UID messageset" in line) {
-                line = "BADUID/" + helper.folder;
+            string? error_id = null;
+            if ("can't verify certificate" in line)
+                error_id = "CERT";
+            else if ("NO Login failed" in line)
+                error_id = "LOGIN";
+            else if ("UIDVALIDITY of slave changed" in line)
+                error_id = "UIDVAL";
+            else if ("Invalid UID messageset" in line)
+                error_id = "BADUID";
+            else if ("BAD Could not parse command" in line)
+                error_id = "BADCMD";
+            else if ("Failed to create pipe for communicating" in line)
+                error_id = "NOPIPE";
+            else if ("Error: channel" in line && " is locked" in line)
+                error_id = "LOCK";
+            if (error_id != null) {
+                line = "PSTL/" + error_id + "/" + helper.folder + "/" + line;
                 return;
             }
 
@@ -252,12 +263,11 @@ namespace Postler {
                         string line = current_line;
                         display_status (helper, ref line);
 
-                        if ("can't verify certificate" in line
-                         && helper.unverified)
+                        if (line.has_prefix ("PSTL/CERT/") && helper.unverified)
                             /* Do nothing, no verification desired. */ ;
-                        else if (line.has_prefix ("UIDVALIDITY/"))
+                        else if (line.has_prefix ("PSTL/UIDVAL/"))
                             helper.done (line); /* Try to proceed. */
-                        else if ("Error: channel" in line && " is locked" in line)
+                        else if (line.has_prefix ("PSTL/LOCK/"))
                             helper.finnish (); /* Parallel access to one inbox */
                         else if (is_error)
                             helper.finnish (line);



More information about the Xfce4-commits mailing list