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 DF33F431FC0 for ; Fri, 14 Dec 2012 19:07:46 -0800 (PST) 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 wgD3qHmbBnUK for ; Fri, 14 Dec 2012 19:07:45 -0800 (PST) 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 3B385431FBF for ; Fri, 14 Dec 2012 19:07:45 -0800 (PST) Received: by mail-pb0-f53.google.com with SMTP id jt11so2594955pbb.26 for ; Fri, 14 Dec 2012 19:07:44 -0800 (PST) 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=RfpN/7IuGITTDxMg3E9NMKL6WkIORa/P8nh0+PnKgyg=; b=j0BIyl3t6Ip9spGYiuQtWU+O3xRxu3BnCbXXxV1pdIpjeT0/9PbAz+2Pbtmow/bLfK ard5JHzICIsGeRunXm6UABXw9/tCEexWauF3dgkJm1vIzWEZpkv/iUHfEgED1+DbbVXe sGUt59JbHEJSEvL2K1Rte5oNWFfbkpHx3FsbIbBvQmQxbISQJJkfUuPcVueCgQnCcQT9 +7FgBhtMX6xIVBGSE1xs1QHqr4hYRjl+CFYEqQRI5gQo3aTBhi5avetveUGsfbSgFiiy oz/cuu1Sr3fOPbrfboHQtxvPUJDaxUc6RxTAl9sM+KulphcmnIC9CEf8eXkvOe3PC31y isKQ== Received: by 10.66.81.166 with SMTP id b6mr21331498pay.7.1355540864500; Fri, 14 Dec 2012 19:07:44 -0800 (PST) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id o11sm3945729pby.8.2012.12.14.19.07.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 19:07:43 -0800 (PST) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH v5 2/4] show: indicate charset for all omitted parts Date: Sat, 15 Dec 2012 14:06:43 +1100 Message-Id: <1355540805-24937-3-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1355540805-24937-1-git-send-email-novalazy@gmail.com> References: <1355540805-24937-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: Sat, 15 Dec 2012 03:07:47 -0000 Write a "charset" field for all omitted parts for which it is applicable, not only text/html parts. Factor out the code to a separate function. It will be extended with more fields next. --- notmuch-show.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index a83fef9..a781a49 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -599,6 +599,17 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, return NOTMUCH_STATUS_SUCCESS; } +static void +format_omitted_part_meta (sprinter_t *sp, GMimeObject *meta) +{ + const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset"); + + if (content_charset != NULL) { + sp->map_key (sp, "content-charset"); + sp->string (sp, content_charset); + } +} + void format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body) @@ -677,14 +688,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, * makes charset decoding the responsibility on the caller, we * report the charset for text/html parts. */ - if (g_mime_content_type_is_type (content_type, "text", "html")) { - const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset"); - - if (content_charset != NULL) { - sp->map_key (sp, "content-charset"); - sp->string (sp, content_charset); - } - } else if (g_mime_content_type_is_type (content_type, "text", "*")) { + if (g_mime_content_type_is_type (content_type, "text", "*") && + ! g_mime_content_type_is_type (content_type, "text", "html")) + { GMimeStream *stream_memory = g_mime_stream_mem_new (); GByteArray *part_content; show_text_part_content (node->part, stream_memory, 0); @@ -692,6 +698,8 @@ format_part_sprinter (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 { + format_omitted_part_meta (sp, meta); } } else if (GMIME_IS_MULTIPART (node->part)) { sp->map_key (sp, "content"); -- 1.7.12.1