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 1D3A96DE0B78 for ; Thu, 10 May 2018 22:56:11 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.019 X-Spam-Level: X-Spam-Status: No, score=-0.019 tagged_above=-999 required=5 tests=[AWL=-0.019, RCVD_IN_DNSWL_NONE=-0.0001] 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 5ONTAyDaxZoI for ; Thu, 10 May 2018 22:56:10 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id EA7136DE034D for ; Thu, 10 May 2018 22:56:03 -0700 (PDT) Received: from fifthhorseman.net (unknown [38.109.115.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id 25921F9AD for ; Fri, 11 May 2018 01:55:59 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 16BEA21B3E; Fri, 11 May 2018 01:55:53 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 16/20] cli: introduce flags for format_headers_sprinter Date: Fri, 11 May 2018 01:55:40 -0400 Message-Id: <20180511055544.13676-17-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511055544.13676-1-dkg@fifthhorseman.net> References: <20180511055544.13676-1-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Fri, 11 May 2018 05:56:11 -0000 Rather than passing a boolean to indicate whether this is a reply to format_headers_sprinter(), we use a flag field. This will be used shortly to allow clients to indicate that they can responsibly protect the subject line. This changeset has no functional change itself, just modifying the types passed. --- devel/schemata | 4 ++-- notmuch-client.h | 12 +++++++++++- notmuch-reply.c | 2 +- notmuch-show.c | 9 +++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/devel/schemata b/devel/schemata index 5e59b806..1ea4f798 100644 --- a/devel/schemata +++ b/devel/schemata @@ -131,7 +131,7 @@ part = { content-transfer-encoding?: string } -# The headers of a message or part (format_headers_sprinter with reply = FALSE) +# The headers of a message or part (format_headers_sprinter with flags = FORMAT_HEADERS_NORMAL) headers = { Subject: string, From: string, @@ -223,7 +223,7 @@ reply = { original: message } -# Reply headers (format_headers_sprinter with reply = TRUE) +# Reply headers (format_headers_sprinter with flags = FORMAT_HEADERS_REPLY) reply_headers = { Subject: string, From: string, diff --git a/notmuch-client.h b/notmuch-client.h index 73c8a163..0af96986 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -230,9 +230,19 @@ format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node, bool output_body, bool include_html); + +typedef enum { + /* typical "notmuch show" or other standard output: */ + HEADERS_FORMAT_NORMAL = 0, + /* set only if this is being generated as a reply: */ + HEADERS_FORMAT_REPLY = 1 << 0 +} notmuch_headers_format_flags; + + void format_headers_sprinter (struct sprinter *sp, GMimeMessage *message, - bool reply, const _notmuch_message_crypto_t *msg_crypto); + notmuch_headers_format_flags flags, + const _notmuch_message_crypto_t *msg_crypto); typedef enum { NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0, diff --git a/notmuch-reply.c b/notmuch-reply.c index fe02c590..749eac6d 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -665,7 +665,7 @@ static int do_reply(notmuch_config_t *config, sp->map_key (sp, "reply-headers"); /* FIXME: send msg_crypto here to avoid killing the * subject line on reply to encrypted messages! */ - format_headers_sprinter (sp, reply, true, NULL); + format_headers_sprinter (sp, reply, HEADERS_FORMAT_REPLY, NULL); /* Start the original */ sp->map_key (sp, "original"); diff --git a/notmuch-show.c b/notmuch-show.c index 4cc1ce8c..799940f8 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -196,7 +196,8 @@ _is_from_line (const char *line) void format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, - bool reply, const _notmuch_message_crypto_t *msg_crypto) + notmuch_headers_format_flags flags, + const _notmuch_message_crypto_t *msg_crypto) { /* Any changes to the JSON or S-Expression format should be * reflected in the file devel/schemata. */ @@ -243,7 +244,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, sp->string (sp, reply_to_string); } - if (reply) { + if (flags & HEADERS_FORMAT_REPLY) { sp->map_key (sp, "In-reply-to"); sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")); @@ -665,7 +666,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, } sp->map_key (sp, "headers"); - format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, msg_crypto); + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), HEADERS_FORMAT_NORMAL, msg_crypto); sp->end (sp); return; @@ -758,7 +759,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->begin_map (sp); sp->map_key (sp, "headers"); - format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, NULL); + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), HEADERS_FORMAT_NORMAL, NULL); sp->map_key (sp, "body"); sp->begin_list (sp); -- 2.17.0