aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-composer-utils.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-11-10 18:46:41 +0800
committerMilan Crha <mcrha@redhat.com>2009-11-10 18:46:41 +0800
commitb9953ceaed91acfcca24a54240ff51847526e6a8 (patch)
tree46b10672faa374ed0fb072e480d52a1032f2d2a0 /mail/em-composer-utils.c
parent5beeca1f80c3a618feeeb2c5b7e09cc47b64387d (diff)
downloadgsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.gz
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.bz2
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.lz
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.xz
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.tar.zst
gsoc2013-evolution-b9953ceaed91acfcca24a54240ff51847526e6a8.zip
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
Diffstat (limited to 'mail/em-composer-utils.c')
-rw-r--r--mail/em-composer-utils.c75
1 files changed, 69 insertions, 6 deletions
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 32c30fdb60..44ad930405 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))