From 88302aeafab56210ab24b0cdfdb16a63ad9fe123 Mon Sep 17 00:00:00 2001 From: Radoslaw Jablonski Date: Fri, 9 Jul 2010 17:34:30 +0300 Subject: [PATCH] obexd: Fix empty 'N:' parameter handling for vCards Bluetooth PBAP specification expects for call history listing that the parameter N: shall be empty when we cannot retrieve personal data from PSE phone book. Some devices (e.g. Nokia BH-903) have problems when unnecessary characters occur after N:. The list of dialed/incoming calls on the carkit becomes then useless since the carkit shows only blank lines and it's impossible to determine who made call. In previous version unnecessary semicolons were added after N:("N:;;;;") to represent empty name. Now if none of the contact fields is available, then adding real empty "N:" parameter (without semicolons). --- obexd/plugins/vcard.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index 5948a4a8f..9beb62a83 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -133,9 +133,43 @@ static void vcard_printf_begin(GString *vcards, uint8_t format) vcard_printf(vcards, "VERSION:2.1"); } +/* check if there is at least one contact field with personal data present */ +static gboolean contact_fields_present(struct phonebook_contact * contact) +{ + if (contact->family && strlen(contact->family) > 0) + return TRUE; + + if (contact->given && strlen(contact->given) > 0) + return TRUE; + + if (contact->additional && strlen(contact->additional) > 0) + return TRUE; + + if (contact->prefix && strlen(contact->prefix) > 0) + return TRUE; + + if (contact->suffix && strlen(contact->suffix) > 0) + return TRUE; + + /* none of the personal data fields are present*/ + return FALSE; +} + static void vcard_printf_name(GString *vcards, struct phonebook_contact *contact) { + if (contact_fields_present(contact) == FALSE) { + /* If fields are empty, add only 'N:' as parameter. + * This is crucial for some devices (Nokia BH-903) which + * have problems with history listings and can't determine + * that a parameter is really empty if there are unnecessary + * characters after 'N:' (e.g. 'N:;;;;'). + * We need to add only'N:' param - without semicolons. + */ + vcard_printf(vcards, "N:"); + return; + } + vcard_printf(vcards, "N:%s;%s;%s;%s;%s", contact->family, contact->given, contact->additional, contact->prefix, contact->suffix); -- 2.47.3