[Xfce4-commits] <postler:master> Confirm fetching without authenticity verification

Christian Dywan noreply at xfce.org
Fri Feb 11 03:38:04 CET 2011


Updating branch refs/heads/master
         to 0254ca19b4d170629e2ed207a887d50f089dfec5 (commit)
       from 879a9f4d0c891a30bbbe6f6f226592327ed95a34 (commit)

commit 0254ca19b4d170629e2ed207a887d50f089dfec5
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Feb 11 01:09:44 2011 +0100

    Confirm fetching without authenticity verification
    
    Lack of a certificate deserves a friendlier message than
    what mbsync outputs. A button allows fetching even if
    verification isn't possible and sets a boolean in the
    account configuration.

 postler/postler-accounts.vala |    5 +++++
 postler/postler-bureau.vala   |   33 ++++++++++++++++++++++++++-------
 postler/postler-service.vala  |   12 +++++++++---
 3 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 87fe400..dc58e16 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -93,6 +93,7 @@ namespace Postler {
         public string prefix;
         public string path;
         public string certificate;
+        public bool unverified;
         public string reply;
         public string organization;
         public string? signature;
@@ -250,6 +251,8 @@ public class Postler.Accounts : GLib.Object {
                     if (account_info.certificate != null)
                         keyfile.set_string (group, "certificate",
                                             account_info.certificate);
+                    if (account_info.unverified)
+                        keyfile.set_boolean (group, "unverified", true);
                     if (account_info.reply != null)
                         keyfile.set_string (group, "reply", account_info.reply);
                     if (account_info.organization != null)
@@ -337,6 +340,8 @@ public class Postler.Accounts : GLib.Object {
                         info.send = keyfile.get_string (group, "send");
                     if (keyfile.has_key (group, "certificate"))
                         info.certificate = keyfile.get_string (group, "certificate");
+                    if (keyfile.has_key (group, "unverified"))
+                        info.unverified = keyfile.get_boolean (group, "unverified");
                     if (keyfile.has_key (group, "reply"))
                         info.reply = keyfile.get_string (group, "reply");
                     if (keyfile.has_key (group, "organization"))
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 13c2961..6ad9b09 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -458,7 +458,7 @@ public class Postler.Bureau : Gtk.Window {
         infobar.show_all ();
 
         /* Infobar closes on button, folder change or fetching mail */
-        infobar.response.connect ((response) => {
+        infobar.response.connect_after ((response) => {
             infobar.destroy ();
         });
         messages.notify["selected-location"].connect ((object, pspec) => {
@@ -471,6 +471,30 @@ public class Postler.Bureau : Gtk.Window {
         return infobar;
     }
 
+    void client_received (string account, string? error_message) {
+        if (error_message == null)
+            return;
+
+        if ("can't verify certificate" in error_message) {
+            var infobar = show_fetch_error_infobar (account,
+        _("Can't verify mail server authenticity. Fetching could be unsafe"));
+            infobar.add_button (_("Fetch Without Verifying"), Gtk.ResponseType.OK);
+            infobar.response.connect ((response) => {
+                foreach (var info in accounts.get_infos ()) {
+                    if (info.display_name == account) {
+                        info.unverified = true;
+                        accounts.update ();
+                        client.receive ();
+                        return;
+                    }
+                }
+                GLib.critical (_("Account \"%s\" doesn't exist"), account);
+            });
+        }
+        else
+            show_fetch_error_infobar (account, error_message);
+    }
+
     public Bureau () {
         GLib.Object (icon_name: STOCK_INTERNET_MAIL,
                      title: GLib.Environment.get_application_name ());
@@ -622,12 +646,7 @@ public class Postler.Bureau : Gtk.Window {
         }
         messages_box.pack_start (search_options, false, false, 0);
 
-        client.received.connect ((account, error_message) => {
-            if (error_message == null)
-                return;
-
-            var infobar = show_fetch_error_infobar (account, error_message);
-        });
+        client.received.connect (client_received);
 
         messages = new Postler.Messages (accounts);
         messages.set_size_request (250, 250);
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index ef113d9..d626643 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -12,12 +12,14 @@
 namespace Postler {
     internal class HelperProcess {
         internal string? display_name;
+        internal bool unverified;
         string? command = null;
         IOChannel inputc;
         IOChannel errorc;
 
-        internal HelperProcess (string? display_name=null) {
+        internal HelperProcess (string? display_name=null, bool unverified=false) {
             this.display_name = display_name;
+            this.unverified = unverified;
         }
 
         internal void execute (string command) {
@@ -224,11 +226,15 @@ namespace Postler {
                 try {
                     progress (info.display_name, _("Fetching..."), 0.0);
                     string command = accounts.get_receive_command (info);
-                    var helper = new HelperProcess (info.display_name);
+                    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]);
-                        if (is_error)
+
+                        if ("can't verify certificate" in line
+                         && helper.unverified)
+                            /* Do nothing, no verification desired. */ ;
+                        else if (is_error)
                             helper.finnish (line);
                     });
                     helper.done.connect ((helper, error_message) => {



More information about the Xfce4-commits mailing list