From abcdcfeb537fa40b9925ec20a2e8159e76ae67ec Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 7 Jun 2010 20:23:08 -0300 Subject: [PATCH] obexd: Fix wrong assumption about name fields The only situation that we should put some content to the name fields is the phonebook listing case, where we should use the telephone number as name. In the content of the vCard in the case of the mandatory fields we add them, even if they are empty. --- obexd/plugins/phonebook-tracker.c | 13 +++++++++++-- obexd/plugins/vcard.c | 16 +++------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index e64a3f2b7..18c6fc5a6 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -558,12 +558,21 @@ static void add_to_cache(char **reply, int num_fields, void *user_data) { struct cache_data *cache = user_data; char *formatted; + int i; if (reply == NULL) goto done; - formatted = g_strdup_printf("%s;%s;%s;%s;%s", reply[1], reply[2], - reply[3], reply[4], reply[5]); + for (i = 1; i < 6; i++) + if (reply[i][0] != '\0') { + formatted = g_strdup_printf("%s;%s;%s;%s;%s", + reply[1], reply[2], reply[3], reply[4], + reply[5]); + break; + } + + if (i == 6) + formatted = g_strdup(reply[6]); /* The owner vCard must have the 0 handle */ if (strcmp(reply[0], TRACKER_DEFAULT_CONTACT_ME) == 0) diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index 4a128edb0..dc6e283d3 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -236,19 +236,6 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact, vcard_printf_begin(vcards, format); - if (filter & FILTER_FN) { - char* fullname; - if (contact->fullname == NULL || contact->fullname[0] == '\0') { - struct phonebook_number *number; - - number = contact->numbers->data; - fullname = number->tel; - } else - fullname = contact->fullname; - - vcard_printf_fullname(vcards, fullname); - } - if (filter & FILTER_TEL) { GSList *l; @@ -263,6 +250,9 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact, if (filter & FILTER_N) vcard_printf_name(vcards, contact); + if (filter & FILTER_FN) + vcard_printf_fullname(vcards, contact->fullname); + if (filter & FILTER_EMAIL) vcard_printf_email(vcards, contact->email); -- 2.47.3