NOISSUE fix build and change how NetJob is used

Feed it network upfront...
This commit is contained in:
Petr Mrázek 2021-12-31 05:27:59 +01:00
parent 9cc168c526
commit 9579231ccc
31 changed files with 103 additions and 113 deletions

View File

@ -55,14 +55,14 @@ void InstanceImportTask::executeTask()
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path(); const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
auto entry = APPLICATION->metacache()->resolveEntry("general", path); auto entry = APPLICATION->metacache()->resolveEntry("general", path);
entry->setStale(true); entry->setStale(true);
m_filesNetJob.reset(new NetJob(tr("Modpack download"))); m_filesNetJob = new NetJob(tr("Modpack download"), APPLICATION->network());
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry)); m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
m_archivePath = entry->getFullPath(); m_archivePath = entry->getFullPath();
auto job = m_filesNetJob.get(); auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded); connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged); connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed); connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed);
m_filesNetJob->start(APPLICATION->network()); m_filesNetJob->start();
} }
} }
@ -337,7 +337,7 @@ void InstanceImportTask::processFlame()
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]() connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]()
{ {
auto results = m_modIdResolver->getResults(); auto results = m_modIdResolver->getResults();
m_filesNetJob.reset(new NetJob(tr("Mod download"))); m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
for(auto result: results.files) for(auto result: results.files)
{ {
QString filename = result.fileName; QString filename = result.fileName;
@ -391,7 +391,7 @@ void InstanceImportTask::processFlame()
setProgress(current, total); setProgress(current, total);
}); });
setStatus(tr("Downloading mods...")); setStatus(tr("Downloading mods..."));
m_filesNetJob->start(APPLICATION->network()); m_filesNetJob->start();
} }
); );
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason) connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason)

View File

@ -117,7 +117,7 @@ void Meta::BaseEntity::load(Net::Mode loadType)
{ {
return; return;
} }
m_updateTask = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename())); m_updateTask = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()), APPLICATION->network());
auto url = this->url(); auto url = this->url();
auto entry = APPLICATION->metacache()->resolveEntry("meta", localFilename()); auto entry = APPLICATION->metacache()->resolveEntry("meta", localFilename());
entry->setStale(true); entry->setStale(true);
@ -140,7 +140,7 @@ void Meta::BaseEntity::load(Net::Mode loadType)
m_updateStatus = UpdateStatus::Failed; m_updateStatus = UpdateStatus::Failed;
m_updateTask.reset(); m_updateTask.reset();
}); });
m_updateTask->start(APPLICATION->network()); m_updateTask->start();
} }
bool Meta::BaseEntity::isLoaded() const bool Meta::BaseEntity::isLoaded() const

View File

@ -29,6 +29,8 @@
#include "net/ChecksumValidator.h" #include "net/ChecksumValidator.h"
#include "BuildConfig.h" #include "BuildConfig.h"
#include "Application.h"
namespace { namespace {
QSet<QString> collectPathsFromDir(QString dirPath) QSet<QString> collectPathsFromDir(QString dirPath)
{ {
@ -318,7 +320,7 @@ QString AssetObject::getRelPath()
NetJob::Ptr AssetsIndex::getDownloadJob() NetJob::Ptr AssetsIndex::getDownloadJob()
{ {
auto job = new NetJob(QObject::tr("Assets for %1").arg(id)); auto job = new NetJob(QObject::tr("Assets for %1").arg(id), APPLICATION->network());
for (auto &object : objects.values()) for (auto &object : objects.values())
{ {
auto dl = object.getDownloadAction(); auto dl = object.getDownloadAction();

View File

@ -24,7 +24,10 @@ void AssetUpdateTask::executeTask()
auto assets = profile->getMinecraftAssets(); auto assets = profile->getMinecraftAssets();
QUrl indexUrl = assets->url; QUrl indexUrl = assets->url;
QString localPath = assets->id + ".json"; QString localPath = assets->id + ".json";
auto job = new NetJob(tr("Asset index for %1").arg(m_inst->name())); auto job = new NetJob(
tr("Asset index for %1").arg(m_inst->name()),
APPLICATION->network()
);
auto metacache = APPLICATION->metacache(); auto metacache = APPLICATION->metacache();
auto entry = metacache->resolveEntry("asset_indexes", localPath); auto entry = metacache->resolveEntry("asset_indexes", localPath);
@ -43,7 +46,7 @@ void AssetUpdateTask::executeTask()
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress); connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
qDebug() << m_inst->name() << ": Starting asset index download"; qDebug() << m_inst->name() << ": Starting asset index download";
downloadJob->start(APPLICATION->network()); downloadJob->start();
} }
bool AssetUpdateTask::canAbort() const bool AssetUpdateTask::canAbort() const
@ -78,7 +81,7 @@ void AssetUpdateTask::assetIndexFinished()
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded); connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed); connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress); connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
downloadJob->start(APPLICATION->network()); downloadJob->start();
return; return;
} }
emitSucceeded(); emitSucceeded();

