From d6615b554e6ade878d3bc3caf9ff93be1a4cf143 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 2 Nov 2009 13:27:34 -0800 Subject: [PATCH] Print "part" markers for each MIME part (with Content-type). This can allow for the client to hide undesired MIME parts such as text/html. --- TODO | 2 -- notmuch.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index b68be371..bfdd8bc4 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -Fix "notmuch show" to actually MIME-decode messages. - Add support to format a reply buffer for a particular message. Add feedback for tag addition/removal to notmuch.el. diff --git a/notmuch.c b/notmuch.c index 20191084..0d08a546 100644 --- a/notmuch.c +++ b/notmuch.c @@ -904,6 +904,7 @@ show_message_part (GMimeObject *part) GMimeStream *stream; GMimeDataWrapper *wrapper; GMimeContentDisposition *disposition; + GMimeContentType *content_type; if (GMIME_IS_MULTIPART (part)) { GMimeMultipart *multipart = GMIME_MULTIPART (part); @@ -943,13 +944,22 @@ show_message_part (GMimeObject *part) strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) { const char *filename = g_mime_part_get_filename (GMIME_PART (part)); + content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); + + printf ("%%attachment{ Content-type: %s\n", + g_mime_content_type_to_string (content_type)); + printf ("%s\n", filename); + printf ("%%attachment}\n"); - /* XXX: Need to print content type here as well. */ - printf ("%%attachment{ %s %%attachment}\n", filename); return; } /* Stream the MIME part out to stdout. */ + content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); + + printf ("%%part{ Content-type: %s\n", + g_mime_content_type_to_string (content_type)); + stream = g_mime_stream_file_new (stdout); g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE); @@ -957,6 +967,8 @@ show_message_part (GMimeObject *part) if (wrapper) g_mime_data_wrapper_write_to_stream (wrapper, stream); + printf ("%%part}\n"); + g_object_unref (stream); } -- 2.43.0