X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-show.c;h=c8f5a48f78312744505e4637683a1a5fdeab6377;hp=311ac6ac43cb71f442a8f9927bca4ff206ae24c5;hb=a1260896f6b2beb82f46c41663f00cb42a4c5ce7;hpb=c7b9bdb81e49321170dc6f0a522301f28e791521 diff --git a/notmuch-show.c b/notmuch-show.c index 311ac6ac..c8f5a48f 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -196,7 +196,7 @@ _is_from_line (const char *line) void format_headers_sprinter (sprinter_t *sp, GMimeMessage *message, - notmuch_bool_t reply) + bool reply) { /* Any changes to the JSON or S-Expression format should be * reflected in the file devel/schemata. */ @@ -283,7 +283,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out, return; stream_filter = g_mime_stream_filter_new (stream_out); - crlf_filter = g_mime_filter_crlf_new (FALSE, FALSE); + crlf_filter = g_mime_filter_crlf_new (false, false); g_mime_stream_filter_add(GMIME_STREAM_FILTER (stream_filter), crlf_filter); g_object_unref (crlf_filter); @@ -305,7 +305,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out, if (flags & NOTMUCH_SHOW_TEXT_PART_REPLY) { GMimeFilter *reply_filter; - reply_filter = g_mime_filter_reply_new (TRUE); + reply_filter = g_mime_filter_reply_new (true); if (reply_filter) { g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter), reply_filter); @@ -350,7 +350,7 @@ do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map, for (unsigned int i = 0; i < array_map_len; i++) { if (errors & key_map[i].bit) { sp->map_key (sp, key_map[i].string); - sp->boolean (sp, TRUE); + sp->boolean (sp, true); } } @@ -450,7 +450,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node) /* note that gmime is using the term "trust" here, which * is WRONG. It's actually user id "validity". */ if (certificate) { - const char *name = g_mime_certificate_get_name (certificate); + const char *name = g_mime_certificate_get_uid (certificate); GMimeCertificateTrust trust = g_mime_certificate_get_trust (certificate); if (name && (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE)) { sp->map_key (sp, "userid"); @@ -458,7 +458,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node) } } } else if (certificate) { - const char *key_id = g_mime_certificate_get_key_id (certificate); + const char *key_id = g_mime_certificate_get_fpr16 (certificate); if (key_id) { sp->map_key (sp, "keyid"); sp->string (sp, key_id); @@ -490,7 +490,7 @@ format_part_text (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 notmuch_bool_t leaf = GMIME_IS_PART (node->part); + const bool leaf = GMIME_IS_PART (node->part); GMimeStream *stream = params->out_stream; const char *part_type; int i; @@ -603,8 +603,8 @@ format_omitted_part_meta_sprinter (sprinter_t *sp, GMimeObject *meta, GMimePart void format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, - notmuch_bool_t first, notmuch_bool_t output_body, - notmuch_bool_t include_html) + bool output_body, + bool include_html) { /* Any changes to the JSON or S-Expression format should be * reflected in the file devel/schemata. */ @@ -614,12 +614,12 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, format_message_sprinter (sp, node->envelope_file); sp->map_key (sp, "headers"); - format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE); + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false); if (output_body) { sp->map_key (sp, "body"); sp->begin_list (sp); - format_part_sprinter (ctx, sp, mime_node_child (node, 0), first, TRUE, include_html); + format_part_sprinter (ctx, sp, mime_node_child (node, 0), true, include_html); sp->end (sp); } sp->end (sp); @@ -713,7 +713,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->begin_map (sp); sp->map_key (sp, "headers"); - format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE); + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false); sp->map_key (sp, "body"); sp->begin_list (sp); @@ -721,7 +721,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, } for (i = 0; i < node->nchildren; i++) - format_part_sprinter (ctx, sp, mime_node_child (node, i), i == 0, TRUE, include_html); + format_part_sprinter (ctx, sp, mime_node_child (node, i), true, include_html); /* Close content structures */ for (i = 0; i < nclose; i++) @@ -735,7 +735,7 @@ format_part_sprinter_entry (const void *ctx, sprinter_t *sp, mime_node_t *node, unused (int indent), const notmuch_show_params_t *params) { - format_part_sprinter (ctx, sp, node, TRUE, params->output_body, params->include_html); + format_part_sprinter (ctx, sp, node, params->output_body, params->include_html); return NOTMUCH_STATUS_SUCCESS; } @@ -898,8 +898,8 @@ show_messages (void *ctx, notmuch_show_params_t *params) { notmuch_message_t *message; - notmuch_bool_t match; - notmuch_bool_t excluded; + bool match; + bool excluded; int next_indent; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; @@ -1081,35 +1081,36 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) sprinter_t *sprinter; notmuch_show_params_t params = { .part = -1, - .omit_excluded = TRUE, - .output_body = TRUE, + .omit_excluded = true, + .output_body = true, + .crypto = { .decrypt = NOTMUCH_DECRYPT_AUTO }, }; int format = NOTMUCH_FORMAT_NOT_SPECIFIED; - int exclude = TRUE; - - /* This value corresponds to neither true nor false being passed - * on the command line */ - int entire_thread = -1; - notmuch_bool_t single_message; + bool exclude = true; + bool entire_thread_set = false; + bool single_message; + bool decrypt = false; + bool decrypt_set = false; notmuch_opt_desc_t options[] = { - { NOTMUCH_OPT_KEYWORD, &format, "format", 'f', + { .opt_keyword = &format, .name = "format", .keywords = (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, { "text", NOTMUCH_FORMAT_TEXT }, { "sexp", NOTMUCH_FORMAT_SEXP }, { "mbox", NOTMUCH_FORMAT_MBOX }, { "raw", NOTMUCH_FORMAT_RAW }, { 0, 0 } } }, - { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 }, - { NOTMUCH_OPT_BOOLEAN, &exclude, "exclude", 'x', 0 }, - { NOTMUCH_OPT_BOOLEAN, &entire_thread, "entire-thread", 't', 0 }, - { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 }, - { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, - { 0, 0, 0, 0, 0 } + { .opt_int = ¬much_format_version, .name = "format-version" }, + { .opt_bool = &exclude, .name = "exclude" }, + { .opt_bool = ¶ms.entire_thread, .name = "entire-thread", + .present = &entire_thread_set }, + { .opt_int = ¶ms.part, .name = "part" }, + { .opt_bool = &decrypt, .name = "decrypt", .present = &decrypt_set }, + { .opt_bool = ¶ms.crypto.verify, .name = "verify" }, + { .opt_bool = ¶ms.output_body, .name = "body" }, + { .opt_bool = ¶ms.include_html, .name = "include-html" }, + { .opt_inherit = notmuch_shared_options }, + { } }; opt_index = parse_arguments (argc, argv, options, 1); @@ -1118,9 +1119,15 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_process_shared_options (argv[0]); - /* decryption implies verification */ - if (params.crypto.decrypt) - params.crypto.verify = TRUE; + if (decrypt_set) { + if (decrypt) { + params.crypto.decrypt = NOTMUCH_DECRYPT_TRUE; + /* decryption implies verification */ + params.crypto.verify = true; + } else { + params.crypto.decrypt = NOTMUCH_DECRYPT_FALSE; + } + } /* specifying a part implies single message display */ single_message = params.part >= 0; @@ -1140,26 +1147,21 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) } } else if (format == NOTMUCH_FORMAT_RAW) { /* raw format only supports single message display */ - single_message = TRUE; + single_message = true; } notmuch_exit_if_unsupported_format (); - /* Default is entire-thread = FALSE except for format=json and + /* Default is entire-thread = false except for format=json and * format=sexp. */ - if (entire_thread != FALSE && entire_thread != TRUE) { - if (format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP) - params.entire_thread = TRUE; - else - params.entire_thread = FALSE; - } else { - params.entire_thread = entire_thread; - } + if (! entire_thread_set && + (format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP)) + params.entire_thread = true; if (!params.output_body) { if (params.part > 0) { fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n"); - params.output_body = TRUE; + params.output_body = true; } else { if (format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP) fprintf (stderr, @@ -1183,7 +1185,9 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) return EXIT_FAILURE; } +#if (GMIME_MAJOR_VERSION < 3) params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config); +#endif if (notmuch_database_open (notmuch_config_get_database_path (config), NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) @@ -1227,9 +1231,9 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) } } - if (exclude == FALSE) { - notmuch_query_set_omit_excluded (query, FALSE); - params.omit_excluded = FALSE; + if (exclude == false) { + notmuch_query_set_omit_excluded (query, false); + params.omit_excluded = false; } ret = do_show (config, query, formatter, sprinter, ¶ms); @@ -1239,7 +1243,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) g_mime_stream_flush (params.out_stream); g_object_unref (params.out_stream); - notmuch_crypto_cleanup (¶ms.crypto); + _notmuch_crypto_cleanup (¶ms.crypto); notmuch_query_destroy (query); notmuch_database_destroy (notmuch);