mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 05:15:40 +03:00
IconJob: Send request through the accounts NAS
This helps tracking requests on the server Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
parent
db337c4457
commit
3e368ee4df
4 changed files with 15 additions and 15 deletions
|
@ -113,7 +113,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
|
|||
a._icon = json.value("icon").toString();
|
||||
|
||||
if (!a._icon.isEmpty()) {
|
||||
auto *iconJob = new IconJob(QUrl(a._icon));
|
||||
auto *iconJob = new IconJob(_accountState->account(), QUrl(a._icon));
|
||||
iconJob->setProperty("activityId", a._id);
|
||||
connect(iconJob, &IconJob::jobFinished, this, &ServerNotificationHandler::slotIconDownloaded);
|
||||
}
|
||||
|
|
|
@ -16,22 +16,23 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
IconJob::IconJob(const QUrl &url, QObject *parent) :
|
||||
QObject(parent)
|
||||
IconJob::IconJob(AccountPtr account, const QUrl &url, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
connect(&_accessManager, &QNetworkAccessManager::finished,
|
||||
this, &IconJob::finished);
|
||||
|
||||
QNetworkRequest request(url);
|
||||
#if (QT_VERSION >= 0x050600)
|
||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
#endif
|
||||
_accessManager.get(request);
|
||||
const auto reply = account->sendRawRequest(QByteArrayLiteral("GET"), url, request);
|
||||
connect(reply, &QNetworkReply::finished, this, &IconJob::finished);
|
||||
}
|
||||
|
||||
void IconJob::finished(QNetworkReply *reply)
|
||||
void IconJob::finished()
|
||||
{
|
||||
reply->deleteLater();
|
||||
const auto reply = qobject_cast<QNetworkReply *>(sender());
|
||||
if (!reply) {
|
||||
return;
|
||||
}
|
||||
deleteLater();
|
||||
|
||||
const auto networkError = reply->error();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#ifndef ICONJOB_H
|
||||
#define ICONJOB_H
|
||||
|
||||
#include "account.h"
|
||||
#include "accountfwd.h"
|
||||
#include "owncloudlib.h"
|
||||
|
||||
#include <QObject>
|
||||
|
@ -33,17 +35,14 @@ class OWNCLOUDSYNC_EXPORT IconJob : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IconJob(const QUrl &url, QObject *parent = nullptr);
|
||||
explicit IconJob(AccountPtr account, const QUrl &url, QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void jobFinished(QByteArray iconData);
|
||||
void error(QNetworkReply::NetworkError errorType);
|
||||
|
||||
private slots:
|
||||
void finished(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager _accessManager;
|
||||
void finished();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ void OcsProfileConnector::loadHovercardActionIcon(const std::size_t hovercardAct
|
|||
void OcsProfileConnector::startFetchIconJob(const std::size_t hovercardActionIndex)
|
||||
{
|
||||
const auto hovercardAction = _currentHovercard._actions[hovercardActionIndex];
|
||||
const auto iconJob = new IconJob{hovercardAction._iconUrl, this};
|
||||
const auto iconJob = new IconJob{_account, hovercardAction._iconUrl, this};
|
||||
connect(iconJob, &IconJob::jobFinished,
|
||||
[this, hovercardActionIndex](QByteArray iconData) { loadHovercardActionIcon(hovercardActionIndex, iconData); });
|
||||
connect(iconJob, &IconJob::error, this, [](QNetworkReply::NetworkError errorType) {
|
||||
|
|
Loading…
Reference in a new issue