View File

@ -61,7 +61,7 @@ void FMLLibrariesTask::executeTask()
// download missing libs to our place // download missing libs to our place
setStatus(tr("Downloading FML libraries...")); setStatus(tr("Downloading FML libraries..."));
auto dljob = new NetJob("FML libraries"); auto dljob = new NetJob("FML libraries", APPLICATION->network());
auto metacache = APPLICATION->metacache(); auto metacache = APPLICATION->metacache();
for (auto &lib : fmlLibsToProcess) for (auto &lib : fmlLibsToProcess)
{ {
@ -74,7 +74,7 @@ void FMLLibrariesTask::executeTask()
connect(dljob, &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed); connect(dljob, &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed);
connect(dljob, &NetJob::progress, this, &FMLLibrariesTask::progress); connect(dljob, &NetJob::progress, this, &FMLLibrariesTask::progress);
downloadJob.reset(dljob); downloadJob.reset(dljob);
downloadJob->start(APPLICATION->network()); downloadJob->start();
} }
bool FMLLibrariesTask::canAbort() const bool FMLLibrariesTask::canAbort() const

View File

@ -20,7 +20,7 @@ void LibrariesTask::executeTask()
auto components = inst->getPackProfile(); auto components = inst->getPackProfile();
auto profile = components->getProfile(); auto profile = components->getProfile();
auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name())); auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()), APPLICATION->network());
downloadJob.reset(job); downloadJob.reset(job);
auto metacache = APPLICATION->metacache(); auto metacache = APPLICATION->metacache();
@ -65,7 +65,7 @@ void LibrariesTask::executeTask()
connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded); connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed); connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress); connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
downloadJob->start(APPLICATION->network()); downloadJob->start();
} }
bool LibrariesTask::canAbort() const bool LibrariesTask::canAbort() const

View File

@ -58,12 +58,12 @@ bool PackInstallTask::abort()
void PackInstallTask::executeTask() void PackInstallTask::executeTask()
{ {
qDebug() << "PackInstallTask::executeTask: " << QThread::currentThreadId(); qDebug() << "PackInstallTask::executeTask: " << QThread::currentThreadId();
auto *netJob = new NetJob("ATLauncher::VersionFetch"); auto *netJob = new NetJob("ATLauncher::VersionFetch", APPLICATION->network());
auto searchUrl = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.json") auto searchUrl = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.json")
.arg(m_pack).arg(m_version_name); .arg(m_pack).arg(m_version_name);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
@ -424,7 +424,7 @@ void PackInstallTask::installConfigs()
{ {
qDebug() << "PackInstallTask::installConfigs: " << QThread::currentThreadId(); qDebug() << "PackInstallTask::installConfigs: " << QThread::currentThreadId();
setStatus(tr("Downloading configs...")); setStatus(tr("Downloading configs..."));
jobPtr.reset(new NetJob(tr("Config download"))); jobPtr = new NetJob(tr("Config download"), APPLICATION->network());
auto path = QString("Configs/%1/%2.zip").arg(m_pack).arg(m_version_name); auto path = QString("Configs/%1/%2.zip").arg(m_pack).arg(m_version_name);
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.zip") auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.zip")
@ -458,7 +458,7 @@ void PackInstallTask::installConfigs()
setProgress(current, total); setProgress(current, total);
}); });
jobPtr->start(APPLICATION->network()); jobPtr->start();
} }
void PackInstallTask::extractConfigs() void PackInstallTask::extractConfigs()
@ -508,7 +508,7 @@ void PackInstallTask::downloadMods()
setStatus(tr("Downloading mods...")); setStatus(tr("Downloading mods..."));
jarmods.clear(); jarmods.clear();
jobPtr.reset(new NetJob(tr("Mod download"))); jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
for(const auto& mod : m_version.mods) { for(const auto& mod : m_version.mods) {
// skip non-client mods // skip non-client mods
if(!mod.client) continue; if(!mod.client) continue;
@ -613,7 +613,7 @@ void PackInstallTask::downloadMods()
setProgress(current, total); setProgress(current, total);
}); });
jobPtr->start(APPLICATION->network()); jobPtr->start();
} }
void PackInstallTask::onModsDownloaded() { void PackInstallTask::onModsDownloaded() {

View File

@ -14,7 +14,7 @@ void Flame::FileResolvingTask::executeTask()
{ {
setStatus(tr("Resolving mod IDs...")); setStatus(tr("Resolving mod IDs..."));
setProgress(0, m_toProcess.files.size()); setProgress(0, m_toProcess.files.size());
m_dljob = new NetJob("Mod id resolver"); m_dljob = new NetJob("Mod id resolver", m_network);
results.resize(m_toProcess.files.size()); results.resize(m_toProcess.files.size());
int index = 0; int index = 0;
for(auto & file: m_toProcess.files) for(auto & file: m_toProcess.files)
@ -27,7 +27,7 @@ void Flame::FileResolvingTask::executeTask()
index ++; index ++;
} }
connect(m_dljob.get(), &NetJob::finished, this, &Flame::FileResolvingTask::netJobFinished); connect(m_dljob.get(), &NetJob::finished, this, &Flame::FileResolvingTask::netJobFinished);
m_dljob->start(m_network); m_dljob->start();
} }
void Flame::FileResolvingTask::netJobFinished() void Flame::FileResolvingTask::netJobFinished()

