[Xfce4-commits] <postler:master> Implement msmtp io callback with debug output

Christian Dywan noreply at xfce.org
Tue Dec 14 20:52:02 CET 2010


Updating branch refs/heads/master
         to 75fb7302d0ddf042e0f3e2d6156f7d139c193153 (commit)
       from 47e8654ebd23107dde001a9e13c3a6fc985085f2 (commit)

commit 75fb7302d0ddf042e0f3e2d6156f7d139c193153
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Dec 13 21:03:24 2010 +0100

    Implement msmtp io callback with debug output

 postler/postler-service.vala |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index faa1cbd..af18707 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -17,7 +17,7 @@ namespace Postler {
         int unread = 0;
         string folder = "";
 
-        bool execute_command_with_status (string command) {
+        bool execute_command_with_status (string command, IOFunc io_callback) {
             try {
                 string[] argv;
                 Pid pid;
@@ -27,7 +27,7 @@ namespace Postler {
                     SpawnFlags.SEARCH_PATH,
                     null, out pid, null, out out_fd, null);
                 IOChannel ioc = new IOChannel.unix_new (out_fd);
-                ioc.add_watch (IOCondition.IN | IOCondition.HUP, mbsync_input);
+                ioc.add_watch (IOCondition.IN | IOCondition.HUP, io_callback);
             }
             catch (GLib.Error error) {
                 var error_dialog = new Gtk.MessageDialog (null, 0,
@@ -126,7 +126,7 @@ namespace Postler {
             foreach (var info in infos) {
                 try {
                     string command = accounts.get_receive_command (info);
-                    execute_command_with_status (command);
+                    execute_command_with_status (command, mbsync_input);
                 } catch (Error error) {
                     return false;
                 }
@@ -135,13 +135,32 @@ namespace Postler {
             return true;
         }
 
+        bool msmtp_input (IOChannel channel, IOCondition condition) {
+            if ((condition & IOCondition.HUP) == IOCondition.HUP) {
+                /* FIXME: Move file */
+                GLib.debug ("Done sending");
+                return false;
+            }
+
+            try {
+                StringBuilder msg = new StringBuilder ();
+                size_t len;
+                channel.read_line_string (msg, out len);
+                GLib.debug ("%s", msg.str);
+            }
+            catch (Error error) {
+                GLib.warning ("Error reading: %s", error.message);
+            }
+            return true;
+        }
+
         public bool send (string account, string filename) {
             var accounts = new Accounts ();
             try {
                 foreach (var info in accounts.get_infos ())
                     if (info.name == account) {
                         string command = accounts.get_send_command (info, filename);
-                        Postler.App.execute_command (command);
+                        execute_command_with_status (command, msmtp_input);
                         return true;
                     }
             } catch (Error error) {



More information about the Xfce4-commits mailing list