* [RFC PATCH] cli/show: include content type parameters in formatted output
@ 2017-02-22 21:40 Jani Nikula
2017-03-05 11:17 ` [REBASED RFC " Jani Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Jani Nikula @ 2017-02-22 21:40 UTC (permalink / raw)
To: notmuch; +Cc: Damien Cassou, jani
This is primarily to be able to handle "text/plain; format=flowed",
but I don't see much point in making this specific to
format=flowed. Just include all content type parameters in the
formatted output, like this:
"content-type" : "text/plain",
"content-type-params" : [
{
"format" : "flowed"
}
],
It might make sense to change the content-type key in schemata to
include the parameters in a more structured fashion instead of adding
a separate key like here, but this doesn't require a change in
consumers or schemata version bump.
This was just a quick proof of concept, and obviously lacks tests,
schemata updates, etc.
---
notmuch-show.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/notmuch-show.c b/notmuch-show.c
index 22fa655ad20d..7100b2d0b578 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -601,6 +601,19 @@ 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));
+ const GMimeParam *params = g_mime_content_type_get_params (content_type);
+ if (params) {
+ sp->map_key (sp, "content-type-params");
+ sp->begin_list (sp);
+ sp->begin_map (sp);
+ for (; params; params = params->next) {
+ sp->map_key (sp, params->name);
+ sp->string (sp, params->value);
+ }
+ sp->end (sp);
+ sp->end (sp);
+ }
+
if (cid) {
sp->map_key (sp, "content-id");
sp->string (sp, cid);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [REBASED RFC PATCH] cli/show: include content type parameters in formatted output
2017-02-22 21:40 [RFC PATCH] cli/show: include content type parameters in formatted output Jani Nikula
@ 2017-03-05 11:17 ` Jani Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2017-03-05 11:17 UTC (permalink / raw)
To: notmuch; +Cc: Damien Cassou, jani
This is primarily to be able to handle "text/plain; format=flowed",
but I don't see much point in making this specific to
format=flowed. Just include all content type parameters in the
formatted output, like this:
"content-type" : "text/plain",
"content-type-params" : [
{
"format" : "flowed"
}
],
It might make sense to change the content-type key in schemata to
include the parameters in a more structured fashion instead of adding
a separate key like here, but this doesn't require a change in
consumers or schemata version bump.
This was just a quick proof of concept, and obviously lacks tests,
schemata updates, etc.
---
notmuch-show.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/notmuch-show.c b/notmuch-show.c
index 744b62727c26..866b974fcefa 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -625,6 +625,19 @@ 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));
+ const GMimeParam *params = g_mime_content_type_get_params (content_type);
+ if (params) {
+ sp->map_key (sp, "content-type-params");
+ sp->begin_list (sp);
+ sp->begin_map (sp);
+ for (; params; params = params->next) {
+ sp->map_key (sp, params->name);
+ sp->string (sp, params->value);
+ }
+ sp->end (sp);
+ sp->end (sp);
+ }
+
if (disposition) {
sp->map_key (sp, "content-disposition");
sp->string (sp, disposition);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-05 11:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 21:40 [RFC PATCH] cli/show: include content type parameters in formatted output Jani Nikula
2017-03-05 11:17 ` [REBASED RFC " Jani Nikula
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).