View File

@ -12,7 +12,7 @@ void PackFetchTask::fetch()
publicPacks.clear(); publicPacks.clear();
thirdPartyPacks.clear(); thirdPartyPacks.clear();
jobPtr = new NetJob("LegacyFTB::ModpackFetch"); jobPtr = new NetJob("LegacyFTB::ModpackFetch", m_network);
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml"); QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
qDebug() << "Downloading public version info from" << publicPacksUrl.toString(); qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
@ -25,7 +25,7 @@ void PackFetchTask::fetch()
QObject::connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished); QObject::connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
QObject::connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed); QObject::connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
jobPtr->start(m_network); jobPtr->start();
} }
void PackFetchTask::fetchPrivate(const QStringList & toFetch) void PackFetchTask::fetchPrivate(const QStringList & toFetch)
@ -35,7 +35,7 @@ void PackFetchTask::fetchPrivate(const QStringList & toFetch)
for (auto &packCode: toFetch) for (auto &packCode: toFetch)
{ {
QByteArray *data = new QByteArray(); QByteArray *data = new QByteArray();
NetJob *job = new NetJob("Fetching private pack"); NetJob *job = new NetJob("Fetching private pack", m_network);
job->addNetAction(Net::Download::makeByteArray(privatePackBaseUrl.arg(packCode), data)); job->addNetAction(Net::Download::makeByteArray(privatePackBaseUrl.arg(packCode), data));
QObject::connect(job, &NetJob::succeeded, this, [this, job, data, packCode] QObject::connect(job, &NetJob::succeeded, this, [this, job, data, packCode]
@ -63,7 +63,7 @@ void PackFetchTask::fetchPrivate(const QStringList & toFetch)
delete data; delete data;
}); });
job->start(m_network); job->start();
} }
} }

View File

@ -33,7 +33,7 @@ void PackInstallTask::downloadPack()
auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file); auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", packoffset); auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", packoffset);
netJobContainer = new NetJob("Download FTB Pack"); netJobContainer = new NetJob("Download FTB Pack", m_network);
entry->setStale(true); entry->setStale(true);
QString url; QString url;
@ -51,7 +51,7 @@ void PackInstallTask::downloadPack()
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed); connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress); connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
netJobContainer->start(m_network); netJobContainer->start();
progress(1, 4); progress(1, 4);
} }

View File

@ -63,12 +63,11 @@ void PackInstallTask::executeTask()
return; return;
} }
auto *netJob = new NetJob("ModpacksCH::VersionFetch"); auto *netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network());
auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2") auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2").arg(m_pack.id).arg(version.id);
.arg(m_pack.id).arg(version.id);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
@ -113,7 +112,7 @@ void PackInstallTask::downloadPack()
{ {
setStatus(tr("Downloading mods...")); setStatus(tr("Downloading mods..."));
jobPtr = new NetJob(tr("Mod download")); jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
for(auto file : m_version.files) { for(auto file : m_version.files) {
if(file.serverOnly) continue; if(file.serverOnly) continue;
@ -159,7 +158,7 @@ void PackInstallTask::downloadPack()
setProgress(current, total); setProgress(current, total);
}); });
jobPtr->start(APPLICATION->network()); jobPtr->start();
} }
void PackInstallTask::install() void PackInstallTask::install()

View File

@ -44,14 +44,14 @@ void Technic::SingleZipPackInstallTask::executeTask()
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path(); const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
auto entry = APPLICATION->metacache()->resolveEntry("general", path); auto entry = APPLICATION->metacache()->resolveEntry("general", path);
entry->setStale(true); entry->setStale(true);
m_filesNetJob.reset(new NetJob(tr("Modpack download"))); m_filesNetJob = new NetJob(tr("Modpack download"), APPLICATION->network());
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry)); m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
m_archivePath = entry->getFullPath(); m_archivePath = entry->getFullPath();
auto job = m_filesNetJob.get(); auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &Technic::SingleZipPackInstallTask::downloadSucceeded); connect(job, &NetJob::succeeded, this, &Technic::SingleZipPackInstallTask::downloadSucceeded);
connect(job, &NetJob::progress, this, &Technic::SingleZipPackInstallTask::downloadProgressChanged); connect(job, &NetJob::progress, this, &Technic::SingleZipPackInstallTask::downloadProgressChanged);
connect(job, &NetJob::failed, this, &Technic::SingleZipPackInstallTask::downloadFailed); connect(job, &NetJob::failed, this, &Technic::SingleZipPackInstallTask::downloadFailed);
m_filesNetJob->start(APPLICATION->network()); m_filesNetJob->start();
} }
void Technic::SingleZipPackInstallTask::downloadSucceeded() void Technic::SingleZipPackInstallTask::downloadSucceeded()

