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

Commit

Permalink
[libcontacts] Avoid requests with invalid IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Jul 19, 2013
1 parent 6999a3f commit cf4a80b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/seasidecache.cpp
Expand Up @@ -529,8 +529,11 @@ void SeasideCache::updateContactData(
models.at(i)->sourceDataChanged(row, row);
}

void SeasideCache::removeContact(const QContact &contact)
bool SeasideCache::removeContact(const QContact &contact)
{
if (!validId(contact.id()))
return false;

ContactIdType id = apiId(contact);

instancePtr->m_contactsToRemove.append(id);
Expand All @@ -539,6 +542,7 @@ void SeasideCache::removeContact(const QContact &contact)
instancePtr->removeContactData(id, FilterAll);

instancePtr->requestUpdate();
return true;
}

void SeasideCache::removeContactData(
Expand All @@ -558,24 +562,30 @@ void SeasideCache::removeContactData(
models.at(i)->sourceItemsRemoved();
}

void SeasideCache::fetchConstituents(const QContact &contact)
bool SeasideCache::fetchConstituents(const QContact &contact)
{
QContactId personId(contact.id());
if (!validId(personId))
return false;

if (!instancePtr->m_contactsToFetchConstituents.contains(personId)) {
instancePtr->m_contactsToFetchConstituents.append(personId);
instancePtr->requestUpdate();
}
return true;
}

void SeasideCache::fetchMergeCandidates(const QContact &contact)
bool SeasideCache::fetchMergeCandidates(const QContact &contact)
{
QContactId personId(contact.id());
if (!validId(personId))
return false;

if (!instancePtr->m_contactsToFetchCandidates.contains(personId)) {
instancePtr->m_contactsToFetchCandidates.append(personId);
instancePtr->requestUpdate();
}
return true;
}

const QVector<SeasideCache::ContactIdType> *SeasideCache::contacts(FilterType type)
Expand Down
6 changes: 3 additions & 3 deletions src/seasidecache.h
Expand Up @@ -203,13 +203,13 @@ class CONTACTCACHE_EXPORT SeasideCache : public QObject
static CacheItem *itemByPhoneNumber(const QString &msisdn);
static CacheItem *itemByEmailAddress(const QString &email);
static bool saveContact(const QContact &contact);
static void removeContact(const QContact &contact);
static bool removeContact(const QContact &contact);

static void aggregateContacts(const QContact &contact1, const QContact &contact2);
static void disaggregateContacts(const QContact &contact1, const QContact &contact2);

static void fetchConstituents(const QContact &contact);
static void fetchMergeCandidates(const QContact &contact);
static bool fetchConstituents(const QContact &contact);
static bool fetchMergeCandidates(const QContact &contact);

static int importContacts(const QString &path);
static QString exportContacts();
Expand Down

0 comments on commit cf4a80b

Please sign in to comment.