Remove undisclosed recipients only for creating new messages, not in simplifying
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 20 Jul 2009 11:07:35 +0000 (13:07 +0200)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 20 Jul 2009 11:10:11 +0000 (13:10 +0200)
src/modest-text-utils.c
src/modest-tny-msg.c

index be439ac..7598f04 100644 (file)
@@ -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, ">");
 
index 2da40e0..b7de9db 100644 (file)
@@ -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;