diff options
author | Radoslaw Jablonski <ext-jablonski.radoslaw@nokia.com> | 2010-07-09 17:34:30 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-07-11 12:10:48 -0300 |
commit | 3f2e1a27e97c5c98523b1e3e009fe5fc314f1740 (patch) | |
tree | d5a16d7583aa7a963d92e926bf2cac3c0efece9a | |
parent | afc9b2f0c8634c8a78c433e266bcd3c920b1e435 (diff) | |
download | obexd-3f2e1a27e97c5c98523b1e3e009fe5fc314f1740.tar.gz |
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).
-rw-r--r-- | plugins/vcard.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/vcard.c b/plugins/vcard.c index 5948a4a..9beb62a 100644 --- a/plugins/vcard.c +++ b/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); |