Diff between 427d45b239cc3da611d26a2d3060d3495489856f and d51596d84c7c49e28595d8333389500b329fb959

Changed Files

File Additions Deletions Status
obexd/plugins/phonebook-tracker.c +8 -38 modified

Full Patch

diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index f41985b..8ffe198 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
@@ -1178,17 +1178,17 @@ static struct phonebook_contact *find_contact(GSList *contacts, const char *id)
 	return NULL;
 }
 
-static struct phonebook_field *find_phone(GSList *numbers, const char *phone,
+static struct phonebook_field *find_field(GSList *fields, const char *value,
 								int type)
 {
 	GSList *l;
 
-	for (l = numbers; l; l = l->next) {
-		struct phonebook_field *pb_num = l->data;
+	for (l = fields; l; l = l->next) {
+		struct phonebook_field *field = l->data;
 		/* Returning phonebook number if phone values and type values
 		 * are equal */
-		if (g_strcmp0(pb_num->text, phone) == 0 && pb_num->type == type)
-			return pb_num;
+		if (g_strcmp0(field->text, value) == 0 && field->type == type)
+			return field;
 	}
 
 	return NULL;
@@ -1203,7 +1203,7 @@ static void add_phone_number(struct phonebook_contact *contact,
 		return;
 
 	/* Not adding number if there is already added with the same value */
-	if (find_phone(contact->numbers, phone, type))
+	if (find_field(contact->numbers, phone, type))
 		return;
 
 	number = g_new0(struct phonebook_field, 1);
@@ -1213,21 +1213,6 @@ static void add_phone_number(struct phonebook_contact *contact,
 	contact->numbers = g_slist_append(contact->numbers, number);
 }
 
-static struct phonebook_field *find_email(GSList *emails, const char *address,
-								int type)
-{
-	GSList *l;
-
-	for (l = emails; l; l = l->next) {
-		struct phonebook_field *email = l->data;
-		if (g_strcmp0(email->text, address) == 0 &&
-						email->type == type)
-			return email;
-	}
-
-	return NULL;
-}
-
 static void add_email(struct phonebook_contact *contact, const char *address,
 								int type)
 {
@@ -1237,7 +1222,7 @@ static void add_email(struct phonebook_contact *contact, const char *address,
 		return;
 
 	/* Not adding email if there is already added with the same value */
-	if (find_email(contact->emails, address, type))
+	if (find_field(contact->emails, address, type))
 		return;
 
 	email = g_new0(struct phonebook_field, 1);
@@ -1247,21 +1232,6 @@ static void add_email(struct phonebook_contact *contact, const char *address,
 	contact->emails = g_slist_append(contact->emails, email);
 }
 
-static struct phonebook_field *find_address(GSList *addresses,
-					const char *address, int type)
-{
-	GSList *l;
-
-	for (l = addresses; l; l = l->next) {
-		struct phonebook_field *addr = l->data;
-		if (g_strcmp0(addr->text, address) == 0 &&
-						addr->type == type)
-			return addr;
-	}
-
-	return NULL;
-}
-
 static void add_address(struct phonebook_contact *contact,
 					const char *address, int type)
 {
@@ -1271,7 +1241,7 @@ static void add_address(struct phonebook_contact *contact,
 		return;
 
 	/* Not adding address if there is already added with the same value */
-	if (find_address(contact->addresses, address, type))
+	if (find_field(contact->addresses, address, type))
 		return;
 
 	addr = g_new0(struct phonebook_field, 1);