[Xfce4-commits] <postler:master> Track folder in helper and show friendly validity error

Christian Dywan noreply at xfce.org
Sun Feb 13 19:18:04 CET 2011


Updating branch refs/heads/master
         to d312242be8905d71528a636e9b07801d3e7d7843 (commit)
       from 7ae88da1a3c1b4d9a60ac0684f4540edb3a74c30 (commit)

commit d312242be8905d71528a636e9b07801d3e7d7843
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Feb 13 15:50:23 2011 +0100

    Track folder in helper and show friendly validity error

 postler/postler-bureau.vala  |    6 ++++--
 postler/postler-service.vala |   34 ++++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 0da99b2..b5094c2 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -486,8 +486,10 @@ public class Postler.Bureau : Gtk.Window {
         }
         else if ("NO Login failed" in error_message)
             show_fetch_error_infobar (account, _("Wrong username or password."));
-        else if ("UIDVALIDITY of slave changed" in error_message) {
-            var infobar = show_fetch_error_infobar (account, error_message);
+        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));
             infobar.set_message_type (Gtk.MessageType.WARNING);
         }
         else
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index cd2217d..8e8a092 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -10,9 +10,10 @@
 */
 
 namespace Postler {
-    internal class HelperProcess {
+    internal class HelperProcess : Object {
         internal string? display_name;
         internal bool unverified;
+        internal string? folder = null;
         string? command = null;
         IOChannel inputc;
         IOChannel errorc;
@@ -88,7 +89,6 @@ namespace Postler {
     class PostlerService : Object {
         double total = 0;
         int unread = 0;
-        string folder = "";
 #if HAVE_INDICATE
         int interval = 600; /* 10 minutes */
         Indicate.Server indicator;
@@ -176,31 +176,37 @@ namespace Postler {
         }
 #endif
 
-        void display_status (string account, string msg) {
+        void display_status (HelperProcess helper, ref string line) {
+            if ("UIDVALIDITY of slave changed" in line) {
+                line = "UIDVALIDITY/" + helper.folder;
+                return;
+            }
+
+            string msg = line.split ("\n") [0];
             if (msg.contains ("master: ")) {
                 total = (msg.split (" ") [1]).to_double ();
             }
             else if (msg.contains ("slave: ")) {
                 string[] pieces = msg.split (" ");
                 total = total - pieces[1].to_double ();
-                if (folder == "INBOX") {
+                if (helper.folder == "INBOX") {
                     unread += pieces[3].to_int ();
-                    folder = _("Inbox");
+                    helper.folder = _("Inbox");
                 }
             }
             else if (msg.contains ("S: ?")) {
                 double count = (((msg.split ("/"))[2]).split (" ") [0]).to_double ();
-                if (folder.contains ("/"))
-                    folder = folder.split ("/") [1];
+                if (helper.folder.contains ("/"))
+                    helper.folder = helper.folder.split ("/") [1];
                 string state = _("Fetching %d of %d").printf ((int)count, (int)total);
-                folder = Postler.Folders.decode_foldername (folder);
-                progress (account, folder + "\n" + state,
+                helper.folder = Postler.Folders.decode_foldername (helper.folder);
+                progress (helper.display_name, helper.folder + "\n" + state,
                           total > count ? count / total : 0);
             }
             else if (!(msg.contains ("Synchronizing")) ) {
                 if (msg.contains ("Selecting master ")) {
                     var tmp = msg.replace ("Selecting master ", "");
-                    folder = tmp.replace ("...", "");
+                    helper.folder = tmp.replace ("...", "");
                 }
             }
         }
@@ -234,14 +240,14 @@ namespace Postler {
                     progress (info.display_name, _("Fetching..."), 0.0);
                     string command = accounts.get_receive_command (info);
                     var helper = new HelperProcess (info.display_name, info.unverified);
-                    helper.line_read.connect ((line, is_error) => {
-                        /* FIXME: the status itself isn't updated - escape chars? */
-                        display_status (helper.display_name, line.split ("\n") [0]);
+                    helper.line_read.connect ((current_line, is_error) => {
+                        string line = current_line;
+                        display_status (helper, ref line);
 
                         if ("can't verify certificate" in line
                          && helper.unverified)
                             /* Do nothing, no verification desired. */ ;
-                        else if ("UIDVALIDITY of slave changed" in line)
+                        else if (line.has_prefix ("UIDVALIDITY/"))
                             helper.done (line); /* Try to proceed. */
                         else if (is_error)
                             helper.finnish (line);



More information about the Xfce4-commits mailing list