unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] MIME: Output the filename of a part whatever the declared disposition.
@ 2010-11-22 11:36 David Edmondson
  0 siblings, 0 replies; only message in thread
From: David Edmondson @ 2010-11-22 11:36 UTC (permalink / raw)
  To: notmuch

Some user agents create MIME parts that are generally not rendered
inline by the emacs user interface (for example application/pdf) yet
set the disposition for the part to 'inline'. If the user wishes to
save such parts it is convenient to be prompted with the filename used
for the attachment by the sender, should it be present. To allow this,
output the filename for all MIME parts if it is known irrespective of
the declared disposition.
---
 notmuch-show.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index ef421ec..f8e37c5 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -423,7 +423,7 @@ static void
 format_part_json (GMimeObject *part, int *part_count)
 {
     GMimeContentType *content_type;
-    GMimeContentDisposition *disposition;
+    const char *filename;
     void *ctx = talloc_new (NULL);
     GMimeStream *stream_memory = g_mime_stream_mem_new ();
     GByteArray *part_content;
@@ -437,14 +437,9 @@ format_part_json (GMimeObject *part, int *part_count)
 	    *part_count,
 	    json_quote_str (ctx, g_mime_content_type_to_string (content_type)));
 
-    disposition = g_mime_object_get_content_disposition (part);
-    if (disposition &&
-	strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
-    {
-	const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-
+    filename = g_mime_part_get_filename (GMIME_PART (part));
+    if (filename != NULL)
 	printf (", \"filename\": %s", json_quote_str (ctx, filename));
-    }
 
     if (g_mime_content_type_is_type (content_type, "text", "*") &&
 	!g_mime_content_type_is_type (content_type, "text", "html"))
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-11-22 11:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-22 11:36 [PATCH] MIME: Output the filename of a part whatever the declared disposition David Edmondson

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).