From 8b8fdabfa64d627ba3e13a77cbb104d463d29fb5 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 14 Jul 2010 00:41:57 +0100 Subject: Warn on reply-to-all with too many recipients --- mail/e-mail-reader-utils.c | 12 ++++-- mail/e-mail-reader-utils.h | 1 + mail/e-mail-reader.c | 87 ++++++++++++++++++++++++++++++++++++++++-- mail/evolution-mail.schemas.in | 15 ++++++++ mail/mail-config.ui | 15 ++++++++ mail/mail.error.xml | 8 ++++ 6 files changed, 131 insertions(+), 7 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index f10702ddd3..24655e72c7 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -353,13 +353,12 @@ html_contains_nonwhitespace (const gchar *html, } void -e_mail_reader_reply_to_message (EMailReader *reader, +e_mail_reader_reply_to_message (EMailReader *reader, CamelMimeMessage *src_message, gint reply_mode) { EMFormatHTML *formatter; GtkWidget *message_list; CamelMimeMessage *new_message; - CamelMimeMessage *src_message; CamelFolder *folder; EWebView *web_view; struct _camel_header_raw *header; @@ -382,6 +381,12 @@ e_mail_reader_reply_to_message (EMailReader *reader, uid = MESSAGE_LIST (message_list)->cursor_uid; g_return_if_fail (uid != NULL); + if (!gtk_widget_get_mapped (GTK_WIDGET(web_view))) + goto whole_message; + + if (!src_message) + src_message = CAMEL_MIME_MESSAGE (EM_FORMAT (formatter)->message); + if (!e_mail_reader_get_quote_from_selection (reader)) goto whole_message; @@ -395,7 +400,6 @@ e_mail_reader_reply_to_message (EMailReader *reader, if (!html_contains_nonwhitespace (selection, length)) goto whole_message; - src_message = CAMEL_MIME_MESSAGE (EM_FORMAT (formatter)->message); new_message = camel_mime_message_new (); /* Filter out "content-*" headers. */ @@ -426,7 +430,7 @@ e_mail_reader_reply_to_message (EMailReader *reader, whole_message: em_utils_reply_to_message ( - folder, uid, NULL, reply_mode, EM_FORMAT (formatter)); + folder, uid, src_message, reply_mode, EM_FORMAT (formatter)); } void diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h index 72ad761cc3..9f3a06bb81 100644 --- a/mail/e-mail-reader-utils.h +++ b/mail/e-mail-reader-utils.h @@ -48,6 +48,7 @@ guint e_mail_reader_open_selected (EMailReader *reader); void e_mail_reader_print (EMailReader *reader, GtkPrintOperationAction action); void e_mail_reader_reply_to_message (EMailReader *reader, + CamelMimeMessage *message, gint reply_mode); void e_mail_reader_select_next_message (EMailReader *reader, diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 17242d7725..d9f49bfee0 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -821,18 +821,99 @@ action_mail_redirect_cb (GtkAction *action, em_utils_redirect_message_by_uid (folder, uid); } +static void +action_mail_reply_all_check(CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, gpointer user_data) +{ + EMailReader *reader = user_data; + CamelInternetAddress *to, *cc; + gint recip_count = 0; + gint mode = REPLY_MODE_ALL; + + if (!message) + return; + + to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); + cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); + + recip_count = camel_address_length(CAMEL_ADDRESS(to)); + recip_count += camel_address_length(CAMEL_ADDRESS(cc)); + + if (recip_count >= 15) { + GConfClient *gconf = mail_config_get_gconf_client (); + GtkDialog *dialog; + GtkWidget *content_area, *check; + gint response; + + dialog = (GtkDialog*) e_alert_dialog_new_for_args (e_mail_reader_get_window (reader), + "mail:ask-reply-many-recips", NULL); + + /*Check buttons*/ + check = gtk_check_button_new_with_mnemonic (_("_Do not ask me again.")); + gtk_container_set_border_width((GtkContainer *)check, 12); + content_area = gtk_dialog_get_content_area (dialog); + gtk_box_pack_start (GTK_BOX (content_area), check, TRUE, TRUE, 0); + gtk_widget_show (check); + + response = gtk_dialog_run ((GtkDialog *) dialog); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) + gconf_client_set_bool(gconf, "/apps/evolution/mail/prompts/reply_many_recips", FALSE, NULL); + + gtk_widget_destroy((GtkWidget *)dialog); + + if (response == GTK_RESPONSE_NO) + mode = REPLY_MODE_SENDER; + else if (response == GTK_RESPONSE_CANCEL) + return; + } + + e_mail_reader_reply_to_message (reader, message, mode); +} + static void action_mail_reply_all_cb (GtkAction *action, EMailReader *reader) { - e_mail_reader_reply_to_message (reader, REPLY_MODE_ALL); + guint32 state = e_mail_reader_check_state (reader); + GConfClient *gconf = mail_config_get_gconf_client (); + + if (gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/reply_many_recips", NULL) && + !(state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) { + CamelMimeMessage *message = NULL; + EWebView *web_view; + EMFormatHTML *formatter; + + formatter = e_mail_reader_get_formatter (reader); + web_view = em_format_html_get_web_view (formatter); + if (gtk_widget_get_mapped (GTK_WIDGET(web_view))) + message = CAMEL_MIME_MESSAGE (EM_FORMAT (formatter)->message); + + if (!message) { + CamelFolder *folder; + GtkWidget *message_list; + gchar *uid; + + folder = e_mail_reader_get_folder (reader); + message_list = e_mail_reader_get_message_list (reader); + + uid = MESSAGE_LIST (message_list)->cursor_uid; + g_return_if_fail (uid != NULL); + + mail_get_message(folder, uid, action_mail_reply_all_check, reader, mail_msg_unordered_push); + return; + } + action_mail_reply_all_check(NULL, NULL, message, reader); + return; + } + + e_mail_reader_reply_to_message (reader, NULL, REPLY_MODE_ALL); } static void action_mail_reply_list_cb (GtkAction *action, EMailReader *reader) { - e_mail_reader_reply_to_message (reader, REPLY_MODE_LIST); + e_mail_reader_reply_to_message (reader, NULL, REPLY_MODE_LIST); } static void @@ -873,7 +954,7 @@ action_mail_reply_sender_cb (GtkAction *action, else if (response == GTK_RESPONSE_CANCEL) return; } - e_mail_reader_reply_to_message (reader, mode); + e_mail_reader_reply_to_message (reader, NULL, mode); } static void diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index 8956974393..a8024a7aec 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -1067,6 +1067,21 @@ + + /schemas/apps/evolution/mail/prompts/reply_many_recips + /apps/evolution/mail/prompts/reply_many_recips + evolution-mail + bool + true + + Prompt when replying to many recipients + + It disables/enables the repeated prompts to warn that you are + sending a reply to many people. + + + + diff --git a/mail/mail-config.ui b/mail/mail-config.ui index 3817d06792..6c1f57b080 100644 --- a/mail/mail-config.ui +++ b/mail/mail-config.ui @@ -4816,6 +4816,21 @@ For example: "Work" or "Personal" 2 + + + Prompt when sending replies to _many recipients + True + True + False + True + True + + + False + False + 3 + + diff --git a/mail/mail.error.xml b/mail/mail.error.xml index a9be483a99..962a5090a2 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -67,6 +67,14 @@ Many email systems add an Apparently-To header to messages that only have BCC re + + <_primary>Send reply to all recipients? + <_secondary>You are replying to a message which was sent to many recipients. Are you sure you want to reply to ALL of them? + +