aboutsummaryrefslogtreecommitdiff
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-07-01 18:45:44 -0300
committerDavid Bremner <david@tethera.net>2022-07-30 08:41:50 -0300
commit4612f3eb3dbf16bf98ccbadef77d7a6f6361e692 (patch)
tree11f6350c5731fe3777d66cbb87e198377c0c342e /notmuch-show.c
parentcef5eaaef61b1f4dde6276ef267fb923f1b16680 (diff)
CLI/show: support --duplicate for structured output
This introduces a new mandatory key for message structures, namely "duplicate". Per convention in devel/schemata this does _not_ increase the format version. This means that clients are responsible for checking that it exists, and not crashing if it does not. The main functional change is teaching mime_node_open to understand a 'duplicate' argument. Support for --duplicate in notmuch-reply would make sense, but we defer it to a later commit.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index 81b37e7c..ee9efa74 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -673,6 +673,7 @@ format_omitted_part_meta_sprinter (sprinter_t *sp, GMimeObject *meta, GMimePart
void
format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
+ int duplicate,
bool output_body,
bool include_html)
{
@@ -684,10 +685,13 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
sp->begin_map (sp);
format_message_sprinter (sp, node->envelope_file);
+ sp->map_key (sp, "duplicate");
+ sp->integer (sp, duplicate > 0 ? duplicate : 1);
+
if (output_body) {
sp->map_key (sp, "body");
sp->begin_list (sp);
- format_part_sprinter (ctx, sp, mime_node_child (node, 0), true, include_html);
+ format_part_sprinter (ctx, sp, mime_node_child (node, 0), -1, true, include_html);
sp->end (sp);
}
@@ -851,7 +855,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
}
for (i = 0; i < node->nchildren; i++)
- format_part_sprinter (ctx, sp, mime_node_child (node, i), true, include_html);
+ format_part_sprinter (ctx, sp, mime_node_child (node, i), -1, true, include_html);
/* Close content structures */
for (i = 0; i < nclose; i++)
@@ -865,7 +869,8 @@ format_part_sprinter_entry (const void *ctx, sprinter_t *sp,
mime_node_t *node, unused (int indent),
const notmuch_show_params_t *params)
{
- format_part_sprinter (ctx, sp, node, params->output_body, params->include_html);
+ format_part_sprinter (ctx, sp, node, params->duplicate, params->output_body,
+ params->include_html);
return NOTMUCH_STATUS_SUCCESS;
}
@@ -1019,7 +1024,7 @@ show_message (void *ctx,
session_key_count_error = notmuch_message_count_properties (message, "session-key",
&session_keys);
- status = mime_node_open (local, message, &(params->crypto), &root);
+ status = mime_node_open (local, message, params->duplicate, &(params->crypto), &root);
if (status)
goto DONE;
part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));