[evolution-data-server/openismus-work-master: 8/8] Fixing e_book_backend_sexp_match_contact() for emails and phone numbers



commit c17ad800ed9d16adc2ed9da7f7c42af3336b2e9e
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Thu Nov 8 17:13:07 2012 +0900

    Fixing e_book_backend_sexp_match_contact() for emails and phone numbers
    
    This patch fixes the match function to match any phone number or email
    found in a given vcard, not only the restrictive list of phone number
    and email types defined in the EContactField enumeration.

 addressbook/libedata-book/e-book-backend-sexp.c |   33 ++++++++++++++--------
 1 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-sexp.c b/addressbook/libedata-book/e-book-backend-sexp.c
index 5f2c090..6e73917 100644
--- a/addressbook/libedata-book/e-book-backend-sexp.c
+++ b/addressbook/libedata-book/e-book-backend-sexp.c
@@ -61,8 +61,7 @@ compare_im (EContact *contact,
 		}
 	}
 
-	g_list_foreach (aims, (GFunc) g_free, NULL);
-	g_list_free (aims);
+	e_contact_attr_list_free (aims);
 
 	return found_it;
 }
@@ -154,16 +153,23 @@ compare_email (EContact *contact,
                gchar * (*compare) (const gchar *,
                                    const gchar *))
 {
-	gint i;
+	gboolean rv = FALSE;
+	GList *list, *l;
+
+	list = e_contact_get (contact, E_CONTACT_EMAIL);
 
-	for (i = E_CONTACT_EMAIL_1; i <= E_CONTACT_EMAIL_4; i++) {
-		const gchar *email = e_contact_get_const (contact, i);
+	for (l = list; l; l = l->next) {
+		const gchar *email = l->data;
 
-		if (email && compare (email, str))
-			return TRUE;
+		rv = email && compare (email, str);
+
+		if (rv)
+			break;
 	}
 
-	return FALSE;
+	e_contact_attr_list_free (list);
+
+	return rv;
 }
 
 static gboolean
@@ -172,19 +178,22 @@ compare_phone (EContact *contact,
                gchar * (*compare) (const gchar *,
                                    const gchar *))
 {
-	gint i;
+	GList *list, *l;
 	gboolean rv = FALSE;
 
-	for (i = E_CONTACT_FIRST_PHONE_ID; i <= E_CONTACT_LAST_PHONE_ID; i++) {
-		gchar *phone = e_contact_get (contact, i);
+	list = e_contact_get (contact, E_CONTACT_TEL);
+
+	for (l = list; l; l = l->next) {
+		gchar *phone = l->data;
 
 		rv = phone && compare (phone, str);
-		g_free (phone);
 
 		if (rv)
 			break;
 	}
 
+	e_contact_attr_list_free (list);
+
 	return rv;
 }
 



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