[PATCH 16/20] cli: introduce flags for format_headers_sprinter
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu May 10 22:55:40 PDT 2018
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
More information about the notmuch
mailing list