[Xfce4-commits] <postler:master> Use DBus client from composer for sending messages
Christian Dywan
noreply at xfce.org
Sat Dec 11 20:08:02 CET 2010
Updating branch refs/heads/master
to 008ce471ae18d36004670a40700586edc7ffc36e (commit)
from e1222fb75ec5f682f0d92b3ea4f9d34130d0c266 (commit)
commit 008ce471ae18d36004670a40700586edc7ffc36e
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Dec 10 23:28:55 2010 +0100
Use DBus client from composer for sending messages
postler/postler-client.vala | 9 +++++++++
postler/postler-composer.vala | 4 +++-
postler/postler-service.vala | 12 +++++++++++-
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/postler/postler-client.vala b/postler/postler-client.vala
index fc14bd5..d5386a2 100644
--- a/postler/postler-client.vala
+++ b/postler/postler-client.vala
@@ -14,6 +14,7 @@ namespace Postler {
[DBus (name = "org.elementary.Postler")]
interface PostlerClient : Object {
public abstract void receive_mail () throws IOError;
+ public abstract bool send (string account, string filename) throws IOError;
}
public class Client : Object {
@@ -39,6 +40,14 @@ namespace Postler {
client.receive_mail ();
} catch (GLib.Error error) { }
}
+
+ public bool send (string account, string filename) {
+ try {
+ return client.send (account, filename);
+ } catch (GLib.Error error) {
+ return false;
+ }
+ }
}
}
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index b1615ad..8d29f64 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -11,6 +11,7 @@
public class Postler.Composer : Gtk.Window {
Accounts accounts = new Accounts ();
+ Postler.Client client = new Postler.Client ();
Dexter.Dexter dexter = new Dexter.Dexter ();
Gtk.UIManager ui;
@@ -203,7 +204,8 @@ public class Postler.Composer : Gtk.Window {
+ Postler.Messages.generate_maildir_filename ("S");
FileUtils.set_contents (filename, header + body, -1);
FileUtils.chmod (filename, 0700);
- accounts.send (info, filename);
+ if (!client.send (info.name, filename))
+ throw new GLib.FileError.FAILED (_("Sending failed."));
/* TODO: Handle failure to send */
destroy ();
} catch (GLib.Error error) {
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index 1fe6733..1a7faef 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -16,7 +16,17 @@ namespace Postler {
public void receive_mail () {
var accounts = new Accounts ();
accounts.receive (null);
- }
+ }
+
+ public bool send (string account, string filename) {
+ var accounts = new Accounts ();
+ foreach (var info in accounts.get_infos ())
+ if (info.name == account) {
+ accounts.send (info, filename);
+ return true;
+ }
+ return false;
+ }
}
public class Service {
More information about the Xfce4-commits
mailing list