[geary/mjog/fix-null-message-ids: 4/4] Make serialisation of Geary.Email.Field more usable
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/fix-null-message-ids: 4/4] Make serialisation of Geary.Email.Field more usable
- Date: Fri, 1 Nov 2019 05:10:10 +0000 (UTC)
commit 47927aaff4402263ed9908aa4b5bb597f14e886e
Author: Michael Gratton <mike vee net>
Date: Fri Nov 1 15:48:19 2019 +1100
Make serialisation of Geary.Email.Field more usable
src/engine/api/geary-email.vala | 27 +++++++++++++++++----------
src/engine/imap-db/imap-db-folder.vala | 16 ++++++++++------
src/engine/imap/api/imap-folder-session.vala | 17 ++++++++++++-----
3 files changed, 39 insertions(+), 21 deletions(-)
---
diff --git a/src/engine/api/geary-email.vala b/src/engine/api/geary-email.vala
index 2b4d7ec4..04a2cdb4 100644
--- a/src/engine/api/geary-email.vala
+++ b/src/engine/api/geary-email.vala
@@ -157,18 +157,25 @@ public class Geary.Email : BaseObject, EmailHeaderSet {
return is_any_set(required_fields);
}
- public string to_list_string() {
- StringBuilder builder = new StringBuilder();
- foreach (Field f in all()) {
- if (is_all_set(f)) {
- if (!String.is_empty(builder.str))
- builder.append(", ");
-
- builder.append(f.to_string());
+ public string to_string() {
+ string value = "NONE";
+ if (this == ALL) {
+ value = "ALL";
+ } else if (this > 0) {
+ StringBuilder builder = new StringBuilder();
+ foreach (Field f in all()) {
+ if (is_all_set(f)) {
+ if (!String.is_empty(builder.str)) {
+ builder.append(",");
+ }
+ builder.append(
+ ObjectUtils.to_enum_nick(typeof(Field), f).up()
+ );
+ }
}
+ value = builder.str;
}
-
- return builder.str;
+ return value;
}
}
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 615d8194..9b854173 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -1288,10 +1288,11 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
int64 id = -1;
// if fields not present, then no duplicate can reliably be found
if (!email.fields.is_all_set(REQUIRED_FIELDS)) {
- debug("%s: Unable to detect duplicates for %s, fields available: %s",
- this.to_string(),
- email.id.to_string(),
- email.fields.to_list_string()
+ debug(
+ "%s: Unable to detect duplicates for %s, fields available: %s",
+ this.to_string(),
+ email.id.to_string(),
+ email.fields.to_string()
);
return id;
}
@@ -1304,8 +1305,11 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
int64 rfc822_size = (imap_properties != null) ? imap_properties.rfc822_size.value : -1;
if (String.is_empty(internaldate) || rfc822_size < 0) {
- debug("Unable to detect duplicates for %s (%s available but invalid)", email.id.to_string(),
- email.fields.to_list_string());
+ debug(
+ "Unable to detect duplicates for %s (%s available but invalid)",
+ email.id.to_string(),
+ email.fields.to_string()
+ );
return id;
}
diff --git a/src/engine/imap/api/imap-folder-session.vala b/src/engine/imap/api/imap-folder-session.vala
index c6d9a91b..00f48ca8 100644
--- a/src/engine/imap/api/imap-folder-session.vala
+++ b/src/engine/imap/api/imap-folder-session.vala
@@ -497,8 +497,11 @@ private class Geary.Imap.FolderSession : Geary.Imap.SessionObject {
out preview_charset_specifier
);
if (cmds.size == 0) {
- throw new ImapError.INVALID("No FETCH commands generate for list request %s %s",
- msg_set.to_string(), fields.to_list_string());
+ throw new ImapError.INVALID(
+ "No FETCH commands generate for list request %s %s",
+ msg_set.to_string(),
+ fields.to_string()
+ );
}
// Commands prepped, do the fetch and accumulate all the responses
@@ -549,9 +552,13 @@ private class Geary.Imap.FolderSession : Geary.Imap.SessionObject {
preview_charset_specifier
);
if (!email.fields.fulfills(fields)) {
- message("%s: %s missing=%s fetched=%s", to_string(), email.id.to_string(),
- fields.clear(email.fields).to_list_string(), fetched_data.to_string());
-
+ message(
+ "%s: %s missing=%s fetched=%s",
+ to_string(),
+ email.id.to_string(),
+ fields.clear(email.fields).to_string(),
+ fetched_data.to_string()
+ );
continue;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]