@ -34,12 +34,12 @@
|
||||
*/
|
||||
|
||||
#include "CheckJava.h"
|
||||
#include "java/JavaUtils.h"
|
||||
#include <launch/LaunchTask.h>
|
||||
#include <FileSystem.h>
|
||||
#include <QStandardPaths>
|
||||
#include <QFileInfo>
|
||||
#include <launch/LaunchTask.h>
|
||||
#include <sys.h>
|
||||
#include <QFileInfo>
|
||||
#include <QStandardPaths>
|
||||
#include "java/JavaUtils.h"
|
||||
|
||||
void CheckJava::executeTask()
|
||||
{
|
||||
@ -49,32 +49,26 @@ void CheckJava::executeTask()
|
||||
bool perInstance = settings->get("OverrideJava").toBool() || settings->get("OverrideJavaLocation").toBool();
|
||||
|
||||
auto realJavaPath = QStandardPaths::findExecutable(m_javaPath);
|
||||
if (realJavaPath.isEmpty())
|
||||
{
|
||||
if (perInstance)
|
||||
{
|
||||
emit logLine(
|
||||
QString("The java binary \"%1\" couldn't be found. Please fix the java path "
|
||||
"override in the instance's settings or disable it.").arg(m_javaPath),
|
||||
MessageLevel::Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (realJavaPath.isEmpty()) {
|
||||
if (perInstance) {
|
||||
emit logLine(QString("The java binary \"%1\" couldn't be found. Please fix the java path "
|
||||
"override in the instance's settings or disable it.")
|
||||
.arg(m_javaPath),
|
||||
MessageLevel::Warning);
|
||||
} else {
|
||||
emit logLine(QString("The java binary \"%1\" couldn't be found. Please set up java in "
|
||||
"the settings.").arg(m_javaPath),
|
||||
"the settings.")
|
||||
.arg(m_javaPath),
|
||||
MessageLevel::Warning);
|
||||
}
|
||||
emitFailed(QString("Java path is not valid."));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::Launcher);
|
||||
}
|
||||
|
||||
if (JavaUtils::getJavaCheckPath().isEmpty())
|
||||
{
|
||||
const char *reason = QT_TR_NOOP("Java checker library could not be found. Please check your installation.");
|
||||
if (JavaUtils::getJavaCheckPath().isEmpty()) {
|
||||
const char* reason = QT_TR_NOOP("Java checker library could not be found. Please check your installation.");
|
||||
emit logLine(tr(reason), MessageLevel::Fatal);
|
||||
emitFailed(tr(reason));
|
||||
return;
|
||||
@ -94,19 +88,15 @@ void CheckJava::executeTask()
|
||||
m_javaSignature = hash.result().toHex();
|
||||
|
||||
// if timestamps are not the same, or something is missing, check!
|
||||
if (m_javaSignature != storedSignature || storedVersion.size() == 0
|
||||
|| storedArchitecture.size() == 0 || storedRealArchitecture.size() == 0
|
||||
|| storedVendor.size() == 0)
|
||||
{
|
||||
if (m_javaSignature != storedSignature || storedVersion.size() == 0 || storedArchitecture.size() == 0 ||
|
||||
storedRealArchitecture.size() == 0 || storedVendor.size() == 0) {
|
||||
m_JavaChecker.reset(new JavaChecker);
|
||||
emit logLine(QString("Checking Java version..."), MessageLevel::Launcher);
|
||||
connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished);
|
||||
m_JavaChecker->m_path = realJavaPath;
|
||||
m_JavaChecker->performCheck();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
auto verString = instance->settings()->get("JavaVersion").toString();
|
||||
auto archString = instance->settings()->get("JavaArchitecture").toString();
|
||||
auto realArchString = settings->get("JavaRealArchitecture").toString();
|
||||
@ -118,10 +108,8 @@ void CheckJava::executeTask()
|
||||
|
||||
void CheckJava::checkJavaFinished(JavaCheckResult result)
|
||||
{
|
||||
switch (result.validity)
|
||||
{
|
||||
case JavaCheckResult::Validity::Errored:
|
||||
{
|
||||
switch (result.validity) {
|
||||
case JavaCheckResult::Validity::Errored: {
|
||||
// Error message displayed if java can't start
|
||||
emit logLine(QString("Could not start java:"), MessageLevel::Error);
|
||||
emit logLines(result.errorLog.split('\n'), MessageLevel::Error);
|
||||
@ -129,16 +117,14 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
|
||||
emitFailed(QString("Could not start java!"));
|
||||
return;
|
||||
}
|
||||
case JavaCheckResult::Validity::ReturnedInvalidData:
|
||||
{
|
||||
case JavaCheckResult::Validity::ReturnedInvalidData: {
|
||||
emit logLine(QString("Java checker returned some invalid data we don't understand:"), MessageLevel::Error);
|
||||
emit logLines(result.outLog.split('\n'), MessageLevel::Warning);
|
||||
emit logLine("\nMinecraft might not start properly.", MessageLevel::Launcher);
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
case JavaCheckResult::Validity::Valid:
|
||||
{
|
||||
case JavaCheckResult::Validity::Valid: {
|
||||
auto instance = m_parent->instance();
|
||||
printJavaInfo(result.javaVersion.toString(), result.mojangPlatform, result.realPlatform, result.javaVendor);
|
||||
instance->settings()->set("JavaVersion", result.javaVersion.toString());
|
||||
@ -152,8 +138,9 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
|
||||
}
|
||||
}
|
||||
|
||||
void CheckJava::printJavaInfo(const QString& version, const QString& architecture, const QString& realArchitecture, const QString & vendor)
|
||||
void CheckJava::printJavaInfo(const QString& version, const QString& architecture, const QString& realArchitecture, const QString& vendor)
|
||||
{
|
||||
emit logLine(QString("Java is version %1, using %2 (%3) architecture, from %4.\n\n")
|
||||
.arg(version, architecture, realArchitecture, vendor), MessageLevel::Launcher);
|
||||
emit logLine(
|
||||
QString("Java is version %1, using %2 (%3) architecture, from %4.\n\n").arg(version, architecture, realArchitecture, vendor),
|
||||
MessageLevel::Launcher);
|
||||
}
|
||||
|
@ -15,30 +15,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <LoggedProcess.h>
|
||||
#include <java/JavaChecker.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
|
||||
class CheckJava: public LaunchStep
|
||||
{
|
||||
class CheckJava : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckJava(LaunchTask *parent) :LaunchStep(parent){};
|
||||
virtual ~CheckJava() {};
|
||||
public:
|
||||
explicit CheckJava(LaunchTask* parent) : LaunchStep(parent){};
|
||||
virtual ~CheckJava(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
private slots:
|
||||
virtual bool canAbort() const { return false; }
|
||||
private slots:
|
||||
void checkJavaFinished(JavaCheckResult result);
|
||||
|
||||
private:
|
||||
void printJavaInfo(const QString & version, const QString & architecture, const QString & realArchitecture, const QString & vendor);
|
||||
private:
|
||||
void printJavaInfo(const QString& version, const QString& architecture, const QString& realArchitecture, const QString& vendor);
|
||||
void printSystemInfo(bool javaIsKnown, bool javaIs64bit);
|
||||
|
||||
private:
|
||||
private:
|
||||
QString m_javaPath;
|
||||
QString m_javaSignature;
|
||||
JavaCheckerPtr m_JavaChecker;
|
||||
|
@ -13,20 +13,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "LookupServerAddress.h"
|
||||
|
||||
#include <launch/LaunchTask.h>
|
||||
|
||||
LookupServerAddress::LookupServerAddress(LaunchTask *parent) :
|
||||
LaunchStep(parent), m_dnsLookup(new QDnsLookup(this))
|
||||
LookupServerAddress::LookupServerAddress(LaunchTask* parent) : LaunchStep(parent), m_dnsLookup(new QDnsLookup(this))
|
||||
{
|
||||
connect(m_dnsLookup, &QDnsLookup::finished, this, &LookupServerAddress::on_dnsLookupFinished);
|
||||
|
||||
m_dnsLookup->setType(QDnsLookup::SRV);
|
||||
}
|
||||
|
||||
void LookupServerAddress::setLookupAddress(const QString &lookupAddress)
|
||||
void LookupServerAddress::setLookupAddress(const QString& lookupAddress)
|
||||
{
|
||||
m_lookupAddress = lookupAddress;
|
||||
m_dnsLookup->setName(QString("_minecraft._tcp.%1").arg(lookupAddress));
|
||||
@ -51,41 +49,40 @@ void LookupServerAddress::executeTask()
|
||||
|
||||
void LookupServerAddress::on_dnsLookupFinished()
|
||||
{
|
||||
if (isFinished())
|
||||
{
|
||||
if (isFinished()) {
|
||||
// Aborted
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_dnsLookup->error() != QDnsLookup::NoError)
|
||||
{
|
||||
if (m_dnsLookup->error() != QDnsLookup::NoError) {
|
||||
emit logLine(QString("Failed to resolve server address (this is NOT an error!) %1: %2\n")
|
||||
.arg(m_dnsLookup->name(), m_dnsLookup->errorString()), MessageLevel::Launcher);
|
||||
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||
.arg(m_dnsLookup->name(), m_dnsLookup->errorString()),
|
||||
MessageLevel::Launcher);
|
||||
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||
return;
|
||||
}
|
||||
|
||||
const auto records = m_dnsLookup->serviceRecords();
|
||||
if (records.empty())
|
||||
{
|
||||
emit logLine(
|
||||
QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n")
|
||||
.arg(m_dnsLookup->name()), MessageLevel::Warning);
|
||||
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||
if (records.empty()) {
|
||||
emit logLine(QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n")
|
||||
.arg(m_dnsLookup->name()),
|
||||
MessageLevel::Warning);
|
||||
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &firstRecord = records.at(0);
|
||||
const auto& firstRecord = records.at(0);
|
||||
quint16 port = firstRecord.port();
|
||||
|
||||
emit logLine(QString("Resolved server address %1 to %2 with port %3\n").arg(
|
||||
m_dnsLookup->name(), firstRecord.target(), QString::number(port)),MessageLevel::Launcher);
|
||||
emit logLine(
|
||||
QString("Resolved server address %1 to %2 with port %3\n").arg(m_dnsLookup->name(), firstRecord.target(), QString::number(port)),
|
||||
MessageLevel::Launcher);
|
||||
resolve(firstRecord.target(), port);
|
||||
}
|
||||
|
||||
void LookupServerAddress::resolve(const QString &address, quint16 port)
|
||||
void LookupServerAddress::resolve(const QString& address, quint16 port)
|
||||
{
|
||||
m_output->address = address;
|
||||
m_output->port = port;
|
||||
|
@ -15,35 +15,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <QObjectPtr.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <QDnsLookup>
|
||||
|
||||
#include "minecraft/launch/MinecraftServerTarget.h"
|
||||
|
||||
class LookupServerAddress: public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LookupServerAddress(LaunchTask *parent);
|
||||
virtual ~LookupServerAddress() {};
|
||||
class LookupServerAddress : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LookupServerAddress(LaunchTask* parent);
|
||||
virtual ~LookupServerAddress(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
virtual bool canAbort() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool canAbort() const { return true; }
|
||||
|
||||
void setLookupAddress(const QString &lookupAddress);
|
||||
void setLookupAddress(const QString& lookupAddress);
|
||||
void setOutputAddressPtr(MinecraftServerTargetPtr output);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void on_dnsLookupFinished();
|
||||
|
||||
private:
|
||||
void resolve(const QString &address, quint16 port);
|
||||
private:
|
||||
void resolve(const QString& address, quint16 port);
|
||||
|
||||
QDnsLookup *m_dnsLookup;
|
||||
QDnsLookup* m_dnsLookup;
|
||||
QString m_lookupAddress;
|
||||
MinecraftServerTargetPtr m_output;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "PostLaunchCommand.h"
|
||||
#include <launch/LaunchTask.h>
|
||||
|
||||
PostLaunchCommand::PostLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
PostLaunchCommand::PostLaunchCommand(LaunchTask* parent) : LaunchStep(parent)
|
||||
{
|
||||
auto instance = m_parent->instance();
|
||||
m_command = instance->getPostExitCommand();
|
||||
@ -47,7 +47,7 @@ PostLaunchCommand::PostLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
|
||||
void PostLaunchCommand::executeTask()
|
||||
{
|
||||
//FIXME: where to put this?
|
||||
// FIXME: where to put this?
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto args = QProcess::splitCommand(m_command);
|
||||
m_parent->substituteVariables(args);
|
||||
@ -65,31 +65,22 @@ void PostLaunchCommand::executeTask()
|
||||
|
||||
void PostLaunchCommand::on_state(LoggedProcess::State state)
|
||||
{
|
||||
auto getError = [&]()
|
||||
{
|
||||
return tr("Post-Launch command failed with code %1.\n\n").arg(m_process.exitCode());
|
||||
};
|
||||
switch(state)
|
||||
{
|
||||
auto getError = [&]() { return tr("Post-Launch command failed with code %1.\n\n").arg(m_process.exitCode()); };
|
||||
switch (state) {
|
||||
case LoggedProcess::Aborted:
|
||||
case LoggedProcess::Crashed:
|
||||
case LoggedProcess::FailedToStart:
|
||||
{
|
||||
case LoggedProcess::FailedToStart: {
|
||||
auto error = getError();
|
||||
emit logLine(error, MessageLevel::Fatal);
|
||||
emitFailed(error);
|
||||
return;
|
||||
}
|
||||
case LoggedProcess::Finished:
|
||||
{
|
||||
if(m_process.exitCode() != 0)
|
||||
{
|
||||
case LoggedProcess::Finished: {
|
||||
if (m_process.exitCode() != 0) {
|
||||
auto error = getError();
|
||||
emit logLine(error, MessageLevel::Fatal);
|
||||
emitFailed(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::Launcher);
|
||||
emitSucceeded();
|
||||
}
|
||||
@ -99,7 +90,7 @@ void PostLaunchCommand::on_state(LoggedProcess::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void PostLaunchCommand::setWorkingDirectory(const QString &wd)
|
||||
void PostLaunchCommand::setWorkingDirectory(const QString& wd)
|
||||
{
|
||||
m_process.setWorkingDirectory(wd);
|
||||
}
|
||||
@ -107,8 +98,7 @@ void PostLaunchCommand::setWorkingDirectory(const QString &wd)
|
||||
bool PostLaunchCommand::abort()
|
||||
{
|
||||
auto state = m_process.state();
|
||||
if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
|
||||
{
|
||||
if (state == LoggedProcess::Running || state == LoggedProcess::Starting) {
|
||||
m_process.kill();
|
||||
}
|
||||
return true;
|
||||
|
@ -15,27 +15,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <LoggedProcess.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
|
||||
class PostLaunchCommand: public LaunchStep
|
||||
{
|
||||
class PostLaunchCommand : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PostLaunchCommand(LaunchTask *parent);
|
||||
virtual ~PostLaunchCommand() {};
|
||||
public:
|
||||
explicit PostLaunchCommand(LaunchTask* parent);
|
||||
virtual ~PostLaunchCommand(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
virtual bool canAbort() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void setWorkingDirectory(const QString &wd);
|
||||
private slots:
|
||||
virtual bool canAbort() const { return true; }
|
||||
void setWorkingDirectory(const QString& wd);
|
||||
private slots:
|
||||
void on_state(LoggedProcess::State state);
|
||||
|
||||
private:
|
||||
private:
|
||||
LoggedProcess m_process;
|
||||
QString m_command;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "PreLaunchCommand.h"
|
||||
#include <launch/LaunchTask.h>
|
||||
|
||||
PreLaunchCommand::PreLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
PreLaunchCommand::PreLaunchCommand(LaunchTask* parent) : LaunchStep(parent)
|
||||
{
|
||||
auto instance = m_parent->instance();
|
||||
m_command = instance->getPreLaunchCommand();
|
||||
@ -47,7 +47,7 @@ PreLaunchCommand::PreLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
|
||||
void PreLaunchCommand::executeTask()
|
||||
{
|
||||
//FIXME: where to put this?
|
||||
// FIXME: where to put this?
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto args = QProcess::splitCommand(m_command);
|
||||
m_parent->substituteVariables(args);
|
||||
@ -65,31 +65,22 @@ void PreLaunchCommand::executeTask()
|
||||
|
||||
void PreLaunchCommand::on_state(LoggedProcess::State state)
|
||||
{
|
||||
auto getError = [&]()
|
||||
{
|
||||
return tr("Pre-Launch command failed with code %1.\n\n").arg(m_process.exitCode());
|
||||
};
|
||||
switch(state)
|
||||
{
|
||||
auto getError = [&]() { return tr("Pre-Launch command failed with code %1.\n\n").arg(m_process.exitCode()); };
|
||||
switch (state) {
|
||||
case LoggedProcess::Aborted:
|
||||
case LoggedProcess::Crashed:
|
||||
case LoggedProcess::FailedToStart:
|
||||
{
|
||||
case LoggedProcess::FailedToStart: {
|
||||
auto error = getError();
|
||||
emit logLine(error, MessageLevel::Fatal);
|
||||
emitFailed(error);
|
||||
return;
|
||||
}
|
||||
case LoggedProcess::Finished:
|
||||
{
|
||||
if(m_process.exitCode() != 0)
|
||||
{
|
||||
case LoggedProcess::Finished: {
|
||||
if (m_process.exitCode() != 0) {
|
||||
auto error = getError();
|
||||
emit logLine(error, MessageLevel::Fatal);
|
||||
emitFailed(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emit logLine(tr("Pre-Launch command ran successfully.\n\n"), MessageLevel::Launcher);
|
||||
emitSucceeded();
|
||||
}
|
||||
@ -99,7 +90,7 @@ void PreLaunchCommand::on_state(LoggedProcess::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void PreLaunchCommand::setWorkingDirectory(const QString &wd)
|
||||
void PreLaunchCommand::setWorkingDirectory(const QString& wd)
|
||||
{
|
||||
m_process.setWorkingDirectory(wd);
|
||||
}
|
||||
@ -107,8 +98,7 @@ void PreLaunchCommand::setWorkingDirectory(const QString &wd)
|
||||
bool PreLaunchCommand::abort()
|
||||
{
|
||||
auto state = m_process.state();
|
||||
if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
|
||||
{
|
||||
if (state == LoggedProcess::Running || state == LoggedProcess::Starting) {
|
||||
m_process.kill();
|
||||
}
|
||||
return true;
|
||||
|
@ -15,27 +15,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "launch/LaunchStep.h"
|
||||
#include "LoggedProcess.h"
|
||||
#include "launch/LaunchStep.h"
|
||||
|
||||
class PreLaunchCommand: public LaunchStep
|
||||
{
|
||||
class PreLaunchCommand : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PreLaunchCommand(LaunchTask *parent);
|
||||
virtual ~PreLaunchCommand() {};
|
||||
public:
|
||||
explicit PreLaunchCommand(LaunchTask* parent);
|
||||
virtual ~PreLaunchCommand(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
virtual bool canAbort() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void setWorkingDirectory(const QString &wd);
|
||||
private slots:
|
||||
virtual bool canAbort() const { return true; }
|
||||
void setWorkingDirectory(const QString& wd);
|
||||
private slots:
|
||||
void on_state(LoggedProcess::State state);
|
||||
|
||||
private:
|
||||
private:
|
||||
LoggedProcess m_process;
|
||||
QString m_command;
|
||||
};
|
||||
|
@ -20,16 +20,12 @@
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
|
||||
class QuitAfterGameStop: public LaunchStep
|
||||
{
|
||||
class QuitAfterGameStop : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QuitAfterGameStop(LaunchTask *parent) :LaunchStep(parent){};
|
||||
virtual ~QuitAfterGameStop() {};
|
||||
public:
|
||||
explicit QuitAfterGameStop(LaunchTask* parent) : LaunchStep(parent){};
|
||||
virtual ~QuitAfterGameStop(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool canAbort() const { return false; }
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "TextPrint.h"
|
||||
|
||||
TextPrint::TextPrint(LaunchTask * parent, const QStringList &lines, MessageLevel::Enum level) : LaunchStep(parent)
|
||||
TextPrint::TextPrint(LaunchTask* parent, const QStringList& lines, MessageLevel::Enum level) : LaunchStep(parent)
|
||||
{
|
||||
m_lines = lines;
|
||||
m_level = level;
|
||||
}
|
||||
TextPrint::TextPrint(LaunchTask *parent, const QString &line, MessageLevel::Enum level) : LaunchStep(parent)
|
||||
TextPrint::TextPrint(LaunchTask* parent, const QString& line, MessageLevel::Enum level) : LaunchStep(parent)
|
||||
{
|
||||
m_lines.append(line);
|
||||
m_level = level;
|
||||
|
@ -15,27 +15,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <LoggedProcess.h>
|
||||
#include <java/JavaChecker.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
|
||||
/*
|
||||
* FIXME: maybe do not export
|
||||
*/
|
||||
|
||||
class TextPrint: public LaunchStep
|
||||
{
|
||||
class TextPrint : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextPrint(LaunchTask *parent, const QStringList &lines, MessageLevel::Enum level);
|
||||
explicit TextPrint(LaunchTask *parent, const QString &line, MessageLevel::Enum level);
|
||||
public:
|
||||
explicit TextPrint(LaunchTask* parent, const QStringList& lines, MessageLevel::Enum level);
|
||||
explicit TextPrint(LaunchTask* parent, const QString& line, MessageLevel::Enum level);
|
||||
virtual ~TextPrint(){};
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool canAbort() const;
|
||||
virtual bool abort();
|
||||
|
||||
private:
|
||||
private:
|
||||
QStringList m_lines;
|
||||
MessageLevel::Enum m_level;
|
||||
};
|
||||
|
@ -18,14 +18,12 @@
|
||||
|
||||
void Update::executeTask()
|
||||
{
|
||||
if(m_aborted)
|
||||
{
|
||||
if (m_aborted) {
|
||||
emitFailed(tr("Task aborted."));
|
||||
return;
|
||||
}
|
||||
m_updateTask.reset(m_parent->instance()->createUpdateTask(m_mode));
|
||||
if(m_updateTask)
|
||||
{
|
||||
if (m_updateTask) {
|
||||
connect(m_updateTask.get(), &Task::finished, this, &Update::updateFinished);
|
||||
connect(m_updateTask.get(), &Task::progress, this, &Update::setProgress);
|
||||
connect(m_updateTask.get(), &Task::stepProgress, this, &Update::propagateStepProgress);
|
||||
@ -44,13 +42,10 @@ void Update::proceed()
|
||||
|
||||
void Update::updateFinished()
|
||||
{
|
||||
if(m_updateTask->wasSuccessful())
|
||||
{
|
||||
if (m_updateTask->wasSuccessful()) {
|
||||
m_updateTask.reset();
|
||||
emitSucceeded();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
QString reason = tr("Instance update failed because: %1\n\n").arg(m_updateTask->failReason());
|
||||
m_updateTask.reset();
|
||||
emit logLine(reason, MessageLevel::Fatal);
|
||||
@ -60,21 +55,17 @@ void Update::updateFinished()
|
||||
|
||||
bool Update::canAbort() const
|
||||
{
|
||||
if(m_updateTask)
|
||||
{
|
||||
if (m_updateTask) {
|
||||
return m_updateTask->canAbort();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Update::abort()
|
||||
{
|
||||
m_aborted = true;
|
||||
if(m_updateTask)
|
||||
{
|
||||
if(m_updateTask->canAbort())
|
||||
{
|
||||
if (m_updateTask) {
|
||||
if (m_updateTask->canAbort()) {
|
||||
return m_updateTask->abort();
|
||||
}
|
||||
}
|
||||
|
@ -15,30 +15,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <QObjectPtr.h>
|
||||
#include <LoggedProcess.h>
|
||||
#include <QObjectPtr.h>
|
||||
#include <java/JavaChecker.h>
|
||||
#include <launch/LaunchStep.h>
|
||||
#include <net/Mode.h>
|
||||
|
||||
// FIXME: stupid. should be defined by the instance type? or even completely abstracted away...
|
||||
class Update: public LaunchStep
|
||||
{
|
||||
class Update : public LaunchStep {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Update(LaunchTask *parent, Net::Mode mode):LaunchStep(parent), m_mode(mode) {};
|
||||
virtual ~Update() {};
|
||||
public:
|
||||
explicit Update(LaunchTask* parent, Net::Mode mode) : LaunchStep(parent), m_mode(mode){};
|
||||
virtual ~Update(){};
|
||||
|
||||
void executeTask() override;
|
||||
bool canAbort() const override;
|
||||
void proceed() override;
|
||||
public slots:
|
||||
public slots:
|
||||
bool abort() override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void updateFinished();
|
||||
|
||||
private:
|
||||
private:
|
||||
Task::Ptr m_updateTask;
|
||||
bool m_aborted = false;
|
||||
Net::Mode m_mode = Net::Mode::Offline;
|
||||
|
Reference in New Issue
Block a user