From 9c48a0dd672154bc3786af354a196ff3956db821 Mon Sep 17 00:00:00 2001 From: Matt Vogt Date: Wed, 8 Jan 2014 17:30:33 -0800 Subject: [PATCH] [libcontacts] Update partial contact correctly Using the nemomobile contacts engine, a partially fetched contact will always contain the detail types from the main contact table, even if they are not included in the detail mask. Therefore, they should not be copied from the existing cache item if already present. --- src/seasidecache.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/seasidecache.cpp b/src/seasidecache.cpp index a5908fa..edee2cc 100644 --- a/src/seasidecache.cpp +++ b/src/seasidecache.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -187,19 +188,29 @@ QContactFetchHint presenceFetchHint() return fetchHint; } -QContactFetchHint metadataFetchHint(quint32 fetchTypes = 0) +DetailList contactsTableDetails() { - QContactFetchHint fetchHint(basicFetchHint()); - - // Include all detail types which come from the main contacts table DetailList types; + + // These details are reported in every query types << detailType() << detailType() << detailType() << detailType() << + detailType() << detailType() << detailType(); + return types; +} + +QContactFetchHint metadataFetchHint(quint32 fetchTypes = 0) +{ + QContactFetchHint fetchHint(basicFetchHint()); + + // Include all detail types which come from the main contacts table + DetailList types(contactsTableDetails()); + // Include nickname, as some contacts have no other name types << detailType(); @@ -2206,7 +2217,13 @@ void updateDetailsFromCache(QContact &contact, SeasideCache::CacheItem *item, co { // Copy any existing detail types that are in the current record to the new instance foreach (const QContactDetail &existing, item->contact.details()) { - if (!queryDetailTypes.contains(detailType(existing))) { + const DetailTypeId existingType(detailType(existing)); + + static const DetailList contactsTableTypes(contactsTableDetails()); + + // The queried contact already contains any types in the contacts table, and those + // types explicitly fetched by the query + if (!queryDetailTypes.contains(existingType) && !contactsTableTypes.contains(existingType)) { QContactDetail copy(existing); contact.saveDetail(©); }