diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index ab874e5..2d94bc6 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
static struct phonebook_number *find_phone(GSList *numbers, const char *phone,
int type)
{
- GSList *l;
+ GSList *l = numbers;
struct phonebook_number *pb_num;
- for (l = numbers; l; l = l->next) {
+ if (g_slist_length(l) == 1 && (pb_num = l->data) &&
+ g_strcmp0(pb_num->tel, phone) == 0) {
+
+ if ((type == TEL_TYPE_HOME || type == TEL_TYPE_WORK) &&
+ pb_num->type == TEL_TYPE_OTHER) {
+ pb_num->type = type;
+ return pb_num;
+ }
+
+ if (type == TEL_TYPE_OTHER && (pb_num->type == TEL_TYPE_HOME ||
+ pb_num->type == TEL_TYPE_WORK))
+ return pb_num;
+ }
+
+ for (; l; l = l->next) {
pb_num = l->data;
/* Returning phonebook number if phone values and type values
* are equal */
diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c
index c720954..41f9fbd 100644
--- a/obexd/plugins/vcard.c
+++ b/obexd/plugins/vcard.c
static void vcard_printf_end(GString *vcards)
{
vcard_printf(vcards, "END:VCARD");
- vcard_printf(vcards, "");
}
void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,