summaryrefslogtreecommitdiffstats
path: root/src/mail
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-05-11 23:36:39 +0200
committerSebastian Reichel <sre@ring0.de>2013-05-11 23:36:39 +0200
commit7bd2535f171e1a083c3fe5c64e6e9d22a8ff8c23 (patch)
treeded92ee7890ecd303875d42ed2cee1faff868d05 /src/mail
parentda9cefd2fa5bbe40d3890c6382710f1034fb1c29 (diff)
downloadserial-barcode-scanner-7bd2535f171e1a083c3fe5c64e6e9d22a8ff8c23.tar.bz2
send mails in the background
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/mailer.vala18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mail/mailer.vala b/src/mail/mailer.vala
index 58b1b45..756a131 100644
--- a/src/mail/mailer.vala
+++ b/src/mail/mailer.vala
@@ -25,7 +25,7 @@ public class MailerImplementation {
}
HashTable<string,MailEntry?> mails;
- MailImplementation current_mail;
+ MailImplementation? current_mail;
string server;
string username;
@@ -136,10 +136,19 @@ public class MailerImplementation {
if(!(path in mails))
throw new IOError.NOT_FOUND("No such mail");
+ if(current_mail != null)
+ throw new IOError.BUSY("Mail system is busy");
+
+ current_mail = mails[path].mail;
+ Idle.add(send_mail_background);
+
+ delete_mail(path);
+ }
+
+ private bool send_mail_background() {
var message = session.add_message();
messagecb_done = false;
- current_mail = mails[path].mail;
message.set_messagecb(callback);
foreach(var recipient in current_mail.get_recipients()) {
@@ -155,6 +164,9 @@ public class MailerImplementation {
if(status.code < 200 || status.code >= 300)
throw new IOError.FAILED("Reply from SMTP-Server: %s", status.text);
- delete_mail(path);
+ current_mail = null;
+
+ /* do not run again */
+ return false;
}
}