[PATCH 18/23] lib: wrap use of g_mime_utils_header_decode_date

Subject: [PATCH 18/23] lib: wrap use of g_mime_utils_header_decode_date

Date: Sat, 3 Jun 2017 14:47:49 -0300

To: notmuch@notmuchmail.org, notmuch@freelists.org

Cc:

From: David Bremner


This changes return type in gmime 3.0
---
 lib/message.cc     |  2 +-
 util/gmime-extra.c | 19 +++++++++++++++++++
 util/gmime-extra.h |  2 ++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/message.cc b/lib/message.cc
index b330dcce..f78e5a9d 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1037,7 +1037,7 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
     if (date == NULL || *date == '\0') {
 	time_value = 0;
     } else {
-	time_value = g_mime_utils_header_decode_date (date, NULL);
+	time_value = g_mime_utils_header_decode_date_unix (date);
 	/*
 	 * Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=779923
 	 */
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 350f75ea..3c50a293 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -99,6 +99,11 @@ g_mime_signature_status_error (GMimeSignatureError error) {
     return (error != GMIME_SIGNATURE_ERROR_NONE);
 }
 
+time_t
+g_mime_utils_header_decode_date_unix (const char *date) {
+    return g_mime_utils_header_decode_date (date, NULL);
+}
+
 #else /* GMime >= 3.0 */
 
 char *
@@ -166,5 +171,19 @@ g_mime_signature_status_error (GMimeSignatureStatus status) {
     return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
 }
 
+gint64
+g_mime_utils_header_decode_date_unix (const char *date) {
+    GDateTime* parsed_date = g_mime_utils_header_decode_date (date);
+    time_t ret;
+
+    if (parsed_date) {
+	ret = g_date_time_to_unix (parsed_date);
+	g_date_time_unref (parsed_date);
+    } else {
+	ret = 0;
+    }
+
+    return ret;
+}
 
 #endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 6b74724e..d744c4e4 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -94,4 +94,6 @@ gboolean g_mime_signature_status_good (GMimeSignatureStatus status);
 gboolean g_mime_signature_status_bad (GMimeSignatureStatus status);
 
 gboolean g_mime_signature_status_error (GMimeSignatureError status);
+
+gint64 g_mime_utils_header_decode_date_unix (const char *date);
 #endif
-- 
2.11.0


Thread: