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 04A09429E36
\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 R0YazFFrYvgF for <notmuch@notmuchmail.org>;
\r
16 Thu, 2 Aug 2012 18:15:08 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id DEFBC431FAF
\r
20 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:07 -0700 (PDT)
\r
21 X-AuditID: 1209190d-b7fd56d000000933-d2-501b261be0a9
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 69.7E.02355.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 q731F6d3012767;
\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 q731F42H002793
\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-0003wX-FS; 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 10/13] show: Convert envelope format_part_json to use
\r
42 Date: Thu, 2 Aug 2012 21:14:56 -0400
\r
43 Message-Id: <1343956499-14543-11-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+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrCutJh1g0H9a3mL1XB6L6zdnMlu8
\r
49 WTmP1YHZY+esu+weh78uZPF4tuoWcwBzFJdNSmpOZllqkb5dAlfGuQX/2AveSVWsPzaJqYFx
\r
50 oWgXIyeHhICJxKwfJxkhbDGJC/fWs3UxcnEICexjlPg6cSsrhLOeUeL49E1QmYdMEi8mzGCG
\r
51 cOYySjTP7GEF6WcT0JDYtn852CwRAWmJnXdng8WZBeIktkz5DxYXFgiU2PbhBZjNIqAqMf/G
\r
52 IqCpHBy8Ao4S905FQpwhL/H0fh8biM0JFH799hVYuZCAg8Tytm7WCYz8CxgZVjHKpuRW6eYm
\r
53 ZuYUpybrFicn5uWlFuka6eVmluilppRuYgQHlyTvDsZ3B5UOMQpwMCrx8JpISgcIsSaWFVfm
\r
54 HmKU5GBSEuVlVgIK8SXlp1RmJBZnxBeV5qQWH2KU4GBWEuGtWiIVIMSbklhZlVqUD5OS5mBR
\r
55 Eue9knLTX0ggPbEkNTs1tSC1CCYrw8GhJMEbrAo0VLAoNT21Ii0zpwQhzcTBCTKcB2i4PUgN
\r
56 b3FBYm5xZjpE/hSjopQ4bzpIQgAkkVGaB9cLi/5XjOJArwjzeoFU8QATB1z3K6DBTECD7cxA
\r
57 ri4uSURISTUwiqpMCrv5m8f2z/YEBXtLtkcPL7yYNG3G4dbAgolib3KNHrs833B9vWbQEfFn
\r
58 J95+E7dVuyw4QXd6kuWpWWbn5Y+JZPxZ/DVZ9KHL3nCZEu548SyrJ65pwj9iOUqNbry+sPXw
\r
59 f+l1YaceeWe0Lfmz4/gj8zuXjnkJJS5t2bHa5VtwmUFZrKS6rxJLcUaioRZzUXEiADNrQvbZ AgAA
\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 | 57 +++++++++++++++++++++++++++++++++-----------------------
\r
77 1 file changed, 34 insertions(+), 23 deletions(-)
\r
79 diff --git a/notmuch-show.c b/notmuch-show.c
\r
80 index afbd9d0..b9d9f5d 100644
\r
81 --- a/notmuch-show.c
\r
82 +++ b/notmuch-show.c
\r
83 @@ -109,35 +109,45 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
84 from, relative_date, tags);
\r
87 +/* Emit a sequence of key/value pairs for the metadata of message.
\r
88 + * The caller should begin a map before calling this. */
\r
90 -format_message_json (const void *ctx, notmuch_message_t *message)
\r
91 +format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
93 + void *local = talloc_new (NULL);
\r
94 notmuch_tags_t *tags;
\r
96 - void *ctx_quote = talloc_new (ctx);
\r
98 const char *relative_date;
\r
100 + sp->map_key (sp, "id");
\r
101 + sp->string (sp, notmuch_message_get_message_id (message));
\r
103 + sp->map_key (sp, "match");
\r
104 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH));
\r
106 + sp->map_key (sp, "excluded");
\r
107 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED));
\r
109 + sp->map_key (sp, "filename");
\r
110 + sp->string (sp, notmuch_message_get_filename (message));
\r
112 + sp->map_key (sp, "timestamp");
\r
113 date = notmuch_message_get_date (message);
\r
114 - relative_date = notmuch_time_relative_date (ctx, date);
\r
115 + sp->integer (sp, date);
\r
117 - printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
118 - json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
119 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
120 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
121 - json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
122 - date, relative_date);
\r
123 + sp->map_key (sp, "date_relative");
\r
124 + relative_date = notmuch_time_relative_date (local, date);
\r
125 + sp->string (sp, relative_date);
\r
127 + sp->map_key (sp, "tags");
\r
128 + sp->begin_list (sp);
\r
129 for (tags = notmuch_message_get_tags (message);
\r
130 notmuch_tags_valid (tags);
\r
131 notmuch_tags_move_to_next (tags))
\r
133 - printf("%s%s", first ? "" : ",",
\r
134 - json_quote_str (ctx_quote, notmuch_tags_get (tags)));
\r
138 - talloc_free (ctx_quote);
\r
139 + sp->string (sp, notmuch_tags_get (tags));
\r
142 + talloc_free (local);
\r
145 /* Extract just the email address from the contents of a From:
\r
146 @@ -573,18 +583,19 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
147 * devel/schemata. */
\r
149 if (node->envelope_file) {
\r
151 - format_message_json (ctx, node->envelope_file);
\r
152 + sp->begin_map (sp);
\r
153 + format_message_json (sp, node->envelope_file);
\r
155 - printf ("\"headers\": ");
\r
156 + sp->map_key (sp, "headers");
\r
157 format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
160 - printf (", \"body\": [");
\r
161 + sp->map_key (sp, "body");
\r
162 + sp->begin_list (sp);
\r
163 format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r