From 4276d74d2713f8b835bc7db8e0e9f92b7e10fdbc Mon Sep 17 00:00:00 2001 From: Sushma Rai Date: Wed, 28 Sep 2005 08:54:35 +0000 Subject: Not skipping the entries which have only e-mail id and not name. Fixes #303286. svn path=/trunk/; revision=30387 --- plugins/bbdb/ChangeLog | 6 ++++++ plugins/bbdb/bbdb.c | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/bbdb/ChangeLog b/plugins/bbdb/ChangeLog index 5def505a3e..b167ba281c 100644 --- a/plugins/bbdb/ChangeLog +++ b/plugins/bbdb/ChangeLog @@ -1,3 +1,9 @@ +2005-09-13 Sushma Rai + + * bbdb.c (bbdb_do_it): If the contact has only e-mail id and not name, + extract the name from e-mail id and add it to the address book. + Fixes #303286. + 2005-07-28 Vivek Jain * bbdb.c:(bbdb_handle_reply):check for NULL diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index 7ac34375f6..0021d81f21 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -156,24 +156,26 @@ bbdb_handle_reply (EPlugin *ep, EMEventTargetMessage *target) static void bbdb_do_it (EBook *book, const char *name, const char *email) { - char *query_string; + char *query_string, *delim, *temp_name = NULL; EBookQuery *query; GList *contacts, *l; EContact *contact; - gboolean status; GError *error = NULL; g_return_if_fail (book != NULL); - if (name == NULL || email == NULL) + if (email == NULL || !strcmp (email, "")) return; - if (! strcmp (name, "") || ! strcmp (email, "")) + if ((delim = strchr (email, '@')) == NULL) return; - if (strchr (email, '@') == NULL) - return; + /* don't miss the entry if the mail has only e-mail id and no name */ + if (name == NULL || ! strcmp (name, "")) { + temp_name = g_strndup (email, delim - email); + name = temp_name; + } /* If any contacts exists with this email address, don't do anything */ query_string = g_strdup_printf ("(contains \"email\" \"%s\")", email); @@ -187,7 +189,8 @@ bbdb_do_it (EBook *book, const char *name, const char *email) for (l = contacts; l != NULL; l = l->next) g_object_unref ((GObject *)l->data); g_list_free (contacts); - + g_free (temp_name); + return; } @@ -208,6 +211,7 @@ bbdb_do_it (EBook *book, const char *name, const char *email) for (l = contacts; l != NULL; l = l->next) g_object_unref ((GObject *)l->data); g_list_free (contacts); + g_free (temp_name); return; } @@ -222,6 +226,7 @@ bbdb_do_it (EBook *book, const char *name, const char *email) g_object_unref ((GObject *)l->data); g_list_free (contacts); + g_free (temp_name); return; } @@ -229,6 +234,7 @@ bbdb_do_it (EBook *book, const char *name, const char *email) contact = e_contact_new (); e_contact_set (contact, E_CONTACT_FULL_NAME, (gpointer) name); add_email_to_contact (contact, email); + g_free (temp_name); if (! e_book_add_contact (book, contact, &error)) { g_warning ("bbdb: Failed to add new contact: %s\n", error->message); -- cgit v1.2.3