Commit 0dcb9e20 authored by mvogt's avatar mvogt

[libcontacts] Report unknown addresses immediately

When we are asked to resolve an address that was previously resolved
as unknown, report unknown immediately without querying the backend
again.
parent 50a5847d
......@@ -1406,8 +1406,16 @@ bool SeasideCache::event(QEvent *event)
return QObject::event(event);
// Test these conditions in priority order
if ((!m_relationshipsToSave.isEmpty() && !m_relationshipSaveRequest.isActive()) ||
(!m_relationshipsToRemove.isEmpty() && !m_relationshipRemoveRequest.isActive())) {
if (!m_unknownResolveAddresses.isEmpty()) {
while (!m_unknownResolveAddresses.isEmpty()) {
const ResolveData &resolve = m_unknownResolveAddresses.takeFirst();
resolve.listener->addressResolved(resolve.first, resolve.second, 0);
}
// Send another event to trigger further processing
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
} else if ((!m_relationshipsToSave.isEmpty() && !m_relationshipSaveRequest.isActive()) ||
(!m_relationshipsToRemove.isEmpty() && !m_relationshipRemoveRequest.isActive())) {
// this has to be before contact saves are processed so that the disaggregation flow
// works properly
if (!m_relationshipsToSave.isEmpty()) {
......@@ -2951,7 +2959,22 @@ void SeasideCache::resolveAddress(ResolveListener *listener, const QString &firs
data.requireComplete = requireComplete;
data.listener = listener;
m_resolveAddresses.append(data);
// Is this address a known-unknown?
bool knownUnknown = false;
QList<ResolveData>::const_iterator it = instancePtr->m_unknownAddresses.constBegin(), end = m_unknownAddresses.constEnd();
for ( ; it != end; ++it) {
if (it->first == first && it->second == second) {
knownUnknown = true;
break;
}
}
if (knownUnknown) {
m_unknownResolveAddresses.append(data);
} else {
m_resolveAddresses.append(data);
}
requestUpdate();
}
......
......@@ -510,6 +510,7 @@ private:
ResolveListener *listener;
};
QList<ResolveData> m_resolveAddresses;
QList<ResolveData> m_unknownResolveAddresses;
QList<ResolveData> m_unknownAddresses;
const ResolveData *m_activeResolve;
QSet<QString> m_resolvedPhoneNumbers;
......
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