unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Peter Wang <novalazy@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v5b] show: indicate charset for all omitted parts
Date: Sun, 16 Dec 2012 10:22:50 +1100	[thread overview]
Message-ID: <1355613770-3793-1-git-send-email-novalazy@gmail.com> (raw)
In-Reply-To: <1355540805-24937-3-git-send-email-novalazy@gmail.com>

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..6a9278c 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 (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_sprinter (sp, meta);
 	}
     } else if (GMIME_IS_MULTIPART (node->part)) {
 	sp->map_key (sp, "content");
-- 
1.7.12.1

  reply	other threads:[~2012-12-15 23:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-15  3:06 [PATCH v5 0/4] indicate length of omitted body content Peter Wang
2012-12-15  3:06 ` [PATCH v5 1/4] test: normalize only message filenames in show json Peter Wang
2012-12-15  3:06 ` [PATCH v5 2/4] show: indicate charset for all omitted parts Peter Wang
2012-12-15 23:22   ` Peter Wang [this message]
2012-12-15  3:06 ` [PATCH v5 3/4] show: indicate length, encoding of omitted body content Peter Wang
2012-12-15 23:24   ` [PATCH v5b] " Peter Wang
2012-12-15  3:06 ` [PATCH v5 4/4] test: conform to content length, encoding fields Peter Wang
2012-12-15  8:45 ` [PATCH v5 0/4] indicate length of omitted body content Mark Walters
2012-12-15 11:04   ` Peter Wang
2012-12-15 12:53     ` David Bremner
2012-12-15 17:02       ` Tomi Ollila
2012-12-16  8:03       ` Mark Walters
2012-12-17 13:15 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355613770-3793-1-git-send-email-novalazy@gmail.com \
    --to=novalazy@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).