View File

@ -42,12 +42,12 @@ bool Technic::SolderPackInstallTask::abort() {
void Technic::SolderPackInstallTask::executeTask() void Technic::SolderPackInstallTask::executeTask()
{ {
setStatus(tr("Finding recommended version:\n%1").arg(m_sourceUrl.toString())); setStatus(tr("Finding recommended version:\n%1").arg(m_sourceUrl.toString()));
m_filesNetJob.reset(new NetJob(tr("Finding recommended version"))); m_filesNetJob = new NetJob(tr("Finding recommended version"), m_network);
m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response)); m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response));
auto job = m_filesNetJob.get(); auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::versionSucceeded); connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::versionSucceeded);
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed); connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
m_filesNetJob->start(m_network); m_filesNetJob->start();
} }
void Technic::SolderPackInstallTask::versionSucceeded() void Technic::SolderPackInstallTask::versionSucceeded()
@ -67,12 +67,12 @@ void Technic::SolderPackInstallTask::versionSucceeded()
} }
setStatus(tr("Resolving modpack files:\n%1").arg(m_sourceUrl.toString())); setStatus(tr("Resolving modpack files:\n%1").arg(m_sourceUrl.toString()));
m_filesNetJob.reset(new NetJob(tr("Resolving modpack files"))); m_filesNetJob = new NetJob(tr("Resolving modpack files"), m_network);
m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response)); m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response));
auto job = m_filesNetJob.get(); auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded); connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed); connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
m_filesNetJob->start(m_network); m_filesNetJob->start();
} }
void Technic::SolderPackInstallTask::fileListSucceeded() void Technic::SolderPackInstallTask::fileListSucceeded()
@ -99,7 +99,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
m_filesNetJob.reset(); m_filesNetJob.reset();
return; return;
} }
m_filesNetJob.reset(new NetJob(tr("Downloading modpack"))); m_filesNetJob = new NetJob(tr("Downloading modpack"), m_network);
int i = 0; int i = 0;
for (auto &modUrl: modUrls) for (auto &modUrl: modUrls)
{ {
@ -113,7 +113,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded); connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged); connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed); connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
m_filesNetJob->start(m_network); m_filesNetJob->start();
} }
void Technic::SolderPackInstallTask::downloadSucceeded() void Technic::SolderPackInstallTask::downloadSucceeded()

View File

@ -98,12 +98,6 @@ void NetJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTotal)
void NetJob::executeTask() void NetJob::executeTask()
{ {
if(!m_network) {
qCritical() << "Attempted to start NetJob" << objectName() << "without the network set!";
emitFailed(tr("Internal error: NetJob '%1' has been started without a network pointer!").arg(objectName()));
return;
}
// hack that delays early failures so they can be caught easier // hack that delays early failures so they can be caught easier
QMetaObject::invokeMethod(this, "startMoreParts", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "startMoreParts", Qt::QueuedConnection);
} }

View File

@ -29,17 +29,12 @@ class NetJob : public Task
public: public:
using Ptr = shared_qobject_ptr<NetJob>; using Ptr = shared_qobject_ptr<NetJob>;
explicit NetJob(QString job_name) : Task() explicit NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network) : Task(), m_network(network)
{ {
setObjectName(job_name); setObjectName(job_name);
} }
virtual ~NetJob(); virtual ~NetJob();
void setNetwork(shared_qobject_ptr<QNetworkAccessManager> network)
{
m_network = network;
}
bool addNetAction(NetAction::Ptr action); bool addNetAction(NetAction::Ptr action);
NetAction::Ptr operator[](int index) NetAction::Ptr operator[](int index)
@ -70,10 +65,6 @@ private slots:
public slots: public slots:
virtual void executeTask() override; virtual void executeTask() override;
virtual bool abort() override; virtual bool abort() override;
virtual void start(shared_qobject_ptr<QNetworkAccessManager> network) {
m_network = network;
Task::start();
}
private slots: private slots:
void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal); void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);

View File

@ -37,12 +37,12 @@ void NewsChecker::reloadNews()
qDebug() << "Reloading news."; qDebug() << "Reloading news.";
NetJob* job = new NetJob("News RSS Feed"); NetJob* job = new NetJob("News RSS Feed", m_network);
job->addNetAction(Net::Download::makeByteArray(m_feedUrl, &newsData)); job->addNetAction(Net::Download::makeByteArray(m_feedUrl, &newsData));
QObject::connect(job, &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished); QObject::connect(job, &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished);
QObject::connect(job, &NetJob::failed, this, &NewsChecker::rssDownloadFailed); QObject::connect(job, &NetJob::failed, this, &NewsChecker::rssDownloadFailed);
m_newsNetJob.reset(job); m_newsNetJob.reset(job);
job->start(m_network); job->start();
} }
void NewsChecker::rssDownloadFinished() void NewsChecker::rssDownloadFinished()

