diff options
author | Forkk <forkk@forkk.net> | 2014-01-08 21:45:13 -0600 |
---|---|---|
committer | Forkk <forkk@forkk.net> | 2014-01-08 21:45:13 -0600 |
commit | 06b5fa5dccdfc54496cd79e6eba6d025bc6e1204 (patch) | |
tree | 83d2f49d9e694bdd8f8d2cdd3879e696f435ba10 /logic | |
parent | 51817962aa64bc5c084e33fb29a21261d19bc8f3 (diff) | |
parent | b767d4b134148ddb3f956253a2f7f2cad831e782 (diff) | |
download | MultiMC-06b5fa5dccdfc54496cd79e6eba6d025bc6e1204.tar MultiMC-06b5fa5dccdfc54496cd79e6eba6d025bc6e1204.tar.gz MultiMC-06b5fa5dccdfc54496cd79e6eba6d025bc6e1204.tar.lz MultiMC-06b5fa5dccdfc54496cd79e6eba6d025bc6e1204.tar.xz MultiMC-06b5fa5dccdfc54496cd79e6eba6d025bc6e1204.zip |
Merge branch 'release-0.1'0.1
Release MultiMC version 0.1.
Diffstat (limited to 'logic')
-rw-r--r-- | logic/JavaChecker.cpp | 18 | ||||
-rw-r--r-- | logic/JavaChecker.h | 4 | ||||
-rw-r--r-- | logic/JavaCheckerJob.cpp | 6 | ||||
-rw-r--r-- | logic/LegacyInstance.cpp | 6 | ||||
-rw-r--r-- | logic/lists/JavaVersionList.cpp | 4 | ||||
-rw-r--r-- | logic/updater/NotificationChecker.cpp | 11 | ||||
-rw-r--r-- | logic/updater/NotificationChecker.h | 2 | ||||
-rw-r--r-- | logic/updater/UpdateChecker.cpp | 4 |
8 files changed, 25 insertions, 30 deletions
diff --git a/logic/JavaChecker.cpp b/logic/JavaChecker.cpp index 113974ff..6ee7b4cf 100644 --- a/logic/JavaChecker.cpp +++ b/logic/JavaChecker.cpp @@ -1,26 +1,20 @@ #include "JavaChecker.h" +#include "MultiMC.h" +#include <pathutils.h> #include <QFile> #include <QProcess> #include <QMap> #include <QTemporaryFile> -#define CHECKER_FILE "JavaChecker.jar" - JavaChecker::JavaChecker(QObject *parent) : QObject(parent) { } void JavaChecker::performCheck() { - checkerJar.setFileTemplate("checker_XXXXXX.jar"); - checkerJar.open(); - QFile inner(":/java/checker.jar"); - inner.open(QIODevice::ReadOnly); - checkerJar.write(inner.readAll()); - inner.close(); - checkerJar.close(); + QString checkerJar = PathCombine(MMC->bin(), "jars", "JavaCheck.jar"); - QStringList args = {"-jar", checkerJar.fileName()}; + QStringList args = {"-jar", checkerJar}; process.reset(new QProcess()); process->setArguments(args); @@ -42,11 +36,11 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status) killTimer.stop(); QProcessPtr _process; _process.swap(process); - checkerJar.remove(); JavaCheckResult result; { result.path = path; + result.id = id; } if (status == QProcess::CrashExit || exitcode == 1) @@ -99,11 +93,11 @@ void JavaChecker::error(QProcess::ProcessError err) if(err == QProcess::FailedToStart) { killTimer.stop(); - checkerJar.remove(); JavaCheckResult result; { result.path = path; + result.id = id; } emit checkFinished(result); diff --git a/logic/JavaChecker.h b/logic/JavaChecker.h index 291bf46c..e19895f7 100644 --- a/logic/JavaChecker.h +++ b/logic/JavaChecker.h @@ -1,7 +1,6 @@ #pragma once #include <QProcess> #include <QTimer> -#include <QTemporaryFile> #include <memory> class JavaChecker; @@ -15,6 +14,7 @@ struct JavaCheckResult QString javaVersion; bool valid = false; bool is_64bit = false; + int id; }; typedef std::shared_ptr<QProcess> QProcessPtr; @@ -27,13 +27,13 @@ public: void performCheck(); QString path; + int id; signals: void checkFinished(JavaCheckResult result); private: QProcessPtr process; QTimer killTimer; - QTemporaryFile checkerJar; public slots: void timeout(); diff --git a/logic/JavaCheckerJob.cpp b/logic/JavaCheckerJob.cpp index 36a8a050..b0aea758 100644 --- a/logic/JavaCheckerJob.cpp +++ b/logic/JavaCheckerJob.cpp @@ -26,10 +26,7 @@ void JavaCheckerJob::partFinished(JavaCheckResult result) << javacheckers.size(); emit progress(num_finished, javacheckers.size()); - javaresults.append(result); - int result_size = javacheckers.size(); - - emit progress(num_finished, result_size); + javaresults.replace(result.id, result); if (num_finished == javacheckers.size()) { @@ -43,6 +40,7 @@ void JavaCheckerJob::start() m_running = true; for (auto iter : javacheckers) { + javaresults.append(JavaCheckResult()); connect(iter.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult))); iter->performCheck(); } diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index 0bc0961e..5ab19fc9 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -31,8 +31,6 @@ #include "gui/dialogs/LegacyModEditDialog.h" -#define LAUNCHER_FILE "MultiMCLauncher.jar" - LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent) @@ -61,7 +59,7 @@ MinecraftProcess *LegacyInstance::prepareForLaunch(MojangAccountPtr account) pixmap.save(PathCombine(minecraftRoot(), "icon.png"), "PNG"); // extract the legacy launcher - QFile(":/java/launcher.jar").copy(PathCombine(minecraftRoot(), LAUNCHER_FILE)); + QString launcherJar = PathCombine(MMC->bin(), "jars", "MultiMCLauncher.jar"); // set the process arguments { @@ -104,7 +102,7 @@ MinecraftProcess *LegacyInstance::prepareForLaunch(MojangAccountPtr account) "minecraft.exe.heapdump"); #endif - args << "-jar" << LAUNCHER_FILE; + args << "-jar" << launcherJar; args << account->currentProfile()->name; args << account->sessionId(); args << windowTitle; diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp index e8c5acd0..eb1c5650 100644 --- a/logic/lists/JavaVersionList.cpp +++ b/logic/lists/JavaVersionList.cpp @@ -182,13 +182,17 @@ void JavaListLoadTask::executeTask() connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int))); QLOG_DEBUG() << "Probing the following Java paths: "; + int id = 0; for(QString candidate : candidate_paths) { QLOG_DEBUG() << " " << candidate; auto candidate_checker = new JavaChecker(); candidate_checker->path = candidate; + candidate_checker->id = id; m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker)); + + id++; } m_job->start(); diff --git a/logic/updater/NotificationChecker.cpp b/logic/updater/NotificationChecker.cpp index 40367eac..b2d67632 100644 --- a/logic/updater/NotificationChecker.cpp +++ b/logic/updater/NotificationChecker.cpp @@ -5,8 +5,8 @@ #include <QJsonArray> #include "MultiMC.h" +#include "MultiMCVersion.h" #include "logic/net/CacheDownload.h" -#include "config.h" NotificationChecker::NotificationChecker(QObject *parent) : QObject(parent), m_notificationsUrl(QUrl(NOTIFICATION_URL)) @@ -66,7 +66,7 @@ void NotificationChecker::downloadSucceeded(int) entry.id = obj.value("id").toDouble(); entry.message = obj.value("message").toString(); entry.channel = obj.value("channel").toString(); - entry.buildtype = obj.value("buildtype").toString(); + entry.platform = obj.value("platform").toString(); entry.from = obj.value("from").toString(); entry.to = obj.value("to").toString(); const QString type = obj.value("type").toString("critical"); @@ -93,13 +93,14 @@ void NotificationChecker::downloadSucceeded(int) bool NotificationChecker::NotificationEntry::applies() const { - bool channelApplies = channel.isEmpty() || channel == VERSION_CHANNEL; - bool buildtypeApplies = buildtype.isEmpty() || buildtype == VERSION_BUILD_TYPE; + MultiMCVersion version = MMC->version(); + bool channelApplies = channel.isEmpty() || channel == version.channel; + bool platformApplies = platform.isEmpty() || platform == version.platform; bool fromApplies = from.isEmpty() || from == FULL_VERSION_STR || !versionLessThan(FULL_VERSION_STR, from); bool toApplies = to.isEmpty() || to == FULL_VERSION_STR || !versionLessThan(to, FULL_VERSION_STR); - return channelApplies && buildtypeApplies && fromApplies && toApplies; + return channelApplies && platformApplies && fromApplies && toApplies; } bool NotificationChecker::NotificationEntry::versionLessThan(const QString &v1, diff --git a/logic/updater/NotificationChecker.h b/logic/updater/NotificationChecker.h index 20541757..915ee54d 100644 --- a/logic/updater/NotificationChecker.h +++ b/logic/updater/NotificationChecker.h @@ -26,7 +26,7 @@ public: Information } type; QString channel; - QString buildtype; + QString platform; QString from; QString to; bool applies() const; diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp index 489e7769..8a280dd1 100644 --- a/logic/updater/UpdateChecker.cpp +++ b/logic/updater/UpdateChecker.cpp @@ -142,8 +142,6 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate) if (newestVersion.value("Id").toVariant().toInt() < version.value("Id").toVariant().toInt()) { - QLOG_DEBUG() << "Found newer version with ID" - << version.value("Id").toVariant().toInt(); newestVersion = version; } } @@ -153,6 +151,7 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate) int newBuildNumber = newestVersion.value("Id").toVariant().toInt(); if (newBuildNumber != MMC->version().build) { + QLOG_DEBUG() << "Found newer version with ID" << newBuildNumber; // Update! emit updateAvailable(m_repoUrl, newestVersion.value("Name").toVariant().toString(), newBuildNumber); @@ -262,3 +261,4 @@ void UpdateChecker::chanListDownloadFailed() QLOG_ERROR() << "Failed to download channel list."; emit channelListLoaded(); } + |