From 51a41db621693114f5ee60d48e7e6442fc85fcc4 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 15 Jul 2010 17:20:16 +0100 Subject: Add nag popup when mailing list hijacks private reply with Reply-To: header --- mail/e-mail-reader.c | 43 +++++++++++++++++++++++++++++++++++- mail/em-composer-utils.c | 29 ++++++++++++++++++++++++ mail/em-composer-utils.h | 3 ++- mail/evolution-mail.schemas.in | 12 ++++++++++ mail/mail-config.ui | 15 +++++++++++++ mail/mail.error.xml | 8 +++++++ modules/mail/e-mail-shell-settings.c | 4 ++++ modules/mail/em-composer-prefs.c | 5 +++++ 8 files changed, 117 insertions(+), 2 deletions(-) diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 9a6d5cb3ea..3548bfa962 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -980,6 +980,46 @@ action_mail_reply_sender_check(CamelFolder *folder, const gchar *uid, CamelMimeM mode = REPLY_MODE_LIST; else if (response == GTK_RESPONSE_CANCEL) return; + } else if (gconf_client_get_bool(gconf, "/apps/evolution/mail/prompts/list_reply_to", NULL)) { + GtkDialog *dialog; + GtkWidget *content_area, *vbox, *check_again, *check_always_ignore; + gint response; + + dialog = (GtkDialog*) e_alert_dialog_new_for_args (e_mail_reader_get_window (reader), + "mail:ask-list-honour-reply-to", NULL); + + /*Check buttons*/ + vbox = gtk_vbox_new (FALSE, 0); + content_area = gtk_dialog_get_content_area (dialog); + gtk_container_set_border_width((GtkContainer *)vbox, 12); + gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0); + gtk_widget_show (vbox); + + check_again = gtk_check_button_new_with_mnemonic (_("_Do not ask me again.")); + gtk_box_pack_start (GTK_BOX (vbox), check_again, TRUE, TRUE, 0); + gtk_widget_show (check_again); + + check_always_ignore = gtk_check_button_new_with_mnemonic (_("_Always ignore Reply-To: for mailing lists.")); + gtk_box_pack_start (GTK_BOX (vbox), check_always_ignore, TRUE, TRUE, 0); + gtk_widget_show (check_always_ignore); + + response = gtk_dialog_run ((GtkDialog *) dialog); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_again))) + gconf_client_set_bool(gconf, "/apps/evolution/mail/prompts/list_reply_to", FALSE, NULL); + + gconf_client_set_bool(gconf, "/apps/evolution/mail/composer/ignore_list_reply_to", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_always_ignore)), + NULL); + + gtk_widget_destroy((GtkWidget *)dialog); + + if (response == GTK_RESPONSE_NO) + mode = REPLY_MODE_FROM; + else if (response == GTK_RESPONSE_OK) + mode = REPLY_MODE_LIST; + else if (response == GTK_RESPONSE_CANCEL) + return; } e_mail_reader_reply_to_message (reader, message, mode); @@ -992,7 +1032,8 @@ action_mail_reply_sender_cb (GtkAction *action, GConfClient *gconf; gconf = mail_config_get_gconf_client (); - if (gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/private_list_reply", NULL) && + if ((gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/private_list_reply", NULL) || + gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/list_reply_to", NULL)) && e_mail_reader_check_state(reader) & E_MAIL_READER_SELECTION_IS_MAILING_LIST) { CamelMimeMessage *message = NULL; EWebView *web_view; diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 4bc91c65a0..d01a421013 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1860,6 +1860,29 @@ em_utils_get_reply_sender (CamelMimeMessage *message, CamelInternetAddress *to, get_reply_sender (message, to, postto); } +static void +get_reply_from (CamelMimeMessage *message, CamelInternetAddress *to, CamelNNTPAddress *postto) +{ + CamelInternetAddress *from; + const gchar *name, *addr, *posthdr; + gint i; + + /* check whether there is a 'Newsgroups: ' header in there */ + if (postto + && ((posthdr = camel_medium_get_header((CamelMedium *)message, "Followup-To")) + || (posthdr = camel_medium_get_header((CamelMedium *)message, "Newsgroups")))) { + camel_address_decode((CamelAddress *)postto, posthdr); + return; + } + + from = camel_mime_message_get_from (message); + + if (from) { + for (i = 0; camel_internet_address_get (from, i, &name, &addr); i++) + camel_internet_address_add (to, name, addr); + } +} + static void concat_unique_addrs (CamelInternetAddress *dest, CamelInternetAddress *src, GHashTable *rcpt_hash) { @@ -2274,6 +2297,12 @@ em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessag flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN; switch (mode) { + case REPLY_MODE_FROM: + if (folder) + postto = camel_nntp_address_new(); + + get_reply_from (message, to, postto); + break; case REPLY_MODE_SENDER: if (folder) postto = camel_nntp_address_new(); diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index a1d2da374d..eaa46d9d20 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -53,7 +53,8 @@ void em_utils_handle_receipt (CamelFolder *folder, const gchar *uid, CamelMimeMe void em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message); enum { - REPLY_MODE_SENDER, + REPLY_MODE_SENDER, /* Reply-To?:From */ + REPLY_MODE_FROM, REPLY_MODE_ALL, REPLY_MODE_LIST }; diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index de4f4daa8f..2cc0fb06e4 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -1105,6 +1105,18 @@ + + /schemas/apps/evolution/mail/prompts/list_reply_to + /apps/evolution/mail/prompts/list_reply_to + evolution-mail + bool + true + + Prompt when mailing list hijacks private replies + It disables/enables the repeated prompts to warn that you are trying sending a private reply to a message which arrived via a mailing list, but the list sets a Reply-To: header which redirects your reply back to the list + + + /schemas/apps/evolution/mail/prompts/reply_many_recips /apps/evolution/mail/prompts/reply_many_recips diff --git a/mail/mail-config.ui b/mail/mail-config.ui index 8603940dcd..2a4ce8b9e0 100644 --- a/mail/mail-config.ui +++ b/mail/mail-config.ui @@ -4861,6 +4861,21 @@ For example: "Work" or "Personal" 3 + + + Prompt when mailing list redirects private reply back to list + True + True + False + True + True + + + False + False + 4 + + diff --git a/mail/mail.error.xml b/mail/mail.error.xml index 962a5090a2..f376cfaec2 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -58,6 +58,14 @@ Many email systems add an Apparently-To header to messages that only have BCC re + + <_primary>Send private reply? <_secondary>You are replying to a message which arrived via a mailing list, but you are replying privately to the sender; not to the list. Are you sure you want to proceed? diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c index c17cc8744f..ca51acf72f 100644 --- a/modules/mail/e-mail-shell-settings.c +++ b/modules/mail/e-mail-shell-settings.c @@ -235,6 +235,10 @@ e_mail_shell_settings_init (EShell *shell) "composer-prompt-reply-many-recips", "/apps/evolution/mail/prompts/reply_many_recips"); + e_shell_settings_install_property_for_key ( + "composer-prompt-list-reply-to", + "/apps/evolution/mail/prompts/list_reply_to"); + e_shell_settings_install_property_for_key ( "composer-prompt-empty-subject", "/apps/evolution/mail/prompts/empty_subject"); diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 93620669a3..a975a3a92d 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -427,6 +427,11 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, shell_settings, "composer-prompt-reply-many-recips", widget, "active"); + widget = e_builder_get_widget (prefs->builder, "chkPromptListReplyTo"); + e_mutual_binding_new ( + shell_settings, "composer-prompt-list-reply-to", + widget, "active"); + widget = e_builder_get_widget (prefs->builder, "chkAutoSmileys"); e_mutual_binding_new ( shell_settings, "composer-magic-smileys", -- cgit v1.2.3