View File

@ -52,12 +52,12 @@ void NotificationChecker::checkForNotifications()
{ {
return; return;
} }
m_checkJob.reset(new NetJob("Checking for notifications")); m_checkJob = new NetJob("Checking for notifications", APPLICATION->network());
auto entry = APPLICATION->metacache()->resolveEntry("root", "notifications.json"); auto entry = APPLICATION->metacache()->resolveEntry("root", "notifications.json");
entry->setStale(true); entry->setStale(true);
m_checkJob->addNetAction(m_download = Net::Download::makeCached(m_notificationsUrl, entry)); m_checkJob->addNetAction(m_download = Net::Download::makeCached(m_notificationsUrl, entry));
connect(m_download.get(), &Net::Download::succeeded, this, &NotificationChecker::downloadSucceeded); connect(m_download.get(), &Net::Download::succeeded, this, &NotificationChecker::downloadSucceeded);
m_checkJob->start(APPLICATION->network()); m_checkJob->start();
} }
void NotificationChecker::downloadSucceeded(int) void NotificationChecker::downloadSucceeded(int)

View File

@ -573,14 +573,14 @@ void TranslationsModel::downloadIndex()
return; return;
} }
qDebug() << "Downloading Translations Index..."; qDebug() << "Downloading Translations Index...";
d->m_index_job.reset(new NetJob("Translations Index")); d->m_index_job = new NetJob("Translations Index", APPLICATION->network());
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("translations", "index_v2.json"); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("translations", "index_v2.json");
entry->setStale(true); entry->setStale(true);
d->m_index_task = Net::Download::makeCached(QUrl("https://files.multimc.org/translations/index_v2.json"), entry); d->m_index_task = Net::Download::makeCached(QUrl("https://files.multimc.org/translations/index_v2.json"), entry);
d->m_index_job->addNetAction(d->m_index_task); d->m_index_job->addNetAction(d->m_index_task);
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed); connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived); connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived);
d->m_index_job->start(APPLICATION->network()); d->m_index_job->start();
} }
void TranslationsModel::updateLanguage(QString key) void TranslationsModel::updateLanguage(QString key)
@ -625,13 +625,13 @@ void TranslationsModel::downloadTranslation(QString key)
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash)); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash));
dl->m_total_progress = lang->file_size; dl->m_total_progress = lang->file_size;
d->m_dl_job.reset(new NetJob("Translation for " + key)); d->m_dl_job = new NetJob("Translation for " + key, APPLICATION->network());
d->m_dl_job->addNetAction(dl); d->m_dl_job->addNetAction(dl);
connect(d->m_dl_job.get(), &NetJob::succeeded, this, &TranslationsModel::dlGood); connect(d->m_dl_job.get(), &NetJob::succeeded, this, &TranslationsModel::dlGood);
connect(d->m_dl_job.get(), &NetJob::failed, this, &TranslationsModel::dlFailed); connect(d->m_dl_job.get(), &NetJob::failed, this, &TranslationsModel::dlFailed);
d->m_dl_job->start(APPLICATION->network()); d->m_dl_job->start();
} }
void TranslationsModel::downloadNext() void TranslationsModel::downloadNext()

View File

@ -133,10 +133,10 @@ AboutDialog::~AboutDialog()
void AboutDialog::loadPatronList() void AboutDialog::loadPatronList()
{ {
netJob = new NetJob("Patreon Patron List"); netJob = new NetJob("Patreon Patron List", APPLICATION->network());
netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink)); netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink));
connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded); connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded);
netJob->start(APPLICATION->network()); netJob->start();
} }
void AboutDialog::patronListLoaded() void AboutDialog::patronListLoaded()

View File

@ -34,7 +34,7 @@ UpdateDialog::~UpdateDialog()
void UpdateDialog::loadChangelog() void UpdateDialog::loadChangelog()
{ {
auto channel = APPLICATION->settings()->get("UpdateChannel").toString(); auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
dljob.reset(new NetJob("Changelog")); dljob = new NetJob("Changelog", APPLICATION->network());
QString url; QString url;
if(channel == "stable") if(channel == "stable")
{ {
@ -49,7 +49,7 @@ void UpdateDialog::loadChangelog()
dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData)); dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData));
connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded); connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded);
connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed); connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed);
dljob->start(APPLICATION->network()); dljob->start();
} }
QString reprocessMarkdown(QByteArray markdown) QString reprocessMarkdown(QByteArray markdown)

View File

