From dda1d7691dfbc11c0f8f3c4a9eeb89e8d0f14c31 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 23 Mar 2012 23:34:06 +2000 Subject: [PATCH] [PATCH 2/3] reply: Convert default reply format to self-recursive style --- 33/88bef277230fdf4fb5eb34c53152eb0c6a5fb2 | 243 ++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 33/88bef277230fdf4fb5eb34c53152eb0c6a5fb2 diff --git a/33/88bef277230fdf4fb5eb34c53152eb0c6a5fb2 b/33/88bef277230fdf4fb5eb34c53152eb0c6a5fb2 new file mode 100644 index 000000000..cfdb5f561 --- /dev/null +++ b/33/88bef277230fdf4fb5eb34c53152eb0c6a5fb2 @@ -0,0 +1,243 @@ +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 2CE60431FBD + for ; Thu, 22 Mar 2012 20:34:14 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 ncvPiQqky7pU for ; + Thu, 22 Mar 2012 20:34:13 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id EC595431FAE + for ; Thu, 22 Mar 2012 20:34:12 -0700 (PDT) +X-AuditID: 1209190f-b7f8a6d000000914-fd-4f6bef33b9b2 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id B0.F8.02324.33FEB6F4; Thu, 22 Mar 2012 23:34:11 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q2N3YBL0025960; + Thu, 22 Mar 2012 23:34:11 -0400 +Received: from drake.mit.edu + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q2N3Y8ZE007969 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 22 Mar 2012 23:34:10 -0400 (EDT) +Received: from amthrax by drake.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SAvGS-0002PH-Ml; Thu, 22 Mar 2012 23:34:08 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 2/3] reply: Convert default reply format to self-recursive + style +Date: Thu, 22 Mar 2012 23:34:06 -0400 +Message-Id: <1332473647-9133-3-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.7.3 +In-Reply-To: <1332473647-9133-1-git-send-email-amdragon@mit.edu> +References: <1332473647-9133-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nrmv8PtvfYGW/vsX1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CVsf8YS8FWo4qrV++xNTBu0Oxi5OSQEDCR2HvtECuELSZx4d56 + ti5GLg4hgX2MEi83zGaCcDYwSnzed4MdwrnPJDH1xgWosvmMEku/tLOB9LMJaEhs27+cEcQW + EZCW2Hl3NtBcDg5mATWJP10qIGFhgQCJ5v53bCBhFgFVieebDUHCvAL2EtOv7GKBuEJB4tzq + c+wgNqeAg8TZz/fAJgoB1Wx98oV9AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRbomermZ + JXqpKaWbGEEhwynJv4Px20GlQ4wCHIxKPLzNPtn+QqyJZcWVuYcYJTmYlER5Gd4BhfiS8lMq + MxKLM+KLSnNSiw8xSnAwK4nwKjkD5XhTEiurUovyYVLSHCxK4rxqWu/8hATSE0tSs1NTC1KL + YLIyHBxKEryTQIYKFqWmp1akZeaUIKSZODhBhvMADV8KUsNbXJCYW5yZDpE/xagoJc67BCQh + AJLIKM2D64XF9CtGcaBXhHkXg1TxANMBXPcroMFMQIMnXMsCGVySiJCSamDUnx60LkPyYpXD + jueJNf1Gl8QK53mu3qUw+/t+n7cy0Rf4a+vXf393ROqT+PPp++fJfJJrO3O+ps4twvhdQqBV + 4IL++IJtBy0a7Kxss2bLdh+fYN6QWO/jdu1dc2HLxXJ9ya9vrdfKTZ72NbBX+0hSz6usUiWO + P049My2ab/C0zOiJkp9SyKrEUpyRaKjFXFScCABKPIbYxAIAAA== +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: Fri, 23 Mar 2012 03:34:14 -0000 + +This re-arranges the default reply formatter code to use the +mime_node_t abstraction. There are no semantic changes. +--- + notmuch-reply.c | 119 +++++++++++++++++++++---------------------------------- + 1 files changed, 45 insertions(+), 74 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 2f5ed3d..84a1220 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -24,28 +24,6 @@ + #include "gmime-filter-headers.h" + + static void +-reply_headers_message_part (GMimeMessage *message); +- +-static void +-reply_part_content (GMimeObject *part); +- +-static const notmuch_show_format_t format_reply = { +- "", NULL, +- "", NULL, +- "", NULL, reply_headers_message_part, ">\n", +- "", +- NULL, +- NULL, +- NULL, +- reply_part_content, +- NULL, +- "", +- "", +- "", "", +- "" +-}; +- +-static void + show_reply_headers (GMimeMessage *message) + { + GMimeStream *stream_stdout = NULL, *stream_filter = NULL; +@@ -65,66 +43,55 @@ show_reply_headers (GMimeMessage *message) + } + + static void +-reply_headers_message_part (GMimeMessage *message) ++format_part_reply (mime_node_t *node) + { +- InternetAddressList *recipients; +- const char *recipients_string; ++ int i; + +- printf ("> From: %s\n", g_mime_message_get_sender (message)); +- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); +- recipients_string = internet_address_list_to_string (recipients, 0); +- if (recipients_string) +- printf ("> To: %s\n", +- recipients_string); +- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC); +- recipients_string = internet_address_list_to_string (recipients, 0); +- if (recipients_string) +- printf ("> Cc: %s\n", +- recipients_string); +- printf ("> Subject: %s\n", g_mime_message_get_subject (message)); +- printf ("> Date: %s\n", g_mime_message_get_date_as_string (message)); +-} ++ if (GMIME_IS_MESSAGE (node->part)) { ++ GMimeMessage *message = GMIME_MESSAGE (node->part); ++ InternetAddressList *recipients; ++ const char *recipients_string; + ++ printf ("> From: %s\n", g_mime_message_get_sender (message)); ++ recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); ++ recipients_string = internet_address_list_to_string (recipients, 0); ++ if (recipients_string) ++ printf ("> To: %s\n", ++ recipients_string); ++ recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC); ++ recipients_string = internet_address_list_to_string (recipients, 0); ++ if (recipients_string) ++ printf ("> Cc: %s\n", ++ recipients_string); ++ printf ("> Subject: %s\n", g_mime_message_get_subject (message)); ++ printf ("> Date: %s\n", g_mime_message_get_date_as_string (message)); ++ printf (">\n"); ++ } else if (GMIME_IS_PART (node->part)) { ++ GMimeContentType *content_type = g_mime_object_get_content_type (node->part); ++ GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (node->part); + +-static void +-reply_part_content (GMimeObject *part) +-{ +- GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); +- GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (part); +- +- if (g_mime_content_type_is_type (content_type, "multipart", "*") || +- g_mime_content_type_is_type (content_type, "message", "rfc822")) +- { +- /* Output nothing, since multipart subparts will be handled individually. */ +- } +- else if (g_mime_content_type_is_type (content_type, "application", "pgp-encrypted") || +- g_mime_content_type_is_type (content_type, "application", "pgp-signature")) +- { +- /* Ignore PGP/MIME cruft parts */ +- } +- else if (g_mime_content_type_is_type (content_type, "text", "*") && +- !g_mime_content_type_is_type (content_type, "text", "html")) +- { +- GMimeStream *stream_stdout = g_mime_stream_file_new (stdout); +- g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE); +- show_text_part_content (part, stream_stdout, NOTMUCH_SHOW_TEXT_PART_REPLY); +- g_object_unref(stream_stdout); +- } +- else +- { +- if (disposition && +- strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) +- { +- const char *filename = g_mime_part_get_filename (GMIME_PART (part)); ++ if (g_mime_content_type_is_type (content_type, "application", "pgp-encrypted") || ++ g_mime_content_type_is_type (content_type, "application", "pgp-signature")) { ++ /* Ignore PGP/MIME cruft parts */ ++ } else if (g_mime_content_type_is_type (content_type, "text", "*") && ++ !g_mime_content_type_is_type (content_type, "text", "html")) { ++ GMimeStream *stream_stdout = g_mime_stream_file_new (stdout); ++ g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE); ++ show_text_part_content (node->part, stream_stdout, NOTMUCH_SHOW_TEXT_PART_REPLY); ++ g_object_unref(stream_stdout); ++ } else if (disposition && ++ strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) { ++ const char *filename = g_mime_part_get_filename (GMIME_PART (node->part)); + printf ("Attachment: %s (%s)\n", filename, + g_mime_content_type_to_string (content_type)); +- } +- else +- { ++ } else { + printf ("Non-text part: %s\n", + g_mime_content_type_to_string (content_type)); + } + } ++ ++ for (i = 0; i < node->nchildren; i++) ++ format_part_reply (mime_node_child (node, i)); + } + + /* Is the given address configured as one of the user's "personal" or +@@ -550,7 +517,7 @@ notmuch_reply_format_default(void *ctx, + GMimeMessage *reply; + notmuch_messages_t *messages; + notmuch_message_t *message; +- const notmuch_show_format_t *format = &format_reply; ++ mime_node_t *root; + + for (messages = notmuch_query_search_messages (query); + notmuch_messages_valid (messages); +@@ -577,7 +544,11 @@ notmuch_reply_format_default(void *ctx, + notmuch_message_get_header (message, "date"), + notmuch_message_get_header (message, "from")); + +- show_message_body (message, format, params); ++ if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt, ++ &root) == NOTMUCH_STATUS_SUCCESS) { ++ format_part_reply (mime_node_child (root, 0)); ++ talloc_free (root); ++ } + + notmuch_message_destroy (message); + } +-- +1.7.7.3 + -- 2.26.2