X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-show.c;h=2dbf8704cee1df0abe172b0674f2cde553b26918;hp=43560256a7c41a674f44882b10762f55460724dc;hb=195361c8cd100005e6562f54ccab15cb98cb20fd;hpb=005c2f0df17de8afdf9f67b923d26f2358236171 diff --git a/notmuch-show.c b/notmuch-show.c index 43560256..2dbf8704 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -110,6 +110,17 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message) from, relative_date, tags); } +static const char *_get_disposition(GMimeObject *meta) +{ + GMimeContentDisposition *disposition; + + disposition = g_mime_object_get_content_disposition (meta); + if (!disposition) + return NULL; + + return g_mime_content_disposition_get_disposition (disposition); +} + /* Emit a sequence of key/value pairs for the metadata of message. * The caller should begin a map before calling this. */ static void @@ -133,7 +144,20 @@ format_message_sprinter (sprinter_t *sp, notmuch_message_t *message) sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED)); sp->map_key (sp, "filename"); - sp->string (sp, notmuch_message_get_filename (message)); + if (notmuch_format_version >= 3) { + notmuch_filenames_t *filenames; + + sp->begin_list (sp); + for (filenames = notmuch_message_get_filenames (message); + notmuch_filenames_valid (filenames); + notmuch_filenames_move_to_next (filenames)) { + sp->string (sp, notmuch_filenames_get (filenames)); + } + notmuch_filenames_destroy (filenames); + sp->end (sp); + } else { + sp->string (sp, notmuch_message_get_filename (message)); + } sp->map_key (sp, "timestamp"); date = notmuch_message_get_date (message); @@ -220,8 +244,9 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, * reflected in the file devel/schemata. */ InternetAddressList *recipients; - const char *recipients_string; + char *recipients_string; const char *reply_to_string; + char *date_string; sp->begin_map (sp); @@ -236,6 +261,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, if (recipients_string) { sp->map_key (sp, "To"); sp->string (sp, recipients_string); + g_free (recipients_string); } recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC); @@ -243,6 +269,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, if (recipients_string) { sp->map_key (sp, "Cc"); sp->string (sp, recipients_string); + g_free (recipients_string); } recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC); @@ -250,6 +277,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, if (recipients_string) { sp->map_key (sp, "Bcc"); sp->string (sp, recipients_string); + g_free (recipients_string); } reply_to_string = g_mime_message_get_reply_to (message); @@ -266,7 +294,9 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References")); } else { sp->map_key (sp, "Date"); - sp->string (sp, g_mime_message_get_date_as_string (message)); + date_string = g_mime_message_get_date_as_string (message); + sp->string (sp, date_string); + g_free (date_string); } sp->end (sp); @@ -450,13 +480,13 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0, notmuch_message_get_filename (message)); } else { - GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta); + const char *disposition = _get_disposition (meta); const char *cid = g_mime_object_get_content_id (meta); const char *filename = leaf ? g_mime_part_get_filename (GMIME_PART (node->part)) : NULL; if (disposition && - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) + strcasecmp (disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) part_type = "attachment"; else part_type = "part"; @@ -571,6 +601,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, GMimeObject *meta = node->envelope_part ? GMIME_OBJECT (node->envelope_part) : node->part; GMimeContentType *content_type = g_mime_object_get_content_type (meta); + const char *disposition = _get_disposition (meta); const char *cid = g_mime_object_get_content_id (meta); const char *filename = GMIME_IS_PART (node->part) ? g_mime_part_get_filename (GMIME_PART (node->part)) : NULL; @@ -600,6 +631,11 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->map_key (sp, "content-type"); sp->string (sp, g_mime_content_type_to_string (content_type)); + if (disposition) { + sp->map_key (sp, "content-disposition"); + sp->string (sp, disposition); + } + if (cid) { sp->map_key (sp, "content-id"); sp->string (sp, cid); @@ -895,13 +931,22 @@ do_show_single (void *ctx, { notmuch_messages_t *messages; notmuch_message_t *message; + notmuch_status_t status; + unsigned int count; - if (notmuch_query_count_messages (query) != 1) { - fprintf (stderr, "Error: search term did not match precisely one message.\n"); + status = notmuch_query_count_messages_st (query, &count); + if (print_status_query ("notmuch show", query, status)) + return 1; + + if (count != 1) { + fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count); return 1; } - messages = notmuch_query_search_messages (query); + status = notmuch_query_search_messages_st (query, &messages); + if (print_status_query ("notmuch show", query, status)) + return 1; + message = notmuch_messages_get (messages); if (message == NULL) { @@ -928,8 +973,8 @@ do_show (void *ctx, notmuch_messages_t *messages; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; - threads = notmuch_query_search_threads (query); - if (! threads) + status= notmuch_query_search_threads_st (query, &threads); + if (print_status_query ("notmuch show", query, status)) return 1; sp->begin_list (sp);