From 65e2e08584664fba9f265404a05f33246333582f Mon Sep 17 00:00:00 2001 From: Lukasz Pawlik Date: Fri, 29 Oct 2010 16:04:26 +0200 Subject: [PATCH] obexd: Fix handling nco affiliation fields Previously when contact record was divided into separate replies, phonebook-tracker would use first reply and merge only phone numbers, addresses and emails from next. Now it's merging all fields dependent on the nco:hasAffiliation as well. --- obexd/plugins/phonebook-tracker.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index 96290a496..284d68790 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1094,6 +1094,16 @@ fail: g_free(data); } +static void add_affiliation(char **field, const char *value) +{ + if (strlen(*field) > 0 || value == NULL || strlen(value) == 0) + return; + + g_free(*field); + + *field = g_strdup(value); +} + static void pull_contacts(char **reply, int num_fields, void *user_data) { struct phonebook_data *data = user_data; @@ -1196,6 +1206,13 @@ add_numbers: g_free(home_addr); g_free(work_addr); + /* Adding fields connected by nco:hasAffiliation - they may be in + * separate replies */ + add_affiliation(&contact->title, reply[33]); + add_affiliation(&contact->company, reply[22]); + add_affiliation(&contact->department, reply[23]); + add_affiliation(&contact->role, reply[24]); + DBG("contact %p", contact); /* Adding contacts data to wrapper struct - this data will be used to -- 2.47.3