diff options
author | Milan Crha <mcrha@redhat.com> | 2013-06-04 01:18:23 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-06-04 01:22:03 +0800 |
commit | 5b0e9e7791cc960408fb772e9a1ec05037b5719a (patch) | |
tree | d30f024f22fe83bf193beada7425736cffa7e39a /libemail-engine/e-mail-utils.c | |
parent | 853c7125c183cef4b72cf6904cc21114066a3117 (diff) | |
download | gsoc2013-evolution-5b0e9e7791cc960408fb772e9a1ec05037b5719a.tar.gz gsoc2013-evolution-5b0e9e7791cc960408fb772e9a1ec05037b5719a.tar.zst gsoc2013-evolution-5b0e9e7791cc960408fb772e9a1ec05037b5719a.zip |
Bug #250046 - Empty group address as recipient prevents message send
Empty group addresses were left as-is when sending an email directly,
not through Outbox, which could cause a send error through SMTP.
Expanding group addresses, or removing empty groups, from a list
or recipients before sending the message fixes the issue.
Diffstat (limited to 'libemail-engine/e-mail-utils.c')
-rw-r--r-- | libemail-engine/e-mail-utils.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c index 83f90fe4f8..b65fbc32dd 100644 --- a/libemail-engine/e-mail-utils.c +++ b/libemail-engine/e-mail-utils.c @@ -705,3 +705,44 @@ em_utils_is_local_delivery_mbox_file (CamelURL *url) !g_file_test (url->path, G_FILE_TEST_IS_DIR); } +/* Expands groups to individual addresses, or removes empty groups completely. + Usual email addresses are left untouched. +*/ +void +em_utils_expand_groups (CamelInternetAddress *addresses) +{ + gint ii, len; + const gchar *addr; + CamelAddress *addrs; + + g_return_if_fail (CAMEL_IS_INTERNET_ADDRESS (addresses)); + + addrs = CAMEL_ADDRESS (addresses); + len = camel_address_length (addrs); + for (ii = len - 1; ii >= 0; ii--) { + addr = NULL; + + if (!camel_internet_address_get (addresses, ii, NULL, &addr)) { + camel_address_remove (addrs, ii); + } else if (addr) { + gchar *encoded = camel_internet_address_encode_address (NULL, NULL, addr); + + if (encoded) { + CamelInternetAddress *iaddr = camel_internet_address_new (); + gint decoded; + + /* decode expands respective groups */ + decoded = camel_address_decode (CAMEL_ADDRESS (iaddr), encoded); + if (decoded <= 0 || decoded > 1) { + camel_address_remove (addrs, ii); + + if (decoded > 1) + camel_address_cat (addrs, CAMEL_ADDRESS (iaddr)); + } + + g_object_unref (iaddr); + g_free (encoded); + } + } + } +} |