diff options
author | Rafal Michalski <michalski.raf@gmail.com> | 2010-11-15 11:41:40 +0100 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-11-16 13:33:13 +0000 |
commit | d090a552e7eb3a8e892e811a3607b5b0e775fbe7 (patch) | |
tree | 28a69f07320277c9a433d3203b7fb552948a155f | |
parent | 68fb987d03b31d693caa9b1e3c62397e5d0be301 (diff) | |
download | obexd-d090a552e7eb3a8e892e811a3607b5b0e775fbe7.tar.gz |
Fix pull phonebook with non-zero offset parameter
For non-zero liststartoffset parameter, contacts which index was before
offset were indexed more than once (e.g. when contact had more than one
phone number or address etc.), so pulling was started earlier - before
offset index was reached. This patch fix this problem and each contact
is indexed only once.
-rw-r--r-- | plugins/phonebook-tracker.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c index 672d59f..4309e28 100644 --- a/plugins/phonebook-tracker.c +++ b/plugins/phonebook-tracker.c @@ -1361,6 +1361,7 @@ static void pull_contacts(char **reply, int num_fields, void *user_data) int last_index, i; gboolean cdata_present = FALSE; char *home_addr, *work_addr, *other_addr; + static char *temp_id = NULL; if (num_fields < 0) { data->cb(NULL, 0, num_fields, 0, data->user_data); @@ -1396,7 +1397,11 @@ static void pull_contacts(char **reply, int num_fields, void *user_data) TRACKER_DEFAULT_CONTACT_ME)) return; - data->index++; + if (g_strcmp0(temp_id, reply[CONTACTS_ID_COL])) { + data->index++; + g_free(temp_id); + temp_id = g_strdup(reply[CONTACTS_ID_COL]); + } last_index = params->liststartoffset + params->maxlistcount; @@ -1495,6 +1500,8 @@ done: fail: g_slist_free(data->contacts); g_free(data); + g_free(temp_id); + temp_id = NULL; } static void add_to_cache(char **reply, int num_fields, void *user_data) |