summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-09 12:06:33 -0600
committerAndrew <forkk@forkk.net>2013-12-09 12:06:33 -0600
commit712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d (patch)
tree3a525b7e4488a7ea03521ddff33800ef81f92f07 /logic
parent7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c (diff)
parentb0dbd4f4afcf60e4021cbb3218bfe280c4989859 (diff)
downloadMultiMC-712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d.tar
MultiMC-712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d.tar.gz
MultiMC-712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d.tar.lz
MultiMC-712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d.tar.xz
MultiMC-712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d.zip
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.h2
-rw-r--r--logic/LegacyInstance.cpp4
-rw-r--r--logic/LegacyInstance.h2
-rw-r--r--logic/LegacyUpdate.cpp22
-rw-r--r--logic/LegacyUpdate.h4
-rw-r--r--logic/OneSixInstance.cpp4
-rw-r--r--logic/OneSixInstance.h2
-rw-r--r--logic/OneSixUpdate.cpp54
-rw-r--r--logic/OneSixUpdate.h7
-rw-r--r--logic/auth/MojangAccount.h4
-rw-r--r--logic/auth/YggdrasilTask.cpp4
11 files changed, 77 insertions, 32 deletions
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index 603f6105..93e57414 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -150,7 +150,7 @@ public:
virtual SettingsObject &settings() const;
/// returns a valid update task if update is needed, NULL otherwise
- virtual std::shared_ptr<Task> doUpdate(bool prepare_for_launch) = 0;
+ virtual std::shared_ptr<Task> doUpdate(bool only_prepare) = 0;
/// returns a valid minecraft process, ready for launch with the given account.
virtual MinecraftProcess *prepareForLaunch(MojangAccountPtr account) = 0;
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 55523048..fef27bcd 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -44,12 +44,12 @@ LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
settings->registerSetting(new Setting("IntendedJarVersion", ""));
}
-std::shared_ptr<Task> LegacyInstance::doUpdate(bool prepare_for_launch)
+std::shared_ptr<Task> LegacyInstance::doUpdate(bool only_prepare)
{
// make sure the jar mods list is initialized by asking for it.
auto list = jarModList();
// create an update task
- return std::shared_ptr<Task> (new LegacyUpdate(this, prepare_for_launch , this));
+ return std::shared_ptr<Task> (new LegacyUpdate(this, only_prepare , this));
}
MinecraftProcess *LegacyInstance::prepareForLaunch(MojangAccountPtr account)
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 948d4be4..1e7d9eb6 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -76,7 +76,7 @@ public:
virtual bool shouldUpdate() const override;
virtual void setShouldUpdate(bool val) override;
- virtual std::shared_ptr<Task> doUpdate(bool prepare_for_launch) override;
+ virtual std::shared_ptr<Task> doUpdate(bool only_prepare) override;
virtual MinecraftProcess *prepareForLaunch(MojangAccountPtr account) override;
virtual void cleanupAfterRun() override;
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index 3fc17351..6125101b 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -26,14 +26,30 @@
#include <JlCompress.h>
#include "logger/QsLog.h"
-LegacyUpdate::LegacyUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent)
- : Task(parent), m_inst(inst), m_prepare_for_launch(prepare_for_launch)
+LegacyUpdate::LegacyUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
+ : Task(parent), m_inst(inst), m_only_prepare(only_prepare)
{
}
void LegacyUpdate::executeTask()
{
- lwjglStart();
+ if(m_only_prepare)
+ {
+ // FIXME: think this through some more.
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+ if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
+ {
+ ModTheJar();
+ }
+ else
+ {
+ emitSucceeded();
+ }
+ }
+ else
+ {
+ lwjglStart();
+ }
}
void LegacyUpdate::lwjglStart()
diff --git a/logic/LegacyUpdate.h b/logic/LegacyUpdate.h
index d753197f..0b573ca5 100644
--- a/logic/LegacyUpdate.h
+++ b/logic/LegacyUpdate.h
@@ -31,7 +31,7 @@ class LegacyUpdate : public Task
{
Q_OBJECT
public:
- explicit LegacyUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent = 0);
+ explicit LegacyUpdate(BaseInstance *inst, bool only_prepare, QObject *parent = 0);
virtual void executeTask();
private
@@ -72,5 +72,5 @@ private:
private:
NetJobPtr legacyDownloadJob;
BaseInstance *m_inst = nullptr;
- bool m_prepare_for_launch = false;
+ bool m_only_prepare = false;
};
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 7a1d7dad..b18dd2ba 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -37,9 +37,9 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_o
reloadFullVersion();
}
-std::shared_ptr<Task> OneSixInstance::doUpdate(bool prepare_for_launch)
+std::shared_ptr<Task> OneSixInstance::doUpdate(bool only_prepare)
{
- return std::shared_ptr<Task> (new OneSixUpdate(this, prepare_for_launch));
+ return std::shared_ptr<Task> (new OneSixUpdate(this, only_prepare));
}
QString replaceTokensIn(QString text, QMap<QString, QString> with)
diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h
index 7ea2d08b..cdfdf324 100644
--- a/logic/OneSixInstance.h
+++ b/logic/OneSixInstance.h
@@ -39,7 +39,7 @@ public:
QString loaderModsDir() const;
virtual QString instanceConfigFolder() const override;
- virtual std::shared_ptr<Task> doUpdate(bool prepare_for_launch) override;
+ virtual std::shared_ptr<Task> doUpdate(bool only_prepare) override;
virtual MinecraftProcess *prepareForLaunch(MojangAccountPtr account) override;
virtual void cleanupAfterRun() override;
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 25e16328..7be0c056 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -33,8 +33,8 @@
#include "pathutils.h"
#include <JlCompress.h>
-OneSixUpdate::OneSixUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent)
- : Task(parent), m_inst(inst), m_prepare_for_launch(prepare_for_launch)
+OneSixUpdate::OneSixUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
+ : Task(parent), m_inst(inst), m_only_prepare(only_prepare)
{
}
@@ -50,6 +50,23 @@ void OneSixUpdate::executeTask()
return;
}
+ if(m_only_prepare)
+ {
+ if (m_inst->shouldUpdate())
+ {
+ emitFailed("Unable to update instance in offline mode.");
+ return;
+ }
+ setStatus("Testing the Java installation.");
+ QString java_path = m_inst->settings().get("JavaPath").toString();
+
+ checker.reset(new JavaChecker());
+ connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
+ SLOT(checkFinishedOffline(JavaCheckResult)));
+ checker->performCheck(java_path);
+ return;
+ }
+
if (m_inst->shouldUpdate())
{
// Get a pointer to the version object that corresponds to the instance's version.
@@ -65,35 +82,43 @@ void OneSixUpdate::executeTask()
}
else
{
- checkJava();
+ checkJavaOnline();
}
}
-void OneSixUpdate::checkJava()
+void OneSixUpdate::checkJavaOnline()
{
- QLOG_INFO() << m_inst->name() << ": checking java binary";
setStatus("Testing the Java installation.");
- // TODO: cache this so we don't have to run an extra java process every time.
QString java_path = m_inst->settings().get("JavaPath").toString();
checker.reset(new JavaChecker());
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
- SLOT(checkFinished(JavaCheckResult)));
+ SLOT(checkFinishedOnline(JavaCheckResult)));
checker->performCheck(java_path);
}
-void OneSixUpdate::checkFinished(JavaCheckResult result)
+void OneSixUpdate::checkFinishedOnline(JavaCheckResult result)
{
if (result.valid)
{
- QLOG_INFO() << m_inst->name() << ": java is "
- << (result.is_64bit ? "64 bit" : "32 bit");
java_is_64bit = result.is_64bit;
jarlibStart();
}
else
{
- QLOG_INFO() << m_inst->name() << ": java isn't valid";
+ emitFailed("The java binary doesn't work. Check the settings and correct the problem");
+ }
+}
+
+void OneSixUpdate::checkFinishedOffline(JavaCheckResult result)
+{
+ if (result.valid)
+ {
+ java_is_64bit = result.is_64bit;
+ prepareForLaunch();
+ }
+ else
+ {
emitFailed("The java binary doesn't work. Check the settings and correct the problem");
}
}
@@ -160,7 +185,7 @@ void OneSixUpdate::versionFileFinished()
}
inst->reloadFullVersion();
- checkJava();
+ checkJavaOnline();
}
void OneSixUpdate::versionFileFailed()
@@ -240,10 +265,7 @@ void OneSixUpdate::jarlibStart()
void OneSixUpdate::jarlibFinished()
{
- if (m_prepare_for_launch)
- prepareForLaunch();
- else
- emitSucceeded();
+ prepareForLaunch();
}
void OneSixUpdate::jarlibFailed()
diff --git a/logic/OneSixUpdate.h b/logic/OneSixUpdate.h
index 5fd2c59f..7ff9d881 100644
--- a/logic/OneSixUpdate.h
+++ b/logic/OneSixUpdate.h
@@ -43,8 +43,9 @@ slots:
void jarlibFinished();
void jarlibFailed();
- void checkJava();
- void checkFinished(JavaCheckResult result);
+ void checkJavaOnline();
+ void checkFinishedOnline(JavaCheckResult result);
+ void checkFinishedOffline(JavaCheckResult result);
// extract the appropriate libraries
void prepareForLaunch();
@@ -56,7 +57,7 @@ private:
// target version, determined during this task
std::shared_ptr<MinecraftVersion> targetVersion;
BaseInstance *m_inst = nullptr;
- bool m_prepare_for_launch = false;
+ bool m_only_prepare = false;
std::shared_ptr<JavaChecker> checker;
bool java_is_64bit = false;
diff --git a/logic/auth/MojangAccount.h b/logic/auth/MojangAccount.h
index 8c44ce58..95f777ce 100644
--- a/logic/auth/MojangAccount.h
+++ b/logic/auth/MojangAccount.h
@@ -97,6 +97,10 @@ public: /* manipulation */
*/
std::shared_ptr<Task> login(QString password = QString());
+ void downgrade()
+ {
+ m_online = false;
+ }
public: /* queries */
const QString &username() const
{
diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp
index 6b938ea7..45155058 100644
--- a/logic/auth/YggdrasilTask.cpp
+++ b/logic/auth/YggdrasilTask.cpp
@@ -78,7 +78,9 @@ void YggdrasilTask::processReply()
{
setStatus(getStateMessage(STATE_PROCESSING_RESPONSE));
- if (m_netReply->error() == QNetworkReply::OperationCanceledError)
+ // any network errors lead to offline mode right now
+ if (m_netReply->error() >= QNetworkReply::ConnectionRefusedError &&
+ m_netReply->error() <= QNetworkReply::UnknownNetworkError)
{
// WARNING/FIXME: the value here is used in MojangAccount to detect the cancel/timeout
emitFailed("Yggdrasil task cancelled.");