* Fixes NB#86176, do not remove own address when selecting reply to all to a message...
authorSergio Villar Senin <svillar@igalia.com>
Wed, 2 Jul 2008 13:11:05 +0000 (13:11 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 2 Jul 2008 13:11:05 +0000 (13:11 +0000)
pmo-trunk-r4864

src/modest-text-utils.c

index 8deb5cc..ba1ac54 100644 (file)
@@ -360,17 +360,24 @@ modest_text_utils_remove_duplicate_addresses (const gchar *address_list)
        
        g_return_val_if_fail (address_list, NULL);
 
        
        g_return_val_if_fail (address_list, NULL);
 
-       table = g_hash_table_new (g_str_hash, g_str_equal);
+       table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
        addresses = modest_text_utils_split_addresses_list (address_list);
 
        cursor = addresses;
        while (cursor) {
                const gchar* address = (const gchar*)cursor->data;
 
        addresses = modest_text_utils_split_addresses_list (address_list);
 
        cursor = addresses;
        while (cursor) {
                const gchar* address = (const gchar*)cursor->data;
 
+               /* We need only the email to just compare it and not
+                  the full address which would make "a <a@a.com>"
+                  different from "a@a.com" */
+               const gchar *email = get_email_from_address (address);
+
                /* ignore the address if already seen */
                /* ignore the address if already seen */
-               if (g_hash_table_lookup (table, address) == 0) {
+               if (g_hash_table_lookup (table, email) == 0) {
                        gchar *tmp;
 
                        gchar *tmp;
 
+                       /* Include the full address and not only the
+                          email in the returned list */
                        if (!new_list) {
                                tmp = g_strdup (address);
                        } else {
                        if (!new_list) {
                                tmp = g_strdup (address);
                        } else {
@@ -379,12 +386,12 @@ modest_text_utils_remove_duplicate_addresses (const gchar *address_list)
                        }
                        new_list = tmp;
                        
                        }
                        new_list = tmp;
                        
-                       g_hash_table_insert (table, (gchar*)address, GINT_TO_POINTER(1));
+                       g_hash_table_insert (table, (gchar*)email, GINT_TO_POINTER(1));
                }
                cursor = g_slist_next (cursor);
        }
 
                }
                cursor = g_slist_next (cursor);
        }
 
-       g_hash_table_destroy (table);
+       g_hash_table_unref (table);
        g_slist_foreach (addresses, (GFunc)g_free, NULL);
        g_slist_free (addresses);
 
        g_slist_foreach (addresses, (GFunc)g_free, NULL);
        g_slist_free (addresses);