[geary] Support multiple Message-IDs with In-Reply-To



commit 15cac889f714015283244f08f322264c6cddb3d4
Author: Jim Nelson <jim yorba org>
Date:   Thu Oct 9 18:14:12 2014 -0700

    Support multiple Message-IDs with In-Reply-To
    
    Prior RFC822 code treated In-Reply-To as only capable of listing a
    single Message-ID parent.  The spec does allow for multiple parent
    messages, so this change reflects that.
    
    This potentially can also fix bugs where messages were not included
    in conversations, but this would be an edge case, as that would
    require the MUA not listing the In-Reply-To Message-IDs in the
    References list, which Geary does properly parse.

 src/client/composer/composer-widget.vala           |    2 +-
 src/engine/api/geary-email.vala                    |    8 ++++----
 src/engine/imap-db/imap-db-message-row.vala        |    4 ++--
 src/engine/imap/api/imap-folder.vala               |    4 ++--
 src/engine/imap/message/imap-envelope.vala         |    4 ++--
 .../imap/response/imap-fetch-data-decoder.vala     |    2 +-
 src/engine/rfc822/rfc822-message.vala              |    6 +++---
 src/engine/rfc822/rfc822-utils.vala                |   11 +++++++----
 8 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 52086c3..d34b69f 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -408,7 +408,7 @@ public class ComposerWidget : Gtk.EventBox {
                     if (referred.bcc != null)
                         bcc = referred.bcc.to_rfc822_string();
                     if (referred.in_reply_to != null)
-                        in_reply_to = referred.in_reply_to.value;
+                        in_reply_to = referred.in_reply_to.to_rfc822_string();
                     if (referred.references != null)
                         references = referred.references.to_rfc822_string();
                     if (referred.subject != null)
diff --git a/src/engine/api/geary-email.vala b/src/engine/api/geary-email.vala
index c9b3b6a..f7ffddc 100644
--- a/src/engine/api/geary-email.vala
+++ b/src/engine/api/geary-email.vala
@@ -124,7 +124,7 @@ public class Geary.Email : BaseObject {
     
     // REFERENCES
     public Geary.RFC822.MessageID? message_id { get; private set; default = null; }
-    public Geary.RFC822.MessageID? in_reply_to { get; private set; default = null; }
+    public Geary.RFC822.MessageIDList? in_reply_to { get; private set; default = null; }
     public Geary.RFC822.MessageIDList? references { get; private set; default = null; }
     
     // SUBJECT
@@ -191,7 +191,7 @@ public class Geary.Email : BaseObject {
         fields |= Field.RECEIVERS;
     }
     
-    public void set_full_references(Geary.RFC822.MessageID? message_id, Geary.RFC822.MessageID? in_reply_to,
+    public void set_full_references(Geary.RFC822.MessageID? message_id, Geary.RFC822.MessageIDList? 
in_reply_to,
         Geary.RFC822.MessageIDList? references) {
         this.message_id = message_id;
         this.in_reply_to = in_reply_to;
@@ -305,13 +305,13 @@ public class Geary.Email : BaseObject {
             ancestors.add(message_id);
         
         // References list the email trail back to its source
-        if (references != null && references.list != null)
+        if (references != null)
             ancestors.add_all(references.list);
         
         // RFC822 requires the In-Reply-To Message-ID be prepended to the References list, but
         // this ensures that's the case
         if (in_reply_to != null)
-           ancestors.add(in_reply_to);
+           ancestors.add_all(in_reply_to.list);
        
        return (ancestors.size > 0) ? ancestors : null;
     }
diff --git a/src/engine/imap-db/imap-db-message-row.vala b/src/engine/imap-db/imap-db-message-row.vala
index 386e6c2..98c5c60 100644
--- a/src/engine/imap-db/imap-db-message-row.vala
+++ b/src/engine/imap-db/imap-db-message-row.vala
@@ -119,7 +119,7 @@ private class Geary.ImapDB.MessageRow {
         if (fields.is_all_set(Geary.Email.Field.REFERENCES)) {
             email.set_full_references(
                 (message_id != null) ? new RFC822.MessageID(message_id) : null,
-                (in_reply_to != null) ? new RFC822.MessageID(in_reply_to) : null,
+                (in_reply_to != null) ? new RFC822.MessageIDList.from_rfc822_string(in_reply_to) : null,
                 (references != null) ? new RFC822.MessageIDList.from_rfc822_string(references) : null);
         }
         
@@ -204,7 +204,7 @@ private class Geary.ImapDB.MessageRow {
         
         if (email.fields.is_all_set(Geary.Email.Field.REFERENCES)) {
             message_id = (email.message_id != null) ? email.message_id.value : null;
-            in_reply_to = (email.in_reply_to != null) ? email.in_reply_to.value : null;
+            in_reply_to = (email.in_reply_to != null) ? email.in_reply_to.to_rfc822_string() : null;
             references = (email.references != null) ? email.references.to_rfc822_string() : null;
             
             fields = fields.set(Geary.Email.Field.REFERENCES);
diff --git a/src/engine/imap/api/imap-folder.vala b/src/engine/imap/api/imap-folder.vala
index 628f430..e4290dd 100644
--- a/src/engine/imap/api/imap-folder.vala
+++ b/src/engine/imap/api/imap-folder.vala
@@ -781,7 +781,7 @@ private class Geary.Imap.Folder : BaseObject {
         
         // accumulate these to submit References all at once
         RFC822.MessageID? message_id = null;
-        RFC822.MessageID? in_reply_to = null;
+        RFC822.MessageIDList? in_reply_to = null;
         RFC822.MessageIDList? references = null;
         
         // loop through all available FetchDataTypes and gather converted data
@@ -907,7 +907,7 @@ private class Geary.Imap.Folder : BaseObject {
             if (in_reply_to == null) {
                 string? value = headers.get_header("In-Reply-To");
                 if (!String.is_empty(value))
-                    in_reply_to = new RFC822.MessageID(value);
+                    in_reply_to = new RFC822.MessageIDList.from_rfc822_string(value);
             }
             
             if (references == null) {
diff --git a/src/engine/imap/message/imap-envelope.vala b/src/engine/imap/message/imap-envelope.vala
index 71c7394..d69bf02 100644
--- a/src/engine/imap/message/imap-envelope.vala
+++ b/src/engine/imap/message/imap-envelope.vala
@@ -19,14 +19,14 @@ public class Geary.Imap.Envelope : Geary.MessageData.AbstractMessageData, Geary.
     public Geary.RFC822.MailboxAddresses? to { get; private set; }
     public Geary.RFC822.MailboxAddresses? cc { get; private set; }
     public Geary.RFC822.MailboxAddresses? bcc { get; private set; }
-    public Geary.RFC822.MessageID? in_reply_to { get; private set; }
+    public Geary.RFC822.MessageIDList? in_reply_to { get; private set; }
     public Geary.RFC822.MessageID? message_id { get; private set; }
     
     public Envelope(Geary.RFC822.Date? sent, Geary.RFC822.Subject subject,
         Geary.RFC822.MailboxAddresses from, Geary.RFC822.MailboxAddresses sender,
         Geary.RFC822.MailboxAddresses? reply_to, Geary.RFC822.MailboxAddresses? to,
         Geary.RFC822.MailboxAddresses? cc, Geary.RFC822.MailboxAddresses? bcc,
-        Geary.RFC822.MessageID? in_reply_to, Geary.RFC822.MessageID? message_id) {
+        Geary.RFC822.MessageIDList? in_reply_to, Geary.RFC822.MessageID? message_id) {
         this.sent = sent;
         this.subject = subject;
         this.from = from;
diff --git a/src/engine/imap/response/imap-fetch-data-decoder.vala 
b/src/engine/imap/response/imap-fetch-data-decoder.vala
index 4cbb23f..6f9e2ca 100644
--- a/src/engine/imap/response/imap-fetch-data-decoder.vala
+++ b/src/engine/imap/response/imap-fetch-data-decoder.vala
@@ -151,7 +151,7 @@ public class Geary.Imap.EnvelopeDecoder : Geary.Imap.FetchDataDecoder {
             (to != null) ? parse_addresses(to) : null, 
             (cc != null) ? parse_addresses(cc) : null,
             (bcc != null) ? parse_addresses(bcc) : null,
-            (in_reply_to != null) ? new Geary.RFC822.MessageID(in_reply_to.value) : null,
+            (in_reply_to != null) ? new Geary.RFC822.MessageIDList.from_rfc822_string(in_reply_to.value) : 
null,
             (message_id != null) ? new Geary.RFC822.MessageID(message_id.value) : null);
     }
     
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index ae06fa3..7d02de8 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -25,7 +25,7 @@ public class Geary.RFC822.Message : BaseObject {
     public RFC822.MailboxAddresses? to { get; private set; default = null; }
     public RFC822.MailboxAddresses? cc { get; private set; default = null; }
     public RFC822.MailboxAddresses? bcc { get; private set; default = null; }
-    public RFC822.MessageID? in_reply_to { get; private set; default = null; }
+    public RFC822.MessageIDList? in_reply_to { get; private set; default = null; }
     public RFC822.MessageIDList? references { get; private set; default = null; }
     public RFC822.Subject? subject { get; private set; default = null; }
     public string? mailer { get; private set; default = null; }
@@ -120,7 +120,7 @@ public class Geary.RFC822.Message : BaseObject {
         }
 
         if (email.in_reply_to != null) {
-            in_reply_to = new Geary.RFC822.MessageID(email.in_reply_to);
+            in_reply_to = new Geary.RFC822.MessageIDList.from_rfc822_string(email.in_reply_to);
             message.set_header(HEADER_IN_REPLY_TO, email.in_reply_to);
         }
         
@@ -335,7 +335,7 @@ public class Geary.RFC822.Message : BaseObject {
             bcc = new RFC822.MailboxAddresses(converted);
         
         if (!String.is_empty(message.get_header(HEADER_IN_REPLY_TO)))
-            in_reply_to = new RFC822.MessageID(message.get_header(HEADER_IN_REPLY_TO));
+            in_reply_to = new 
RFC822.MessageIDList.from_rfc822_string(message.get_header(HEADER_IN_REPLY_TO));
         
         if (!String.is_empty(message.get_header(HEADER_REFERENCES)))
             references = new RFC822.MessageIDList.from_rfc822_string(message.get_header(HEADER_REFERENCES));
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 9048ee1..6aa4043 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -119,10 +119,13 @@ public string reply_references(Geary.Email source) {
     if (source.references != null && source.references.list.size > 0)
         list.add_all(source.references.list);
     
-    // 2. If there's an In-Reply-To Message-ID and it's not the last Message-ID on the 
-    //    References list, append it
-    if (source.in_reply_to != null && list.size > 0 && !list.last().equal_to(source.in_reply_to))
-        list.add(source.in_reply_to);
+    // 2. If there are In-Reply-To Message-IDs and they're not in the References list, append them
+    if (source.in_reply_to != null) {
+        foreach (RFC822.MessageID reply_id in source.in_reply_to.list) {
+            if (!list.contains(reply_id))
+                list.add(reply_id);
+        }
+    }
     
     // 3. Append the source's Message-ID, if available.
     if (source.message_id != null)


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