show_reply_headers (GMimeStream *stream, GMimeMessage *message)
{
/* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */
show_reply_headers (GMimeStream *stream, GMimeMessage *message)
{
/* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */
- if (g_mime_object_write_to_stream (GMIME_OBJECT(message), stream) < 0) {
- INTERNAL_ERROR("failed to write headers to stdout\n");
+ if (g_mime_object_write_to_stream (GMIME_OBJECT (message), NULL, stream) < 0) {
+ INTERNAL_ERROR ("failed to write headers to stdout\n");
GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (node->part);
if (g_mime_content_type_is_type (content_type, "application", "pgp-encrypted") ||
GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (node->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 */
+ g_mime_content_type_is_type (content_type, "application", "pgp-signature") ||
+ g_mime_content_type_is_type (content_type, "application", "pkcs7-mime")) {
+ /* Ignore PGP/MIME and S/MIME cruft parts */
show_text_part_content (node->part, stream, NOTMUCH_SHOW_TEXT_PART_REPLY);
} else if (disposition &&
strcasecmp (g_mime_content_disposition_get_disposition (disposition),
GMIME_DISPOSITION_ATTACHMENT) == 0) {
const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));
g_mime_stream_printf (stream, "Attachment: %s (%s)\n", filename,
show_text_part_content (node->part, stream, NOTMUCH_SHOW_TEXT_PART_REPLY);
} else if (disposition &&
strcasecmp (g_mime_content_disposition_get_disposition (disposition),
GMIME_DISPOSITION_ATTACHMENT) == 0) {
const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));
g_mime_stream_printf (stream, "Attachment: %s (%s)\n", filename,
/* Match given string against user's configured "primary" and "other"
* addresses according to mode. */
static const char *
/* Match given string against user's configured "primary" and "other"
* addresses according to mode. */
static const char *
- other = notmuch_config_get_user_other_email (config, &other_len);
- for (i = 0; i < other_len; i++) {
- if (match_address (str, other[i], mode))
- return other[i];
- }
+ for (other = notmuch_config_get_values (notmuch, NOTMUCH_CONFIG_OTHER_EMAIL);
+ notmuch_config_values_valid (other);
+ notmuch_config_values_move_to_next (other)) {
+ const char *addr = notmuch_config_values_get (other);
* user's "primary" or "other" addresses. If so, return the matching
* address, NULL otherwise. */
static const char *
* user's "primary" or "other" addresses. If so, return the matching
* address, NULL otherwise. */
static const char *
}
/* Do any of the addresses configured as one of the user's "primary"
* or "other" addresses contain the given string. If so, return the
* matching address, NULL otherwise. */
static const char *
}
/* Do any of the addresses configured as one of the user's "primary"
* or "other" addresses contain the given string. If so, return the
* matching address, NULL otherwise. */
static const char *
- n += scan_address_list (group_list, config, message, type, user_from);
+ n += scan_address_list (group_list, notmuch, message, type, user_from);
- g_mime_message_add_recipient (message, type, name, addr);
+ g_mime_message_add_mailbox (message, type, name, addr);
{
InternetAddressList *reply_to_list;
reply_to_list = g_mime_message_get_reply_to_list (message);
if (reply_to_list &&
internet_address_list_length (reply_to_list) > 0) {
{
InternetAddressList *reply_to_list;
reply_to_list = g_mime_message_get_reply_to_list (message);
if (reply_to_list &&
internet_address_list_length (reply_to_list) > 0) {
* Some mailing lists munge the Reply-To header despite it
* being A Bad Thing, see
* http://marc.merlins.org/netrants/reply-to-harmful.html
* Some mailing lists munge the Reply-To header despite it
* being A Bad Thing, see
* http://marc.merlins.org/netrants/reply-to-harmful.html
- { get_sender, GMIME_ADDRESS_TYPE_TO },
- { get_to, GMIME_ADDRESS_TYPE_TO },
- { get_cc, GMIME_ADDRESS_TYPE_CC },
- { get_bcc, GMIME_ADDRESS_TYPE_BCC },
+ { get_sender, GMIME_ADDRESS_TYPE_TO },
+ { get_to, GMIME_ADDRESS_TYPE_TO },
+ { get_cc, GMIME_ADDRESS_TYPE_CC },
+ { get_bcc, GMIME_ADDRESS_TYPE_BCC },
- n += scan_address_list (recipients, config, reply,
+ n += scan_address_list (recipients, notmuch, reply,
- g_mime_message_add_recipient (reply, GMIME_ADDRESS_TYPE_TO, NULL, from_addr);
+ g_mime_message_add_mailbox (reply, GMIME_ADDRESS_TYPE_TO, NULL, from_addr);
* (last Received: header added) and try to extract from them
* indications to which email address this message was delivered.
*
* (last Received: header added) and try to extract from them
* indications to which email address this message was delivered.
*
for (i = 0; i < ARRAY_SIZE (to_headers); i++) {
tohdr = notmuch_message_get_header (message, to_headers[i]);
/* Note: tohdr potentially contains a list of email addresses. */
for (i = 0; i < ARRAY_SIZE (to_headers); i++) {
tohdr = notmuch_message_get_header (message, to_headers[i]);
/* Note: tohdr potentially contains a list of email addresses. */
-create_reply_message(void *ctx,
- notmuch_config_t *config,
- notmuch_message_t *message,
- GMimeMessage *mime_message,
- bool reply_all,
- bool limited)
+create_reply_message (void *ctx,
+ notmuch_message_t *message,
+ GMimeMessage *mime_message,
+ bool reply_all,
+ bool limited)
{
const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references;
{
const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references;
/*
* Use the below header order for limited headers, "pretty" order
* otherwise.
*/
GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);
/*
* Use the below header order for limited headers, "pretty" order
* otherwise.
*/
GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);
in_reply_to = talloc_asprintf (ctx, "<%s>",
notmuch_message_get_message_id (message));
in_reply_to = talloc_asprintf (ctx, "<%s>",
notmuch_message_get_message_id (message));
- g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to);
+ g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to, NULL);
orig_references = notmuch_message_get_header (message, "references");
if (orig_references && *orig_references)
orig_references = notmuch_message_get_header (message, "references");
if (orig_references && *orig_references)
- g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);
+ g_mime_object_set_header (GMIME_OBJECT (reply), "References", references, NULL);
mime_message, reply_all);
/* The above is all that is needed for limited headers. */
mime_message, reply_all);
/* The above is all that is needed for limited headers. */
- g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr);
+ g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr, NULL);
if (subject) {
if (strncasecmp (subject, "Re:", 3))
subject = talloc_asprintf (ctx, "Re: %s", subject);
if (subject) {
if (strncasecmp (subject, "Re:", 3))
subject = talloc_asprintf (ctx, "Re: %s", subject);
-static int do_reply(notmuch_config_t *config,
- notmuch_query_t *query,
- notmuch_show_params_t *params,
- int format,
- bool reply_all)
+static int
+do_reply (notmuch_database_t *notmuch,
+ notmuch_query_t *query,
+ notmuch_show_params_t *params,
+ int format,
+ bool reply_all)
- if (mime_node_open (config, message, ¶ms->crypto, &node))
+ if (mime_node_open (notmuch, message, ¶ms->crypto, &node))
- reply = create_reply_message (config, config, message,
+ reply = create_reply_message (notmuch, message,
GMIME_MESSAGE (node->part), reply_all,
format == FORMAT_HEADERS_ONLY);
GMIME_MESSAGE (node->part), reply_all,
format == FORMAT_HEADERS_ONLY);
/* The headers of the reply message we've created */
sp->map_key (sp, "reply-headers");
/* The headers of the reply message we've created */
sp->map_key (sp, "reply-headers");
- format_headers_sprinter (sp, reply, true);
+ /* FIXME: send msg_crypto here to avoid killing the
+ * subject line on reply to encrypted messages! */
+ format_headers_sprinter (sp, reply, true, NULL);
- format_part_sprinter (config, sp, node, true, false);
+ format_part_sprinter (notmuch, sp, node, true, false);
format_part_reply (stream_stdout, node);
}
g_mime_stream_flush (stream_stdout);
format_part_reply (stream_stdout, node);
}
g_mime_stream_flush (stream_stdout);
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
- (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
- { "json", FORMAT_JSON },
- { "sexp", FORMAT_SEXP },
- { "headers-only", FORMAT_HEADERS_ONLY },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
+ { "json", FORMAT_JSON },
+ { "sexp", FORMAT_SEXP },
+ { "headers-only", FORMAT_HEADERS_ONLY },
+ { 0, 0 } } },
{ .opt_int = ¬much_format_version, .name = "format-version" },
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords =
{ .opt_int = ¬much_format_version, .name = "format-version" },
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords =
- (notmuch_keyword_t []){ { "all", true },
- { "sender", false },
- { 0, 0 } } },
- { .opt_keyword = (int*)(¶ms.crypto.decrypt), .name = "decrypt",
+ (notmuch_keyword_t []){ { "all", true },
+ { "sender", false },
+ { 0, 0 } } },
+ { .opt_keyword = (int *) (¶ms.crypto.decrypt), .name = "decrypt",
- (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
- { "auto", NOTMUCH_DECRYPT_AUTO },
- { "true", NOTMUCH_DECRYPT_NOSTASH },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
+ { "auto", NOTMUCH_DECRYPT_AUTO },
+ { "true", NOTMUCH_DECRYPT_NOSTASH },
+ { 0, 0 } } },
if (query_string == NULL) {
fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE;
if (query_string == NULL) {
fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE;
- if (notmuch_database_open (notmuch_config_get_database_path (config),
- NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
+ status = notmuch_query_create_with_syntax (notmuch, query_string,
+ shared_option_query_syntax (),
+ &query);
+ if (print_status_database ("notmuch reply", notmuch, status))
- notmuch_exit_if_unmatched_db_uuid (notmuch);
-
- query = notmuch_query_create (notmuch, query_string);
- if (query == NULL) {
- fprintf (stderr, "Out of memory\n");
- return EXIT_FAILURE;
- }
-
- if (do_reply (config, query, ¶ms, format, reply_all) != 0)
+ if (do_reply (notmuch, query, ¶ms, format, reply_all) != 0)