2010-10-29 14:04:26

by Lukasz Pawlik

[permalink] [raw]
Subject: [PATCHv2] 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.
---
plugins/phonebook-tracker.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 96290a4..30be895 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -982,6 +982,15 @@ static void add_phone_number(struct phonebook_contact *contact,
contact->numbers = g_slist_append(contact->numbers, number);
}

+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 struct phonebook_email *find_email(GSList *emails, const char *address,
int type)
{
@@ -1196,6 +1205,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
--
1.7.0.4



2010-10-29 14:40:33

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCHv2] Fix handling nco affiliation fields

Hi Lukasz,

On Fri, Oct 29, 2010, Lukasz Pawlik wrote:
> 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.
> ---
> plugins/phonebook-tracker.c | 16 ++++++++++++++++
> 1 files changed, 16 insertions(+), 0 deletions(-)

Pushed upstream with a couple of minor tweaks.

Johan