Commit cf4a80b2 authored by mvogt's avatar mvogt

[libcontacts] Avoid requests with invalid IDs

parent 6999a3f6
......@@ -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);
......@@ -539,6 +542,7 @@ void SeasideCache::removeContact(const QContact &contact)
instancePtr->removeContactData(id, FilterAll);
instancePtr->requestUpdate();
return true;
}
void SeasideCache::removeContactData(
......@@ -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)
......
......@@ -203,13 +203,13 @@ public:
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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment