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 AFB2A431FBD
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:13 -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 beZ0ccuKiqAn for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jul 2012 19:35:12 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 8B07F431FAE
\r
20 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:06 -0700 (PDT)
\r
21 X-AuditID: 1209190c-b7f806d000006b87-dc-500f5b59f872
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id E1.C8.27527.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 q6P2Z5nj008579;
\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 q6P2Z24c025129
\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-0004a5-OC; 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 10/13] show: Convert envelope format_part_json to use sprinter
\r
41 Date: Tue, 24 Jul 2012 22:34:50 -0400
\r
42 Message-Id: <1343183693-17134-11-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+NgFtrLIsWRmVeSWpSXmKPExsUixG6nrhsZzR9gcGernsXehnZGi+s3ZzI7
\r
48 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBk3vl5lLPgrWXG+v4G9gfG0SBcjJ4eEgInE
\r
49 zR/dLBC2mMSFe+vZuhi5OIQE9jFKHHw/ixXC2cAocenlS2aQKiGBR0wSVxp0IRJzGSWWP13D
\r
50 DpJgE9CQ2LZ/OSOILSIgLbHz7mxWEJtZwExi7s+JbCC2sICfRPuCm2A2i4CqxNTDx8HqeQUc
\r
51 JX6s2wd1hrzE0/t9YDWcQPHzSxYyQix2kOhZfI19AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJ
\r
52 eXmpRbqGermZJXqpKaWbGEGhxCnJs4PxzUGlQ4wCHIxKPLy/n/AFCLEmlhVX5h5ilORgUhLl
\r
53 rQjmDxDiS8pPqcxILM6ILyrNSS0+xCjBwawkwlsUBpTjTUmsrEotyodJSXOwKInzXk656S8k
\r
54 kJ5YkpqdmlqQWgSTleHgUJLg3R8F1ChYlJqeWpGWmVOCkGbi4AQZzgM0fDdIDW9xQWJucWY6
\r
55 RP4Uo6KUOK82SEIAJJFRmgfXC4v1V4ziQK8IQ7TzANMEXPcroMFMQIOfh/GBDC5JREhJNTDW
\r
56 qk8PfP4ksX7mrrVLQ9vctweJ9EosmWS5b6mzmLOroV7KCq5dwm/fX1D/v+my0bJHRhbT4n9f
\r
57 WyIyWfHT/HuSckWyrMEBAhKz1rIF966KuBt8Y9Ncpge93X/MbkW4XfQqtDb49+WIm+KcWbO2
\r
58 evzZVPx93z1//y3ZU8y3rHq95/N3PqPHDSv3K7EUZyQaajEXFScCADxbndzQAgAA
\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:14 -0000
\r
74 notmuch-show.c | 57 +++++++++++++++++++++++++++++++++-----------------------
\r
75 1 file changed, 34 insertions(+), 23 deletions(-)
\r
77 diff --git a/notmuch-show.c b/notmuch-show.c
\r
78 index afbd9d0..fa1e6e9 100644
\r
79 --- a/notmuch-show.c
\r
80 +++ b/notmuch-show.c
\r
81 @@ -110,34 +110,44 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
85 -format_message_json (const void *ctx, notmuch_message_t *message)
\r
86 +format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
88 + void *local = talloc_new (NULL);
\r
89 notmuch_tags_t *tags;
\r
91 - void *ctx_quote = talloc_new (ctx);
\r
93 const char *relative_date;
\r
95 date = notmuch_message_get_date (message);
\r
96 - relative_date = notmuch_time_relative_date (ctx, date);
\r
97 + relative_date = notmuch_time_relative_date (local, date);
\r
99 + sp->map_key (sp, "id");
\r
100 + sp->string (sp, notmuch_message_get_message_id (message));
\r
102 + sp->map_key (sp, "match");
\r
103 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH));
\r
105 + sp->map_key (sp, "excluded");
\r
106 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED));
\r
108 + sp->map_key (sp, "filename");
\r
109 + sp->string (sp, notmuch_message_get_filename (message));
\r
111 + sp->map_key (sp, "timestamp");
\r
112 + date = notmuch_message_get_date (message);
\r
113 + sp->integer (sp, date);
\r
115 - printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
116 - json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
117 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
118 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
119 - json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
120 - date, relative_date);
\r
121 + sp->map_key (sp, "date_relative");
\r
122 + sp->string (sp, relative_date);
\r
124 + sp->map_key (sp, "tags");
\r
125 + sp->begin_list (sp);
\r
126 for (tags = notmuch_message_get_tags (message);
\r
127 notmuch_tags_valid (tags);
\r
128 notmuch_tags_move_to_next (tags))
\r
130 - printf("%s%s", first ? "" : ",",
\r
131 - json_quote_str (ctx_quote, notmuch_tags_get (tags)));
\r
135 - talloc_free (ctx_quote);
\r
136 + sp->string (sp, notmuch_tags_get (tags));
\r
139 + talloc_free (local);
\r
142 /* Extract just the email address from the contents of a From:
\r
143 @@ -573,18 +583,19 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
144 * devel/schemata. */
\r
146 if (node->envelope_file) {
\r
148 - format_message_json (ctx, node->envelope_file);
\r
149 + sp->begin_map (sp);
\r
150 + format_message_json (sp, node->envelope_file);
\r
152 - printf ("\"headers\": ");
\r
153 + sp->map_key (sp, "headers");
\r
154 format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
157 - printf (", \"body\": [");
\r
158 + sp->map_key (sp, "body");
\r
159 + sp->begin_list (sp);
\r
160 format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r