aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-07-14 07:41:57 +0800
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-07-15 23:48:45 +0800
commit8b8fdabfa64d627ba3e13a77cbb104d463d29fb5 (patch)
tree10d4273116d1a73d507c896230f19e6c51ac6b84
parent0f7b73d6396ccc08c479c86759c0a3016a1aaf3e (diff)
downloadgsoc2013-evolution-8b8fdabfa64d627ba3e13a77cbb104d463d29fb5.tar.gz
gsoc2013-evolution-8b8fdabfa64d627ba3e13a77cbb104d463d29fb5.tar.zst
gsoc2013-evolution-8b8fdabfa64d627ba3e13a77cbb104d463d29fb5.zip
Warn on reply-to-all with too many recipients
-rw-r--r--mail/e-mail-reader-utils.c12
-rw-r--r--mail/e-mail-reader-utils.h1
-rw-r--r--mail/e-mail-reader.c87
-rw-r--r--mail/evolution-mail.schemas.in15
-rw-r--r--mail/mail-config.ui15
-rw-r--r--mail/mail.error.xml8
-rw-r--r--modules/mail/e-mail-shell-settings.c4
-rw-r--r--modules/mail/em-composer-prefs.c5
8 files changed, 140 insertions, 7 deletions
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
@@ -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 8956974393..a8024a7aec 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 3817d06792..6c1f57b080 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 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
<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 d46972ffd8..5c30ddf634 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 f2def6b123..37da770b14 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",