This commit is contained in:
fn2006
2023-02-05 22:11:58 +00:00
294 changed files with 8326 additions and 12400 deletions

View File

@@ -49,14 +49,9 @@
namespace Net {
Download::Download() : NetAction()
{
m_state = State::Inactive;
}
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
{
auto* dl = new Download();
auto dl = makeShared<Download>();
dl->m_url = url;
dl->m_options = options;
auto md5Node = new ChecksumValidator(QCryptographicHash::Md5);
@@ -67,7 +62,7 @@ auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Down
auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> Download::Ptr
{
auto* dl = new Download();
auto dl = makeShared<Download>();
dl->m_url = url;
dl->m_options = options;
dl->m_sink.reset(new ByteArraySink(output));
@@ -76,7 +71,7 @@ auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> D
auto Download::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
{
auto* dl = new Download();
auto dl = makeShared<Download>();
dl->m_url = url;
dl->m_options = options;
dl->m_sink.reset(new FileSink(path));

View File

@@ -52,9 +52,6 @@ class Download : public NetAction {
enum class Option { NoOptions = 0, AcceptLocalFiles = 1, MakeEternal = 2 };
Q_DECLARE_FLAGS(Options, Option)
protected:
explicit Download();
public:
~Download() override = default;

View File

@@ -36,6 +36,7 @@
#include "MetaCacheSink.h"
#include <QFile>
#include <QFileInfo>
#include <QRegularExpression>
#include "Application.h"
namespace Net {

View File

@@ -52,7 +52,6 @@ class NetAction : public Task {
virtual ~NetAction() = default;
QUrl url() { return m_url; }
auto index() -> int { return m_index_within_job; }
void setNetwork(shared_qobject_ptr<QNetworkAccessManager> network) { m_network = network; }
@@ -75,9 +74,6 @@ class NetAction : public Task {
public:
shared_qobject_ptr<QNetworkAccessManager> m_network;
/// index within the parent job, FIXME: nuke
int m_index_within_job = 0;
/// the network reply
unique_qobject_ptr<QNetworkReply> m_reply;

View File

@@ -38,11 +38,10 @@
auto NetJob::addNetAction(NetAction::Ptr action) -> bool
{
action->m_index_within_job = m_queue.size();
m_queue.append(action);
action->setNetwork(m_network);
addTask(action);
return true;
}

View File

@@ -41,9 +41,11 @@
#include <QDebug>
#include <QJsonObject>
#include <QHttpPart>
#include <QJsonArray>
#include <QJsonDocument>
#include <QFile>
#include <QUrlQuery>
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
{{"0x0.st", "https://0x0.st", ""},

View File

@@ -235,7 +235,7 @@ namespace Net {
}
Upload::Ptr Upload::makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data) {
auto* up = new Upload();
auto up = makeShared<Upload>();
up->m_url = std::move(url);
up->m_sink.reset(new ByteArraySink(output));
up->m_post_data = std::move(m_post_data);

View File

@@ -45,6 +45,8 @@ namespace Net {
Q_OBJECT
public:
using Ptr = shared_qobject_ptr<Upload>;
static Upload::Ptr makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data);
auto abort() -> bool override;
auto canAbort() const -> bool override { return true; };