@ -304,7 +304,7 @@ void ScreenshotsPage::on_actionUpload_triggered()
return; return;
QList<ScreenShot::Ptr> uploaded; QList<ScreenShot::Ptr> uploaded;
auto job = NetJob::Ptr(new NetJob("Screenshot Upload")); auto job = NetJob::Ptr(new NetJob("Screenshot Upload", APPLICATION->network()));
if(selection.size() < 2) if(selection.size() < 2)
{ {
auto item = selection.at(0); auto item = selection.at(0);
@ -315,7 +315,6 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = true; m_uploadActive = true;
ProgressDialog dialog(this); ProgressDialog dialog(this);
job->setNetwork(APPLICATION->network());
if(dialog.execWithTask(job.get()) != QDialog::Accepted) if(dialog.execWithTask(job.get()) != QDialog::Accepted)
{ {
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"),
@ -347,19 +346,21 @@ void ScreenshotsPage::on_actionUpload_triggered()
job->addNetAction(ImgurUpload::make(screenshot)); job->addNetAction(ImgurUpload::make(screenshot));
} }
SequentialTask task; SequentialTask task;
auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation")); auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation", APPLICATION->network()));
auto imgurAlbum = ImgurAlbumCreation::make(uploaded); auto imgurAlbum = ImgurAlbumCreation::make(uploaded);
albumTask->addNetAction(imgurAlbum); albumTask->addNetAction(imgurAlbum);
job->setNetwork(APPLICATION->network());
task.addTask(job); task.addTask(job);
albumTask->setNetwork(APPLICATION->network());
task.addTask(albumTask); task.addTask(albumTask);
m_uploadActive = true; m_uploadActive = true;
ProgressDialog prog(this); ProgressDialog prog(this);
if (prog.execWithTask(&task) != QDialog::Accepted) if (prog.execWithTask(&task) != QDialog::Accepted)
{ {
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), CustomMessageBox::selectable(
tr("Unknown error"), QMessageBox::Warning)->exec(); this,
tr("Failed to upload screenshots!"),
tr("Unknown error"),
QMessageBox::Warning
)->exec();
} }
else else
{ {

View File

@ -86,11 +86,11 @@ void ListModel::request()
modpacks.clear(); modpacks.clear();
endResetModel(); endResetModel();
auto *netJob = new NetJob("Atl::Request"); auto *netJob = new NetJob("Atl::Request", APPLICATION->network());
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/json/packsnew.json"); auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/json/packsnew.json");
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished); QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed); QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
@ -183,7 +183,7 @@ void ListModel::requestLogo(QString file, QString url)
} }
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file.section(".", 0, 0))); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
NetJob *job = new NetJob(QString("ATLauncher Icon Download %1").arg(file)); NetJob *job = new NetJob(QString("ATLauncher Icon Download %1").arg(file), APPLICATION->network());
job->addNetAction(Net::Download::makeCached(QUrl(url), entry)); job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
auto fullPath = entry->getFullPath(); auto fullPath = entry->getFullPath();
@ -201,7 +201,7 @@ void ListModel::requestLogo(QString file, QString url)
emit logoFailed(file); emit logoFailed(file);
}); });
job->start(APPLICATION->network()); job->start();
m_loadingLogos.append(file); m_loadingLogos.append(file);
} }

View File

@ -100,7 +100,7 @@ void ListModel::requestLogo(QString logo, QString url)
} }
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0))); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
NetJob *job = new NetJob(QString("Flame Icon Download %1").arg(logo)); NetJob *job = new NetJob(QString("Flame Icon Download %1").arg(logo), APPLICATION->network());
job->addNetAction(Net::Download::makeCached(QUrl(url), entry)); job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
auto fullPath = entry->getFullPath(); auto fullPath = entry->getFullPath();
@ -118,7 +118,7 @@ void ListModel::requestLogo(QString logo, QString url)
emit logoFailed(logo); emit logoFailed(logo);
}); });
job->start(APPLICATION->network()); job->start();
m_loadingLogos.append(logo); m_loadingLogos.append(logo);
} }
@ -158,7 +158,7 @@ void ListModel::fetchMore(const QModelIndex& parent)
void ListModel::performPaginatedSearch() void ListModel::performPaginatedSearch()
{ {
NetJob *netJob = new NetJob("Flame::Search"); NetJob *netJob = new NetJob("Flame::Search", APPLICATION->network());
auto searchUrl = QString( auto searchUrl = QString(
"https://addons-ecs.forgesvc.net/api/v2/addon/search?" "https://addons-ecs.forgesvc.net/api/v2/addon/search?"
"categoryId=0&" "categoryId=0&"
@ -171,7 +171,7 @@ void ListModel::performPaginatedSearch()
).arg(nextSearchOffset).arg(currentSearchTerm).arg(currentSort); ).arg(nextSearchOffset).arg(currentSearchTerm).arg(currentSort);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished); QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed); QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
} }

View File

