[PATCH 12/23] cli: replace use of g_mime_message_get_reply_to
David Bremner
david at tethera.net
Sat Jun 3 10:47:43 PDT 2017
This function changes signature in gmime 3.0, so we provide two new
functions, one for each signature.
---
notmuch-reply.c | 10 ++++------
notmuch-show.c | 4 +++-
util/gmime-extra.c | 37 +++++++++++++++++++++++++++++++++++++
util/gmime-extra.h | 12 ++++++++++++
4 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 65753c18..12439284 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -268,12 +268,11 @@ reply_to_header_is_redundant (GMimeMessage *message,
static InternetAddressList *get_sender(GMimeMessage *message)
{
- const char *reply_to;
-
- reply_to = g_mime_message_get_reply_to (message);
- if (reply_to && *reply_to) {
- InternetAddressList *reply_to_list;
+ InternetAddressList *reply_to_list;
+ reply_to_list = g_mime_message_get_reply_to_list (message);
+ if (reply_to_list &&
+ internet_address_list_length (reply_to_list) > 0) {
/*
* Some mailing lists munge the Reply-To header despite it
* being A Bad Thing, see
@@ -287,7 +286,6 @@ static InternetAddressList *get_sender(GMimeMessage *message)
* to the list. Note that the address in the Reply-To header
* will always appear in the reply if reply_all is true.
*/
- reply_to_list = internet_address_list_parse_string (reply_to);
if (! reply_to_header_is_redundant (message, reply_to_list))
return reply_to_list;
diff --git a/notmuch-show.c b/notmuch-show.c
index 62275923..b4339abe 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -204,6 +204,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
InternetAddressList *recipients;
char *recipients_string;
const char *reply_to_string;
+ void *local = talloc_new (sp);
sp->begin_map (sp);
@@ -237,7 +238,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
g_free (recipients_string);
}
- reply_to_string = g_mime_message_get_reply_to (message);
+ reply_to_string = g_mime_message_get_reply_to_string (local, message);
if (reply_to_string) {
sp->map_key (sp, "Reply-To");
sp->string (sp, reply_to_string);
@@ -255,6 +256,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
}
sp->end (sp);
+ talloc_free (local);
}
/* Write a MIME text part out to the given stream.
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 01fe9e35..33751de7 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -39,6 +39,28 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
return g_string_talloc_strdup (ctx, date);
}
+InternetAddressList *
+g_mime_message_get_reply_to_list (GMimeMessage *message)
+{
+ const char *reply_to;
+
+ reply_to = g_mime_message_get_reply_to (message);
+ if (reply_to && *reply_to)
+ return internet_address_list_parse_string (reply_to);
+ else
+ return NULL;
+}
+
+/**
+ * return talloc allocated reply-to string
+ */
+char *
+g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
+{
+ return talloc_strdup(ctx, g_mime_message_get_reply_to (message));
+}
+
+
#else /* GMime >= 3.0 */
char *
@@ -52,4 +74,19 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
}
}
+
+InternetAddressList *
+g_mime_message_get_reply_to_list(GMimeMessage *message)
+{
+ return g_mime_message_get_reply_to (message);
+}
+
+char *
+g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
+{
+ InternetAddressList *list = g_mime_message_get_reply_to (message);
+ return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
+}
+
+
#endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 6e2f6ca5..794ffbfd 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -10,5 +10,17 @@ GMimeStream *g_mime_stream_stdout_new(void);
* return talloc allocated date string
*/
char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
+InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
+
+/**
+ * return talloc allocated reply-to string
+ */
+char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+
+
+/**
+ * Return glib allocated reply-to list
+ */
+InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
#endif
--
2.11.0
More information about the notmuch
mailing list