[geary/mjog/rfc822-cleanup-part-n: 1/9] Composer.Widget: Convert references to a MessageIdList instance
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/rfc822-cleanup-part-n: 1/9] Composer.Widget: Convert references to a MessageIdList instance
- Date: Thu, 30 Jul 2020 03:08:57 +0000 (UTC)
commit b78dfe7cb88d198d2382a6db26128fd2c5609eee
Author: Michael Gratton <mike vee net>
Date: Tue Jun 30 11:53:22 2020 +1000
Composer.Widget: Convert references to a MessageIdList instance
Using the high-level representation avoids having to re-parse and
re-format the list.
Update the util method Geary.RFC822.Utils.reply_references to support
this.
src/client/composer/composer-widget.vala | 10 ++++------
src/engine/rfc822/rfc822-utils.vala | 13 ++++---------
2 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 19b853cbd..de2213857 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -341,7 +341,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
private Gee.Set<Geary.RFC822.MessageID> in_reply_to = new Gee.HashSet<Geary.RFC822.MessageID>();
- private string references { get; private set; }
+ private Geary.RFC822.MessageIDList? references = null;
[GtkChild]
private Gtk.Grid editor_container;
@@ -1143,7 +1143,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
if (referred.in_reply_to != null)
this.in_reply_to.add_all(referred.in_reply_to.get_all());
if (referred.references != null)
- this.references = referred.references.to_rfc822_string();
+ this.references = referred.references;
if (referred.subject != null)
this.subject = referred.subject.value ?? "";
break;
@@ -1373,10 +1373,8 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
new Geary.RFC822.MessageIDList(this.in_reply_to)
);
- if (!Geary.String.is_empty(this.references)) {
- email.set_references(
- new Geary.RFC822.MessageIDList.from_rfc822_string(this.references)
- );
+ if (this.references != null) {
+ email.set_references(this.references);
}
email.attached_files.add_all(this.attached_files);
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 51fae6a37..4e7d5b058 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -96,9 +96,9 @@ namespace Geary.RFC822.Utils {
return new MailboxAddresses(result);
}
- public string reply_references(Email source) {
- // generate list for References
- var list = new Gee.ArrayList<MessageID>();
+ /** Generate a References header value in reply to a message. */
+ public MessageIDList? reply_references(Email source) {
+ var list = new Gee.LinkedList<MessageID>();
// 1. Start with the source's References list
if (source.references != null) {
@@ -119,12 +119,7 @@ namespace Geary.RFC822.Utils {
list.add(source.message_id);
}
- string[] strings = new string[list.size];
- for(int i = 0; i < list.size; ++i) {
- strings[i] = list[i].value;
- }
-
- return (list.size > 0) ? string.joinv(" ", strings) : "";
+ return (list.is_empty) ? null : new MessageIDList(list);
}
public string email_addresses_for_reply(MailboxAddresses? addresses,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]