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 D7F8A431FC0 for ; Sun, 5 Aug 2012 00:22:57 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 YPoJ4FswajM3 for ; Sun, 5 Aug 2012 00:22:56 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id EC46A431FC9 for ; Sun, 5 Aug 2012 00:22:52 -0700 (PDT) Received: by mail-pb0-f53.google.com with SMTP id ro8so3935886pbb.26 for ; Sun, 05 Aug 2012 00:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=2r9napsdlhmpo6bzVYOfb4NhdMAwQsnGQhu3cVy1zHs=; b=AE+EsX9PYbv8ocarLfThTQoWmg3Lrn0MvBg+B6fiTgqdh/A7q9Kfnc+VgcuDd5Yb8c ng12jrNItoVA4oJGURFkgvouArBG/7Tw5la09ycNVT+7cBubQGBwLmkRwa7Lqy9W2ZhS qYPrtZMgUSzjW4t5zegBh3pLAL0mxCH6az//P7DuhmAJt7cTHoDKLH0n7JquFgPFnbyX JKfgQ81tN5iIMFKV30u+ksxAcL1foRIRKuTFQSJ3pvH3fYzTMGZinhKeyTTPUFXZyAIq WKbGhYHEZWM6N9el0vB7hOt7buBEOJlR0YM5G0YoAj7lgROubj/3/WolPGlGXmtMSXRN ijDQ== Received: by 10.66.75.74 with SMTP id a10mr9866871paw.46.1344151372775; Sun, 05 Aug 2012 00:22:52 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id sh3sm6413930pbc.16.2012.08.05.00.22.50 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 05 Aug 2012 00:22:52 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH 3/4] show: indicate length of omitted body content (text) Date: Sun, 5 Aug 2012 17:22:24 +1000 Message-Id: <1344151345-25411-3-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com> References: <1344151345-25411-1-git-send-email-novalazy@gmail.com> 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 07:22:58 -0000 If a leaf part's body content is omitted, return the content length in --format=text output, for parity with --format=json output. --- notmuch-show.c | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 5c54257..cde8a1e 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -488,9 +488,17 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, GMIME_OBJECT (node->envelope_part) : node->part; GMimeContentType *content_type = g_mime_object_get_content_type (meta); const notmuch_bool_t leaf = GMIME_IS_PART (node->part); + notmuch_bool_t leaf_text_part = FALSE; const char *part_type; int i; + if (leaf && + g_mime_content_type_is_type (content_type, "text", "*") && + !g_mime_content_type_is_type (content_type, "text", "html")) + { + leaf_text_part = TRUE; + } + if (node->envelope_file) { notmuch_message_t *message = node->envelope_file; @@ -519,7 +527,16 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, printf (", Filename: %s", filename); if (cid) printf (", Content-id: %s", cid); - printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type)); + printf (", Content-type: %s", g_mime_content_type_to_string (content_type)); + if (leaf && !leaf_text_part) { + 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) { + printf (", Content-length: %ld", length); + } + } + printf ("\n"); } if (GMIME_IS_MESSAGE (node->part)) { @@ -547,9 +564,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, } if (leaf) { - if (g_mime_content_type_is_type (content_type, "text", "*") && - !g_mime_content_type_is_type (content_type, "text", "html")) - { + if (leaf_text_part) { GMimeStream *stream_stdout = g_mime_stream_file_new (stdout); g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE); show_text_part_content (node->part, stream_stdout, 0); -- 1.7.4.4