aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>2012-03-18 10:32:36 -0600
committerDavid Bremner <bremner@debian.org>2012-03-19 21:53:53 -0300
commit1904b01b96c1b731afb9649e7b5bceffce901b88 (patch)
tree6e31d5b9fdc7536dbcf83ddb705bc8e3b46a502d /notmuch-show.c
parent06a34f1407a3465724d7950e7179d7f1df130a2b (diff)
reply: Add a JSON reply format.
This new JSON format for replies includes headers generated for a reply message as well as the headers of the original message. Using this data, a client can intelligently create a reply. For example, the emacs client will be able to create replies with quoted HTML parts by parsing the HTML parts.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index a7463dc8..ff9d4278 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -200,8 +200,8 @@ _is_from_line (const char *line)
return 0;
}
-static void
-format_headers_json (const void *ctx, GMimeMessage *message)
+void
+format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply)
{
void *local = talloc_new (ctx);
InternetAddressList *recipients;
@@ -225,9 +225,22 @@ format_headers_json (const void *ctx, GMimeMessage *message)
printf (", %s: %s",
json_quote_str (local, "Cc"),
json_quote_str (local, recipients_string));
- printf (", %s: %s}",
- json_quote_str (local, "Date"),
- json_quote_str (local, g_mime_message_get_date_as_string (message)));
+
+ if (reply) {
+ printf (", %s: %s",
+ json_quote_str (local, "In-reply-to"),
+ json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")));
+
+ printf (", %s: %s",
+ json_quote_str (local, "References"),
+ json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "References")));
+ } else {
+ printf (", %s: %s",
+ json_quote_str (local, "Date"),
+ json_quote_str (local, g_mime_message_get_date_as_string (message)));
+ }
+
+ printf ("}");
talloc_free (local);
}
@@ -538,7 +551,7 @@ format_part_text (const void *ctx, mime_node_t *node,
return NOTMUCH_STATUS_SUCCESS;
}
-static void
+void
format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
{
/* Any changes to the JSON format should be reflected in the file
@@ -549,7 +562,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, GMIME_MESSAGE (node->part));
+ format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);
printf (", \"body\": [");
format_part_json (ctx, mime_node_child (node, 0), first);
@@ -623,7 +636,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
} else if (GMIME_IS_MESSAGE (node->part)) {
printf (", \"content\": [{");
printf ("\"headers\": ");
- format_headers_json (local, GMIME_MESSAGE (node->part));
+ format_headers_json (local, GMIME_MESSAGE (node->part), FALSE);
printf (", \"body\": [");
terminator = "]}]";