aboutsummaryrefslogtreecommitdiff
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorAustin Clements <amdragon@MIT.EDU>2012-01-23 18:33:10 -0500
committerDavid Bremner <bremner@debian.org>2012-01-25 07:21:40 -0400
commit7430a42e23ee775818f84ed75f417302da694152 (patch)
tree91bb8d5d577f44d160efd30efbb25f6099b5a38b /notmuch-show.c
parenta66e65d604c5e658daa97acbb9d0487788863521 (diff)
show: Introduce mime_node formatter callback
This callback is the gateway to the new mime_node_t-based formatters. This maintains backwards compatibility so the formatters can be transitioned one at a time. Once all formatters are converted, the formatter structure can be reduced to only message_set_{start,sep,end} and part, most of show_message can be deleted, and all of show-message.c can be deleted.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index 682aa71..dec799c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -42,7 +42,7 @@ static void
format_part_end_text (GMimeObject *part);
static const notmuch_show_format_t format_text = {
- "",
+ "", NULL,
"\fmessage{ ", format_message_text,
"\fheader{\n", format_headers_text, format_headers_message_part_text, "\fheader}\n",
"\fbody{\n",
@@ -89,7 +89,7 @@ static void
format_part_end_json (GMimeObject *part);
static const notmuch_show_format_t format_json = {
- "[",
+ "[", NULL,
"{", format_message_json,
"\"headers\": {", format_headers_json, format_headers_message_part_json, "}",
", \"body\": [",
@@ -110,7 +110,7 @@ format_message_mbox (const void *ctx,
unused (int indent));
static const notmuch_show_format_t format_mbox = {
- "",
+ "", NULL,
"", format_message_mbox,
"", NULL, NULL, "",
"",
@@ -129,7 +129,7 @@ static void
format_part_content_raw (GMimeObject *part);
static const notmuch_show_format_t format_raw = {
- "",
+ "", NULL,
"", NULL,
"", NULL, format_headers_message_part_text, "\n",
"",
@@ -850,6 +850,19 @@ show_message (void *ctx,
int indent,
notmuch_show_params_t *params)
{
+ if (format->part) {
+ void *local = talloc_new (ctx);
+ mime_node_t *root, *part;
+
+ if (mime_node_open (local, message, params->cryptoctx, params->decrypt,
+ &root) == NOTMUCH_STATUS_SUCCESS &&
+ (part = mime_node_seek_dfs (root, (params->part < 0 ?
+ 0 : params->part))))
+ format->part (local, part, indent, params);
+ talloc_free (local);
+ return;
+ }
+
if (params->part <= 0) {
fputs (format->message_start, stdout);
if (format->message)