[PATCH 2/2] cli/show: add content-disposition to structured output message parts

Jani Nikula jani at nikula.org
Sat Jan 28 04:21:30 PST 2017


Help the clients decide how to display parts.

---

I'm not sure if this should bump the version in schemata, because the
comment in notmuch-client.h says new map fields can be added without
increasing NOTMUCH_FORMAT_CUR. Yet the schemata version history says
thread_summary.query was added in v2... which looks like a change that
shouldn't need a version bump. Confused.

The problem could be avoided by conflating both this change and
id:20170110201929.21875-1-jani at nikula.org into v3... ;)
---
 devel/schemata | 1 +
 notmuch-show.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/devel/schemata b/devel/schemata
index 41dc4a60fff3..c94459eb783a 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -76,6 +76,7 @@ part = {
     sigstatus?:     sigstatus,
 
     content-type:   string,
+    content-disposition?:       string,
     content-id?:    string,
     # if content-type starts with "multipart/":
     content:        [part*],
diff --git a/notmuch-show.c b/notmuch-show.c
index 8b38fe6db136..8e69b3465886 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -582,6 +582,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
     GMimeObject *meta = node->envelope_part ?
 	GMIME_OBJECT (node->envelope_part) : node->part;
     GMimeContentType *content_type = g_mime_object_get_content_type (meta);
+    const char *disposition = _get_disposition (meta);
     const char *cid = g_mime_object_get_content_id (meta);
     const char *filename = GMIME_IS_PART (node->part) ?
 	g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;
@@ -611,6 +612,11 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
     sp->map_key (sp, "content-type");
     sp->string (sp, g_mime_content_type_to_string (content_type));
 
+    if (disposition) {
+	sp->map_key (sp, "content-disposition");
+	sp->string (sp, disposition);
+    }
+
     if (cid) {
 	sp->map_key (sp, "content-id");
 	sp->string (sp, cid);
-- 
2.11.0



More information about the notmuch mailing list