summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-05-03 23:11:52 +0200
committerPetr Mrázek <peterix@gmail.com>2017-05-03 23:13:49 +0200
commite76e6329cdf4f1613c6303debd3ca43493147f7b (patch)
tree69a21f72da050a7c67435eae8850a73942ada1bd /api/logic/minecraft
parent0efa714ba55a33ea6dbcbd08b50c0b09675ce83b (diff)
downloadMultiMC-e76e6329cdf4f1613c6303debd3ca43493147f7b.tar
MultiMC-e76e6329cdf4f1613c6303debd3ca43493147f7b.tar.gz
MultiMC-e76e6329cdf4f1613c6303debd3ca43493147f7b.tar.lz
MultiMC-e76e6329cdf4f1613c6303debd3ca43493147f7b.tar.xz
MultiMC-e76e6329cdf4f1613c6303debd3ca43493147f7b.zip
NOISSUE Revert all recent changes to NetAction and NetJob
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r--api/logic/minecraft/AssetsUtils.cpp2
-rw-r--r--api/logic/minecraft/Library.cpp2
-rw-r--r--api/logic/minecraft/SkinUpload.cpp2
-rw-r--r--api/logic/minecraft/auth/YggdrasilTask.cpp2
-rw-r--r--api/logic/minecraft/flame/FileResolvingTask.cpp2
-rw-r--r--api/logic/minecraft/forge/ForgeXzDownload.cpp56
-rw-r--r--api/logic/minecraft/forge/ForgeXzDownload.h7
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.cpp4
-rw-r--r--api/logic/minecraft/legacy/LegacyUpdate.cpp16
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.cpp14
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.h2
-rw-r--r--api/logic/minecraft/onesix/update/AssetUpdateTask.cpp4
-rw-r--r--api/logic/minecraft/onesix/update/FMLLibrariesTask.cpp6
-rw-r--r--api/logic/minecraft/onesix/update/LibrariesTask.cpp2
14 files changed, 60 insertions, 61 deletions
diff --git a/api/logic/minecraft/AssetsUtils.cpp b/api/logic/minecraft/AssetsUtils.cpp
index ad864d51..5191e5bd 100644
--- a/api/logic/minecraft/AssetsUtils.cpp
+++ b/api/logic/minecraft/AssetsUtils.cpp
@@ -199,7 +199,7 @@ NetActionPtr AssetObject::getDownloadAction()
auto rawHash = QByteArray::fromHex(hash.toLatin1());
objectDL->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash));
}
- objectDL->setProgress(0, size);
+ objectDL->m_total_progress = size;
return objectDL;
}
return nullptr;
diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp
index 0fdc2e12..22e1bd33 100644
--- a/api/logic/minecraft/Library.cpp
+++ b/api/logic/minecraft/Library.cpp
@@ -51,7 +51,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
}
}
-QList<NetActionPtr> Library::getDownloads(OpSys system, class HttpMetaCache* cache,
+QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class HttpMetaCache* cache,
QStringList& failedFiles, const QString & overridePath) const
{
QList<NetActionPtr> out;
diff --git a/api/logic/minecraft/SkinUpload.cpp b/api/logic/minecraft/SkinUpload.cpp
index dafd3a85..1d1e38f3 100644
--- a/api/logic/minecraft/SkinUpload.cpp
+++ b/api/logic/minecraft/SkinUpload.cpp
@@ -43,7 +43,7 @@ void SkinUpload::executeTask()
QNetworkReply *rep = ENV.qnam().put(request, multiPart);
m_reply = std::shared_ptr<QNetworkReply>(rep);
- setStatusText(tr("Uploading skin"));
+ setStatus(tr("Uploading skin"));
connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
diff --git a/api/logic/minecraft/auth/YggdrasilTask.cpp b/api/logic/minecraft/auth/YggdrasilTask.cpp
index 72c1c66f..425da76a 100644
--- a/api/logic/minecraft/auth/YggdrasilTask.cpp
+++ b/api/logic/minecraft/auth/YggdrasilTask.cpp
@@ -237,7 +237,7 @@ QString YggdrasilTask::getStateMessage() const
void YggdrasilTask::changeState(YggdrasilTask::State newState, QString reason)
{
m_state = newState;
- setStatusText(getStateMessage());
+ setStatus(getStateMessage());
if (newState == STATE_SUCCEEDED)
{
emitSucceeded();
diff --git a/api/logic/minecraft/flame/FileResolvingTask.cpp b/api/logic/minecraft/flame/FileResolvingTask.cpp
index 093de3ec..582e4a07 100644
--- a/api/logic/minecraft/flame/FileResolvingTask.cpp
+++ b/api/logic/minecraft/flame/FileResolvingTask.cpp
@@ -10,7 +10,7 @@ Flame::FileResolvingTask::FileResolvingTask(Flame::Manifest& toProcess)
void Flame::FileResolvingTask::executeTask()
{
- setStatusText(tr("Resolving mod IDs..."));
+ setStatus(tr("Resolving mod IDs..."));
setProgress(0, m_toProcess.files.size());
m_dljob.reset(new NetJob("Mod id resolver"));
results.resize(m_toProcess.files.size());
diff --git a/api/logic/minecraft/forge/ForgeXzDownload.cpp b/api/logic/minecraft/forge/ForgeXzDownload.cpp
index 8bcd43aa..4d94dd12 100644
--- a/api/logic/minecraft/forge/ForgeXzDownload.cpp
+++ b/api/logic/minecraft/forge/ForgeXzDownload.cpp
@@ -28,31 +28,31 @@ ForgeXzDownload::ForgeXzDownload(QString relative_path, MetaEntryPtr entry) : Ne
m_entry = entry;
m_target_path = entry->getFullPath();
m_pack200_xz_file.setFileTemplate("./dl_temp.XXXXXX");
- m_status = Status::NotStarted;
+ m_status = Job_NotStarted;
m_url_path = relative_path;
m_url = "http://files.minecraftforge.net/maven/" + m_url_path + ".pack.xz";
}
-void ForgeXzDownload::executeTask()
+void ForgeXzDownload::start()
{
- if(m_status == Status::Aborted)
+ if(m_status == Job_Aborted)
{
qWarning() << "Attempt to start an aborted Download:" << m_url.toString();
- emit aborted();
+ emit aborted(m_index_within_job);
return;
}
- m_status = Status::InProgress;
+ m_status = Job_InProgress;
if (!m_entry->isStale())
{
- m_status = Status::Finished;
- emit succeeded();
+ m_status = Job_Finished;
+ emit succeeded(m_index_within_job);
return;
}
// can we actually create the real, final file?
if (!FS::ensureFilePathExists(m_target_path))
{
- m_status = Status::Failed;
- emit failed();
+ m_status = Job_Failed;
+ emit failed(m_index_within_job);
return;
}
@@ -72,9 +72,9 @@ void ForgeXzDownload::executeTask()
void ForgeXzDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
- m_progressTotal = bytesTotal;
+ m_total_progress = bytesTotal;
m_progress = bytesReceived;
- emit progress(bytesReceived, bytesTotal);
+ emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
}
void ForgeXzDownload::downloadError(QNetworkReply::NetworkError error)
@@ -82,29 +82,29 @@ void ForgeXzDownload::downloadError(QNetworkReply::NetworkError error)
if(error == QNetworkReply::OperationCanceledError)
{
qCritical() << "Aborted " << m_url.toString();
- m_status = Status::Aborted;
+ m_status = Job_Aborted;
}
else
{
// error happened during download.
qCritical() << "Failed " << m_url.toString() << " with reason " << error;
- m_status = Status::Failed;
+ m_status = Job_Failed;
}
}
void ForgeXzDownload::failAndTryNextMirror()
{
- m_status = Status::Failed;
- emit failed();
+ m_status = Job_Failed;
+ emit failed(m_index_within_job);
}
void ForgeXzDownload::downloadFinished()
{
// if the download succeeded
- if (m_status != Status::Failed && m_status != Status::Aborted)
+ if (m_status != Job_Failed && m_status != Job_Aborted)
{
// nothing went wrong...
- m_status = Status::Finished;
+ m_status = Job_Finished;
if (m_pack200_xz_file.isOpen())
{
// we actually downloaded something! process and isntall it
@@ -114,25 +114,25 @@ void ForgeXzDownload::downloadFinished()
else
{
// something bad happened -- on the local machine!
- m_status = Status::Failed;
+ m_status = Job_Failed;
m_pack200_xz_file.remove();
m_reply.reset();
- emit failed();
+ emit failed(m_index_within_job);
return;
}
}
- else if(m_status == Status::Aborted)
+ else if(m_status == Job_Aborted)
{
m_pack200_xz_file.remove();
m_reply.reset();
- emit failed();
- emit aborted();
+ emit failed(m_index_within_job);
+ emit aborted(m_index_within_job);
return;
}
// else the download failed
else
{
- m_status = Status::Failed;
+ m_status = Job_Failed;
m_pack200_xz_file.close();
m_pack200_xz_file.remove();
m_reply.reset();
@@ -152,7 +152,7 @@ void ForgeXzDownload::downloadReadyRead()
* Can't open the file... the job failed
*/
m_reply->abort();
- emit failed();
+ emit failed(m_index_within_job);
return;
}
}
@@ -345,7 +345,7 @@ void ForgeXzDownload::decompressAndInstall()
}
catch (std::runtime_error &err)
{
- m_status = Status::Failed;
+ m_status = Job_Failed;
qCritical() << "Error unpacking " << pack200_file.fileName() << " : " << err.what();
QFile f(m_target_path);
if (f.exists())
@@ -374,18 +374,18 @@ void ForgeXzDownload::decompressAndInstall()
ENV.metacache()->updateEntry(m_entry);
m_reply.reset();
- emit succeeded();
+ emit succeeded(m_index_within_job);
}
bool ForgeXzDownload::abort()
{
if(m_reply)
m_reply->abort();
- m_status = Status::Aborted;
+ m_status = Job_Aborted;
return true;
}
-bool ForgeXzDownload::canAbort() const
+bool ForgeXzDownload::canAbort()
{
return true;
}
diff --git a/api/logic/minecraft/forge/ForgeXzDownload.h b/api/logic/minecraft/forge/ForgeXzDownload.h
index 8d6ad74a..ef23809b 100644
--- a/api/logic/minecraft/forge/ForgeXzDownload.h
+++ b/api/logic/minecraft/forge/ForgeXzDownload.h
@@ -19,9 +19,8 @@
#include "net/HttpMetaCache.h"
#include <QFile>
#include <QTemporaryFile>
-#include "QObjectPtr.h"
-typedef shared_qobject_ptr<class ForgeXzDownload> ForgeXzDownloadPtr;
+typedef std::shared_ptr<class ForgeXzDownload> ForgeXzDownloadPtr;
class ForgeXzDownload : public NetAction
{
@@ -42,7 +41,7 @@ public:
return ForgeXzDownloadPtr(new ForgeXzDownload(relative_path, entry));
}
virtual ~ForgeXzDownload(){};
- bool canAbort() const override;
+ bool canAbort() override;
protected
slots:
@@ -53,7 +52,7 @@ slots:
public
slots:
- void executeTask() override;
+ void start() override;
bool abort() override;
private:
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp
index 5894d7f0..0987d56f 100644
--- a/api/logic/minecraft/legacy/LegacyInstance.cpp
+++ b/api/logic/minecraft/legacy/LegacyInstance.cpp
@@ -131,7 +131,7 @@ std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
return;
}
- setStatusText(tr("Installing mods: Backing up minecraft.jar ..."));
+ setStatus(tr("Installing mods: Backing up minecraft.jar ..."));
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
{
emitFailed("It seems both the active and base jar are gone. A fresh base jar will "
@@ -155,7 +155,7 @@ std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
return;
}
- setStatusText(tr("Installing mods: Opening minecraft.jar ..."));
+ setStatus(tr("Installing mods: Opening minecraft.jar ..."));
QString outputJarPath = runnableJar.filePath();
QString inputJarPath = baseJar.filePath();
diff --git a/api/logic/minecraft/legacy/LegacyUpdate.cpp b/api/logic/minecraft/legacy/LegacyUpdate.cpp
index 4bde6ff8..337a3e4e 100644
--- a/api/logic/minecraft/legacy/LegacyUpdate.cpp
+++ b/api/logic/minecraft/legacy/LegacyUpdate.cpp
@@ -58,7 +58,7 @@ void LegacyUpdate::fmllibsStart()
auto &libList = fmlLibsMapping[version];
// determine if we need some libs for FML or forge
- setStatusText(tr("Checking for FML libraries..."));
+ setStatus(tr("Checking for FML libraries..."));
for (unsigned i = 0; i < modList->size(); i++)
{
auto &mod = modList->operator[](i);
@@ -105,7 +105,7 @@ void LegacyUpdate::fmllibsStart()
}
// download missing libs to our place
- setStatusText(tr("Dowloading FML libraries..."));
+ setStatus(tr("Dowloading FML libraries..."));
auto dljob = new NetJob("FML libraries");
auto metacache = ENV.metacache();
for (auto &lib : fmlLibsToProcess)
@@ -128,7 +128,7 @@ void LegacyUpdate::fmllibsFinished()
legacyDownloadJob.reset();
if(!fmlLibsToProcess.isEmpty())
{
- setStatusText(tr("Copying FML libraries into the instance..."));
+ setStatus(tr("Copying FML libraries into the instance..."));
LegacyInstance *inst = (LegacyInstance *)m_inst;
auto metacache = ENV.metacache();
int index = 0;
@@ -183,7 +183,7 @@ void LegacyUpdate::lwjglStart()
return;
}
- setStatusText(tr("Downloading new LWJGL..."));
+ setStatus(tr("Downloading new LWJGL..."));
auto version = std::dynamic_pointer_cast<LWJGLVersion>(list->findVersion(lwjglVersion));
if (!version)
{
@@ -247,7 +247,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
saveMe.open(QIODevice::WriteOnly);
saveMe.write(m_reply->readAll());
saveMe.close();
- setStatusText(tr("Installing new LWJGL..."));
+ setStatus(tr("Installing new LWJGL..."));
extractLwjgl();
jarStart();
}
@@ -323,7 +323,7 @@ void LegacyUpdate::extractLwjgl()
// Now if destFileName is still empty, go to the next file.
if (!destFileName.isEmpty())
{
- setStatusText(tr("Installing new LWJGL - extracting ") + name + "...");
+ setStatus(tr("Installing new LWJGL - extracting ") + name + "...");
QFile output(destFileName);
output.open(QIODevice::WriteOnly);
output.write(file.readAll());
@@ -353,7 +353,7 @@ void LegacyUpdate::jarStart()
return;
}
- setStatusText(tr("Checking for jar updates..."));
+ setStatus(tr("Checking for jar updates..."));
// Make directories
QDir binDir(inst->binRoot());
if (!binDir.exists() && !binDir.mkpath("."))
@@ -363,7 +363,7 @@ void LegacyUpdate::jarStart()
}
// Build a list of URLs that will need to be downloaded.
- setStatusText(tr("Downloading new minecraft.jar ..."));
+ setStatus(tr("Downloading new minecraft.jar ..."));
QString version_id = inst->intendedVersionId();
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp
index 163cb1a3..e0027032 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -41,7 +41,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
{
// create folders
{
- m_tasks.append(new FoldersTask(m_inst));
+ m_tasks.append(std::make_shared<FoldersTask>(m_inst));
}
// add metadata update tasks, if necessary
@@ -66,7 +66,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
if(task)
{
qDebug() << "Loading remote meta patch" << id;
- m_tasks.append(task);
+ m_tasks.append(task.unwrap());
}
}
else
@@ -78,17 +78,17 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
// libraries download
{
- m_tasks.append(new LibrariesTask(m_inst));
+ m_tasks.append(std::make_shared<LibrariesTask>(m_inst));
}
// FML libraries download and copy into the instance
{
- m_tasks.append(new FMLLibrariesTask(m_inst));
+ m_tasks.append(std::make_shared<FMLLibrariesTask>(m_inst));
}
// assets update
{
- m_tasks.append(new AssetUpdateTask(m_inst));
+ m_tasks.append(std::make_shared<AssetUpdateTask>(m_inst));
}
}
@@ -116,7 +116,7 @@ void OneSixUpdate::next()
disconnect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
disconnect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
disconnect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
- disconnect(task.get(), &Task::status, this, &OneSixUpdate::setStatusText);
+ disconnect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
}
if(m_currentTask == m_tasks.size())
{
@@ -132,7 +132,7 @@ void OneSixUpdate::next()
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
- connect(task.get(), &Task::status, this, &OneSixUpdate::setStatusText);
+ connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
// if the task is already running, do not start it again
if(!task->isRunning())
{
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.h b/api/logic/minecraft/onesix/OneSixUpdate.h
index 7b6fa5ca..6bcfd41a 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.h
+++ b/api/logic/minecraft/onesix/OneSixUpdate.h
@@ -46,7 +46,7 @@ private:
private:
OneSixInstance *m_inst = nullptr;
- QList<shared_qobject_ptr<Task>> m_tasks;
+ QList<std::shared_ptr<Task>> m_tasks;
QString m_preFailure;
int m_currentTask = -1;
bool m_abort = false;
diff --git a/api/logic/minecraft/onesix/update/AssetUpdateTask.cpp b/api/logic/minecraft/onesix/update/AssetUpdateTask.cpp
index bdd50fd1..21600ff0 100644
--- a/api/logic/minecraft/onesix/update/AssetUpdateTask.cpp
+++ b/api/logic/minecraft/onesix/update/AssetUpdateTask.cpp
@@ -10,7 +10,7 @@ AssetUpdateTask::AssetUpdateTask(OneSixInstance * inst)
}
void AssetUpdateTask::executeTask()
{
- setStatusText(tr("Updating assets index..."));
+ setStatus(tr("Updating assets index..."));
auto profile = m_inst->getMinecraftProfile();
auto assets = profile->getMinecraftAssets();
QUrl indexUrl = assets->url;
@@ -63,7 +63,7 @@ void AssetUpdateTask::assetIndexFinished()
auto job = index.getDownloadJob();
if(job)
{
- setStatusText(tr("Getting the assets files from Mojang..."));
+ setStatus(tr("Getting the assets files from Mojang..."));
downloadJob = job;
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
diff --git a/api/logic/minecraft/onesix/update/FMLLibrariesTask.cpp b/api/logic/minecraft/onesix/update/FMLLibrariesTask.cpp
index 4a0a97ea..1cbee95e 100644
--- a/api/logic/minecraft/onesix/update/FMLLibrariesTask.cpp
+++ b/api/logic/minecraft/onesix/update/FMLLibrariesTask.cpp
@@ -32,7 +32,7 @@ void FMLLibrariesTask::executeTask()
auto &libList = fmlLibsMapping[version];
// determine if we need some libs for FML or forge
- setStatusText(tr("Checking for FML libraries..."));
+ setStatus(tr("Checking for FML libraries..."));
forge_present = (profile->versionPatch("net.minecraftforge") != nullptr);
// we don't...
if (!forge_present)
@@ -58,7 +58,7 @@ void FMLLibrariesTask::executeTask()
}
// download missing libs to our place
- setStatusText(tr("Dowloading FML libraries..."));
+ setStatus(tr("Dowloading FML libraries..."));
auto dljob = new NetJob("FML libraries");
auto metacache = ENV.metacache();
for (auto &lib : fmlLibsToProcess)
@@ -86,7 +86,7 @@ void FMLLibrariesTask::fmllibsFinished()
downloadJob.reset();
if (!fmlLibsToProcess.isEmpty())
{
- setStatusText(tr("Copying FML libraries into the instance..."));
+ setStatus(tr("Copying FML libraries into the instance..."));
OneSixInstance *inst = (OneSixInstance *)m_inst;
auto metacache = ENV.metacache();
int index = 0;
diff --git a/api/logic/minecraft/onesix/update/LibrariesTask.cpp b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
index 748ab10c..2cd41ded 100644
--- a/api/logic/minecraft/onesix/update/LibrariesTask.cpp
+++ b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
@@ -9,7 +9,7 @@ LibrariesTask::LibrariesTask(OneSixInstance * inst)
void LibrariesTask::executeTask()
{
- setStatusText(tr("Getting the library files from Mojang..."));
+ setStatus(tr("Getting the library files from Mojang..."));
qDebug() << m_inst->name() << ": downloading libraries";
OneSixInstance *inst = (OneSixInstance *)m_inst;
inst->reloadProfile();