From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id DD3626DE1034 for ; Sat, 3 Jun 2017 10:48:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=0.010, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VAg64V0m3rRM for ; Sat, 3 Jun 2017 10:48:18 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 734DC6DE0BA5 for ; Sat, 3 Jun 2017 10:48:13 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1dHD8s-0002Od-P4; Sat, 03 Jun 2017 13:47:14 -0400 Received: (nullmailer pid 17100 invoked by uid 1000); Sat, 03 Jun 2017 17:48:04 -0000 From: David Bremner To: notmuch@notmuchmail.org, notmuch@freelists.org Subject: [PATCH 13/23] lib/cli: replace use of g_mime_message_get_sender Date: Sat, 3 Jun 2017 14:47:44 -0300 Message-Id: <20170603174754.16911-14-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170603174754.16911-1-david@tethera.net> References: <20170603174754.16911-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jun 2017 17:48:23 -0000 This function changes semantics in gmime-3.0 so make a new function that provides the same functionality in both --- lib/index.cc | 6 ++---- lib/notmuch-private.h | 2 +- notmuch-reply.c | 5 ++--- notmuch-show.c | 4 ++-- util/gmime-extra.c | 17 +++++++++++++++++ util/gmime-extra.h | 17 +++++++++++++---- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index 8c145540..d2472896 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -439,7 +439,7 @@ _notmuch_message_index_file (notmuch_message_t *message, { GMimeMessage *mime_message; InternetAddressList *addresses; - const char *from, *subject; + const char *subject; notmuch_status_t status; status = _notmuch_message_file_get_mime_message (message_file, @@ -447,9 +447,7 @@ _notmuch_message_index_file (notmuch_message_t *message, if (status) return status; - from = g_mime_message_get_sender (mime_message); - - addresses = internet_address_list_parse_string (from); + addresses = g_mime_message_get_from (mime_message); if (addresses) { _index_address_list (message, "from", addresses); g_object_unref (addresses); diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index ac315e4c..5dfebf5d 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -46,7 +46,7 @@ NOTMUCH_BEGIN_DECLS #include -#include +#include "gmime-extra.h" #include "xutil.h" #include "error_util.h" diff --git a/notmuch-reply.c b/notmuch-reply.c index 12439284..29a5ab6c 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -47,9 +47,9 @@ format_part_reply (GMimeStream *stream, mime_node_t *node) InternetAddressList *recipients; char *recipients_string; - g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_sender (message)); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); recipients_string = internet_address_list_to_string (recipients, 0); + g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_from_string (message)); if (recipients_string) g_mime_stream_printf (stream, "> To: %s\n", recipients_string); @@ -292,8 +292,7 @@ static InternetAddressList *get_sender(GMimeMessage *message) g_object_unref (G_OBJECT (reply_to_list)); } - return internet_address_list_parse_string ( - g_mime_message_get_sender (message)); + return g_mime_message_get_from (message); } static InternetAddressList *get_to(GMimeMessage *message) diff --git a/notmuch-show.c b/notmuch-show.c index b4339abe..edc0537c 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -212,7 +212,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, sp->string (sp, g_mime_message_get_subject (message)); sp->map_key (sp, "From"); - sp->string (sp, g_mime_message_get_sender (message)); + sp->string (sp, g_mime_message_get_from_string (message)); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); recipients_string = internet_address_list_to_string (recipients, 0); @@ -520,9 +520,9 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, if (node->envelope_file) g_mime_stream_printf (stream, "%s\n", _get_one_line_summary (ctx, node->envelope_file)); g_mime_stream_printf (stream, "Subject: %s\n", g_mime_message_get_subject (message)); - g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_sender (message)); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); recipients_string = internet_address_list_to_string (recipients, 0); + g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_from_string (message)); if (recipients_string) g_mime_stream_printf (stream, "To: %s\n", recipients_string); g_free (recipients_string); diff --git a/util/gmime-extra.c b/util/gmime-extra.c index 33751de7..8590c55d 100644 --- a/util/gmime-extra.c +++ b/util/gmime-extra.c @@ -40,6 +40,17 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message) } InternetAddressList * +g_mime_message_get_from (GMimeMessage *message) +{ + return internet_address_list_parse_string (g_mime_message_get_sender (message)); +} + +const char * +g_mime_message_get_from_string (GMimeMessage *message) { + return g_mime_message_get_sender (message); +} + +InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message) { const char *reply_to; @@ -81,6 +92,12 @@ g_mime_message_get_reply_to_list(GMimeMessage *message) return g_mime_message_get_reply_to (message); } +const char * +g_mime_message_get_from_string (GMimeMessage *message) +{ + return g_mime_object_get_header (GMIME_OBJECT (message), "From"); +} + char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message) { diff --git a/util/gmime-extra.h b/util/gmime-extra.h index 794ffbfd..04d63026 100644 --- a/util/gmime-extra.h +++ b/util/gmime-extra.h @@ -9,18 +9,27 @@ 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 + * glib allocated list of From: addresses */ -char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message); +InternetAddressList * g_mime_message_get_from (GMimeMessage *message); /** - * Return glib allocated reply-to list + * return string for From: address + * (owned by gmime) */ +const char * g_mime_message_get_from_string (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); + + #endif -- 2.11.0