diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-04-26 13:47:14 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-26 18:33:29 +0200 |
commit | 84549ed8078bdbd029aa5a89facc0412b8b5e753 (patch) | |
tree | 3a5bd2727195f18c42cdb428421cab5fc6562d9d /logic | |
parent | d5c79db12c326bd0175cd2990764948a536abbbb (diff) | |
download | MultiMC-84549ed8078bdbd029aa5a89facc0412b8b5e753.tar MultiMC-84549ed8078bdbd029aa5a89facc0412b8b5e753.tar.gz MultiMC-84549ed8078bdbd029aa5a89facc0412b8b5e753.tar.lz MultiMC-84549ed8078bdbd029aa5a89facc0412b8b5e753.tar.xz MultiMC-84549ed8078bdbd029aa5a89facc0412b8b5e753.zip |
GH-849 Further NetJob related fixes
Diffstat (limited to 'logic')
-rw-r--r-- | logic/minecraft/LegacyUpdate.cpp | 28 | ||||
-rw-r--r-- | logic/minecraft/LegacyUpdate.h | 6 | ||||
-rw-r--r-- | logic/net/NetJob.cpp | 6 | ||||
-rw-r--r-- | logic/net/NetJob.h | 8 | ||||
-rw-r--r-- | logic/updater/DownloadTask.cpp | 7 | ||||
-rw-r--r-- | logic/updater/DownloadTask.h | 2 | ||||
-rw-r--r-- | logic/updater/UpdateChecker.cpp | 6 | ||||
-rw-r--r-- | logic/updater/UpdateChecker.h | 2 |
8 files changed, 31 insertions, 34 deletions
diff --git a/logic/minecraft/LegacyUpdate.cpp b/logic/minecraft/LegacyUpdate.cpp index 6c0a4cdf..78f2f5b7 100644 --- a/logic/minecraft/LegacyUpdate.cpp +++ b/logic/minecraft/LegacyUpdate.cpp @@ -116,9 +116,9 @@ void LegacyUpdate::fmllibsStart() dljob->addNetAction(CacheDownload::make(QUrl(urlString), entry)); } - connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished())); - connect(dljob, SIGNAL(failed()), SLOT(fmllibsFailed())); - connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); + connect(dljob, &NetJob::succeeded, this, &LegacyUpdate::fmllibsFinished); + connect(dljob, &NetJob::failed, this, &LegacyUpdate::fmllibsFailed); + connect(dljob, &NetJob::progress, this, &LegacyUpdate::progress); legacyDownloadJob.reset(dljob); legacyDownloadJob->start(); } @@ -154,9 +154,9 @@ void LegacyUpdate::fmllibsFinished() lwjglStart(); } -void LegacyUpdate::fmllibsFailed() +void LegacyUpdate::fmllibsFailed(QString reason) { - emitFailed("Game update failed: it was impossible to fetch the required FML libraries."); + emitFailed(tr("Game update failed: it was impossible to fetch the required FML libraries. Reason: %1").arg(reason)); return; } @@ -201,9 +201,8 @@ void LegacyUpdate::lwjglStart() QNetworkReply *rep = worker->get(req); m_reply = std::shared_ptr<QNetworkReply>(rep); - connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); - connect(worker.get(), SIGNAL(finished(QNetworkReply *)), - SLOT(lwjglFinished(QNetworkReply *))); + connect(rep, &QNetworkReply::downloadProgress, this, &LegacyUpdate::progress); + connect(worker.get(), &QNetworkAccessManager::finished, this, &LegacyUpdate::lwjglFinished); } void LegacyUpdate::lwjglFinished(QNetworkReply *reply) @@ -240,8 +239,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply *reply) req.setRawHeader("Host", hostname.toLatin1()); req.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)"); QNetworkReply *rep = worker->get(req); - connect(rep, SIGNAL(downloadProgress(qint64, qint64)), - SIGNAL(progress(qint64, qint64))); + connect(rep, &QNetworkReply::downloadProgress, this, &LegacyUpdate::progress); m_reply = std::shared_ptr<QNetworkReply>(rep); return; } @@ -341,9 +339,9 @@ void LegacyUpdate::extractLwjgl() doneFile.close(); } -void LegacyUpdate::lwjglFailed() +void LegacyUpdate::lwjglFailed(QString reason) { - emitFailed("Bad stuff happened while trying to get the lwjgl libs..."); + emitFailed(tr("Bad stuff happened while trying to get the lwjgl libs: %1").arg(reason)); } void LegacyUpdate::jarStart() @@ -377,7 +375,7 @@ void LegacyUpdate::jarStart() auto entry = metacache->resolveEntry("versions", localPath); dljob->addNetAction(CacheDownload::make(QUrl(urlstr), entry)); connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished())); - connect(dljob, SIGNAL(failed()), SLOT(jarFailed())); + connect(dljob, SIGNAL(failed(QString)), SLOT(jarFailed(QString))); connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); legacyDownloadJob.reset(dljob); legacyDownloadJob->start(); @@ -389,10 +387,10 @@ void LegacyUpdate::jarFinished() ModTheJar(); } -void LegacyUpdate::jarFailed() +void LegacyUpdate::jarFailed(QString reason) { // bad, bad - emitFailed("Failed to download the minecraft jar. Try again later."); + emitFailed(tr("Failed to download the minecraft jar: %1.").arg(reason)); } void LegacyUpdate::ModTheJar() diff --git a/logic/minecraft/LegacyUpdate.h b/logic/minecraft/LegacyUpdate.h index 61de75d3..fc389ae1 100644 --- a/logic/minecraft/LegacyUpdate.h +++ b/logic/minecraft/LegacyUpdate.h @@ -39,15 +39,15 @@ private slots: void lwjglStart(); void lwjglFinished(QNetworkReply *); - void lwjglFailed(); + void lwjglFailed(QString reason); void jarStart(); void jarFinished(); - void jarFailed(); + void jarFailed(QString reason); void fmllibsStart(); void fmllibsFinished(); - void fmllibsFailed(); + void fmllibsFailed(QString reason); void extractLwjgl(); diff --git a/logic/net/NetJob.cpp b/logic/net/NetJob.cpp index b5503daf..40d2d1c9 100644 --- a/logic/net/NetJob.cpp +++ b/logic/net/NetJob.cpp @@ -64,7 +64,7 @@ void NetJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTotal) emit progress(current_progress, total_progress); } -void NetJob::start() +void NetJob::executeTask() { qDebug() << m_job_name.toLocal8Bit() << " started."; m_running = true; @@ -86,12 +86,12 @@ void NetJob::startMoreParts() if(!m_failed.size()) { qDebug() << m_job_name << "succeeded."; - emit succeeded(); + emitSucceeded(); } else { qCritical() << m_job_name << "failed."; - emit failed(tr("%1 failed").arg(m_job_name)); + emitFailed(tr("Job '%1' failed to process:\n%2").arg(m_job_name).arg(getFailedFiles().join("\n"))); } } return; diff --git a/logic/net/NetJob.h b/logic/net/NetJob.h index 912a74b3..c0172bea 100644 --- a/logic/net/NetJob.h +++ b/logic/net/NetJob.h @@ -21,17 +21,17 @@ #include "MD5EtagDownload.h" #include "CacheDownload.h" #include "HttpMetaCache.h" -#include "tasks/ProgressProvider.h" +#include "tasks/Task.h" #include "QObjectPtr.h" class NetJob; typedef QObjectPtr<NetJob> NetJobPtr; -class NetJob : public ProgressProvider +class NetJob : public Task { Q_OBJECT public: - explicit NetJob(QString job_name) : ProgressProvider(), m_job_name(job_name) {} + explicit NetJob(QString job_name) : Task(), m_job_name(job_name) {} virtual ~NetJob() {} template <typename T> bool addNetAction(T action) { @@ -87,7 +87,7 @@ private slots: void startMoreParts(); public slots: - virtual void start(); + virtual void executeTask(); // FIXME: implement virtual void abort() {}; diff --git a/logic/updater/DownloadTask.cpp b/logic/updater/DownloadTask.cpp index 65d894f9..f19607a5 100644 --- a/logic/updater/DownloadTask.cpp +++ b/logic/updater/DownloadTask.cpp @@ -159,11 +159,10 @@ void DownloadTask::fileDownloadFinished() emitSucceeded(); } -void DownloadTask::fileDownloadFailed() +void DownloadTask::fileDownloadFailed(QString reason) { - // TODO: Give more info about the failure. - qCritical() << "Failed to download update files."; - emitFailed(tr("Failed to download update files.")); + qCritical() << "Failed to download update files:" << reason; + emitFailed(tr("Failed to download update files: %1").arg(reason)); } void DownloadTask::fileDownloadProgressChanged(qint64 current, qint64 total) diff --git a/logic/updater/DownloadTask.h b/logic/updater/DownloadTask.h index 24e39415..182e76d6 100644 --- a/logic/updater/DownloadTask.h +++ b/logic/updater/DownloadTask.h @@ -78,7 +78,7 @@ protected slots: void vinfoDownloadFailed(); void fileDownloadFinished(); - void fileDownloadFailed(); + void fileDownloadFailed(QString reason); void fileDownloadProgressChanged(qint64 current, qint64 total); }; diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp index 7d214ed4..1cdac916 100644 --- a/logic/updater/UpdateChecker.cpp +++ b/logic/updater/UpdateChecker.cpp @@ -96,7 +96,7 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate) job->addNetAction(ByteArrayDownload::make(indexUrl)); connect(job, &NetJob::succeeded, [this, notifyNoUpdate]() { updateCheckFinished(notifyNoUpdate); }); - connect(job, SIGNAL(failed()), SLOT(updateCheckFailed())); + connect(job, &NetJob::failed, this, &UpdateChecker::updateCheckFailed); indexJob.reset(job); job->start(); } @@ -260,10 +260,10 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate) emit channelListLoaded(); } -void UpdateChecker::chanListDownloadFailed() +void UpdateChecker::chanListDownloadFailed(QString reason) { m_chanListLoading = false; - qCritical() << "Failed to download channel list."; + qCritical() << QString("Failed to download channel list: %1").arg(reason); emit channelListLoaded(); } diff --git a/logic/updater/UpdateChecker.h b/logic/updater/UpdateChecker.h index 760245cd..39ccd138 100644 --- a/logic/updater/UpdateChecker.h +++ b/logic/updater/UpdateChecker.h @@ -70,7 +70,7 @@ private slots: void updateCheckFailed(); void chanListDownloadFinished(bool notifyNoUpdate); - void chanListDownloadFailed(); + void chanListDownloadFailed(QString reason); private: friend class UpdateCheckerTest; |