From 294bcbac434e16e91b43b1f6c9c7da5bb5d7030f Mon Sep 17 00:00:00 2001 From: Nat Friedman Date: Sat, 23 Oct 2004 08:21:26 +0000 Subject: Change assertions to if statements, so as not to issue warnings in the 2004-10-23 Nat Friedman * bbdb.c (bbdb_do_it): Change assertions to if statements, so as not to issue warnings in the case of routine failures (name is NULL). Don't add an email to a contact if the appropriate contact is ambiguous. svn path=/trunk/; revision=27703 --- plugins/bbdb/ChangeLog | 7 +++++++ plugins/bbdb/bbdb.c | 28 ++++++++++++++++++-------- plugins/bbdb/org-gnome-evolution-bbdb.eplug.in | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) (limited to 'plugins/bbdb') diff --git a/plugins/bbdb/ChangeLog b/plugins/bbdb/ChangeLog index 4f0f84b82d..d471940c29 100644 --- a/plugins/bbdb/ChangeLog +++ b/plugins/bbdb/ChangeLog @@ -1,3 +1,10 @@ +2004-10-23 Nat Friedman + + * bbdb.c (bbdb_do_it): Change assertions to if statements, so as + not to issue warnings in the case of routine failures (name + is NULL). Don't add an email to a contact if the appropriate + contact is ambiguous. + 2004-10-22 Nat Friedman * Initial checkin. diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index 87d728c231..bc1b2cc4fe 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -117,6 +117,7 @@ bbdb_handle_reply (EPlugin *ep, EMEventTargetMessage *target) bbdb_do_it (book, name, email); } + /* If this is a reply-all event, process To: and Cc: also. */ if (((EEventTarget *) target)->mask & EM_EVENT_MESSAGE_REPLY_ALL) { g_object_unref (G_OBJECT (book)); return; @@ -148,12 +149,16 @@ bbdb_do_it (EBook *book, const char *name, const char *email) gboolean status; GError *error = NULL; - g_return_if_fail (name != NULL); - g_return_if_fail (email != NULL); g_return_if_fail (book != NULL); - g_return_if_fail (strcmp (name, "")); - g_return_if_fail (strcmp (email, "")); - g_return_if_fail (strchr (email, '@') != NULL); + + if (name == NULL || email == NULL) + return; + + if (! strcmp (name, "") || ! strcmp (email, "")) + return; + + if (strchr (email, '@') == NULL) + return; /* If any contacts exists with this email address, don't do anything */ query_string = g_strdup_printf ("(contains \"email\" \"%s\")", email); @@ -161,10 +166,8 @@ bbdb_do_it (EBook *book, const char *name, const char *email) g_free (query_string); status = e_book_get_contacts (book, query, &contacts, NULL); - if (contacts != NULL) { - g_warning ("bbdb: contact exists, bailing\n"); + if (contacts != NULL) return; - } /* If a contact exists with this name, add the email address to it. */ query_string = g_strdup_printf ("(is \"full_name\" \"%s\")", name); @@ -173,6 +176,12 @@ bbdb_do_it (EBook *book, const char *name, const char *email) status = e_book_get_contacts (book, query, &contacts, NULL); if (contacts != NULL) { + + /* If there's more than one contact with this name, + just give up; we're not smart enough for this. */ + if (contacts->next != NULL) + return; + contact = (EContact *) contacts->data; add_email_to_contact (contact, email); if (! e_book_commit_contact (book, contact, &error)) @@ -326,3 +335,6 @@ cleanup_cb (GObject *o, gpointer data) g_object_unref (stuff->source_list); g_free (stuff); } + + + diff --git a/plugins/bbdb/org-gnome-evolution-bbdb.eplug.in b/plugins/bbdb/org-gnome-evolution-bbdb.eplug.in index b2b0b1cb63..a70abdfb13 100644 --- a/plugins/bbdb/org-gnome-evolution-bbdb.eplug.in +++ b/plugins/bbdb/org-gnome-evolution-bbdb.eplug.in @@ -17,4 +17,4 @@ - \ No newline at end of file + -- cgit v1.2.3