@ -109,7 +109,7 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
if (current.versionsLoaded == false) if (current.versionsLoaded == false)
{ {
qDebug() << "Loading flame modpack versions"; qDebug() << "Loading flame modpack versions";
NetJob *netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name)); NetJob *netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>(); std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
int addonId = current.addonId; int addonId = current.addonId;
netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response.get())); netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response.get()));
@ -140,7 +140,7 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
suggestCurrent(); suggestCurrent();
}); });
netJob->start(APPLICATION->network()); netJob->start();
} }
else else
{ {

View File

@ -107,11 +107,11 @@ void ListModel::request()
modpacks.clear(); modpacks.clear();
endResetModel(); endResetModel();
auto *netJob = new NetJob("Ftb::Request"); auto *netJob = new NetJob("Ftb::Request", APPLICATION->network());
auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all"); auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all");
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished); QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed); QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
@ -150,12 +150,11 @@ void ListModel::requestFailed(QString reason)
void ListModel::requestPack() void ListModel::requestPack()
{ {
auto *netJob = new NetJob("Ftb::Search"); auto *netJob = new NetJob("Ftb::Search", APPLICATION->network());
auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1") auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1").arg(currentPack);
.arg(currentPack);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::packRequestFinished); QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::packRequestFinished);
QObject::connect(netJob, &NetJob::failed, this, &ListModel::packRequestFailed); QObject::connect(netJob, &NetJob::failed, this, &ListModel::packRequestFailed);
@ -271,7 +270,7 @@ void ListModel::requestLogo(QString logo, QString url)
bool stale = entry->isStale(); bool stale = entry->isStale();
NetJob *job = new NetJob(QString("FTB Icon Download %1").arg(logo)); NetJob *job = new NetJob(QString("FTB Icon Download %1").arg(logo), APPLICATION->network());
job->addNetAction(Net::Download::makeCached(QUrl(url), entry)); job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
auto fullPath = entry->getFullPath(); auto fullPath = entry->getFullPath();
@ -288,7 +287,7 @@ void ListModel::requestLogo(QString logo, QString url)
auto &newLogoEntry = m_logoMap[logo]; auto &newLogoEntry = m_logoMap[logo];
newLogoEntry.downloadJob = job; newLogoEntry.downloadJob = job;
newLogoEntry.fullpath = fullPath; newLogoEntry.fullpath = fullPath;
job->start(APPLICATION->network()); job->start();
} }
} }

View File

@ -216,7 +216,7 @@ void ListModel::requestLogo(QString file)
} }
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0))); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file)); NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file), APPLICATION->network());
job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry)); job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
auto fullPath = entry->getFullPath(); auto fullPath = entry->getFullPath();
@ -234,7 +234,7 @@ void ListModel::requestLogo(QString file)
emit logoFailed(file); emit logoFailed(file);
}); });
job->start(APPLICATION->network()); job->start();
m_loadingLogos.append(file); m_loadingLogos.append(file);
} }

View File

@ -91,7 +91,7 @@ void Technic::ListModel::searchWithTerm(const QString& term)
void Technic::ListModel::performSearch() void Technic::ListModel::performSearch()
{ {
NetJob *netJob = new NetJob("Technic::Search"); NetJob *netJob = new NetJob("Technic::Search", APPLICATION->network());
QString searchUrl = ""; QString searchUrl = "";
if (currentSearchTerm.isEmpty()) { if (currentSearchTerm.isEmpty()) {
searchUrl = "https://api.technicpack.net/trending?build=multimc"; searchUrl = "https://api.technicpack.net/trending?build=multimc";
@ -104,7 +104,7 @@ void Technic::ListModel::performSearch()
} }
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(APPLICATION->network()); jobPtr->start();
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished); QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed); QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
} }
@ -216,7 +216,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
} }
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo)); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
NetJob *job = new NetJob(QString("Technic Icon Download %1").arg(logo)); NetJob *job = new NetJob(QString("Technic Icon Download %1").arg(logo), APPLICATION->network());
job->addNetAction(Net::Download::makeCached(QUrl(url), entry)); job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
auto fullPath = entry->getFullPath(); auto fullPath = entry->getFullPath();
@ -231,7 +231,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
logoFailed(logo); logoFailed(logo);
}); });
job->start(APPLICATION->network()); job->start();
m_loadingLogos.append(logo); m_loadingLogos.append(logo);
} }

View File

@ -110,8 +110,8 @@ void TechnicPage::suggestCurrent()
metadataLoaded(); metadataLoaded();
return; return;
} }
NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name)); NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name), APPLICATION->network());
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>(); std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
QString slug = current.slug; QString slug = current.slug;
netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.technicpack.net/modpack/%1?build=multimc").arg(slug), response.get())); netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.technicpack.net/modpack/%1?build=multimc").arg(slug), response.get()));
@ -167,7 +167,7 @@ void TechnicPage::suggestCurrent()
current.metadataLoaded = true; current.metadataLoaded = true;
metadataLoaded(); metadataLoaded();
}); });
netJob->start(APPLICATION->network()); netJob->start();
} }
// expects current.metadataLoaded to be true // expects current.metadataLoaded to be true

View File

