1 Return-Path: <amthrax@drake.mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 6E84D421198
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 12:29:09 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id kweERuifQIFe for <notmuch@notmuchmail.org>;
\r
16 Mon, 23 Jan 2012 12:29:08 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 929F1429E54
\r
20 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 12:29:08 -0800 (PST)
\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-f4-4f1dc312ccef
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id F6.4D.02234.213CD1F4; Mon, 23 Jan 2012 15:29:06 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0NKT56p008194;
\r
27 Mon, 23 Jan 2012 15:29:05 -0500
\r
28 Received: from drake.mit.edu (26-4-166.dynamic.csail.mit.edu [18.26.4.166])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0NKT4QU000598
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 23 Jan 2012 15:29:05 -0500 (EST)
\r
34 Received: from amthrax by drake.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amthrax@drake.mit.edu>)
\r
36 id 1RpQVj-0000Md-PE; Mon, 23 Jan 2012 15:29:03 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v3 2/2] show: Introduce mime_node formatter callback
\r
40 Date: Mon, 23 Jan 2012 15:29:01 -0500
\r
41 Message-Id: <1327350541-1303-3-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.7.3
\r
43 In-Reply-To: <1327350541-1303-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1326918507-28033-1-git-send-email-amdragon@mit.edu>
\r
45 <1327350541-1303-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixCmqrSt0WNbfYO4JeYvrN2cyOzB6PFt1
\r
48 izmAMYrLJiU1J7MstUjfLoEr4+e6s+wF86Uqvmx9zdzAuFGki5GTQ0LARGLm135GCFtM4sK9
\r
49 9WxdjFwcQgL7GCVmr7nGBOFsYJTYeOYyC4RznEliwZRjUGXzGSWeP+1iB+lnE9CQ2LZ/Odgs
\r
50 EQFpiZ13Z7N2MXJwMAuoSfzpUgEJCwu4SDzYdZkJxGYRUJXo2/OBDcTmFbCX2NH0ngXiDAWJ
\r
51 c6vPgY3kFHCQuP5uKpgtJFAmsfv2ZeYJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Rrp
\r
52 5WaW6KWmlG5iBIeNJO8OxncHlQ4xCnAwKvHwSsyU9RdiTSwrrsw9xCjJwaQkyquyDyjEl5Sf
\r
53 UpmRWJwRX1Sak1p8iFGCg1lJhNfosYy/EG9KYmVValE+TEqag0VJnFdV652fkEB6Yklqdmpq
\r
54 QWoRTFaGg0NJgrfkENBQwaLU9NSKtMycEoQ0EwcnyHAeoOFFIDW8xQWJucWZ6RD5U4yKUuK8
\r
55 eSAJAZBERmkeXC8srl8xigO9IszbDVLFA0wJcN2vgAYzAQ3myJMCGVySiJCSAsb3yc+bhILW
\r
56 Bd2d1JASKxMhnVLFxBuSELXB01vv9OEfB3UVpv8s91/fseNl6oMvQb8tvi0+OJUta86mzOsu
\r
57 n898+ym9Im9V8N4goZIfcqmsR5T5vqucqAi9Iihn8O/J3f+R5QFaKhq6lw9HR96/V6/NxKqm
\r
58 m8m6T02c9XD51L2zpol+fXVis4ISS3FGoqEWc1FxIgB2BxLUxgIAAA==
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Mon, 23 Jan 2012 20:29:09 -0000
\r
73 This callback is the gateway to the new mime_node_t-based formatters.
\r
74 This maintains backwards compatibility so the formatters can be
\r
75 transitioned one at a time. Once all formatters are converted, the
\r
76 formatter structure can be reduced to only message_set_{start,sep,end}
\r
77 and part, most of show_message can be deleted, and all of
\r
78 show-message.c can be deleted.
\r
80 notmuch-client.h | 6 ++++++
\r
81 notmuch-reply.c | 2 +-
\r
82 notmuch-show.c | 23 +++++++++++++++++++----
\r
83 3 files changed, 26 insertions(+), 5 deletions(-)
\r
85 diff --git a/notmuch-client.h b/notmuch-client.h
\r
86 index abfe5d3..59606b4 100644
\r
87 --- a/notmuch-client.h
\r
88 +++ b/notmuch-client.h
\r
90 #define STRINGIFY(s) STRINGIFY_(s)
\r
91 #define STRINGIFY_(s) #s
\r
94 +struct notmuch_show_params;
\r
96 typedef struct notmuch_show_format {
\r
97 const char *message_set_start;
\r
98 + void (*part) (const void *ctx,
\r
99 + struct mime_node *node, int indent,
\r
100 + struct notmuch_show_params *params);
\r
101 const char *message_start;
\r
102 void (*message) (const void *ctx,
\r
103 notmuch_message_t *message,
\r
104 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
105 index bf67960..f55b1d2 100644
\r
106 --- a/notmuch-reply.c
\r
107 +++ b/notmuch-reply.c
\r
108 @@ -31,7 +31,7 @@ static void
\r
109 reply_part_content (GMimeObject *part);
\r
111 static const notmuch_show_format_t format_reply = {
\r
115 "", NULL, reply_headers_message_part, ">\n",
\r
117 diff --git a/notmuch-show.c b/notmuch-show.c
\r
118 index 682aa71..8185b02 100644
\r
119 --- a/notmuch-show.c
\r
120 +++ b/notmuch-show.c
\r
121 @@ -42,7 +42,7 @@ static void
\r
122 format_part_end_text (GMimeObject *part);
\r
124 static const notmuch_show_format_t format_text = {
\r
127 "\fmessage{ ", format_message_text,
\r
128 "\fheader{\n", format_headers_text, format_headers_message_part_text, "\fheader}\n",
\r
130 @@ -89,7 +89,7 @@ static void
\r
131 format_part_end_json (GMimeObject *part);
\r
133 static const notmuch_show_format_t format_json = {
\r
136 "{", format_message_json,
\r
137 "\"headers\": {", format_headers_json, format_headers_message_part_json, "}",
\r
139 @@ -110,7 +110,7 @@ format_message_mbox (const void *ctx,
\r
140 unused (int indent));
\r
142 static const notmuch_show_format_t format_mbox = {
\r
145 "", format_message_mbox,
\r
146 "", NULL, NULL, "",
\r
148 @@ -129,7 +129,7 @@ static void
\r
149 format_part_content_raw (GMimeObject *part);
\r
151 static const notmuch_show_format_t format_raw = {
\r
155 "", NULL, format_headers_message_part_text, "\n",
\r
157 @@ -850,6 +850,21 @@ show_message (void *ctx,
\r
159 notmuch_show_params_t *params)
\r
161 + if (format->part) {
\r
162 + void *local = talloc_new (ctx);
\r
163 + mime_node_t *root, *part;
\r
165 + if (mime_node_open (local, message, params->cryptoctx, params->decrypt,
\r
166 + &root) != NOTMUCH_STATUS_SUCCESS)
\r
168 + part = mime_node_seek_dfs (root, params->part < 0 ? 0 : params->part);
\r
170 + format->part (local, part, indent, params);
\r
172 + talloc_free (local);
\r
176 if (params->part <= 0) {
\r
177 fputs (format->message_start, stdout);
\r
178 if (format->message)
\r