Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
[libcontacts] Update partial contact correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthewvogt committed Jan 9, 2014
1 parent 76227c6 commit 9c48a0d
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/seasidecache.cpp
Expand Up @@ -63,6 +63,7 @@
#include <QContactPhoneNumber>
#include <QContactGlobalPresence>
#include <QContactSyncTarget>
#include <QContactTimestamp>

#include <QVersitContactExporter>
#include <QVersitContactImporter>
Expand Down Expand Up @@ -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<QContactSyncTarget>() <<
detailType<QContactName>() <<
detailType<QContactDisplayLabel>() <<
detailType<QContactFavorite>() <<
detailType<QContactTimestamp>() <<
detailType<QContactGender>() <<
detailType<QContactStatusFlags>();

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<QContactNickname>();

Expand Down Expand Up @@ -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(&copy);
}
Expand Down

0 comments on commit 9c48a0d

Please sign in to comment.