summaryrefslogtreecommitdiffstats
path: root/api/logic/launch/steps
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/launch/steps')
-rw-r--r--api/logic/launch/steps/PostLaunchCommand.cpp96
-rw-r--r--api/logic/launch/steps/PostLaunchCommand.h28
-rw-r--r--api/logic/launch/steps/PreLaunchCommand.cpp98
-rw-r--r--api/logic/launch/steps/PreLaunchCommand.h28
-rw-r--r--api/logic/launch/steps/TextPrint.cpp18
-rw-r--r--api/logic/launch/steps/TextPrint.h20
-rw-r--r--api/logic/launch/steps/Update.cpp86
-rw-r--r--api/logic/launch/steps/Update.h24
8 files changed, 201 insertions, 197 deletions
diff --git a/api/logic/launch/steps/PostLaunchCommand.cpp b/api/logic/launch/steps/PostLaunchCommand.cpp
index bc3b3ffe..e0b2b6fc 100644
--- a/api/logic/launch/steps/PostLaunchCommand.cpp
+++ b/api/logic/launch/steps/PostLaunchCommand.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,67 +18,67 @@
PostLaunchCommand::PostLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
{
- auto instance = m_parent->instance();
- m_command = instance->getPostExitCommand();
- m_process.setProcessEnvironment(instance->createEnvironment());
- connect(&m_process, &LoggedProcess::log, this, &PostLaunchCommand::logLines);
- connect(&m_process, &LoggedProcess::stateChanged, this, &PostLaunchCommand::on_state);
+ auto instance = m_parent->instance();
+ m_command = instance->getPostExitCommand();
+ m_process.setProcessEnvironment(instance->createEnvironment());
+ connect(&m_process, &LoggedProcess::log, this, &PostLaunchCommand::logLines);
+ connect(&m_process, &LoggedProcess::stateChanged, this, &PostLaunchCommand::on_state);
}
void PostLaunchCommand::executeTask()
{
- QString postlaunch_cmd = m_parent->substituteVariables(m_command);
- emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::MultiMC);
- m_process.start(postlaunch_cmd);
+ QString postlaunch_cmd = m_parent->substituteVariables(m_command);
+ emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::MultiMC);
+ m_process.start(postlaunch_cmd);
}
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)
- {
- case LoggedProcess::Aborted:
- case LoggedProcess::Crashed:
- case LoggedProcess::FailedToStart:
- {
- auto error = getError();
- emit logLine(error, MessageLevel::Fatal);
- emitFailed(error);
- return;
- }
- case LoggedProcess::Finished:
- {
- if(m_process.exitCode() != 0)
- {
- auto error = getError();
- emit logLine(error, MessageLevel::Fatal);
- emitFailed(error);
- }
- else
- {
- emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::MultiMC);
- emitSucceeded();
- }
- }
- default:
- break;
- }
+ 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:
+ {
+ auto error = getError();
+ emit logLine(error, MessageLevel::Fatal);
+ emitFailed(error);
+ return;
+ }
+ case LoggedProcess::Finished:
+ {
+ if(m_process.exitCode() != 0)
+ {
+ auto error = getError();
+ emit logLine(error, MessageLevel::Fatal);
+ emitFailed(error);
+ }
+ else
+ {
+ emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::MultiMC);
+ emitSucceeded();
+ }
+ }
+ default:
+ break;
+ }
}
void PostLaunchCommand::setWorkingDirectory(const QString &wd)
{
- m_process.setWorkingDirectory(wd);
+ m_process.setWorkingDirectory(wd);
}
bool PostLaunchCommand::abort()
{
- auto state = m_process.state();
- if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
- {
- m_process.kill();
- }
- return true;
+ auto state = m_process.state();
+ if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
+ {
+ m_process.kill();
+ }
+ return true;
}
diff --git a/api/logic/launch/steps/PostLaunchCommand.h b/api/logic/launch/steps/PostLaunchCommand.h
index 36b3b96f..da200534 100644
--- a/api/logic/launch/steps/PostLaunchCommand.h
+++ b/api/logic/launch/steps/PostLaunchCommand.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +20,22 @@
class PostLaunchCommand: public LaunchStep
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit PostLaunchCommand(LaunchTask *parent);
- virtual void executeTask();
- virtual bool abort();
- virtual bool canAbort() const
- {
- return true;
- }
- void setWorkingDirectory(const QString &wd);
+ 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:
- void on_state(LoggedProcess::State state);
+ void on_state(LoggedProcess::State state);
private:
- LoggedProcess m_process;
- QString m_command;
+ LoggedProcess m_process;
+ QString m_command;
};
diff --git a/api/logic/launch/steps/PreLaunchCommand.cpp b/api/logic/launch/steps/PreLaunchCommand.cpp
index 7c37d5cb..6f1f280d 100644
--- a/api/logic/launch/steps/PreLaunchCommand.cpp
+++ b/api/logic/launch/steps/PreLaunchCommand.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,68 +18,68 @@
PreLaunchCommand::PreLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
{
- auto instance = m_parent->instance();
- m_command = instance->getPreLaunchCommand();
- m_process.setProcessEnvironment(instance->createEnvironment());
- connect(&m_process, &LoggedProcess::log, this, &PreLaunchCommand::logLines);
- connect(&m_process, &LoggedProcess::stateChanged, this, &PreLaunchCommand::on_state);
+ auto instance = m_parent->instance();
+ m_command = instance->getPreLaunchCommand();
+ m_process.setProcessEnvironment(instance->createEnvironment());
+ connect(&m_process, &LoggedProcess::log, this, &PreLaunchCommand::logLines);
+ connect(&m_process, &LoggedProcess::stateChanged, this, &PreLaunchCommand::on_state);
}
void PreLaunchCommand::executeTask()
{
- //FIXME: where to put this?
- QString prelaunch_cmd = m_parent->substituteVariables(m_command);
- emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::MultiMC);
- m_process.start(prelaunch_cmd);
+ //FIXME: where to put this?
+ QString prelaunch_cmd = m_parent->substituteVariables(m_command);
+ emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::MultiMC);
+ m_process.start(prelaunch_cmd);
}
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)
- {
- case LoggedProcess::Aborted:
- case LoggedProcess::Crashed:
- case LoggedProcess::FailedToStart:
- {
- auto error = getError();
- emit logLine(error, MessageLevel::Fatal);
- emitFailed(error);
- return;
- }
- case LoggedProcess::Finished:
- {
- if(m_process.exitCode() != 0)
- {
- auto error = getError();
- emit logLine(error, MessageLevel::Fatal);
- emitFailed(error);
- }
- else
- {
- emit logLine(tr("Pre-Launch command ran successfully.\n\n"), MessageLevel::MultiMC);
- emitSucceeded();
- }
- }
- default:
- break;
- }
+ 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:
+ {
+ auto error = getError();
+ emit logLine(error, MessageLevel::Fatal);
+ emitFailed(error);
+ return;
+ }
+ case LoggedProcess::Finished:
+ {
+ if(m_process.exitCode() != 0)
+ {
+ auto error = getError();
+ emit logLine(error, MessageLevel::Fatal);
+ emitFailed(error);
+ }
+ else
+ {
+ emit logLine(tr("Pre-Launch command ran successfully.\n\n"), MessageLevel::MultiMC);
+ emitSucceeded();
+ }
+ }
+ default:
+ break;
+ }
}
void PreLaunchCommand::setWorkingDirectory(const QString &wd)
{
- m_process.setWorkingDirectory(wd);
+ m_process.setWorkingDirectory(wd);
}
bool PreLaunchCommand::abort()
{
- auto state = m_process.state();
- if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
- {
- m_process.kill();
- }
- return true;
+ auto state = m_process.state();
+ if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
+ {
+ m_process.kill();
+ }
+ return true;
}
diff --git a/api/logic/launch/steps/PreLaunchCommand.h b/api/logic/launch/steps/PreLaunchCommand.h
index 880cc076..f1e9db5d 100644
--- a/api/logic/launch/steps/PreLaunchCommand.h
+++ b/api/logic/launch/steps/PreLaunchCommand.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +20,22 @@
class PreLaunchCommand: public LaunchStep
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit PreLaunchCommand(LaunchTask *parent);
- virtual void executeTask();
- virtual bool abort();
- virtual bool canAbort() const
- {
- return true;
- }
- void setWorkingDirectory(const QString &wd);
+ 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:
- void on_state(LoggedProcess::State state);
+ void on_state(LoggedProcess::State state);
private:
- LoggedProcess m_process;
- QString m_command;
+ LoggedProcess m_process;
+ QString m_command;
};
diff --git a/api/logic/launch/steps/TextPrint.cpp b/api/logic/launch/steps/TextPrint.cpp
index f307b1fd..0c1f320c 100644
--- a/api/logic/launch/steps/TextPrint.cpp
+++ b/api/logic/launch/steps/TextPrint.cpp
@@ -2,28 +2,28 @@
TextPrint::TextPrint(LaunchTask * parent, const QStringList &lines, MessageLevel::Enum level) : LaunchStep(parent)
{
- m_lines = lines;
- m_level = level;
+ m_lines = lines;
+ m_level = level;
}
TextPrint::TextPrint(LaunchTask *parent, const QString &line, MessageLevel::Enum level) : LaunchStep(parent)
{
- m_lines.append(line);
- m_level = level;
+ m_lines.append(line);
+ m_level = level;
}
void TextPrint::executeTask()
{
- emit logLines(m_lines, m_level);
- emitSucceeded();
+ emit logLines(m_lines, m_level);
+ emitSucceeded();
}
bool TextPrint::canAbort() const
{
- return true;
+ return true;
}
bool TextPrint::abort()
{
- emitFailed("Aborted.");
- return true;
+ emitFailed("Aborted.");
+ return true;
}
diff --git a/api/logic/launch/steps/TextPrint.h b/api/logic/launch/steps/TextPrint.h
index 3e3e06cb..099fdc13 100644
--- a/api/logic/launch/steps/TextPrint.h
+++ b/api/logic/launch/steps/TextPrint.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,17 +27,17 @@
class MULTIMC_LOGIC_EXPORT TextPrint: public LaunchStep
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit TextPrint(LaunchTask *parent, const QStringList &lines, MessageLevel::Enum level);
- explicit TextPrint(LaunchTask *parent, const QString &line, MessageLevel::Enum level);
- virtual ~TextPrint(){};
+ 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();
+ virtual void executeTask();
+ virtual bool canAbort() const;
+ virtual bool abort();
private:
- QStringList m_lines;
- MessageLevel::Enum m_level;
+ QStringList m_lines;
+ MessageLevel::Enum m_level;
};
diff --git a/api/logic/launch/steps/Update.cpp b/api/logic/launch/steps/Update.cpp
index d057febb..6eb012f7 100644
--- a/api/logic/launch/steps/Update.cpp
+++ b/api/logic/launch/steps/Update.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,63 +18,63 @@
void Update::executeTask()
{
- if(m_aborted)
- {
- emitFailed(tr("Task aborted."));
- return;
- }
- m_updateTask.reset(m_parent->instance()->createUpdateTask(m_mode));
- if(m_updateTask)
- {
- connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
- connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
- connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
- emit progressReportingRequest();
- return;
- }
- emitSucceeded();
+ if(m_aborted)
+ {
+ emitFailed(tr("Task aborted."));
+ return;
+ }
+ m_updateTask.reset(m_parent->instance()->createUpdateTask(m_mode));
+ if(m_updateTask)
+ {
+ connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
+ connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
+ connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
+ emit progressReportingRequest();
+ return;
+ }
+ emitSucceeded();
}
void Update::proceed()
{
- m_updateTask->start();
+ m_updateTask->start();
}
void Update::updateFinished()
{
- if(m_updateTask->wasSuccessful())
- {
- m_updateTask.reset();
- emitSucceeded();
- }
- else
- {
- QString reason = tr("Instance update failed because: %1.\n\n").arg(m_updateTask->failReason());
- m_updateTask.reset();
- emit logLine(reason, MessageLevel::Fatal);
- emitFailed(reason);
- }
+ if(m_updateTask->wasSuccessful())
+ {
+ m_updateTask.reset();
+ emitSucceeded();
+ }
+ else
+ {
+ QString reason = tr("Instance update failed because: %1\n\n").arg(m_updateTask->failReason());
+ m_updateTask.reset();
+ emit logLine(reason, MessageLevel::Fatal);
+ emitFailed(reason);
+ }
}
bool Update::canAbort() const
{
- if(m_updateTask)
- {
- return m_updateTask->canAbort();
- }
- return true;
+ if(m_updateTask)
+ {
+ return m_updateTask->canAbort();
+ }
+ return true;
}
bool Update::abort()
{
- m_aborted = true;
- if(m_updateTask)
- {
- if(m_updateTask->canAbort())
- {
- return m_updateTask->abort();
- }
- }
- return true;
+ m_aborted = true;
+ if(m_updateTask)
+ {
+ if(m_updateTask->canAbort())
+ {
+ return m_updateTask->abort();
+ }
+ }
+ return true;
}
diff --git a/api/logic/launch/steps/Update.h b/api/logic/launch/steps/Update.h
index 7a14011a..331698bd 100644
--- a/api/logic/launch/steps/Update.h
+++ b/api/logic/launch/steps/Update.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2018 MultiMC Contributors
+/* Copyright 2013-2019 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,22 +24,22 @@
// FIXME: stupid. should be defined by the instance type? or even completely abstracted away...
class Update: public LaunchStep
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit Update(LaunchTask *parent, Net::Mode mode):LaunchStep(parent), m_mode(mode) {};
- virtual ~Update() {};
+ explicit Update(LaunchTask *parent, Net::Mode mode):LaunchStep(parent), m_mode(mode) {};
+ virtual ~Update() {};
- void executeTask() override;
- bool canAbort() const override;
- void proceed() override;
+ void executeTask() override;
+ bool canAbort() const override;
+ void proceed() override;
public slots:
- bool abort() override;
+ bool abort() override;
private slots:
- void updateFinished();
+ void updateFinished();
private:
- shared_qobject_ptr<Task> m_updateTask;
- bool m_aborted = false;
- Net::Mode m_mode = Net::Mode::Offline;
+ shared_qobject_ptr<Task> m_updateTask;
+ bool m_aborted = false;
+ Net::Mode m_mode = Net::Mode::Offline;
};