aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2012-02-19 19:26:26 -0500
committerGravatar David Bremner <bremner@debian.org>2012-03-01 08:28:13 -0400
commit86f89385c3bc34cd91002cc057f6a615b6ab76a9 (patch)
tree0da50818dfd6d36073f0e47296dc6715f206204e /notmuch-show.c
parent2209d7b9520000fbd6941b1e0e8521da90f443c6 (diff)
show: Unify JSON header output for messages and message parts
This has three ramifications: - Blank To and Cc headers are no longer output for messages. - Dates are now canonicalized for messages, which means they always have a day of the week and GMT is printed +0000 (never -0000) - Invalid From message headers are handled slightly differently, since they get parsed by GMime now instead of notmuch.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c35
1 files changed, 3 insertions, 32 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index 9ca98820..209ff450 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -291,36 +291,7 @@ format_headers_message_part_text (GMimeMessage *message)
}
static void
-format_headers_json (const void *ctx, notmuch_message_t *message)
-{
- const char *headers[] = {
- "Subject", "From", "To", "Cc", "Bcc", "Date"
- };
- const char *name, *value;
- unsigned int i;
- int first_header = 1;
- void *ctx_quote = talloc_new (ctx);
-
- for (i = 0; i < ARRAY_SIZE (headers); i++) {
- name = headers[i];
- value = notmuch_message_get_header (message, name);
- if (value)
- {
- if (!first_header)
- fputs (", ", stdout);
- first_header = 0;
-
- printf ("%s: %s",
- json_quote_str (ctx_quote, name),
- json_quote_str (ctx_quote, value));
- }
- }
-
- talloc_free (ctx_quote);
-}
-
-static void
-format_headers_message_part_json (GMimeMessage *message)
+format_headers_json (GMimeMessage *message)
{
void *ctx = talloc_new (NULL);
void *ctx_quote = talloc_new (ctx);
@@ -690,7 +661,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
format_message_json (ctx, node->envelope_file);
printf ("\"headers\": {");
- format_headers_json (ctx, node->envelope_file);
+ format_headers_json (GMIME_MESSAGE (node->part));
printf ("}");
printf (", \"body\": [");
@@ -778,7 +749,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
if (GMIME_IS_MESSAGE (node->part)) {
printf ("\"headers\": {");
- format_headers_message_part_json (GMIME_MESSAGE (node->part));
+ format_headers_json (GMIME_MESSAGE (node->part));
printf ("}");
printf (", \"body\": [");