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 589F5431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:09 -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 bc4P4AXYm3B4 for <notmuch@notmuchmail.org>;
\r
16 Thu, 2 Aug 2012 18:15:08 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id D46B6431FAE
\r
20 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:07 -0700 (PDT)
\r
21 X-AuditID: 12074422-b7f1f6d00000090b-de-501b261b04f0
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id C9.20.02315.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-1.mit.edu (8.13.8/8.9.2) with ESMTP id q731F6jD012766;
\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 q731F4UM002791
\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-0003wR-CH; 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 08/13] show: Convert format_part_sigstatus_json to use
\r
42 Date: Thu, 2 Aug 2012 21:14:54 -0400
\r
43 Message-Id: <1343956499-14543-9-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixCmqrCutJh1gMOOnjMXquTwW12/OZLZ4
\r
49 s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6Mzas2sBZcMq2Y3LCSpYHx
\r
50 r0YXIyeHhICJxMaNM1khbDGJC/fWs3UxcnEICexjlDj0dS4jhLOeUWL/88dQmYdMEtNff4By
\r
51 5jJKbJ+2BKyfTUBDYtv+5YwgtoiAtMTOu7PB4swCcRJbpvwHiwsLBEmca50JZrMIqEqceHKZ
\r
52 CcTmFXCQaOg5AXWHvMTT+31sIDangKPE67evwOqFgGqWt3WzTmDkX8DIsIpRNiW3Sjc3MTOn
\r
53 ODVZtzg5MS8vtUjXVC83s0QvNaV0EyMovNhdlHYw/jyodIhRgINRiYfXWFI6QIg1say4MvcQ
\r
54 oyQHk5IoL7MSUIgvKT+lMiOxOCO+qDQntfgQowQHs5IIb9USqQAh3pTEyqrUonyYlDQHi5I4
\r
55 77WUm/5CAumJJanZqakFqUUwWRkODiUJ3j5VoKGCRanpqRVpmTklCGkmDk6Q4TxAw7eD1PAW
\r
56 FyTmFmemQ+RPMSpKifOmgyQEQBIZpXlwvbD4f8UoDvSKMG87SBUPMHXAdb8CGswENNjODOTq
\r
57 4pJEhJRUAyNnA2vI0mmhzLFbzN5Fnt+2pyZd2/tw927NX/XB3z8ck2Hu+sjA8VRT5NTZgssC
\r
58 5pIdDlXT9/z+yn9K0Pa05MwVnWXvyhxv8VtKsKWuFMn89nHDhypD7vktE51/qX9aVr3DbNva
\r
59 YLFtBS93PhRnVJcVZTTbt+zElQbDmbevrKkSm15RpRn+yEqJpTgj0VCLuag4EQAvGA2d2gIA AA==
\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:09 -0000
\r
76 notmuch-show.c | 118 +++++++++++++++++++++++++++++---------------------------
\r
77 1 file changed, 61 insertions(+), 57 deletions(-)
\r
79 diff --git a/notmuch-show.c b/notmuch-show.c
\r
80 index 9852119..3ff32df 100644
\r
81 --- a/notmuch-show.c
\r
82 +++ b/notmuch-show.c
\r
83 @@ -337,134 +337,138 @@ signer_status_to_string (GMimeSignerStatus x)
\r
85 #ifdef GMIME_ATLEAST_26
\r
87 -format_part_sigstatus_json (mime_node_t *node)
\r
88 +format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
90 GMimeSignatureList *siglist = node->sig_list;
\r
93 + sp->begin_list (sp);
\r
101 - void *ctx_quote = talloc_new (NULL);
\r
103 for (i = 0; i < g_mime_signature_list_length (siglist); i++) {
\r
104 GMimeSignature *signature = g_mime_signature_list_get_signature (siglist, i);
\r
110 + sp->begin_map (sp);
\r
113 GMimeSignatureStatus status = g_mime_signature_get_status (signature);
\r
114 - printf ("\"status\": %s",
\r
115 - json_quote_str (ctx_quote,
\r
116 - signature_status_to_string (status)));
\r
117 + sp->map_key (sp, "status");
\r
118 + sp->string (sp, signature_status_to_string (status));
\r
120 GMimeCertificate *certificate = g_mime_signature_get_certificate (signature);
\r
121 if (status == GMIME_SIGNATURE_STATUS_GOOD) {
\r
123 - printf (", \"fingerprint\": %s", json_quote_str (ctx_quote, g_mime_certificate_get_fingerprint (certificate)));
\r
124 + if (certificate) {
\r
125 + sp->map_key (sp, "fingerprint");
\r
126 + sp->string (sp, g_mime_certificate_get_fingerprint (certificate));
\r
128 /* these dates are seconds since the epoch; should we
\r
129 * provide a more human-readable format string? */
\r
130 time_t created = g_mime_signature_get_created (signature);
\r
131 - if (created != -1)
\r
132 - printf (", \"created\": %d", (int) created);
\r
133 + if (created != -1) {
\r
134 + sp->map_key (sp, "created");
\r
135 + sp->integer (sp, created);
\r
137 time_t expires = g_mime_signature_get_expires (signature);
\r
139 - printf (", \"expires\": %d", (int) expires);
\r
140 + if (expires > 0) {
\r
141 + sp->map_key (sp, "expires");
\r
142 + sp->integer (sp, expires);
\r
144 /* output user id only if validity is FULL or ULTIMATE. */
\r
145 /* note that gmime is using the term "trust" here, which
\r
146 * is WRONG. It's actually user id "validity". */
\r
148 const char *name = g_mime_certificate_get_name (certificate);
\r
149 GMimeCertificateTrust trust = g_mime_certificate_get_trust (certificate);
\r
150 - if (name && (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE))
\r
151 - printf (", \"userid\": %s", json_quote_str (ctx_quote, name));
\r
152 + if (name && (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE)) {
\r
153 + sp->map_key (sp, "userid");
\r
154 + sp->string (sp, name);
\r
157 } else if (certificate) {
\r
158 const char *key_id = g_mime_certificate_get_key_id (certificate);
\r
160 - printf (", \"keyid\": %s", json_quote_str (ctx_quote, key_id));
\r
162 + sp->map_key (sp, "keyid");
\r
163 + sp->string (sp, key_id);
\r
167 GMimeSignatureError errors = g_mime_signature_get_errors (signature);
\r
168 if (errors != GMIME_SIGNATURE_ERROR_NONE) {
\r
169 - printf (", \"errors\": %d", errors);
\r
170 + sp->map_key (sp, "errors");
\r
171 + sp->integer (sp, errors);
\r
180 - talloc_free (ctx_quote);
\r
185 -format_part_sigstatus_json (mime_node_t *node)
\r
186 +format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
188 const GMimeSignatureValidity* validity = node->sig_validity;
\r
191 + sp->begin_list (sp);
\r
199 const GMimeSigner *signer = g_mime_signature_validity_get_signers (validity);
\r
201 - void *ctx_quote = talloc_new (NULL);
\r
210 + sp->begin_map (sp);
\r
213 - printf ("\"status\": %s",
\r
214 - json_quote_str (ctx_quote,
\r
215 - signer_status_to_string (signer->status)));
\r
216 + sp->map_key (sp, "status");
\r
217 + sp->string (sp, signer_status_to_string (signer->status));
\r
219 if (signer->status == GMIME_SIGNER_STATUS_GOOD)
\r
221 - if (signer->fingerprint)
\r
222 - printf (", \"fingerprint\": %s", json_quote_str (ctx_quote, signer->fingerprint));
\r
223 + if (signer->fingerprint) {
\r
224 + sp->map_key (sp, "fingerprint");
\r
225 + sp->string (sp, signer->fingerprint);
\r
227 /* these dates are seconds since the epoch; should we
\r
228 * provide a more human-readable format string? */
\r
229 - if (signer->created)
\r
230 - printf (", \"created\": %d", (int) signer->created);
\r
231 - if (signer->expires)
\r
232 - printf (", \"expires\": %d", (int) signer->expires);
\r
233 + if (signer->created) {
\r
234 + sp->map_key (sp, "created");
\r
235 + sp->integer (sp, signer->created);
\r
237 + if (signer->expires) {
\r
238 + sp->map_key (sp, "expires");
\r
239 + sp->integer (sp, signer->expires);
\r
241 /* output user id only if validity is FULL or ULTIMATE. */
\r
242 /* note that gmime is using the term "trust" here, which
\r
243 * is WRONG. It's actually user id "validity". */
\r
244 if ((signer->name) && (signer->trust)) {
\r
245 - if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE))
\r
246 - printf (", \"userid\": %s", json_quote_str (ctx_quote, signer->name));
\r
247 + if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE)) {
\r
248 + sp->map_key (sp, "userid");
\r
249 + sp->string (sp, signer->name);
\r
253 - if (signer->keyid)
\r
254 - printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid));
\r
255 + if (signer->keyid) {
\r
256 + sp->map_key (sp, "keyid");
\r
257 + sp->string (sp, signer->keyid);
\r
260 if (signer->errors != GMIME_SIGNER_ERROR_NONE) {
\r
261 - printf (", \"errors\": %d", signer->errors);
\r
262 + sp->map_key (sp, "errors");
\r
263 + sp->integer (sp, signer->errors);
\r
268 signer = signer->next;
\r
273 - talloc_free (ctx_quote);
\r
278 @@ -607,7 +611,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
280 if (node->verify_attempted) {
\r
281 printf (", \"sigstatus\": ");
\r
282 - format_part_sigstatus_json (node);
\r
283 + format_part_sigstatus_json (sp, node);
\r
286 printf (", \"content-type\": %s",
\r