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 7BE2F40DF1B for ; Mon, 22 Nov 2010 03:40:32 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham 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 ulegLFMCckpm for ; Mon, 22 Nov 2010 03:40:22 -0800 (PST) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) by olra.theworths.org (Postfix) with ESMTP id 2D53040DF18 for ; Mon, 22 Nov 2010 03:40:22 -0800 (PST) Received: by wyb36 with SMTP id 36so2362221wyb.26 for ; Mon, 22 Nov 2010 03:40:21 -0800 (PST) Received: by 10.216.30.10 with SMTP id j10mr3982583wea.8.1290426017619; Mon, 22 Nov 2010 03:40:17 -0800 (PST) Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com [81.149.164.25]) by mx.google.com with ESMTPS id x3sm2215979wes.22.2010.11.22.03.40.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 22 Nov 2010 03:40:17 -0800 (PST) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 037CD594058; Mon, 22 Nov 2010 11:36:48 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] MIME: Output the filename of a part whatever the declared disposition. Date: Mon, 22 Nov 2010 11:36:47 +0000 Message-Id: <1290425807-14946-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 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: Mon, 22 Nov 2010 11:40:32 -0000 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