@ -47,7 +47,7 @@ void DownloadTask::loadVersionInfo()
{ {
setStatus(tr("Loading version information...")); setStatus(tr("Loading version information..."));
NetJob *netJob = new NetJob("Version Info"); NetJob *netJob = new NetJob("Version Info", m_network);
// Find the index URL. // Find the index URL.
QUrl newIndexUrl = QUrl(m_status.newRepoUrl).resolved(QString::number(m_status.newVersionId) + ".json"); QUrl newIndexUrl = QUrl(m_status.newRepoUrl).resolved(QString::number(m_status.newVersionId) + ".json");
@ -67,7 +67,7 @@ void DownloadTask::loadVersionInfo()
connect(netJob, &NetJob::succeeded, this, &DownloadTask::processDownloadedVersionInfo); connect(netJob, &NetJob::succeeded, this, &DownloadTask::processDownloadedVersionInfo);
connect(netJob, &NetJob::failed, this, &DownloadTask::vinfoDownloadFailed); connect(netJob, &NetJob::failed, this, &DownloadTask::vinfoDownloadFailed);
m_vinfoNetJob.reset(netJob); m_vinfoNetJob.reset(netJob);
netJob->start(m_network); netJob->start();
} }
void DownloadTask::vinfoDownloadFailed() void DownloadTask::vinfoDownloadFailed()
@ -121,7 +121,7 @@ void DownloadTask::processDownloadedVersionInfo()
setStatus(tr("Processing file lists - figuring out how to install the update...")); setStatus(tr("Processing file lists - figuring out how to install the update..."));
// make a new netjob for the actual update files // make a new netjob for the actual update files
NetJob::Ptr netJob (new NetJob("Update Files")); NetJob::Ptr netJob = new NetJob("Update Files", m_network);
// fill netJob and operationList // fill netJob and operationList
if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, m_operations)) if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, m_operations))
@ -145,7 +145,7 @@ void DownloadTask::processDownloadedVersionInfo()
} }
qDebug() << "Begin downloading update files to" << m_updateFilesDir.path(); qDebug() << "Begin downloading update files to" << m_updateFilesDir.path();
m_filesNetJob = netJob; m_filesNetJob = netJob;
m_filesNetJob->start(m_network); m_filesNetJob->start();
} }
void DownloadTask::fileDownloadFinished() void DownloadTask::fileDownloadFinished()

View File

@ -179,7 +179,8 @@ slots:
OperationList operations; OperationList operations;
processFileLists(currentVersion, newVersion, QDir::currentPath(), tempFolder, new NetJob("Dummy"), operations); shared_qobject_ptr<QNetworkAccessManager> network = new QNetworkAccessManager();
processFileLists(currentVersion, newVersion, QDir::currentPath(), tempFolder, new NetJob("Dummy", network), operations);
qDebug() << (operations == expectedOperations); qDebug() << (operations == expectedOperations);
qDebug() << operations; qDebug() << operations;
qDebug() << expectedOperations; qDebug() << expectedOperations;

View File

@ -104,11 +104,11 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
QUrl indexUrl = QUrl(m_newRepoUrl).resolved(QUrl("index.json")); QUrl indexUrl = QUrl(m_newRepoUrl).resolved(QUrl("index.json"));
indexJob = new NetJob("GoUpdate Repository Index"); indexJob = new NetJob("GoUpdate Repository Index", m_network);
indexJob->addNetAction(Net::Download::makeByteArray(indexUrl, &indexData)); indexJob->addNetAction(Net::Download::makeByteArray(indexUrl, &indexData));
connect(indexJob.get(), &NetJob::succeeded, [this, notifyNoUpdate](){ updateCheckFinished(notifyNoUpdate); }); connect(indexJob.get(), &NetJob::succeeded, [this, notifyNoUpdate](){ updateCheckFinished(notifyNoUpdate); });
connect(indexJob.get(), &NetJob::failed, this, &UpdateChecker::updateCheckFailed); connect(indexJob.get(), &NetJob::failed, this, &UpdateChecker::updateCheckFailed);
indexJob->start(m_network); indexJob->start();
} }
void UpdateChecker::updateCheckFinished(bool notifyNoUpdate) void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
@ -191,11 +191,11 @@ void UpdateChecker::updateChanList(bool notifyNoUpdate)
} }
m_chanListLoading = true; m_chanListLoading = true;
chanListJob = new NetJob("Update System Channel List"); chanListJob = new NetJob("Update System Channel List", m_network);
chanListJob->addNetAction(Net::Download::makeByteArray(QUrl(m_channelUrl), &chanlistData)); chanListJob->addNetAction(Net::Download::makeByteArray(QUrl(m_channelUrl), &chanlistData));
connect(chanListJob.get(), &NetJob::succeeded, [this, notifyNoUpdate]() { chanListDownloadFinished(notifyNoUpdate); }); connect(chanListJob.get(), &NetJob::succeeded, [this, notifyNoUpdate]() { chanListDownloadFinished(notifyNoUpdate); });
connect(chanListJob.get(), &NetJob::failed, this, &UpdateChecker::chanListDownloadFailed); connect(chanListJob.get(), &NetJob::failed, this, &UpdateChecker::chanListDownloadFailed);
chanListJob->start(m_network); chanListJob->start();
} }
void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate) void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)