[geary/wip/save-sent-713263: 2/2] Always generate a Message-ID before submission



commit edae8cfb9cb4d795742a65ec865c2de612cb8ae4
Author: Charles Lindsay <chaz yorba org>
Date:   Thu Jan 16 16:59:02 2014 -0800

    Always generate a Message-ID before submission

 src/client/composer/composer-window.vala           |    2 +-
 .../imap-engine/imap-engine-generic-account.vala   |    5 ++++-
 src/engine/rfc822/rfc822-message.vala              |    4 +++-
 src/mailer/main.vala                               |    2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index f1532a6..0f8f5b0 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -850,7 +850,7 @@ public class ComposerWindow : Gtk.Window {
             // only save HTML drafts to avoid resetting the DOM (which happens when converting the
             // HTML to flowed text)
             draft_id = yield drafts_folder.create_email_async(new Geary.RFC822.Message.from_composed_email(
-                get_composed_email(null, true)), flags, null, draft_id, cancellable);
+                get_composed_email(null, true), null), flags, null, draft_id, cancellable);
             
             draft_save_label.label = DRAFT_SAVED_TEXT;
         } catch (Error e) {
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 45730d7..0f5be34 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -526,7 +526,10 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
         Cancellable? cancellable = null) throws Error {
         check_open();
         
-        Geary.RFC822.Message rfc822 = new Geary.RFC822.Message.from_composed_email(composed);
+        // TODO: we should probably not use someone else's FQDN in something
+        // that's supposed to be globally unique...
+        Geary.RFC822.Message rfc822 = new Geary.RFC822.Message.from_composed_email(
+            composed, GMime.utils_generate_message_id(information.get_smtp_endpoint().host_specifier));
         
         // don't use create_email_async() as that requires the folder be open to use
         yield local.outbox.enqueue_email_async(rfc822, cancellable);
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 47b816b..3807c88 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -73,7 +73,7 @@ public class Geary.RFC822.Message : BaseObject {
         stock_from_gmime();
     }
 
-    public Message.from_composed_email(Geary.ComposedEmail email) {
+    public Message.from_composed_email(Geary.ComposedEmail email, string? message_id) {
         message = new GMime.Message(true);
         
         // Required headers
@@ -84,6 +84,8 @@ public class Geary.RFC822.Message : BaseObject {
         message.set_sender(sender.to_rfc822_string());
         message.set_date((time_t) email.date.to_unix(),
             (int) (email.date.get_utc_offset() / TimeSpan.HOUR));
+        if (message_id != null)
+            message.set_message_id(message_id);
         
         // Optional headers
         if (email.to != null) {
diff --git a/src/mailer/main.vala b/src/mailer/main.vala
index 0f1cc92..c53eaca 100644
--- a/src/mailer/main.vala
+++ b/src/mailer/main.vala
@@ -29,7 +29,7 @@ async void main_async() throws Error {
             composed_email.body_text = contents;
         }
         
-        Geary.RFC822.Message msg = new Geary.RFC822.Message.from_composed_email(composed_email);
+        Geary.RFC822.Message msg = new Geary.RFC822.Message.from_composed_email(composed_email, null);
         stdout.printf("\n\n%s\n\n", msg.to_string());
         
         yield session.send_email_async(msg.sender, msg);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]