[evolution] Bug #250046 - Composer addresses reading fixes
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Bug #250046 - Composer addresses reading fixes
- Date: Tue, 10 Nov 2009 10:49:14 +0000 (UTC)
commit b9953ceaed91acfcca24a54240ff51847526e6a8
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 10 11:46:41 2009 +0100
Bug #250046 - Composer addresses reading fixes
- Check for no addresses properly (in post-to only when shown)
- Check for garbage addresses and warn user about those
- Use garbage text in To/CC/Bcc fields when user typed them
composer/e-msg-composer.c | 11 ++++--
mail/em-composer-utils.c | 75 +++++++++++++++++++++++++++++++++++++++++---
mail/mail.error.xml | 18 ++++++++++-
3 files changed, 93 insertions(+), 11 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index c10ef99..d079c52 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -418,7 +418,8 @@ set_recipients_from_destv (CamelMimeMessage *msg,
seen_hidden_list = TRUE;
}
- camel_address_decode (CAMEL_ADDRESS (target), text_addr);
+ if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0)
+ camel_internet_address_add (target, "", text_addr);
}
}
@@ -432,14 +433,16 @@ set_recipients_from_destv (CamelMimeMessage *msg,
seen_hidden_list = TRUE;
}
- camel_address_decode (CAMEL_ADDRESS (target), text_addr);
+ if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0)
+ camel_internet_address_add (target, "", text_addr);
}
}
for (i = 0; bcc_destv != NULL && bcc_destv[i] != NULL; ++i) {
text_addr = e_destination_get_address (bcc_destv[i]);
if (text_addr && *text_addr) {
- camel_address_decode (CAMEL_ADDRESS (bcc_addr), text_addr);
+ if (camel_address_decode (CAMEL_ADDRESS (bcc_addr), text_addr) <= 0)
+ camel_internet_address_add (bcc_addr, "", text_addr);
}
}
@@ -3967,7 +3970,7 @@ e_msg_composer_is_exiting (EMsgComposer *composer)
void
e_msg_composer_request_close (EMsgComposer *composer)
{
- g_return_val_if_fail (composer != NULL, FALSE);
+ g_return_if_fail (composer != NULL);
composer->priv->application_exiting = TRUE;
}
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 32c30fd..44ad930 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -279,6 +279,18 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag
g_free (send);
}
+static gboolean
+is_group_definition (const gchar *str)
+{
+ const gchar *colon;
+
+ if (!str || !*str)
+ return FALSE;
+
+ colon = strchr (str, ':');
+ return colon > str && strchr (str, ';') > colon;
+}
+
static CamelMimeMessage *
composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
{
@@ -292,10 +304,11 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
GConfClient *gconf;
EAccount *account;
gint i;
- GList *postlist;
EMEvent *eme;
EMEventTargetComposer *target;
EComposerHeaderTable *table;
+ EComposerHeader *post_to_header;
+ GString *invalid_addrs = NULL;
gconf = mail_config_get_gconf_client ();
table = e_msg_composer_get_header_table (composer);
@@ -315,8 +328,35 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
const gchar *addr = e_destination_get_address (recipients[i]);
if (addr && addr[0]) {
+ gint len, j;
+
camel_address_decode ((CamelAddress *) cia, addr);
- if (camel_address_length ((CamelAddress *) cia) > 0) {
+ len = camel_address_length ((CamelAddress *) cia);
+
+ if (len > 0) {
+ if (!e_destination_is_evolution_list (recipients[i])) {
+ for (j = 0; j < len; j++) {
+ const gchar *name = NULL, *eml = NULL;
+
+ if (!camel_internet_address_get (cia, j, &name, &eml) ||
+ !eml ||
+ strchr (eml, '@') <= eml) {
+ if (!invalid_addrs)
+ invalid_addrs = g_string_new ("");
+ else
+ g_string_append (invalid_addrs, ", ");
+
+ if (name)
+ g_string_append (invalid_addrs, name);
+ if (eml) {
+ g_string_append (invalid_addrs, name ? " <" : "");
+ g_string_append (invalid_addrs, eml);
+ g_string_append (invalid_addrs, name ? ">" : "");
+ }
+ }
+ }
+ }
+
camel_address_remove ((CamelAddress *) cia, -1);
num++;
if (e_destination_is_evolution_list (recipients[i])
@@ -325,6 +365,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
} else {
shown++;
}
+ } else if (is_group_definition (addr)) {
+ /* like an address, it will not claim on only-bcc */
+ shown++;
+ num++;
+ } else if (!invalid_addrs) {
+ invalid_addrs = g_string_new (addr);
+ } else {
+ g_string_append (invalid_addrs, ", ");
+ g_string_append (invalid_addrs, addr);
}
}
}
@@ -349,10 +398,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
camel_object_unref (cia);
- postlist = e_composer_header_table_get_post_to (table);
- num_post = g_list_length(postlist);
- g_list_foreach(postlist, (GFunc)g_free, NULL);
- g_list_free(postlist);
+ post_to_header = e_composer_header_table_get_header (table, E_COMPOSER_HEADER_POST_TO);
+ if (e_composer_header_get_visible (post_to_header)) {
+ GList *postlist;
+
+ postlist = e_composer_header_table_get_post_to (table);
+ num_post = g_list_length (postlist);
+ g_list_foreach (postlist, (GFunc)g_free, NULL);
+ g_list_free (postlist);
+ }
/* I'm sensing a lack of love, er, I mean recipients. */
if (num == 0 && num_post == 0) {
@@ -360,6 +414,15 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data)
goto finished;
}
+ if (invalid_addrs) {
+ if (e_error_run ((GtkWindow *)composer, strstr (invalid_addrs->str, ", ") ? "mail:ask-send-invalid-recip-multi" : "mail:ask-send-invalid-recip-one", invalid_addrs->str, NULL) == GTK_RESPONSE_CANCEL) {
+ g_string_free (invalid_addrs, TRUE);
+ goto finished;
+ }
+
+ g_string_free (invalid_addrs, TRUE);
+ }
+
if (num > 0 && (num == num_bcc || shown == 0)) {
/* this means that the only recipients are Bcc's */
if (!ask_confirm_for_only_bcc (composer, shown == 0))
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 62c8b53..6f7b62b 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -15,8 +15,8 @@
<_primary>Are you sure you want to send a message in HTML format?</_primary>
<_secondary xml:space="preserve">Please make sure the following recipients are willing and able to receive HTML email:
{0}</_secondary>
- <button _label="_Send" response="GTK_RESPONSE_YES"/>
<button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
</error>
<error id="ask-send-no-subject" type="question" default="GTK_RESPONSE_YES">
@@ -42,6 +42,22 @@ Many email systems add an Apparently-To header to messages that only have BCC re
<button _label="_Send" response="GTK_RESPONSE_YES"/>
</error>
+ <error id="ask-send-invalid-recip-one" type="question" default="GTK_RESPONSE_YES">
+ <_primary>Are you sure you want to send a message with invalid address?</_primary>
+ <_secondary xml:space="preserve">The following recipient was not recognized as a valid mail address:
+{0}</_secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
+ </error>
+
+ <error id="ask-send-invalid-recip-multi" type="question" default="GTK_RESPONSE_YES">
+ <_primary>Are you sure you want to send a message with invalid addresses?</_primary>
+ <_secondary xml:space="preserve">The following recipients were not recognized as valid mail addresses:
+{0}</_secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Send" response="GTK_RESPONSE_YES"/>
+ </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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]