From e2769fe7a2bfef7080c538f3f98f6fd5520f45ac Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Mon, 20 Jul 2009 13:07:35 +0200 Subject: [PATCH 1/1] Remove undisclosed recipients only for creating new messages, not in simplifying --- src/modest-text-utils.c | 3 --- src/modest-tny-msg.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index be439ac..7598f04 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -1939,9 +1939,6 @@ modest_text_utils_simplify_recipients (const gchar *recipients) const gchar *address = (const gchar *) node->data; gchar *left_limit, *right_limit; - if (address && strstr(address, "undisclosed-recipients")) - continue; - left_limit = strstr (address, "<"); right_limit = g_strrstr (address, ">"); diff --git a/src/modest-tny-msg.c b/src/modest-tny-msg.c index 2da40e0..b7de9db 100644 --- a/src/modest-tny-msg.c +++ b/src/modest-tny-msg.c @@ -920,6 +920,38 @@ count_addresses (const gchar* addresses) return count; } +static void +remove_undisclosed_recipients (gchar **recipients) +{ + GSList *addresses, *node; + gboolean is_first; + GString *result; + + g_return_if_fail (recipients); + addresses = modest_text_utils_split_addresses_list (*recipients); + + is_first = TRUE; + result = g_string_new (""); + for (node = addresses; node != NULL; node = g_slist_next (node)) { + const gchar *address = (const gchar *) node->data; + + if (address && strstr (address, "undisclosed-recipients")) + continue; + + if (is_first) + is_first = FALSE; + else + result = g_string_append (result, ", "); + + result = g_string_append (result, address); + } + g_slist_foreach (addresses, (GFunc)g_free, NULL); + g_slist_free (addresses); + + g_free (*recipients); + *recipients = g_string_free (result, FALSE); +} + /* get the new To:, based on the old header, * result is newly allocated or NULL in case of error @@ -996,6 +1028,7 @@ get_new_to (TnyMsg *msg, TnyHeader *header, const gchar* from, } tmp = modest_text_utils_simplify_recipients (new_to); + remove_undisclosed_recipients (&tmp); g_free (new_to); new_to = tmp; @@ -1035,6 +1068,7 @@ get_new_cc (TnyHeader *header, const gchar* from, const gchar *new_to) g_free (dup); dup = result; result = modest_text_utils_simplify_recipients (dup); + remove_undisclosed_recipients (&result); g_free (dup); g_free (old_cc); return result; -- 1.7.9.5