More clenup
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
385babb458
commit
45c39d078f
@ -28,7 +28,6 @@ namespace Net {
|
|||||||
auto ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
|
auto ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<ApiDownload>();
|
auto dl = makeShared<ApiDownload>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("CACHE:") + url.toString());
|
dl->setObjectName(QString("CACHE:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
@ -41,7 +40,6 @@ auto ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> D
|
|||||||
auto ApiDownload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options) -> Download::Ptr
|
auto ApiDownload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<ApiDownload>();
|
auto dl = makeShared<ApiDownload>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("BYTES:") + url.toString());
|
dl->setObjectName(QString("BYTES:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
@ -52,7 +50,6 @@ auto ApiDownload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Op
|
|||||||
auto ApiDownload::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
|
auto ApiDownload::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<ApiDownload>();
|
auto dl = makeShared<ApiDownload>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("FILE:") + url.toString());
|
dl->setObjectName(QString("FILE:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
|
@ -28,7 +28,6 @@ namespace Net {
|
|||||||
Upload::Ptr ApiUpload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data)
|
Upload::Ptr ApiUpload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data)
|
||||||
{
|
{
|
||||||
auto up = makeShared<ApiUpload>();
|
auto up = makeShared<ApiUpload>();
|
||||||
up->logCat = taskUploadLogC;
|
|
||||||
up->m_url = std::move(url);
|
up->m_url = std::move(url);
|
||||||
up->m_sink.reset(new ByteArraySink(output));
|
up->m_sink.reset(new ByteArraySink(output));
|
||||||
up->m_post_data = std::move(m_post_data);
|
up->m_post_data = std::move(m_post_data);
|
||||||
|
@ -47,25 +47,14 @@
|
|||||||
#include "ChecksumValidator.h"
|
#include "ChecksumValidator.h"
|
||||||
#include "MetaCacheSink.h"
|
#include "MetaCacheSink.h"
|
||||||
|
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
|
||||||
#include "Application.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
|
|
||||||
#include "net/Logging.h"
|
|
||||||
#include "net/NetAction.h"
|
#include "net/NetAction.h"
|
||||||
|
|
||||||
#include "MMCTime.h"
|
|
||||||
#include "StringUtils.h"
|
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
|
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<Download>();
|
auto dl = makeShared<Download>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("CACHE:") + url.toString());
|
dl->setObjectName(QString("CACHE:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
@ -79,7 +68,6 @@ auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Down
|
|||||||
auto Download::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options) -> Download::Ptr
|
auto Download::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<Download>();
|
auto dl = makeShared<Download>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("BYTES:") + url.toString());
|
dl->setObjectName(QString("BYTES:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
@ -90,7 +78,6 @@ auto Download::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Optio
|
|||||||
auto Download::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
|
auto Download::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<Download>();
|
auto dl = makeShared<Download>();
|
||||||
dl->logCat = taskDownloadLogC;
|
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->setObjectName(QString("FILE:") + url.toString());
|
dl->setObjectName(QString("FILE:") + url.toString());
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
|
@ -38,12 +38,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include "HttpMetaCache.h"
|
#include "HttpMetaCache.h"
|
||||||
#include "NetAction.h"
|
|
||||||
#include "Sink.h"
|
|
||||||
#include "Validator.h"
|
|
||||||
|
|
||||||
#include "QObjectPtr.h"
|
#include "QObjectPtr.h"
|
||||||
#include "net/NetRequest.h"
|
#include "net/NetRequest.h"
|
||||||
@ -51,12 +46,9 @@
|
|||||||
namespace Net {
|
namespace Net {
|
||||||
class Download : public NetRequest {
|
class Download : public NetRequest {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<class Download>;
|
using Ptr = shared_qobject_ptr<class Download>;
|
||||||
|
explicit Download() : NetRequest() { logCat = taskDownloadLogC; };
|
||||||
public:
|
|
||||||
~Download() override = default;
|
|
||||||
|
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
@ -65,8 +57,6 @@ class Download : public NetRequest {
|
|||||||
static auto makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
|
|
||||||
void init() override{};
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QNetworkReply* getReply(QNetworkRequest&) override;
|
virtual QNetworkReply* getReply(QNetworkRequest&) override;
|
||||||
};
|
};
|
||||||
|
@ -43,17 +43,10 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "ByteArraySink.h"
|
|
||||||
#include "ChecksumValidator.h"
|
|
||||||
#include "MetaCacheSink.h"
|
|
||||||
|
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
|
|
||||||
#include "net/Logging.h"
|
|
||||||
#include "net/NetAction.h"
|
#include "net/NetAction.h"
|
||||||
|
|
||||||
#include "MMCTime.h"
|
#include "MMCTime.h"
|
||||||
@ -70,7 +63,7 @@ void NetRequest::executeTask()
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setStatus(tr("Downloading %1").arg(StringUtils::truncateUrlHumanFriendly(m_url, 80)));
|
setStatus(tr("Requesting %1").arg(StringUtils::truncateUrlHumanFriendly(m_url, 80)));
|
||||||
|
|
||||||
if (getState() == Task::State::AbortedByUser) {
|
if (getState() == Task::State::AbortedByUser) {
|
||||||
qCWarning(logCat) << getUid().toString() << "Attempt to start an aborted Request:" << m_url.toString();
|
qCWarning(logCat) << getUid().toString() << "Attempt to start an aborted Request:" << m_url.toString();
|
||||||
@ -314,9 +307,7 @@ void NetRequest::downloadReadyRead()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Net
|
auto NetRequest::abort() -> bool
|
||||||
|
|
||||||
auto Net::NetRequest::abort() -> bool
|
|
||||||
{
|
{
|
||||||
if (m_reply) {
|
if (m_reply) {
|
||||||
m_reply->abort();
|
m_reply->abort();
|
||||||
@ -325,3 +316,5 @@ auto Net::NetRequest::abort() -> bool
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Net
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
namespace Net {
|
namespace Net {
|
||||||
class NetRequest : public NetAction {
|
class NetRequest : public NetAction {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
explicit NetRequest() : NetAction(){};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<class NetRequest>;
|
using Ptr = shared_qobject_ptr<class NetRequest>;
|
||||||
|
@ -42,8 +42,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include "ByteArraySink.h"
|
#include "ByteArraySink.h"
|
||||||
|
|
||||||
#include "net/Logging.h"
|
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
QNetworkReply* Upload::getReply(QNetworkRequest& request)
|
QNetworkReply* Upload::getReply(QNetworkRequest& request)
|
||||||
@ -55,7 +53,6 @@ QNetworkReply* Upload::getReply(QNetworkRequest& request)
|
|||||||
Upload::Ptr Upload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data)
|
Upload::Ptr Upload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data)
|
||||||
{
|
{
|
||||||
auto up = makeShared<Upload>();
|
auto up = makeShared<Upload>();
|
||||||
up->logCat = taskUploadLogC;
|
|
||||||
up->m_url = std::move(url);
|
up->m_url = std::move(url);
|
||||||
up->m_sink.reset(new ByteArraySink(output));
|
up->m_sink.reset(new ByteArraySink(output));
|
||||||
up->m_post_data = std::move(m_post_data);
|
up->m_post_data = std::move(m_post_data);
|
||||||
|
@ -43,9 +43,9 @@ namespace Net {
|
|||||||
|
|
||||||
class Upload : public NetRequest {
|
class Upload : public NetRequest {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<Upload>;
|
using Ptr = shared_qobject_ptr<Upload>;
|
||||||
|
explicit Upload() : NetRequest() { logCat = taskUploadLogC; };
|
||||||
|
|
||||||
static Upload::Ptr makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data);
|
static Upload::Ptr makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user