[geary/wip/save-sent-713263] Fix Message.without_bcc



commit 1781bf42d97f2263e9b1551c0775954cbb972cfa
Author: Charles Lindsay <chaz yorba org>
Date:   Wed Jan 22 17:39:20 2014 -0800

    Fix Message.without_bcc
    
    It wasn't copying all headers before.  Now it is (except Bcc, of
    course).

 src/engine/rfc822/rfc822-message.vala |   50 +++++---------------------------
 1 files changed, 8 insertions(+), 42 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 3807c88..16117fc 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -17,9 +17,9 @@ public class Geary.RFC822.Message : BaseObject {
     private const string HEADER_IN_REPLY_TO = "In-Reply-To";
     private const string HEADER_REFERENCES = "References";
     private const string HEADER_MAILER = "X-Mailer";
+    private const string HEADER_BCC = "Bcc";
     
-    // Internal note: If a field is added here, it *must* be set in Message.from_parts(),
-    // Message.without_bcc(), and stock_from_gmime().
+    // Internal note: If a field is added here, it *must* be set in stock_from_gmime().
     public RFC822.MailboxAddress? sender { get; private set; default = null; }
     public RFC822.MailboxAddresses? from { get; private set; default = null; }
     public RFC822.MailboxAddresses? to { get; private set; default = null; }
@@ -186,49 +186,15 @@ public class Geary.RFC822.Message : BaseObject {
     public Message.without_bcc(Message email) {
         message = new GMime.Message(true);
         
-        // Required headers.
-        sender = email.sender;
-        message.set_sender(email.message.get_sender());
-        
-        date = email.date;
-        message.set_date_as_string(email.date.to_string());
-        
-        // Optional headers.
-        if (email.to != null) {
-            to = email.to;
-            foreach (RFC822.MailboxAddress mailbox in email.to)
-                message.add_recipient(GMime.RecipientType.TO, mailbox.name, mailbox.address);
-        }
-
-        if (email.cc != null) {
-            cc = email.cc;
-            foreach (RFC822.MailboxAddress mailbox in email.cc)
-                message.add_recipient(GMime.RecipientType.CC, mailbox.name, mailbox.address);
-        }
-
-        if (email.in_reply_to != null) {
-            in_reply_to = email.in_reply_to;
-            message.set_header(HEADER_IN_REPLY_TO, email.in_reply_to.value);
-        }
-
-        if (email.references != null) {
-            references = email.references;
-            message.set_header(HEADER_REFERENCES, email.references.to_rfc822_string());
-        }
-
-        if (email.subject != null) {
-            subject = email.subject;
-            message.set_subject(email.subject.value);
-        }
-
-        // User-Agent
-        if (!Geary.String.is_empty(email.mailer)) {
-            mailer = email.mailer;
-            message.set_header(HEADER_MAILER, email.mailer);
-        }
+        email message headers  foreach((name, value) => {
+            if (name.down() != HEADER_BCC.down())
+                message.append_header(name, value);
+        });
         
         // Setup body depending on what MIME components were filled out.
         message.set_mime_part(email.message.get_mime_part());
+        
+        stock_from_gmime();
     }
     
     private GMime.Object? coalesce_parts(Gee.List<GMime.Object> parts, string subtype) {


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