1 Return-Path: <novalazy@gmail.com>
\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 04C01431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 5 Aug 2012 00:22:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id EwfJmW2X-tWq for <notmuch@notmuchmail.org>;
\r
17 Sun, 5 Aug 2012 00:22:41 -0700 (PDT)
\r
18 Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com
\r
19 [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 804DC431FAE
\r
22 for <notmuch@notmuchmail.org>; Sun, 5 Aug 2012 00:22:41 -0700 (PDT)
\r
23 Received: by pbbro8 with SMTP id ro8so3935886pbb.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 05 Aug 2012 00:22:40 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer;
\r
27 bh=PJUe6fnrljYh20/N+hiZ/B+9DabpRSOCgbWic7ASyCs=;
\r
28 b=lb4dtVfgmmPABIyTQhoi8XqgivAhopEMuuTdDGT+qFWZNIPF+e4luWReVi0IFfiP3c
\r
29 PVpNjVSoq0Y8XlqstNnuIZ2RSv90cL8dmgdOaSdYo+TzW+iXlGg4WmVQotZhHHd0O6L0
\r
30 TW8tPlc0J8athoTix2n23pbANaCEyKyLcnHSFj09NnAgnIn4Zo7RVQw/QNbBSUOJf1Vu
\r
31 ZYSeBm+ooPMjALezXUhzce/FENFljGk9H2xuMaO9omDvbshXhOW1hujmR3N8z0Pke1N2
\r
32 COoi/0q5MLjfzC7pnnxvoZ/z3QPr3viwhiMhHRcIJbUNk8TW/95dDNEJ28Ne7K8TEWk2
\r
34 Received: by 10.68.239.164 with SMTP id vt4mr706718pbc.118.1344151360697;
\r
35 Sun, 05 Aug 2012 00:22:40 -0700 (PDT)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id of4sm6404538pbb.51.2012.08.05.00.22.37
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sun, 05 Aug 2012 00:22:39 -0700 (PDT)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 1/4] show: indicate length of omitted body content (json)
\r
44 Date: Sun, 5 Aug 2012 17:22:22 +1000
\r
45 Message-Id: <1344151345-25411-1-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.4.4
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Sun, 05 Aug 2012 07:22:42 -0000
\r
61 If a leaf part's body content is omitted, return the content length in
\r
62 --format=json output. This information may be used by the consumer,
\r
63 e.g. to decide whether to download a large attachment over a slow link.
\r
65 devel/schemata | 5 ++++-
\r
66 notmuch-show.c | 8 ++++++++
\r
67 2 files changed, 12 insertions(+), 1 deletions(-)
\r
69 diff --git a/devel/schemata b/devel/schemata
\r
70 index 9cb25f5..3df2764 100644
\r
71 --- a/devel/schemata
\r
72 +++ b/devel/schemata
\r
73 @@ -69,7 +69,10 @@ part = {
\r
74 # A leaf part's body content is optional, but may be included if
\r
75 # it can be correctly encoded as a string. Consumers should use
\r
76 # this in preference to fetching the part content separately.
\r
79 + # If a leaf part's body content is not included, the content-length
\r
80 + # may be included instead.
\r
81 + content-length?: int
\r
84 # The headers of a message or part (format_headers_json with reply = FALSE)
\r
85 diff --git a/notmuch-show.c b/notmuch-show.c
\r
86 index 3556293..5c54257 100644
\r
87 --- a/notmuch-show.c
\r
88 +++ b/notmuch-show.c
\r
89 @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
90 sp->map_key (sp, "content");
\r
91 sp->string_len (sp, (char *) part_content->data, part_content->len);
\r
92 g_object_unref (stream_memory);
\r
94 + GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));
\r
95 + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
\r
96 + ssize_t length = g_mime_stream_length (stream);
\r
97 + if (length >= 0) {
\r
98 + sp->map_key (sp, "content-length");
\r
99 + sp->integer (sp, length);
\r
102 } else if (GMIME_IS_MULTIPART (node->part)) {
\r
103 sp->map_key (sp, "content");
\r