[evolution] Warn on reply-to-all with too many recipients
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Warn on reply-to-all with too many recipients
- Date: Thu, 15 Jul 2010 15:51:41 +0000 (UTC)
commit 8b8fdabfa64d627ba3e13a77cbb104d463d29fb5
Author: David Woodhouse <David Woodhouse intel com>
Date: Wed Jul 14 00:41:57 2010 +0100
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 +++
modules/mail/e-mail-shell-settings.c | 4 ++
modules/mail/em-composer-prefs.c | 5 ++
8 files changed, 140 insertions(+), 7 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index f10702d..24655e7 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 72ad761..9f3a06b 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 17242d7..d9f49bf 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -822,17 +822,98 @@ action_mail_redirect_cb (GtkAction *action,
}
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 8956974..a8024a7 100644
--- a/mail/evolution-mail.schemas.in
+++ b/mail/evolution-mail.schemas.in
@@ -1067,6 +1067,21 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/evolution/mail/prompts/reply_many_recips</key>
+ <applyto>/apps/evolution/mail/prompts/reply_many_recips</applyto>
+ <owner>evolution-mail</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Prompt when replying to many recipients</short>
+ <long>
+ It disables/enables the repeated prompts to warn that you are
+ sending a reply to many people.
+ </long>
+ </locale>
+ </schema>
+
<!-- Trash settings -->
<schema>
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 3817d06..6c1f57b 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -4816,6 +4816,21 @@ For example: "Work" or "Personal"</property>
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="chkPromptReplyManyRecips">
+ <property name="label" translatable="yes">Prompt when sending replies to _many recipients</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index a9be483..962a509 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
<button response="GTK_RESPONSE_OK" _label="Reply to _List"></button>
</error>
+ <error id="ask-reply-many-recips" type="question" default="GTK_RESPONSE_CANCEL">
+ <_primary>Send reply to all recipients?</_primary>
+ <_secondary>You are replying to a message which was sent to many recipients. Are you sure you want to reply to ALL of them?</_secondary>
+ <button response="GTK_RESPONSE_YES" _label="Reply to _All"></button>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button response="GTK_RESPONSE_NO" _label="Reply _Privately"/>
+ </error>
+
<error id="send-no-recipients" type="warning">
<_primary>This message cannot be sent because you have not specified any recipients</_primary>
<_secondary xml:space="preserve">Please enter a valid email address in the To: field. You can search for email addresses by clicking on the To: button next to the entry box.</_secondary>
diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c
index d46972f..5c30ddf 100644
--- a/modules/mail/e-mail-shell-settings.c
+++ b/modules/mail/e-mail-shell-settings.c
@@ -224,6 +224,10 @@ e_mail_shell_settings_init (EShell *shell)
"/apps/evolution/mail/prompts/private_list_reply");
e_shell_settings_install_property_for_key (
+ "composer-prompt-reply-many-recips",
+ "/apps/evolution/mail/prompts/reply_many_recips");
+
+ 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 f2def6b..37da770 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -422,6 +422,11 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
shell_settings, "composer-prompt-private-list-reply",
widget, "active");
+ widget = e_builder_get_widget (prefs->builder, "chkPromptReplyManyRecips");
+ e_mutual_binding_new (
+ shell_settings, "composer-prompt-reply-many-recips",
+ widget, "active");
+
widget = e_builder_get_widget (prefs->builder, "chkAutoSmileys");
e_mutual_binding_new (
shell_settings, "composer-magic-smileys",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]