Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4afd8182 authored by Volker Krause's avatar Volker Krause

When using Gravatar as fallback, also check the cache

Reviewers: #kde_pim, mlaurent

Reviewed By: #kde_pim, mlaurent

Subscribers: mlaurent

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D7410
parent 1cc6e8e1
......@@ -114,16 +114,8 @@ void GravatarResolvUrlJob::start()
d->mCalculatedHash.clear();
const QUrl url = createUrl(d->mUseLibravatar);
Q_EMIT resolvUrl(url);
bool haveStoredPixmap = false;
const QPixmap pix = GravatarCache::self()->loadGravatarPixmap(d->mCalculatedHash, haveStoredPixmap);
if (haveStoredPixmap && !pix.isNull()) {
d->mPixmap = pix;
d->mHasGravatar = true;
Q_EMIT finished(this);
deleteLater();
} else {
if (!cacheLookup(d->mCalculatedHash))
startNetworkManager(url);
}
} else {
qCDebug(GRAVATAR_LOG) << "Gravatar can not start";
deleteLater();
......@@ -144,7 +136,8 @@ void GravatarResolvUrlJob::slotFinishLoadPixmap(QNetworkReply *reply)
d->mCalculatedHash.clear();
const QUrl url = createUrl(false);
Q_EMIT resolvUrl(url);
startNetworkManager(url);
if (!cacheLookup(d->mCalculatedHash))
startNetworkManager(url);
return;
}
reply->deleteLater();
......@@ -278,3 +271,17 @@ QUrl GravatarResolvUrlJob::createUrl(bool useLibravatar)
url.setQuery(query);
return url;
}
bool GravatarResolvUrlJob::cacheLookup(const QString &hash)
{
bool haveStoredPixmap = false;
const QPixmap pix = GravatarCache::self()->loadGravatarPixmap(hash, haveStoredPixmap);
if (haveStoredPixmap && !pix.isNull()) {
d->mPixmap = pix;
d->mHasGravatar = true;
Q_EMIT finished(this);
deleteLater();
return true;
}
return false;
}
......@@ -79,6 +79,7 @@ private:
void startNetworkManager(const QUrl &url);
QUrl createUrl(bool useLibravatar);
QString calculateHash(bool useLibravator);
bool cacheLookup(const QString &hash);
GravatarResolvUrlJobPrivate *const d;
};
}
......
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