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 06D8B431FC2
\r
6 for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:08:01 -0800 (PST)
\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 m9afstYt2Abe for <notmuch@notmuchmail.org>;
\r
17 Fri, 14 Dec 2012 19:07:59 -0800 (PST)
\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 4A48D431FBF
\r
22 for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:07:58 -0800 (PST)
\r
23 Received: by mail-pb0-f53.google.com with SMTP id jt11so2595004pbb.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:07:57 -0800 (PST)
\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:in-reply-to:references;
\r
27 bh=mC8lb4V6GNgTAWFt4bV8opLQVwYteG0VKnP3u8LaWvE=;
\r
28 b=OfwvKiIesBXaNAlvGy/uNK5bkX+7thxOo7pEnOJN/JlIeMH+Sjsj/YtFh4lP55uDMa
\r
29 vKqeg5+CLJIQMndSXw7hsXUf8Sf60a3+aqOYwLcaCfZKXe91ZhupnitmLFMdmdrTn02B
\r
30 xXgMGdp/aqNSMH/0rrTNKrXZ6d+ziLp3LWR7k3jl5YLjLb8FS3x2C5hIDviZVrbxB8c0
\r
31 c8s63rLfZ1RUlAznEx5yaMppfZbMjw3378/0T45ckLfnOZBtf3j8YLmGySLUzZQWK6Lw
\r
32 puC/GX8+qjQnrt7KU++TF0IQEF6pPZbhTaNqc0P1kxqHEUjqRpmRHzA+qLQl3ymrAUjE
\r
34 Received: by 10.66.74.98 with SMTP id s2mr21069553pav.64.1355540877564;
\r
35 Fri, 14 Dec 2012 19:07:57 -0800 (PST)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id zv10sm3928874pbc.76.2012.12.14.19.07.52
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Fri, 14 Dec 2012 19:07:56 -0800 (PST)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v5 3/4] show: indicate length, encoding of omitted body
\r
45 Date: Sat, 15 Dec 2012 14:06:44 +1100
\r
46 Message-Id: <1355540805-24937-4-git-send-email-novalazy@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.12.1
\r
48 In-Reply-To: <1355540805-24937-1-git-send-email-novalazy@gmail.com>
\r
49 References: <1355540805-24937-1-git-send-email-novalazy@gmail.com>
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Sat, 15 Dec 2012 03:08:01 -0000
\r
64 If a leaf part's body content is omitted, return the encoded length and
\r
65 transfer encoding in --format=json output. This information may be used
\r
66 by the consumer, e.g. to decide whether to download a large attachment
\r
69 Returning the _encoded_ content length is more efficient than returning
\r
70 the _decoded_ content length. Returning the transfer encoding allows
\r
71 the consumer to estimate the decoded content length.
\r
73 devel/schemata | 9 ++++++++-
\r
74 notmuch-show.c | 16 ++++++++++++++--
\r
75 2 files changed, 22 insertions(+), 3 deletions(-)
\r
77 diff --git a/devel/schemata b/devel/schemata
\r
78 index d1ab983..7d167be 100644
\r
79 --- a/devel/schemata
\r
80 +++ b/devel/schemata
\r
81 @@ -75,7 +75,14 @@ part = {
\r
82 # A leaf part's body content is optional, but may be included if
\r
83 # it can be correctly encoded as a string. Consumers should use
\r
84 # this in preference to fetching the part content separately.
\r
87 + # If a leaf part's body content is not included, the length of
\r
88 + # the encoded content (in bytes) may be given instead.
\r
89 + content-length?: int,
\r
90 + # If a leaf part's body content is not included, its transfer encoding
\r
91 + # may be given. Using this and the encoded content length, it is
\r
92 + # possible for the consumer to estimate the decoded content length.
\r
93 + content-transfer-encoding?: string
\r
96 # The headers of a message or part (format_headers_sprinter with reply = FALSE)
\r
97 diff --git a/notmuch-show.c b/notmuch-show.c
\r
98 index a781a49..a8a348d 100644
\r
99 --- a/notmuch-show.c
\r
100 +++ b/notmuch-show.c
\r
101 @@ -600,14 +600,26 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
105 -format_omitted_part_meta (sprinter_t *sp, GMimeObject *meta)
\r
106 +format_omitted_part_meta (sprinter_t *sp, GMimeObject *meta, GMimePart *part)
\r
108 const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset");
\r
109 + const char *cte = g_mime_object_get_header (meta, "content-transfer-encoding");
\r
110 + GMimeDataWrapper *wrapper = g_mime_part_get_content_object (part);
\r
111 + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
\r
112 + ssize_t content_length = g_mime_stream_length (stream);
\r
114 if (content_charset != NULL) {
\r
115 sp->map_key (sp, "content-charset");
\r
116 sp->string (sp, content_charset);
\r
118 + if (cte != NULL) {
\r
119 + sp->map_key (sp, "content-transfer-encoding");
\r
120 + sp->string (sp, cte);
\r
122 + if (content_length >= 0) {
\r
123 + sp->map_key (sp, "content-length");
\r
124 + sp->integer (sp, content_length);
\r
129 @@ -699,7 +711,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
130 sp->string_len (sp, (char *) part_content->data, part_content->len);
\r
131 g_object_unref (stream_memory);
\r
133 - format_omitted_part_meta (sp, meta);
\r
134 + format_omitted_part_meta (sp, meta, GMIME_PART (node->part));
\r
136 } else if (GMIME_IS_MULTIPART (node->part)) {
\r
137 sp->map_key (sp, "content");
\r