]> git.notmuchmail.org Git - notmuch/commitdiff
cli: replace use of g_mime_message_get_reply_to
authorDavid Bremner <david@tethera.net>
Thu, 4 May 2017 18:59:37 +0000 (14:59 -0400)
committerDavid Bremner <david@tethera.net>
Fri, 14 Jul 2017 20:58:09 +0000 (17:58 -0300)
This function changes signature in gmime 3.0, so we provide two new
functions, one for each signature.

notmuch-reply.c
notmuch-show.c
util/gmime-extra.c
util/gmime-extra.h

index 857e1e141121e7dc66562677e466400b6872cda0..f789a14083e0fa444a294cd2e4d2c0c559459806 100644 (file)
@@ -268,12 +268,11 @@ reply_to_header_is_redundant (GMimeMessage *message,
 
 static InternetAddressList *get_sender(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
         /*
         * 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.
         */
         * 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;
 
        if (! reply_to_header_is_redundant (message, reply_to_list))
            return reply_to_list;
 
index 78d46f1ef1af335a9c677aa4a67eda5b55cea07d..e0433095da37b76bc127d372ee9784172b12c5ae 100644 (file)
@@ -204,6 +204,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     InternetAddressList *recipients;
     char *recipients_string;
     const char *reply_to_string;
     InternetAddressList *recipients;
     char *recipients_string;
     const char *reply_to_string;
+    void *local = talloc_new (sp);
 
     sp->begin_map (sp);
 
 
     sp->begin_map (sp);
 
@@ -237,7 +238,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
        g_free (recipients_string);
     }
 
        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);
     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);
     }
 
     sp->end (sp);
+    talloc_free (local);
 }
 
 /* Write a MIME text part out to the given stream.
 }
 
 /* Write a MIME text part out to the given stream.
index 01fe9e35f979851c1184124a9fee248e42181e5b..33751de7d20c4b70e6cfbed56f1128db4c9467ac 100644 (file)
@@ -39,6 +39,28 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
     return g_string_talloc_strdup (ctx, date);
 }
 
     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 *
 #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");
     }
 }
        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
 #endif
index 6e2f6ca5c83cbfd864a1f08a6a6b5b5a0d2f44f4..794ffbfdf9bbc13a215cb58ea9e09e4fce51b2f3 100644 (file)
@@ -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);
  * 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
 
 #endif