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 5AD7F431FAE
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:15 -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 P9Xawyg0d8BZ for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jul 2012 19:35:13 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 8BB74431FDA
\r
20 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:06 -0700 (PDT)
\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-ff-500f5b596f3d
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 73.7F.02226.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-4.mit.edu (8.13.8/8.9.2) with ESMTP id q6P2Z4Fj008578;
\r
27 Tue, 24 Jul 2012 22:35:04 -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 q6P2Z26R025127
\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-0004Zz-Js; 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 08/13] show: Convert format_part_sigstatus_json to use
\r
42 Date: Tue, 24 Jul 2012 22:34:48 -0400
\r
43 Message-Id: <1343183693-17134-9-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsUixG6nrhsZzR9gcOuOtsXehnZGi+s3ZzI7
\r
49 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBmbV21gLbhkWjG5YSVLA+NfjS5GTg4JAROJ
\r
50 uZdeM0LYYhIX7q1n62Lk4hAS2McoceTbaVYIZwOjxPI1G1kgnEdMEh8+rWSEcOYySpza8Qas
\r
51 n01AQ2Lb/uVgtoiAtMTOu7NZQWxmATOJuT8nsoHYwgL+Ej8WXGMCsVkEVCXmXe4Hi/MKOEhs
\r
52 evGcHeIOeYmn9/vA4pwCjhLnlywEmykEVNOz+Br7BEb+BYwMqxhlU3KrdHMTM3OKU5N1i5MT
\r
53 8/JSi3SN9XIzS/RSU0o3MYKCiVOSbwfj14NKhxgFOBiVeHh/P+ELEGJNLCuuzD3EKMnBpCTK
\r
54 WxHMHyDEl5SfUpmRWJwRX1Sak1p8iFGCg1lJhLcoDCjHm5JYWZValA+TkuZgURLnvZJy019I
\r
55 ID2xJDU7NbUgtQgmK8PBoSTB2xoF1ChYlJqeWpGWmVOCkGbi4AQZzgM0fDdIDW9xQWJucWY6
\r
56 RP4Uo6KUOO9ckIQASCKjNA+uFxbtrxjFgV4R5m0GqeIBJgq47ldAg5mABj8P4wMZXJKIkJJq
\r
57 YAyayZCx0NiK77Zk94ziXg9f7taXFa9ElWfc/XpcIGblYhWbhNq2+syPx1Ll4091rjiwJPHG
\r
58 JvPaywnfVtfkvJ/593V0mG74CofaUK8mZ2nrBx9upWfkTtWzfDTvctk+Yee63Z7vRBpYUv6v
\r
59 iT41hSP2y9Vnnz6fav/XJuXV+E3QqzMkPazNTYmlOCPRUIu5qDgRALe4W8LRAgAA
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Wed, 25 Jul 2012 02:35:15 -0000
\r
75 notmuch-show.c | 118 +++++++++++++++++++++++++++++---------------------------
\r
76 1 file changed, 61 insertions(+), 57 deletions(-)
\r
78 diff --git a/notmuch-show.c b/notmuch-show.c
\r
79 index 9852119..3ff32df 100644
\r
80 --- a/notmuch-show.c
\r
81 +++ b/notmuch-show.c
\r
82 @@ -337,134 +337,138 @@ signer_status_to_string (GMimeSignerStatus x)
\r
84 #ifdef GMIME_ATLEAST_26
\r
86 -format_part_sigstatus_json (mime_node_t *node)
\r
87 +format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
89 GMimeSignatureList *siglist = node->sig_list;
\r
92 + sp->begin_list (sp);
\r
100 - void *ctx_quote = talloc_new (NULL);
\r
102 for (i = 0; i < g_mime_signature_list_length (siglist); i++) {
\r
103 GMimeSignature *signature = g_mime_signature_list_get_signature (siglist, i);
\r
109 + sp->begin_map (sp);
\r
112 GMimeSignatureStatus status = g_mime_signature_get_status (signature);
\r
113 - printf ("\"status\": %s",
\r
114 - json_quote_str (ctx_quote,
\r
115 - signature_status_to_string (status)));
\r
116 + sp->map_key (sp, "status");
\r
117 + sp->string (sp, signature_status_to_string (status));
\r
119 GMimeCertificate *certificate = g_mime_signature_get_certificate (signature);
\r
120 if (status == GMIME_SIGNATURE_STATUS_GOOD) {
\r
122 - printf (", \"fingerprint\": %s", json_quote_str (ctx_quote, g_mime_certificate_get_fingerprint (certificate)));
\r
123 + if (certificate) {
\r
124 + sp->map_key (sp, "fingerprint");
\r
125 + sp->string (sp, g_mime_certificate_get_fingerprint (certificate));
\r
127 /* these dates are seconds since the epoch; should we
\r
128 * provide a more human-readable format string? */
\r
129 time_t created = g_mime_signature_get_created (signature);
\r
130 - if (created != -1)
\r
131 - printf (", \"created\": %d", (int) created);
\r
132 + if (created != -1) {
\r
133 + sp->map_key (sp, "created");
\r
134 + sp->integer (sp, created);
\r
136 time_t expires = g_mime_signature_get_expires (signature);
\r
138 - printf (", \"expires\": %d", (int) expires);
\r
139 + if (expires > 0) {
\r
140 + sp->map_key (sp, "expires");
\r
141 + sp->integer (sp, expires);
\r
143 /* output user id only if validity is FULL or ULTIMATE. */
\r
144 /* note that gmime is using the term "trust" here, which
\r
145 * is WRONG. It's actually user id "validity". */
\r
147 const char *name = g_mime_certificate_get_name (certificate);
\r
148 GMimeCertificateTrust trust = g_mime_certificate_get_trust (certificate);
\r
149 - if (name && (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE))
\r
150 - printf (", \"userid\": %s", json_quote_str (ctx_quote, name));
\r
151 + if (name && (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE)) {
\r
152 + sp->map_key (sp, "userid");
\r
153 + sp->string (sp, name);
\r
156 } else if (certificate) {
\r
157 const char *key_id = g_mime_certificate_get_key_id (certificate);
\r
159 - printf (", \"keyid\": %s", json_quote_str (ctx_quote, key_id));
\r
161 + sp->map_key (sp, "keyid");
\r
162 + sp->string (sp, key_id);
\r
166 GMimeSignatureError errors = g_mime_signature_get_errors (signature);
\r
167 if (errors != GMIME_SIGNATURE_ERROR_NONE) {
\r
168 - printf (", \"errors\": %d", errors);
\r
169 + sp->map_key (sp, "errors");
\r
170 + sp->integer (sp, errors);
\r
179 - talloc_free (ctx_quote);
\r
184 -format_part_sigstatus_json (mime_node_t *node)
\r
185 +format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
187 const GMimeSignatureValidity* validity = node->sig_validity;
\r
190 + sp->begin_list (sp);
\r
198 const GMimeSigner *signer = g_mime_signature_validity_get_signers (validity);
\r
200 - void *ctx_quote = talloc_new (NULL);
\r
209 + sp->begin_map (sp);
\r
212 - printf ("\"status\": %s",
\r
213 - json_quote_str (ctx_quote,
\r
214 - signer_status_to_string (signer->status)));
\r
215 + sp->map_key (sp, "status");
\r
216 + sp->string (sp, signer_status_to_string (signer->status));
\r
218 if (signer->status == GMIME_SIGNER_STATUS_GOOD)
\r
220 - if (signer->fingerprint)
\r
221 - printf (", \"fingerprint\": %s", json_quote_str (ctx_quote, signer->fingerprint));
\r
222 + if (signer->fingerprint) {
\r
223 + sp->map_key (sp, "fingerprint");
\r
224 + sp->string (sp, signer->fingerprint);
\r
226 /* these dates are seconds since the epoch; should we
\r
227 * provide a more human-readable format string? */
\r
228 - if (signer->created)
\r
229 - printf (", \"created\": %d", (int) signer->created);
\r
230 - if (signer->expires)
\r
231 - printf (", \"expires\": %d", (int) signer->expires);
\r
232 + if (signer->created) {
\r
233 + sp->map_key (sp, "created");
\r
234 + sp->integer (sp, signer->created);
\r
236 + if (signer->expires) {
\r
237 + sp->map_key (sp, "expires");
\r
238 + sp->integer (sp, signer->expires);
\r
240 /* output user id only if validity is FULL or ULTIMATE. */
\r
241 /* note that gmime is using the term "trust" here, which
\r
242 * is WRONG. It's actually user id "validity". */
\r
243 if ((signer->name) && (signer->trust)) {
\r
244 - if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE))
\r
245 - printf (", \"userid\": %s", json_quote_str (ctx_quote, signer->name));
\r
246 + if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE)) {
\r
247 + sp->map_key (sp, "userid");
\r
248 + sp->string (sp, signer->name);
\r
252 - if (signer->keyid)
\r
253 - printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid));
\r
254 + if (signer->keyid) {
\r
255 + sp->map_key (sp, "keyid");
\r
256 + sp->string (sp, signer->keyid);
\r
259 if (signer->errors != GMIME_SIGNER_ERROR_NONE) {
\r
260 - printf (", \"errors\": %d", signer->errors);
\r
261 + sp->map_key (sp, "errors");
\r
262 + sp->integer (sp, signer->errors);
\r
267 signer = signer->next;
\r
272 - talloc_free (ctx_quote);
\r
277 @@ -607,7 +611,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
279 if (node->verify_attempted) {
\r
280 printf (", \"sigstatus\": ");
\r
281 - format_part_sigstatus_json (node);
\r
282 + format_part_sigstatus_json (sp, node);
\r
285 printf (", \"content-type\": %s",
\r