Re: [PATCH 1/4] show: indicate length of omitted body content (json)
authorMark Walters <markwalters1009@gmail.com>
Tue, 7 Aug 2012 23:01:06 +0000 (00:01 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:57 +0000 (09:48 -0800)
e2/32ab3b756c72095ad98e188e4c146541f24288 [new file with mode: 0644]

diff --git a/e2/32ab3b756c72095ad98e188e4c146541f24288 b/e2/32ab3b756c72095ad98e188e4c146541f24288
new file mode 100644 (file)
index 0000000..9e28987
--- /dev/null
@@ -0,0 +1,143 @@
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 24339431FAF\r
+       for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 16:01:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 7GPS5m8iXfGu for <notmuch@notmuchmail.org>;\r
+       Tue,  7 Aug 2012 16:01:18 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 42EB6431FAE\r
+       for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 16:01:18 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Sysm2-0000Q2-9G; Wed, 08 Aug 2012 00:01:14 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+       helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Sysm1-0003uN-Vw; Wed, 08 Aug 2012 00:01:14 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json)\r
+In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
+References: <1344151345-25411-1-git-send-email-novalazy@gmail.com>\r
+User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Wed, 08 Aug 2012 00:01:06 +0100\r
+Message-ID: <87fw7ymhn1.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 2c10ca421a533dc9ced71399bb17794b (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+       *      domain\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 07 Aug 2012 23:01:19 -0000\r
+\r
+\r
+I like this (and agree with Austin and you that text and json can\r
+diverge). I just hacked something together which uses this and makes the\r
+emacs front-end display the content-length on part buttons and as\r
+someone who uses notmuch over ssh that is nice.\r
+\r
+I have two minor queries: do you think omitted text/html parts should\r
+also have the length given? Or even should it always be sent? But I am\r
+happy with it as is.\r
+\r
+I haven't checked the test patch (or the text ones as they are being\r
+dropped).\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+On Sun, 05 Aug 2012, Peter Wang <novalazy@gmail.com> wrote:\r
+> If a leaf part's body content is omitted, return the content length in\r
+> --format=json output.  This information may be used by the consumer,\r
+> e.g. to decide whether to download a large attachment over a slow link.\r
+> ---\r
+>  devel/schemata |    5 ++++-\r
+>  notmuch-show.c |    8 ++++++++\r
+>  2 files changed, 12 insertions(+), 1 deletions(-)\r
+>\r
+> diff --git a/devel/schemata b/devel/schemata\r
+> index 9cb25f5..3df2764 100644\r
+> --- a/devel/schemata\r
+> +++ b/devel/schemata\r
+> @@ -69,7 +69,10 @@ part = {\r
+>      # A leaf part's body content is optional, but may be included if\r
+>      # it can be correctly encoded as a string.  Consumers should use\r
+>      # this in preference to fetching the part content separately.\r
+> -    content?:       string\r
+> +    content?:       string,\r
+> +    # If a leaf part's body content is not included, the content-length\r
+> +    # may be included instead.\r
+> +    content-length?: int\r
+>  }\r
+>  \r
+>  # The headers of a message or part (format_headers_json with reply = FALSE)\r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index 3556293..5c54257 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+>          sp->map_key (sp, "content");\r
+>          sp->string_len (sp, (char *) part_content->data, part_content->len);\r
+>          g_object_unref (stream_memory);\r
+> +    } else {\r
+> +        GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));\r
+> +        GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);\r
+> +        ssize_t length = g_mime_stream_length (stream);\r
+> +        if (length >= 0) {\r
+> +            sp->map_key (sp, "content-length");\r
+> +            sp->integer (sp, length);\r
+> +        }\r
+>      }\r
+>      } else if (GMIME_IS_MULTIPART (node->part)) {\r
+>      sp->map_key (sp, "content");\r
+> -- \r
+> 1.7.4.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r