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 CCE45429E4D
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:12 -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 L2tW2ssioUTB for <notmuch@notmuchmail.org>;
\r
16 Thu, 2 Aug 2012 18:15:10 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 56A2C431E84
\r
20 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:08 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-bd-501b261beb97
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 29.BD.02244.B162B105; Thu, 2 Aug 2012 21:15:07 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q731F6Io019971;
\r
27 Thu, 2 Aug 2012 21:15:06 -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 q731F4oF002789
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Thu, 2 Aug 2012 21:15:05 -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 1Sx6To-0003wP-Ac; Thu, 02 Aug 2012 21:15:04 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v3 07/13] show: Convert format_headers_json to use sprinter
\r
41 Date: Thu, 2 Aug 2012 21:14:53 -0400
\r
42 Message-Id: <1343956499-14543-8-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10
\r
44 In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixG6noiutJh1gcK5fy2L1XB6L6zdnMlu8
\r
48 WTmP1YHZY+esu+weh78uZPF4tuoWcwBzFJdNSmpOZllqkb5dAlfG1l8aBW9VK/5eX8HWwPhW
\r
49 rouRk0NCwETiR28XI4QtJnHh3nq2LkYuDiGBfYwS31pnQznrGSXuv7vAAuE8ZJLYsKOFHcKZ
\r
50 yyix/fsOFpB+NgENiW37l4PNEhGQlth5dzYriM0sECexZcp/sLiwgLfEubnTmboYOThYBFQl
\r
51 Xr91AQnzCjhInJl3hxXiDHmJp/f72EBsTgFHoJJXYK1CQDXL27pZJzDyL2BkWMUom5JbpZub
\r
52 mJlTnJqsW5ycmJeXWqRroZebWaKXmlK6iREcWi6qOxgnHFI6xCjAwajEw2skKR0gxJpYVlyZ
\r
53 e4hRkoNJSZSXWQkoxJeUn1KZkVicEV9UmpNafIhRgoNZSYS3aolUgBBvSmJlVWpRPkxKmoNF
\r
54 SZz3RspNfyGB9MSS1OzU1ILUIpisDAeHkgSvrCrQUMGi1PTUirTMnBKENBMHJ8hwHqDh9iA1
\r
55 vMUFibnFmekQ+VOMilLivOwgCQGQREZpHlwvLPZfMYoDvSLMe0EFqIoHmDbgul8BDWYCGmxn
\r
56 BnJ1cUkiQkqqgdHqsW9IDecdpXeXxd5nvzI9GBIxq3+K0/ymFMWZrY9uPjpxMbmJTzTPTfHB
\r
57 9u86Vh4bTxTcWsjgdsdBfWtxU+em5pc1542kJRtOyeZY2eXOe1NreNSXd5qU6hG+Jr1HS7tP
\r
58 Pnu43lb/oN/z/DTz6yuqrx7yn24zR6L9zr+VIn9LNC25jt1K6lNiKc5INNRiLipOBADsO7D8
\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: Fri, 03 Aug 2012 01:15:13 -0000
\r
75 This no longer requires a talloc context (not that it really did
\r
76 before since it didn't return anything), so we remove its context
\r
79 notmuch-client.h | 3 ++-
\r
80 notmuch-reply.c | 2 +-
\r
81 notmuch-show.c | 58 ++++++++++++++++++++++++++----------------------------
\r
82 3 files changed, 31 insertions(+), 32 deletions(-)
\r
84 diff --git a/notmuch-client.h b/notmuch-client.h
\r
85 index 112574c..b11caff 100644
\r
86 --- a/notmuch-client.h
\r
87 +++ b/notmuch-client.h
\r
88 @@ -183,7 +183,8 @@ format_part_json (const void *ctx, struct sprinter *sp, mime_node_t *node,
\r
89 notmuch_bool_t first, notmuch_bool_t output_body);
\r
92 -format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
\r
93 +format_headers_json (struct sprinter *sp, GMimeMessage *message,
\r
94 + notmuch_bool_t reply);
\r
97 NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
\r
98 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
99 index 07d4452..fa6665f 100644
\r
100 --- a/notmuch-reply.c
\r
101 +++ b/notmuch-reply.c
\r
102 @@ -617,7 +617,7 @@ notmuch_reply_format_json(void *ctx,
\r
104 /* The headers of the reply message we've created */
\r
105 printf ("{\"reply-headers\": ");
\r
106 - format_headers_json (ctx, reply, TRUE);
\r
107 + format_headers_json (sp, reply, TRUE);
\r
108 g_object_unref (G_OBJECT (reply));
\r
111 diff --git a/notmuch-show.c b/notmuch-show.c
\r
112 index b258f65..9852119 100644
\r
113 --- a/notmuch-show.c
\r
114 +++ b/notmuch-show.c
\r
115 @@ -199,48 +199,46 @@ _is_from_line (const char *line)
\r
119 -format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply)
\r
120 +format_headers_json (sprinter_t *sp, GMimeMessage *message,
\r
121 + notmuch_bool_t reply)
\r
123 - void *local = talloc_new (ctx);
\r
124 InternetAddressList *recipients;
\r
125 const char *recipients_string;
\r
127 - printf ("{%s: %s",
\r
128 - json_quote_str (local, "Subject"),
\r
129 - json_quote_str (local, g_mime_message_get_subject (message)));
\r
130 - printf (", %s: %s",
\r
131 - json_quote_str (local, "From"),
\r
132 - json_quote_str (local, g_mime_message_get_sender (message)));
\r
133 + sp->begin_map (sp);
\r
135 + sp->map_key (sp, "Subject");
\r
136 + sp->string (sp, g_mime_message_get_subject (message));
\r
138 + sp->map_key (sp, "From");
\r
139 + sp->string (sp, g_mime_message_get_sender (message));
\r
141 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
\r
142 recipients_string = internet_address_list_to_string (recipients, 0);
\r
143 - if (recipients_string)
\r
144 - printf (", %s: %s",
\r
145 - json_quote_str (local, "To"),
\r
146 - json_quote_str (local, recipients_string));
\r
147 + if (recipients_string) {
\r
148 + sp->map_key (sp, "To");
\r
149 + sp->string (sp, recipients_string);
\r
152 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
\r
153 recipients_string = internet_address_list_to_string (recipients, 0);
\r
154 - if (recipients_string)
\r
155 - printf (", %s: %s",
\r
156 - json_quote_str (local, "Cc"),
\r
157 - json_quote_str (local, recipients_string));
\r
158 + if (recipients_string) {
\r
159 + sp->map_key (sp, "Cc");
\r
160 + sp->string (sp, recipients_string);
\r
164 - printf (", %s: %s",
\r
165 - json_quote_str (local, "In-reply-to"),
\r
166 - json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")));
\r
167 + sp->map_key (sp, "In-reply-to");
\r
168 + sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to"));
\r
170 - printf (", %s: %s",
\r
171 - json_quote_str (local, "References"),
\r
172 - json_quote_str (local, g_mime_object_get_header (GMIME_OBJECT (message), "References")));
\r
173 + sp->map_key (sp, "References");
\r
174 + sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
\r
176 - printf (", %s: %s",
\r
177 - json_quote_str (local, "Date"),
\r
178 - json_quote_str (local, g_mime_message_get_date_as_string (message)));
\r
179 + sp->map_key (sp, "Date");
\r
180 + sp->string (sp, g_mime_message_get_date_as_string (message));
\r
185 - talloc_free (local);
\r
189 /* Write a MIME text part out to the given stream.
\r
190 @@ -575,7 +573,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
191 format_message_json (ctx, node->envelope_file);
\r
193 printf ("\"headers\": ");
\r
194 - format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);
\r
195 + format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
198 printf (", \"body\": [");
\r
199 @@ -651,7 +649,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
200 } else if (GMIME_IS_MESSAGE (node->part)) {
\r
201 printf (", \"content\": [{");
\r
202 printf ("\"headers\": ");
\r
203 - format_headers_json (local, GMIME_MESSAGE (node->part), FALSE);
\r
204 + format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
206 printf (", \"body\": [");
\r
207 terminator = "]}]";
\r