Re: Hi all
[notmuch-archives.git] / e2 / 32ab3b756c72095ad98e188e4c146541f24288
1 Return-Path: <m.walters@qmul.ac.uk>\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 24339431FAF\r
6         for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 16:01:19 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 7GPS5m8iXfGu for <notmuch@notmuchmail.org>;\r
17         Tue,  7 Aug 2012 16:01:18 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 42EB6431FAE\r
22         for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 16:01:18 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1Sysm2-0000Q2-9G; Wed, 08 Aug 2012 00:01:14 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1Sysm1-0003uN-Vw; Wed, 08 Aug 2012 00:01:14 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json)\r
35 In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
36 References: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
37 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Wed, 08 Aug 2012 00:01:06 +0100\r
40 Message-ID: <87fw7ymhn1.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 94.192.233.223\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: 2c10ca421a533dc9ced71399bb17794b (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -1.8\r
47 X-SpamAssassin-SpamBar: -\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -1.8 points.\r
52         Summary of the scoring: \r
53         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
54         *      medium trust\r
55         *      [138.37.6.40 listed in list.dnswl.org]\r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
59         *      domain\r
60         *  0.5 AWL AWL: From: address is in the auto white-list\r
61 X-QM-Scan-Virus: ClamAV says the message is clean\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\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: Tue, 07 Aug 2012 23:01:19 -0000\r
75 \r
76 \r
77 I like this (and agree with Austin and you that text and json can\r
78 diverge). I just hacked something together which uses this and makes the\r
79 emacs front-end display the content-length on part buttons and as\r
80 someone who uses notmuch over ssh that is nice.\r
81 \r
82 I have two minor queries: do you think omitted text/html parts should\r
83 also have the length given? Or even should it always be sent? But I am\r
84 happy with it as is.\r
85 \r
86 I haven't checked the test patch (or the text ones as they are being\r
87 dropped).\r
88 \r
89 Best wishes\r
90 \r
91 Mark\r
92 \r
93 On Sun, 05 Aug 2012, Peter Wang <novalazy@gmail.com> wrote:\r
94 > If a leaf part's body content is omitted, return the content length in\r
95 > --format=json output.  This information may be used by the consumer,\r
96 > e.g. to decide whether to download a large attachment over a slow link.\r
97 > ---\r
98 >  devel/schemata |    5 ++++-\r
99 >  notmuch-show.c |    8 ++++++++\r
100 >  2 files changed, 12 insertions(+), 1 deletions(-)\r
101 >\r
102 > diff --git a/devel/schemata b/devel/schemata\r
103 > index 9cb25f5..3df2764 100644\r
104 > --- a/devel/schemata\r
105 > +++ b/devel/schemata\r
106 > @@ -69,7 +69,10 @@ part = {\r
107 >      # A leaf part's body content is optional, but may be included if\r
108 >      # it can be correctly encoded as a string.  Consumers should use\r
109 >      # this in preference to fetching the part content separately.\r
110 > -    content?:       string\r
111 > +    content?:       string,\r
112 > +    # If a leaf part's body content is not included, the content-length\r
113 > +    # may be included instead.\r
114 > +    content-length?: int\r
115 >  }\r
116 >  \r
117 >  # The headers of a message or part (format_headers_json with reply = FALSE)\r
118 > diff --git a/notmuch-show.c b/notmuch-show.c\r
119 > index 3556293..5c54257 100644\r
120 > --- a/notmuch-show.c\r
121 > +++ b/notmuch-show.c\r
122 > @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
123 >           sp->map_key (sp, "content");\r
124 >           sp->string_len (sp, (char *) part_content->data, part_content->len);\r
125 >           g_object_unref (stream_memory);\r
126 > +     } else {\r
127 > +         GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));\r
128 > +         GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);\r
129 > +         ssize_t length = g_mime_stream_length (stream);\r
130 > +         if (length >= 0) {\r
131 > +             sp->map_key (sp, "content-length");\r
132 > +             sp->integer (sp, length);\r
133 > +         }\r
134 >       }\r
135 >      } else if (GMIME_IS_MULTIPART (node->part)) {\r
136 >       sp->map_key (sp, "content");\r
137 > -- \r
138 > 1.7.4.4\r
139 >\r
140 > _______________________________________________\r
141 > notmuch mailing list\r
142 > notmuch@notmuchmail.org\r
143 > http://notmuchmail.org/mailman/listinfo/notmuch\r