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 29B88429E2A for ; Sat, 28 May 2011 15:03:29 -0700 (PDT) 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 ErF1iPfad7MK for ; Sat, 28 May 2011 15:03:27 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 14E0D429E27 for ; Sat, 28 May 2011 15:03:26 -0700 (PDT) Received: by fxm8 with SMTP id 8so2108915fxm.26 for ; Sat, 28 May 2011 15:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=5C1tbto9X7nitmA1TngreZgvSoscbeBg0DZf0UpY9Tk=; b=sGs/NHuYfl7kuaJLrqQornqwEIlcjosXMc4IfgagA7G6LjtKddzPIhq+i6uRAXId0y NV/w4xyxXUYkQAdy+xao08AfSgpi2+1FjndWK+owJ8A+i2wdULtaFsPHECi40kuD/RPx ffCMX09nIM8Fp5UXM1kd3T1iBqveyDsZpyTKs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=H2ib3hWIsmb1k1KGc+UYmntMTynh35n4bHP0o2ywAbjvcI6W3ztNK9Yo0qNH66auHh fnD52B1lyM119qtntSAkGh1Yp9kjUgVJSAGSIz3j99afOo2jiMqksuScvM86GbXR2CUd gAmRM80618I3daUnpQ4lWilANZaYkez66D6xM= Received: by 10.223.59.92 with SMTP id k28mr276653fah.27.1306620205560; Sat, 28 May 2011 15:03:25 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id c1sm276644faa.37.2011.05.28.15.03.24 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 May 2011 15:03:24 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 1/2] Add part filename and content-id in notmuch show output if available. Date: Sun, 29 May 2011 02:03:47 +0400 Message-Id: <1306620228-24351-1-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.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: Sat, 28 May 2011 22:03:29 -0000 Before the change, notmuch show output had filename only for parts with "Content-Disposition: attachment". But parts with inline disposition may have filename as well. The patch makes notmuch show always output filename if available, independent of Content-Disposition. Both JSON and text output formats are changed. Also, the patch adds Content-id to text output format of notmuch show. The main goal of these changes is to have filenames on Emacs buttons for inline attachments. In particular, this is very helpful for inline patches. Note: text format changes may require updates in clients that use it. The changes are: * text part header format changed from: ^Lpart{ ID: 2, Content-type: text/x-diff to: ^Lpart{ ID: 2, Filename: cool-feature.patch, Content-type: text/x-diff * attachment format changed from: ^Lattachment{ ID: 4, Content-type: application/octet-stream Attachment: data.tar.bz2 (application/octet-stream) Non-text part: application/octet-stream ^Lattachment} to: ^Lattachment{ ID: 4, Filename: data.tar.bz2, Content-type: application/octet-stream Non-text part: application/octet-stream ^Lattachment} --- notmuch-show.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index e90f07e..8f275d7 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -445,20 +445,22 @@ format_part_start_text (GMimeObject *part, int *part_count) static void format_part_content_text (GMimeObject *part) { - GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (part); + const char *cid = g_mime_object_get_content_id (part); GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); GMimeStream *stream_stdout = g_mime_stream_file_new (stdout); - printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type)); - - if (disposition && - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) + if (GMIME_IS_PART (part)) { const char *filename = g_mime_part_get_filename (GMIME_PART (part)); - printf ("Attachment: %s (%s)\n", filename, - g_mime_content_type_to_string (content_type)); + if (filename) + printf (", Filename: %s", filename); } + if (cid) + printf (", Content-id: %s", cid); + + printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type)); + if (g_mime_content_type_is_type (content_type, "text", "*") && !g_mime_content_type_is_type (content_type, "text", "html")) { @@ -580,7 +582,6 @@ format_part_content_json (GMimeObject *part) GMimeStream *stream_memory = g_mime_stream_mem_new (); const char *cid = g_mime_object_get_content_id (part); void *ctx = talloc_new (NULL); - GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (part); GByteArray *part_content; printf (", \"content-type\": %s", @@ -589,12 +590,11 @@ format_part_content_json (GMimeObject *part) if (cid != NULL) printf(", \"content-id\": %s", json_quote_str (ctx, cid)); - if (disposition && - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) + if (GMIME_IS_PART (part)) { const char *filename = g_mime_part_get_filename (GMIME_PART (part)); - - printf (", \"filename\": %s", json_quote_str (ctx, filename)); + if (filename) + printf (", \"filename\": %s", json_quote_str (ctx, filename)); } if (g_mime_content_type_is_type (content_type, "text", "*") && -- 1.7.5.3