Fix for NB#58037. Not reply to all removes the user's address. To do it
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 11 Jun 2007 11:32:13 +0000 (11:32 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 11 Jun 2007 11:32:13 +0000 (11:32 +0000)
first it gets the address itself (the a@b.c part), and then it removes
all the Cc: addresses that match with this part:
* src/modest-text-utils.c:
        * Now remove_address takes into account the email address
          instead of the full address string.

pmo-trunk-r2149

src/modest-text-utils.c

index 973b19e..d1cc2f6 100644 (file)
@@ -105,6 +105,7 @@ static gchar*   modest_text_utils_quote_plain_text (const gchar *text,
 static gchar*   modest_text_utils_quote_html       (const gchar *text, 
                                                    const gchar *cite, 
                                                    int limit);
 static gchar*   modest_text_utils_quote_html       (const gchar *text, 
                                                    const gchar *cite, 
                                                    int limit);
+static gchar*   get_email_from_address (const gchar *address);
 
 
 /* ******************************************************************* */
 
 
 /* ******************************************************************* */
@@ -262,15 +263,20 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres
 {
        gchar *dup, *token, *ptr, *result;
        GString *filtered_emails;
 {
        gchar *dup, *token, *ptr, *result;
        GString *filtered_emails;
+       gchar *email_address;
 
        g_return_val_if_fail (address_list, NULL);
 
        if (!address)
                return g_strdup (address_list);
 
        g_return_val_if_fail (address_list, NULL);
 
        if (!address)
                return g_strdup (address_list);
+
+       email_address = get_email_from_address (address);
        
        /* search for substring */
        
        /* search for substring */
-       if (!strstr ((const char *) address_list, (const char *) address))
+       if (!strstr ((const char *) address_list, (const char *) email_address)) {
+               g_free (email_address);
                return g_strdup (address_list);
                return g_strdup (address_list);
+       }
 
        dup = g_strdup (address_list);
        filtered_emails = g_string_new (NULL);
 
        dup = g_strdup (address_list);
        filtered_emails = g_string_new (NULL);
@@ -279,7 +285,7 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres
 
        while (token != NULL) {
                /* Add to list if not found */
 
        while (token != NULL) {
                /* Add to list if not found */
-               if (!strstr ((const char *) token, (const char *) address)) {
+               if (!strstr ((const char *) token, (const char *) email_address)) {
                        if (filtered_emails->len == 0)
                                g_string_append_printf (filtered_emails, "%s", g_strstrip (token));
                        else
                        if (filtered_emails->len == 0)
                                g_string_append_printf (filtered_emails, "%s", g_strstrip (token));
                        else
@@ -290,6 +296,7 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres
        result = filtered_emails->str;
 
        /* Clean */
        result = filtered_emails->str;
 
        /* Clean */
+       g_free (email_address);
        g_free (dup);
        g_string_free (filtered_emails, FALSE);
 
        g_free (dup);
        g_string_free (filtered_emails, FALSE);
 
@@ -1129,3 +1136,17 @@ modest_text_utils_get_display_size (guint64 size)
        else
                return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), (float) size / GB); 
 }
        else
                return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), (float) size / GB); 
 }
+
+static gchar *
+get_email_from_address (const gchar * address)
+{
+       gchar *left_limit, *right_limit;
+
+       left_limit = strstr (address, "<");
+       right_limit = g_strrstr (address, ">");
+
+       if ((left_limit == NULL)||(right_limit == NULL)|| (left_limit > right_limit))
+               return g_strdup (address);
+       else
+               return g_strndup (left_limit + 1, (right_limit - left_limit) - 1);
+}