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 CC7D3431FBD
\r
6 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:44 -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 KEWmC6850hhj for <notmuch@notmuchmail.org>;
\r
16 Fri, 27 Jul 2012 21:29:40 -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 5519D431FCF
\r
20 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:28 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-9c-50136aa720fd
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 66.70.02244.7AA63105; Sat, 28 Jul 2012 00:29:28 -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 q6S4TRb4017264;
\r
27 Sat, 28 Jul 2012 00:29:27 -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 q6S4TLxu027361
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 28 Jul 2012 00:29:22 -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 1SuyeW-0002XA-RK; Sat, 28 Jul 2012 00:29:20 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v2 10/13] show: Convert envelope format_part_json to use
\r
42 Date: Sat, 28 Jul 2012 00:29:11 -0400
\r
43 Message-Id: <1343449754-9010-11-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1343449754-9010-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1343449754-9010-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsUixCmqrLsiSzjAYNZHVou9De2MFqvn8lhc
\r
49 vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlXFuwT/2
\r
50 gndSFeuPTWJqYFwo2sXIySEhYCKxc985ZghbTOLCvfVsXYxcHEIC+xglOm7/Y4JwNjBKzDh8
\r
51 ixHCecQk8WJaOwuEM5dRYsLJLUwg/WwCGhLb9i9nBLFFBKQldt6dzdrFyMHBLJAn8XitBEhY
\r
52 WCBQ4t20t+wgNouAqsSrBdPAVvMKOEisv7OIHeIMeYmn9/vYQGxOoPjmlx/AaoQE7CV2T97A
\r
53 OoGRfwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdC73czBK91JTSTYyggGN3Ud3BOOGQ0iFG
\r
54 AQ5GJR7eU1eEAoRYE8uKK3MPMUpyMCmJ8kaFCwcI8SXlp1RmJBZnxBeV5qQWH2KU4GBWEuHd
\r
55 KQiU401JrKxKLcqHSUlzsCiJ895IuekvJJCeWJKanZpakFoEk5Xh4FCS4N2eCdQoWJSanlqR
\r
56 lplTgpBm4uAEGc4DNHwNSA1vcUFibnFmOkT+FKOilDjvJJCEAEgiozQPrheWEF4xigO9Isx7
\r
57 DaSKB5hM4LpfAQ1mAhpsES0EMrgkESEl1cDYtFPS+ti/KXwyt7Q3GCvx9KSuVlG5uOiynPW5
\r
58 khW7/qSs96rWf6rqcpfZuO65i5nthf1VTW7xoZHJSzq+7nvH9Lfm0/XUmiPl0bNcWFc6pi58
\r
59 vNzvzfMbDlb9yhOnVBf+PntxHfu5Vc+SFnv+2fL++6Gn++ZdP/40IP/HKyaBV7sPmDRdCn4Z
\r
60 qMRSnJFoqMVcVJwIAPHw0u3jAgAA
\r
61 Cc: tomi.ollila@iki.fi
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Sat, 28 Jul 2012 04:29:45 -0000
\r
77 notmuch-show.c | 57 +++++++++++++++++++++++++++++++++-----------------------
\r
78 1 file changed, 34 insertions(+), 23 deletions(-)
\r
80 diff --git a/notmuch-show.c b/notmuch-show.c
\r
81 index afbd9d0..b9d9f5d 100644
\r
82 --- a/notmuch-show.c
\r
83 +++ b/notmuch-show.c
\r
84 @@ -109,35 +109,45 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
85 from, relative_date, tags);
\r
88 +/* Emit a sequence of key/value pairs for the metadata of message.
\r
89 + * The caller should begin a map before calling this. */
\r
91 -format_message_json (const void *ctx, notmuch_message_t *message)
\r
92 +format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
94 + void *local = talloc_new (NULL);
\r
95 notmuch_tags_t *tags;
\r
97 - void *ctx_quote = talloc_new (ctx);
\r
99 const char *relative_date;
\r
101 + sp->map_key (sp, "id");
\r
102 + sp->string (sp, notmuch_message_get_message_id (message));
\r
104 + sp->map_key (sp, "match");
\r
105 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH));
\r
107 + sp->map_key (sp, "excluded");
\r
108 + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED));
\r
110 + sp->map_key (sp, "filename");
\r
111 + sp->string (sp, notmuch_message_get_filename (message));
\r
113 + sp->map_key (sp, "timestamp");
\r
114 date = notmuch_message_get_date (message);
\r
115 - relative_date = notmuch_time_relative_date (ctx, date);
\r
116 + sp->integer (sp, date);
\r
118 - printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
119 - json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
120 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
121 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
122 - json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
123 - date, relative_date);
\r
124 + sp->map_key (sp, "date_relative");
\r
125 + relative_date = notmuch_time_relative_date (local, date);
\r
126 + sp->string (sp, relative_date);
\r
128 + sp->map_key (sp, "tags");
\r
129 + sp->begin_list (sp);
\r
130 for (tags = notmuch_message_get_tags (message);
\r
131 notmuch_tags_valid (tags);
\r
132 notmuch_tags_move_to_next (tags))
\r
134 - printf("%s%s", first ? "" : ",",
\r
135 - json_quote_str (ctx_quote, notmuch_tags_get (tags)));
\r
139 - talloc_free (ctx_quote);
\r
140 + sp->string (sp, notmuch_tags_get (tags));
\r
143 + talloc_free (local);
\r
146 /* Extract just the email address from the contents of a From:
\r
147 @@ -573,18 +583,19 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
148 * devel/schemata. */
\r
150 if (node->envelope_file) {
\r
152 - format_message_json (ctx, node->envelope_file);
\r
153 + sp->begin_map (sp);
\r
154 + format_message_json (sp, node->envelope_file);
\r
156 - printf ("\"headers\": ");
\r
157 + sp->map_key (sp, "headers");
\r
158 format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
161 - printf (", \"body\": [");
\r
162 + sp->map_key (sp, "body");
\r
163 + sp->begin_list (sp);
\r
164 format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r