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 A8C2C41ED7C
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 15:27:13 -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 1Dhke5Kyxolm for <notmuch@notmuchmail.org>;
\r
16 Mon, 23 Jan 2012 15:27:12 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 6BE1841ED6B
\r
20 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 15:27:12 -0800 (PST)
\r
21 X-AuditID: 12074424-b7fae6d000000906-ca-4f1decd061b0
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 27.5B.02310.0DCED1F4; Mon, 23 Jan 2012 18:27:12 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q0NNRB8n019977;
\r
27 Mon, 23 Jan 2012 18:27:11 -0500
\r
28 Received: from drake.mit.edu (26-4-180.dynamic.csail.mit.edu [18.26.4.180])
\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 q0NNR9Ko024797
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 23 Jan 2012 18:27:10 -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 1RpTHa-0004qS-8B; Mon, 23 Jan 2012 18:26:38 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v4 3/3] show: Introduce mime_node formatter callback
\r
40 Date: Mon, 23 Jan 2012 18:26:23 -0500
\r
41 Message-Id: <1327361183-18485-4-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.7.3
\r
43 In-Reply-To: <1327361183-18485-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1326918507-28033-1-git-send-email-amdragon@mit.edu>
\r
45 <1327361183-18485-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsUixCmqrHvhjay/wfI7rBZXt/azWzRNd7a4
\r
48 fnMms8WblfNYHVg8ds66y+5x+OtCFo9b91+zezxbdYs5gCWKyyYlNSezLLVI3y6BK+PnurPs
\r
49 BfOlKr5sfc3cwLhRpIuRk0NCwESi6+YWNghbTOLCvfVANheHkMA+Rolv/z+xQjgbGCX+L5rB
\r
50 COEcZ5JYfGEeM4Qzn1Hi4OlL7CD9bAIaEtv2L2cEsUUEpCV23p0N1M7BwSxQIDH5gjFIWFjA
\r
51 ReLNtD1g61gEVCVeL+9mArF5BRwkVjzuhTpDQeLc6nNgIzkFHCX+NHawgthCAuUSbbeOs0xg
\r
52 5F/AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI11wvN7NELzWldBMjKODYXVR2MDYfUjrEKMDB
\r
53 qMTDe2CarL8Qa2JZcWXuIUZJDiYlUV7X10AhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrxq54By
\r
54 vCmJlVWpRfkwKWkOFiVxXg2td35CAumJJanZqakFqUUwWRkODiUJ3kZgZAkJFqWmp1akZeaU
\r
55 IKSZODhBhvMADa8AqeEtLkjMLc5Mh8ifYlSUEud1A0kIgCQySvPgemEJ4RWjONArwry+IFU8
\r
56 wGQC1/0KaDAT0GCOPCmQwSWJCCmpBsZDqw5/W1DZb7XA8MoKTXevCzsVV7kviLloMdkn5cQ0
\r
57 buaHMduqCnWXcy3e2ZfUsmNFU93t5bP/1j+xbV7VFiv4QdKtanreI6NEhq3XYlbetTt6WkFj
\r
58 172Vh4xnenIf79penN3T+PkjS3ols2fIw93bRPMvz19oE7EnZjHnte8uVcpMclcs9Z4qsRRn
\r
59 JBpqMRcVJwIA/EhI3+MCAAA=
\r
60 Cc: tomi.ollila@iki.fi
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Mon, 23 Jan 2012 23:27:13 -0000
\r
75 This callback is the gateway to the new mime_node_t-based formatters.
\r
76 This maintains backwards compatibility so the formatters can be
\r
77 transitioned one at a time. Once all formatters are converted, the
\r
78 formatter structure can be reduced to only message_set_{start,sep,end}
\r
79 and part, most of show_message can be deleted, and all of
\r
80 show-message.c can be deleted.
\r
82 notmuch-client.h | 6 ++++++
\r
83 notmuch-reply.c | 2 +-
\r
84 notmuch-show.c | 23 +++++++++++++++++++----
\r
85 3 files changed, 26 insertions(+), 5 deletions(-)
\r
87 diff --git a/notmuch-client.h b/notmuch-client.h
\r
88 index abfe5d3..59606b4 100644
\r
89 --- a/notmuch-client.h
\r
90 +++ b/notmuch-client.h
\r
92 #define STRINGIFY(s) STRINGIFY_(s)
\r
93 #define STRINGIFY_(s) #s
\r
96 +struct notmuch_show_params;
\r
98 typedef struct notmuch_show_format {
\r
99 const char *message_set_start;
\r
100 + void (*part) (const void *ctx,
\r
101 + struct mime_node *node, int indent,
\r
102 + struct notmuch_show_params *params);
\r
103 const char *message_start;
\r
104 void (*message) (const void *ctx,
\r
105 notmuch_message_t *message,
\r
106 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
107 index bf67960..f55b1d2 100644
\r
108 --- a/notmuch-reply.c
\r
109 +++ b/notmuch-reply.c
\r
110 @@ -31,7 +31,7 @@ static void
\r
111 reply_part_content (GMimeObject *part);
\r
113 static const notmuch_show_format_t format_reply = {
\r
117 "", NULL, reply_headers_message_part, ">\n",
\r
119 diff --git a/notmuch-show.c b/notmuch-show.c
\r
120 index 682aa71..8185b02 100644
\r
121 --- a/notmuch-show.c
\r
122 +++ b/notmuch-show.c
\r
123 @@ -42,7 +42,7 @@ static void
\r
124 format_part_end_text (GMimeObject *part);
\r
126 static const notmuch_show_format_t format_text = {
\r
129 "\fmessage{ ", format_message_text,
\r
130 "\fheader{\n", format_headers_text, format_headers_message_part_text, "\fheader}\n",
\r
132 @@ -89,7 +89,7 @@ static void
\r
133 format_part_end_json (GMimeObject *part);
\r
135 static const notmuch_show_format_t format_json = {
\r
138 "{", format_message_json,
\r
139 "\"headers\": {", format_headers_json, format_headers_message_part_json, "}",
\r
141 @@ -110,7 +110,7 @@ format_message_mbox (const void *ctx,
\r
142 unused (int indent));
\r
144 static const notmuch_show_format_t format_mbox = {
\r
147 "", format_message_mbox,
\r
148 "", NULL, NULL, "",
\r
150 @@ -129,7 +129,7 @@ static void
\r
151 format_part_content_raw (GMimeObject *part);
\r
153 static const notmuch_show_format_t format_raw = {
\r
157 "", NULL, format_headers_message_part_text, "\n",
\r
159 @@ -850,6 +850,21 @@ show_message (void *ctx,
\r
161 notmuch_show_params_t *params)
\r
163 + if (format->part) {
\r
164 + void *local = talloc_new (ctx);
\r
165 + mime_node_t *root, *part;
\r
167 + if (mime_node_open (local, message, params->cryptoctx, params->decrypt,
\r
168 + &root) != NOTMUCH_STATUS_SUCCESS)
\r
170 + part = mime_node_seek_dfs (root, params->part < 0 ? 0 : params->part);
\r
172 + format->part (local, part, indent, params);
\r
174 + talloc_free (local);
\r
178 if (params->part <= 0) {
\r
179 fputs (format->message_start, stdout);
\r
180 if (format->message)
\r