[PATCH v2 05/14] cli/reply: reorganize create_reply_message()
[notmuch-archives.git] / bb / fee4d8e943c39b5c97339cefac7dea30f06e1f
1 Return-Path: <tomi.ollila@iki.fi>\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 B94B5431FAF\r
6         for <notmuch@notmuchmail.org>; Sun,  5 Aug 2012 02:33:50 -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: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 Xxr27X-hQ35T for <notmuch@notmuchmail.org>;\r
16         Sun,  5 Aug 2012 02:33:49 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 75CA4431FAE\r
19         for <notmuch@notmuchmail.org>; Sun,  5 Aug 2012 02:33:49 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 5FAED10014F;\r
22         Sun,  5 Aug 2012 12:33:54 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json)\r
26 In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
27 References: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
28 User-Agent: Notmuch/0.13.2+123~gd19b5be (http://notmuchmail.org) Emacs/24.1.1\r
29         (x86_64-unknown-linux-gnu)\r
30 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
31         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
32         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
33 Date: Sun, 05 Aug 2012 12:32:22 +0300\r
34 Message-ID: <m21ujladll.fsf@guru.guru-group.fi>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Sun, 05 Aug 2012 09:33:50 -0000\r
50 \r
51 On Sun, Aug 05 2012, Peter Wang <novalazy@gmail.com> wrote:\r
52 \r
53 > If a leaf part's body content is omitted, return the content length in\r
54 > --format=json output.  This information may be used by the consumer,\r
55 > e.g. to decide whether to download a large attachment over a slow link.\r
56 > ---\r
57 \r
58 Code looks good to me and tests pass. So I am not against pushing...\r
59 \r
60 Tomi\r
61 \r
62 \r
63 >  devel/schemata |    5 ++++-\r
64 >  notmuch-show.c |    8 ++++++++\r
65 >  2 files changed, 12 insertions(+), 1 deletions(-)\r
66 >\r
67 > diff --git a/devel/schemata b/devel/schemata\r
68 > index 9cb25f5..3df2764 100644\r
69 > --- a/devel/schemata\r
70 > +++ b/devel/schemata\r
71 > @@ -69,7 +69,10 @@ part = {\r
72 >      # A leaf part's body content is optional, but may be included if\r
73 >      # it can be correctly encoded as a string.  Consumers should use\r
74 >      # this in preference to fetching the part content separately.\r
75 > -    content?:       string\r
76 > +    content?:       string,\r
77 > +    # If a leaf part's body content is not included, the content-length\r
78 > +    # may be included instead.\r
79 > +    content-length?: int\r
80 >  }\r
81 >  \r
82 >  # The headers of a message or part (format_headers_json with reply = FALSE)\r
83 > diff --git a/notmuch-show.c b/notmuch-show.c\r
84 > index 3556293..5c54257 100644\r
85 > --- a/notmuch-show.c\r
86 > +++ b/notmuch-show.c\r
87 > @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
88 >           sp->map_key (sp, "content");\r
89 >           sp->string_len (sp, (char *) part_content->data, part_content->len);\r
90 >           g_object_unref (stream_memory);\r
91 > +     } else {\r
92 > +         GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));\r
93 > +         GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);\r
94 > +         ssize_t length = g_mime_stream_length (stream);\r
95 > +         if (length >= 0) {\r
96 > +             sp->map_key (sp, "content-length");\r
97 > +             sp->integer (sp, length);\r
98 > +         }\r
99 >       }\r
100 >      } else if (GMIME_IS_MULTIPART (node->part)) {\r
101 >       sp->map_key (sp, "content");\r
102 > -- \r
103 > 1.7.4.4\r
104 >\r
105 > _______________________________________________\r
106 > notmuch mailing list\r
107 > notmuch@notmuchmail.org\r
108 > http://notmuchmail.org/mailman/listinfo/notmuch\r