[PATCH v2 1/7] test thread breakage when messages are removed and re-added
[notmuch-archives.git] / 02 / 857900888d13edd827d2e328bef7c92fc61da9
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 CA919431FBD\r
6         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 15:24:32 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \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 rHcvmNR0Pw1p for <notmuch@notmuchmail.org>;\r
17         Sat, 15 Dec 2012 15:24:32 -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 00D8C431FB6\r
22         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 15:24:31 -0800 (PST)\r
23 Received: by mail-pb0-f53.google.com with SMTP id jt11so2925347pbb.26\r
24         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 15:24:31 -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=ZqnfGcqVs0ysqH5ESYtLRuWkZTlowtuQGcGSODeMWag=;\r
28         b=xAbYH05v23uKCBQOHccyOWAg6pUvBgTuFP38IbhElxQSvHx6yTOmuoeGlGbfz3SfsM\r
29         FodcfIbZnB/S23nULYt12jbOlyPHCzR2LC8bAcwzNQCrAeY5FGnDJfdFsncQ60yc9bTE\r
30         Rl6NQV1b8mCi6bi9xJ+FQpTMiW50D08c0uwKAuCdtUO/jN+ZItApjqAL+QiZGoViXB0P\r
31         zsoFT0YGya7L+SvHhdlKSWKyeMpnAACCkTZLPSjm/Q1milPqfb9SKT4YWANSOt8CbScR\r
32         Bsu4D5MDeIJOy8SasrZRVpIAZAdcZh5VfuobMpbSXftgSmr9qSHbre59cO8s26drnh8P\r
33         i+Xw==\r
34 Received: by 10.68.245.37 with SMTP id xl5mr28509661pbc.120.1355613871246;\r
35         Sat, 15 Dec 2012 15:24:31 -0800 (PST)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id nm2sm5379595pbc.43.2012.12.15.15.24.28\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 15 Dec 2012 15:24:30 -0800 (PST)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v5b] show: indicate length, encoding of omitted body content\r
44 Date: Sun, 16 Dec 2012 10:24:23 +1100\r
45 Message-Id: <1355613863-3833-1-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1355540805-24937-4-git-send-email-novalazy@gmail.com>\r
48 References: <1355540805-24937-4-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 15 Dec 2012 23:24:32 -0000\r
62 \r
63 If a leaf part's body content is omitted, return the encoded length and\r
64 transfer encoding in --format=json output.  This information may be used\r
65 by the consumer, e.g. to decide whether to download a large attachment\r
66 over a slow link.\r
67 \r
68 Returning the _encoded_ content length is more efficient than returning\r
69 the _decoded_ content length.  Returning the transfer encoding allows\r
70 the consumer to estimate the decoded content length.\r
71 ---\r
72  devel/schemata |  9 ++++++++-\r
73  notmuch-show.c | 16 ++++++++++++++--\r
74  2 files changed, 22 insertions(+), 3 deletions(-)\r
75 \r
76 diff --git a/devel/schemata b/devel/schemata\r
77 index d1ab983..7d167be 100644\r
78 --- a/devel/schemata\r
79 +++ b/devel/schemata\r
80 @@ -75,7 +75,14 @@ part = {\r
81      # A leaf part's body content is optional, but may be included if\r
82      # it can be correctly encoded as a string.  Consumers should use\r
83      # this in preference to fetching the part content separately.\r
84 -    content?:       string\r
85 +    content?:       string,\r
86 +    # If a leaf part's body content is not included, the length of\r
87 +    # the encoded content (in bytes) may be given instead.\r
88 +    content-length?: int,\r
89 +    # If a leaf part's body content is not included, its transfer encoding\r
90 +    # may be given.  Using this and the encoded content length, it is\r
91 +    # possible for the consumer to estimate the decoded content length.\r
92 +    content-transfer-encoding?: string\r
93  }\r
94  \r
95  # The headers of a message or part (format_headers_sprinter with reply = FALSE)\r
96 diff --git a/notmuch-show.c b/notmuch-show.c\r
97 index 6a9278c..2d59865 100644\r
98 --- a/notmuch-show.c\r
99 +++ b/notmuch-show.c\r
100 @@ -600,14 +600,26 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
101  }\r
102  \r
103  static void\r
104 -format_omitted_part_meta_sprinter (sprinter_t *sp, GMimeObject *meta)\r
105 +format_omitted_part_meta_sprinter (sprinter_t *sp, GMimeObject *meta, GMimePart *part)\r
106  {\r
107      const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset");\r
108 +    const char *cte = g_mime_object_get_header (meta, "content-transfer-encoding");\r
109 +    GMimeDataWrapper *wrapper = g_mime_part_get_content_object (part);\r
110 +    GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);\r
111 +    ssize_t content_length = g_mime_stream_length (stream);\r
112  \r
113      if (content_charset != NULL) {\r
114         sp->map_key (sp, "content-charset");\r
115         sp->string (sp, content_charset);\r
116      }\r
117 +    if (cte != NULL) {\r
118 +       sp->map_key (sp, "content-transfer-encoding");\r
119 +       sp->string (sp, cte);\r
120 +    }\r
121 +    if (content_length >= 0) {\r
122 +       sp->map_key (sp, "content-length");\r
123 +       sp->integer (sp, content_length);\r
124 +    }\r
125  }\r
126  \r
127  void\r
128 @@ -699,7 +711,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
129             sp->string_len (sp, (char *) part_content->data, part_content->len);\r
130             g_object_unref (stream_memory);\r
131         } else {\r
132 -           format_omitted_part_meta_sprinter (sp, meta);\r
133 +           format_omitted_part_meta_sprinter (sp, meta, GMIME_PART (node->part));\r
134         }\r
135      } else if (GMIME_IS_MULTIPART (node->part)) {\r
136         sp->map_key (sp, "content");\r
137 -- \r
138 1.7.12.1\r
139 \r