[evolution] I#790 - Automatic contacts: Do not modify contacts with the same full name



commit 080c1a02b084fd3aa6886db9bccdca1968af6dcb
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 17 12:55:57 2020 +0100

    I#790 - Automatic contacts: Do not modify contacts with the same full name
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/790

 src/plugins/bbdb/bbdb.c | 65 +++++++++----------------------------------------
 1 file changed, 12 insertions(+), 53 deletions(-)
---
diff --git a/src/plugins/bbdb/bbdb.c b/src/plugins/bbdb/bbdb.c
index 3c08f19f26..1d12696c18 100644
--- a/src/plugins/bbdb/bbdb.c
+++ b/src/plugins/bbdb/bbdb.c
@@ -392,65 +392,24 @@ bbdb_do_it (EBookClient *client,
                        return;
                }
 
-               if (g_utf8_strchr (name, -1, '\"')) {
-                       GString *tmp = g_string_new (name);
-                       gchar *p;
-
-                       while (p = g_utf8_strchr (tmp->str, tmp->len, '\"'), p)
-                               g_string_erase (tmp, p - tmp->str, 1);
-
-                       g_free (temp_name);
-                       temp_name = g_string_free (tmp, FALSE);
-                       name = temp_name;
-               }
-
-               contacts = NULL;
-               /* If a contact exists with this name, add the email address to it. */
-               query_string = g_strdup_printf ("(is \"full_name\" \"%s\")", name);
-               status = e_book_client_get_contacts_sync (client_addressbook, query_string, &contacts, NULL, 
NULL);
-               g_free (query_string);
-               if (contacts != NULL || !status) {
-                       /* FIXME: If there's more than one contact with this
-                        * name, just give up; we're not smart enough for
-                        * this. */
-                       if (!status || contacts->next != NULL) {
-                               g_slist_free_full (contacts, g_object_unref);
-                               g_object_unref (client_addressbook);
-
-                               if (!status) {
-                                       aux_addressbooks = aux_addressbooks->next;
-                                       continue;
-                               }
-
-                               g_free (temp_name);
-                               g_list_free_full (addressbooks, g_object_unref);
-                               return;
-                       }
-
-                       contact = (EContact *) contacts->data;
-                       add_email_to_contact (contact, email);
+               g_object_unref (client_addressbook);
+               aux_addressbooks = aux_addressbooks->next;
+       }
 
-                       e_book_client_modify_contact_sync (
-                                       client_addressbook, contact, E_BOOK_OPERATION_FLAG_NONE, NULL, 
&error);
+       g_list_free_full (addressbooks, (GDestroyNotify) g_object_unref);
 
-                       if (error != NULL) {
-                               g_warning ("bbdb: Could not modify contact: %s\n", error->message);
-                               g_error_free (error);
-                       }
+       if (g_utf8_strchr (name, -1, '\"')) {
+               GString *tmp = g_string_new (name);
+               gchar *p;
 
-                       g_slist_free_full (contacts, (GDestroyNotify) g_object_unref);
-                       g_free (temp_name);
-                       g_list_free_full (addressbooks, (GDestroyNotify) g_object_unref);
-                       g_object_unref (client_addressbook);
-                       return;
-               }
+               while (p = g_utf8_strchr (tmp->str, tmp->len, '\"'), p)
+                       g_string_erase (tmp, p - tmp->str, 1);
 
-               g_object_unref(client_addressbook);
-               aux_addressbooks = aux_addressbooks->next;
+               g_free (temp_name);
+               temp_name = g_string_free (tmp, FALSE);
+               name = temp_name;
        }
 
-       g_list_free_full (addressbooks, (GDestroyNotify) g_object_unref);
-
        /* Otherwise, create a new contact. */
        contact = e_contact_new ();
        e_contact_set (contact, E_CONTACT_FULL_NAME, (gpointer) name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]