1 Return-Path: <amdragon@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 8C219429E30
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:08 -0700 (PDT)
\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 sQM+Oljdy8qq for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jul 2012 19:35:07 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id E40DC431FBD
\r
20 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:05 -0700 (PDT)
\r
21 X-AuditID: 1209190f-b7f306d0000008b4-cf-500f5b5953d9
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 79.2E.02228.95B5F005; Tue, 24 Jul 2012 22:35:05 -0400 (EDT)
\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 q6P2Z5EL002600;
\r
27 Tue, 24 Jul 2012 22:35:05 -0400
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6P2Z2kY025126
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Tue, 24 Jul 2012 22:35:04 -0400 (EDT)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1StrRG-0004Zw-IO; Tue, 24 Jul 2012 22:35:02 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 07/13] show: Convert format_headers_json to use sprinter
\r
41 Date: Tue, 24 Jul 2012 22:34:47 -0400
\r
42 Message-Id: <1343183693-17134-8-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10
\r
44 In-Reply-To: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsUixCmqrRsZzR9gMPeHqsXehnZGi+s3ZzI7
\r
48 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBltL/+xFjxWrXg61bKB8alcFyMnh4SAiURT
\r
49 8x0mCFtM4sK99WxdjFwcQgL7GCWubTjPDuFsYJT4+/cRC4TziEmi8/1bRghnLqPE1qkzWUD6
\r
50 2QQ0JLbtX84IYosISEvsvDubFcRmFjCTmPtzItBcDg5hAQ+Jjc8YQUwWAVWJ321sIBW8Ag4S
\r
51 x++tZoa4Ql7i6f0+sDingKPE+SULwSYKAdX0LL7GPoGRfwEjwypG2ZTcKt3cxMyc4tRk3eLk
\r
52 xLy81CJdE73czBK91JTSTYzgMJLk38H47aDSIUYBDkYlHt4/T/gChFgTy4orcw8xSnIwKYny
\r
53 VgTzBwjxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4S0KA8rxpiRWVqUW5cOkpDlYlMR5r6bc9BcS
\r
54 SE8sSc1OTS1ILYLJynBwKEnwtkYBNQoWpaanVqRl5pQgpJk4OEGG8wAN3w1Sw1tckJhbnJkO
\r
55 kT/FqCglzjsXJCEAksgozYPrhcX5K0ZxoFeEeZtBqniAKQKu+xXQYCagwc/D+EAGlyQipKQa
\r
56 GAXatr23Fd0hvPP870qenKNfLhUF7eO+cdfc5fCZF2mq5UX6l2U3Fd3o8hIKCp9f/6RyMX+V
\r
57 X2fes9NBO5yT/bZIiNjcPG5xy3LK9TOrHTa1pryf90n5dF8zM/v7SelKbevl7FY9a/Ho+iN/
\r
58 MKVx/VFjSdvjrR/Y3vkZKfZdiYh6a1i37u+dRUosxRmJhlrMRcWJANcHcpXOAgAA
\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: Wed, 25 Jul 2012 02:35:08 -0000
\r
73 This no longer requires a talloc context (not that it really did
\r
74 before since it didn't return anything), so we remove its context
\r
77 notmuch-client.h | 3 ++-
\r
78 notmuch-reply.c | 2 +-
\r
79 notmuch-show.c | 58 ++++++++++++++++++++++++++----------------------------
\r
80 3 files changed, 31 insertions(+), 32 deletions(-)
\r
82 diff --git a/notmuch-client.h b/notmuch-client.h
\r
83 index 8eeedf7..21c3231 100644
\r
84 --- a/notmuch-client.h
\r
85 +++ b/notmuch-client.h
\r
86 @@ -183,7 +183,8 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
87 notmuch_bool_t first, notmuch_bool_t output_body);
\r
90 -format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
\r
91 +format_headers_json (sprinter_t *sp, GMimeMessage *message,
\r
92 + notmuch_bool_t reply);
\r
95 NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
\r
96 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
97 index 07d4452..fa6665f 100644
\r
98 --- a/notmuch-reply.c
\r
99 +++ b/notmuch-reply.c
\r
100 @@ -617,7 +617,7 @@ notmuch_reply_format_json(void *ctx,
\r
102 /* The headers of the reply message we've created */
\r
103 printf ("{\"reply-headers\": ");
\r
104 - format_headers_json (ctx, reply, TRUE);
\r
105 + format_headers_json (sp, reply, TRUE);
\r
106 g_object_unref (G_OBJECT (reply));
\r
109 diff --git a/notmuch-show.c b/notmuch-show.c
\r
110 index b258f65..9852119 100644
\r
111 --- a/notmuch-show.c
\r
112 +++ b/notmuch-show.c
\r
113 @@ -199,48 +199,46 @@ _is_from_line (const char *line)
\r
117 -format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply)
\r
118 +format_headers_json (sprinter_t *sp, GMimeMessage *message,
\r
119 + notmuch_bool_t reply)
\r
121 - void *local = talloc_new (ctx);
\r
122 InternetAddressList *recipients;
\r
123 const char *recipients_string;
\r
125 - printf ("{%s: %s",
\r
126 - json_quote_str (local, "Subject"),
\r
127 - json_quote_str (local, g_mime_message_get_subject (message)));
\r
128 - printf (", %s: %s",
\r
129 - json_quote_str (local, "From"),
\r
130 - json_quote_str (local, g_mime_message_get_sender (message)));
\r
131 + sp->begin_map (sp);
\r
133 + sp->map_key (sp, "Subject");
\r
134 + sp->string (sp, g_mime_message_get_subject (message));
\r
136 + sp->map_key (sp, "From");
\r
137 + sp->string (sp, g_mime_message_get_sender (message));
\r
139 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
\r
140 recipients_string = internet_address_list_to_string (recipients, 0);
\r
141 - if (recipients_string)
\r
142 - printf (", %s: %s",
\r
143 - json_quote_str (local, "To"),
\r
144 - json_quote_str (local, recipients_string));
\r
145 + if (recipients_string) {
\r
146 + sp->map_key (sp, "To");
\r
147 + sp->string (sp, recipients_string);
\r
150 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
\r
151 recipients_string = internet_address_list_to_string (recipients, 0);
\r
152 - if (recipients_string)
\r
153 - printf (", %s: %s",
\r
154 - json_quote_str (local, "Cc"),
\r
155 - json_quote_str (local, recipients_string));
\r
156 + if (recipients_string) {
\r
157 + sp->map_key (sp, "Cc");
\r
158 + sp->string (sp, recipients_string);
\r
162 - printf (", %s: %s",
\r
163 - json_quote_str (local, "In-reply-to"),
\r
164 - json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")));
\r
165 + sp->map_key (sp, "In-reply-to");
\r
166 + sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to"));
\r
168 - printf (", %s: %s",
\r
169 - json_quote_str (local, "References"),
\r
170 - json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "References")));
\r
171 + sp->map_key (sp, "References");
\r
172 + sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
\r
174 - printf (", %s: %s",
\r
175 - json_quote_str (local, "Date"),
\r
176 - json_quote_str (local, g_mime_message_get_date_as_string (message)));
\r
177 + sp->map_key (sp, "Date");
\r
178 + sp->string (sp, g_mime_message_get_date_as_string (message));
\r
183 - talloc_free (local);
\r
187 /* Write a MIME text part out to the given stream.
\r
188 @@ -575,7 +573,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
189 format_message_json (ctx, node->envelope_file);
\r
191 printf ("\"headers\": ");
\r
192 - format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);
\r
193 + format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
196 printf (", \"body\": [");
\r
197 @@ -651,7 +649,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
198 } else if (GMIME_IS_MESSAGE (node->part)) {
\r
199 printf (", \"content\": [{");
\r
200 printf ("\"headers\": ");
\r
201 - format_headers_json (local, GMIME_MESSAGE (node->part), FALSE);
\r
202 + format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
204 printf (", \"body\": [");
\r
205 terminator = "]}]";
\r