Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B94B5431FAF for ; Sun, 5 Aug 2012 02:33:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xxr27X-hQ35T for ; Sun, 5 Aug 2012 02:33:49 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 75CA4431FAE for ; Sun, 5 Aug 2012 02:33:49 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 5FAED10014F; Sun, 5 Aug 2012 12:33:54 +0300 (EEST) From: Tomi Ollila To: Peter Wang , notmuch@notmuchmail.org Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json) In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com> References: <1344151345-25411-1-git-send-email-novalazy@gmail.com> User-Agent: Notmuch/0.13.2+123~gd19b5be (http://notmuchmail.org) Emacs/24.1.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2012 09:33:50 -0000 On Sun, Aug 05 2012, Peter Wang wrote: > If a leaf part's body content is omitted, return the content length in > --format=json output. This information may be used by the consumer, > e.g. to decide whether to download a large attachment over a slow link. > --- Code looks good to me and tests pass. So I am not against pushing... Tomi > devel/schemata | 5 ++++- > notmuch-show.c | 8 ++++++++ > 2 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/devel/schemata b/devel/schemata > index 9cb25f5..3df2764 100644 > --- a/devel/schemata > +++ b/devel/schemata > @@ -69,7 +69,10 @@ part = { > # A leaf part's body content is optional, but may be included if > # it can be correctly encoded as a string. Consumers should use > # this in preference to fetching the part content separately. > - content?: string > + content?: string, > + # If a leaf part's body content is not included, the content-length > + # may be included instead. > + content-length?: int > } > > # The headers of a message or part (format_headers_json with reply = FALSE) > diff --git a/notmuch-show.c b/notmuch-show.c > index 3556293..5c54257 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node, > sp->map_key (sp, "content"); > sp->string_len (sp, (char *) part_content->data, part_content->len); > g_object_unref (stream_memory); > + } else { > + GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part)); > + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper); > + ssize_t length = g_mime_stream_length (stream); > + if (length >= 0) { > + sp->map_key (sp, "content-length"); > + sp->integer (sp, length); > + } > } > } else if (GMIME_IS_MULTIPART (node->part)) { > sp->map_key (sp, "content"); > -- > 1.7.4.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch