[geary/wip/save-sent-713263] Move saving to outbox
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/save-sent-713263] Move saving to outbox
- Date: Fri, 24 Jan 2014 02:41:37 +0000 (UTC)
commit 7dfc11094418b5bc33bcd6a1a7064664445c621e
Author: Charles Lindsay <chaz yorba org>
Date: Thu Jan 23 12:02:26 2014 -0800
Move saving to outbox
src/engine/imap-db/outbox/smtp-outbox-folder.vala | 40 ++++++++++++++++++
.../imap-engine/imap-engine-generic-account.vala | 43 --------------------
2 files changed, 40 insertions(+), 43 deletions(-)
---
diff --git a/src/engine/imap-db/outbox/smtp-outbox-folder.vala
b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
index e196c53..e048632 100644
--- a/src/engine/imap-db/outbox/smtp-outbox-folder.vala
+++ b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
@@ -578,6 +578,46 @@ private class Geary.SmtpOutboxFolder : Geary.AbstractLocalFolder, Geary.FolderSu
throw smtp_err;
email_sent(rfc822);
+
+ try {
+ yield save_sent_email_async(rfc822, cancellable);
+ } catch (Error e) {
+ debug("Error saving sent email: %s", e.message);
+ report_problem(Geary.Account.Problem.SAVE_SENT_EMAIL_FAILED, e);
+ }
+ }
+
+ private async void save_sent_email_async(Geary.RFC822.Message rfc822, Cancellable? cancellable)
+ throws Error {
+ if (!_account.information.allow_save_sent_mail() || !_account.information.save_sent_mail)
+ return;
+
+ Geary.Folder? sent_mail = _account.get_special_folder(Geary.SpecialFolderType.SENT);
+ Geary.FolderSupport.Create? create = sent_mail as Geary.FolderSupport.Create;
+ if (create == null)
+ throw new EngineError.NOT_FOUND("Save sent mail enabled, but no sent mail folder");
+
+ bool open = false;
+ try {
+ yield create.open_async(Geary.Folder.OpenFlags.FAST_OPEN, cancellable);
+ open = true;
+
+ yield create.create_email_async(rfc822, null, new DateTime.now_local(),
+ null, cancellable);
+
+ yield create.close_async(cancellable);
+ open = false;
+ } catch (Error e) {
+ if (open) {
+ try {
+ yield create.close_async(cancellable);
+ open = false;
+ } catch (Error e) {
+ debug("Error closing folder %s: %s", create.to_string(), e.message);
+ }
+ }
+ throw e;
+ }
}
private async bool ordering_exists_async(int64 ordering, Cancellable? cancellable) throws Error {
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 7cdfd4f..4d1a842 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -537,49 +537,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
private void on_email_sent(Geary.RFC822.Message rfc822) {
notify_email_sent(rfc822);
- handle_sent_email_async.begin(rfc822, null, on_handle_sent_email_async_finished);
- }
-
- private void on_handle_sent_email_async_finished(Object? source, AsyncResult result) {
- try {
- handle_sent_email_async.end(result);
- } catch (Error e) {
- debug("Error saving sent email: %s", e.message);
- notify_report_problem(Geary.Account.Problem.SAVE_SENT_EMAIL_FAILED, e);
- }
- }
-
- private async void handle_sent_email_async(Geary.RFC822.Message rfc822, Cancellable? cancellable)
- throws Error {
- if (!information.allow_save_sent_mail() || !information.save_sent_mail)
- return;
-
- Geary.Folder? sent_mail = get_special_folder(Geary.SpecialFolderType.SENT);
- Geary.FolderSupport.Create? create = sent_mail as Geary.FolderSupport.Create;
- if (create == null)
- throw new EngineError.NOT_FOUND("Save sent mail enabled, but no sent mail folder");
-
- bool open = false;
- try {
- yield create.open_async(Geary.Folder.OpenFlags.FAST_OPEN, cancellable);
- open = true;
-
- yield create.create_email_async(rfc822, null, new DateTime.now_local(),
- null, cancellable);
-
- yield create.close_async(cancellable);
- open = false;
- } catch (Error e) {
- if (open) {
- try {
- yield create.close_async(cancellable);
- open = false;
- } catch (Error e) {
- debug("Error closing folder %s: %s", create.to_string(), e.message);
- }
- }
- throw e;
- }
}
private ImapDB.EmailIdentifier check_id(Geary.EmailIdentifier id) throws EngineError {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]