diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 2fced7a..d72c04e 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
contact->datetime = iso8601_utc_to_localtime(datetime);
}
-static struct phonebook_contact *find_contact(GSList *contacts, const char *id)
+static gboolean contact_matches(struct contact_data *c_data, const char *id,
+ const char *datetime)
+{
+ char *localtime;
+ int cmp_ret;
+
+ if (g_strcmp0(c_data->id, id) != 0)
+ return FALSE;
+
+ /* id is equal and not call history entry => contact matches */
+ if (c_data->contact->calltype == CALL_TYPE_NOT_A_CALL)
+ return TRUE;
+
+ /* for call history entries have to compare also timestamps of calls */
+ localtime = iso8601_utc_to_localtime(datetime);
+ cmp_ret = g_strcmp0(c_data->contact->datetime, localtime);
+ g_free(localtime);
+
+ return (cmp_ret == 0) ? TRUE : FALSE;
+}
+
+static struct phonebook_contact *find_contact(GSList *contacts, const char *id,
+ const char *datetime)
{
GSList *l;
for (l = contacts; l; l = l->next) {
struct contact_data *c_data = l->data;
- if (g_strcmp0(c_data->id, id) == 0)
+
+ if (contact_matches(c_data, id, datetime))
return c_data->contact;
}
/* Trying to find contact in recently added contacts. It is needed for
* contacts that have more than one telephone number filled */
- contact = find_contact(data->contacts, reply[CONTACTS_ID_COL]);
+ contact = find_contact(data->contacts, reply[CONTACTS_ID_COL],
+ reply[COL_DATE]);
/* If contact is already created then adding only new phone numbers */
if (contact) {