Commit b9d4941f authored by mvogt's avatar mvogt

[libcontacts] Do not resolve minimized numbers from cache

If we try to resolve a minimized number that we have not previously
queried matches for, then do not resolve to any contact that happens
to be in tha cache that matches that number - there may be a better
match that we should query for.

Once we have queried a specific number, or set the cache to fetch all
numbers, it is safe to resolve from the content of the cache.
parent 329e46b7
......@@ -849,7 +849,15 @@ SeasideCache::CacheItem *SeasideCache::itemByPhoneNumber(const QString &number,
return instancePtr->itemMatchingPhoneNumber(minimizePhoneNumber(normalized), normalized, requireComplete);
const QString minimized(minimizePhoneNumber(normalized));
if (((instancePtr->m_fetchTypes & SeasideCache::FetchPhoneNumber) == 0) &&
!instancePtr->m_resolvedPhoneNumbers.contains(minimized)) {
// We haven't previously queried this number, so there may be more matches than any
// that we already have cached; return 0 to force a query
return 0;
return instancePtr->itemMatchingPhoneNumber(minimized, normalized, requireComplete);
SeasideCache::CacheItem *SeasideCache::itemByEmailAddress(const QString &email, bool requireComplete)
......@@ -2309,6 +2317,11 @@ void SeasideCache::requestStateChanged(QContactAbstractRequest::State state)
} else {
// Result of a specific query
if (m_activeResolve) {
if (m_activeResolve->first == QString()) {
// We have now queried this phone number
CacheItem *item = 0;
const QList<QContact> &resolvedContacts(m_fetchRequest.contacts());
if (!resolvedContacts.isEmpty()) {
......@@ -2611,6 +2624,11 @@ void SeasideCache::keepPopulated(quint32 fetchTypes)
m_fetchTypes |= fetchTypes;
m_fetchTypesChanged = true;
if ((m_fetchTypes & SeasideCache::FetchPhoneNumber) != 0) {
// We don't need to check resolved numbers any further
if (!m_keepPopulated) {
......@@ -498,6 +498,7 @@ private:
QList<ResolveData> m_resolveAddresses;
QList<ResolveData> m_unknownAddresses;
const ResolveData *m_activeResolve;
QSet<QString> m_resolvedPhoneNumbers;
QElapsedTimer m_timer;
QElapsedTimer m_fetchPostponed;
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