mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
refactor!!!: migrate from shared pointers
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
c64d871a28
commit
549405ab2f
199 changed files with 742 additions and 709 deletions
|
|
@ -911,7 +911,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
|
|
||||||
// Init page provider
|
// Init page provider
|
||||||
{
|
{
|
||||||
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
m_globalSettingsProvider = std::make_unique<GenericPageProvider>(tr("Settings"));
|
||||||
m_globalSettingsProvider->addPage<LauncherPage>();
|
m_globalSettingsProvider->addPage<LauncherPage>();
|
||||||
m_globalSettingsProvider->addPage<LanguagePage>();
|
m_globalSettingsProvider->addPage<LanguagePage>();
|
||||||
m_globalSettingsProvider->addPage<AppearancePage>();
|
m_globalSettingsProvider->addPage<AppearancePage>();
|
||||||
|
|
@ -992,7 +992,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
if (FS::checkProblemticPathJava(QDir(instDir))) {
|
if (FS::checkProblemticPathJava(QDir(instDir))) {
|
||||||
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems!";
|
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems!";
|
||||||
}
|
}
|
||||||
m_instances.reset(new InstanceList(m_settings, instDir, this));
|
m_instances.reset(new InstanceList(m_settings.get(), instDir, this));
|
||||||
connect(InstDirSetting.get(), &Setting::SettingChanged, m_instances.get(), &InstanceList::on_InstFolderChanged);
|
connect(InstDirSetting.get(), &Setting::SettingChanged, m_instances.get(), &InstanceList::on_InstFolderChanged);
|
||||||
qInfo() << "Loading Instances...";
|
qInfo() << "Loading Instances...";
|
||||||
m_instances->loadList();
|
m_instances->loadList();
|
||||||
|
|
@ -1038,12 +1038,12 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
m_profilers.insert("jvisualvm", std::shared_ptr<BaseProfilerFactory>(new JVisualVMFactory()));
|
m_profilers.insert("jvisualvm", std::shared_ptr<BaseProfilerFactory>(new JVisualVMFactory()));
|
||||||
m_profilers.insert("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
|
m_profilers.insert("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
|
||||||
for (auto profiler : m_profilers.values()) {
|
for (auto profiler : m_profilers.values()) {
|
||||||
profiler->registerSettings(m_settings);
|
profiler->registerSettings(m_settings.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the MCEdit thing... why is this here?
|
// Create the MCEdit thing... why is this here?
|
||||||
{
|
{
|
||||||
m_mcedit.reset(new MCEditTool(m_settings));
|
m_mcedit.reset(new MCEditTool(m_settings.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
|
@ -1469,7 +1469,7 @@ void Application::messageReceived(const QByteArray& message)
|
||||||
bool offline = received.args["offline_enabled"] == "true";
|
bool offline = received.args["offline_enabled"] == "true";
|
||||||
QString offlineName = received.args["offline_name"];
|
QString offlineName = received.args["offline_name"];
|
||||||
|
|
||||||
InstancePtr instance;
|
BaseInstance* instance;
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
instance = instances()->getInstanceById(id);
|
instance = instances()->getInstanceById(id);
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
|
|
@ -1503,17 +1503,17 @@ void Application::messageReceived(const QByteArray& message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TranslationsModel> Application::translations()
|
TranslationsModel* Application::translations()
|
||||||
{
|
{
|
||||||
return m_translations;
|
return m_translations.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<JavaInstallList> Application::javalist()
|
JavaInstallList* Application::javalist()
|
||||||
{
|
{
|
||||||
if (!m_javalist) {
|
if (!m_javalist) {
|
||||||
m_javalist.reset(new JavaInstallList());
|
m_javalist.reset(new JavaInstallList());
|
||||||
}
|
}
|
||||||
return m_javalist;
|
return m_javalist.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon Application::logo()
|
QIcon Application::logo()
|
||||||
|
|
@ -1532,7 +1532,7 @@ bool Application::openJsonEditor(const QString& filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::launch(InstancePtr instance,
|
bool Application::launch(BaseInstance* instance,
|
||||||
bool online,
|
bool online,
|
||||||
bool demo,
|
bool demo,
|
||||||
MinecraftTarget::Ptr targetToJoin,
|
MinecraftTarget::Ptr targetToJoin,
|
||||||
|
|
@ -1580,7 +1580,7 @@ bool Application::launch(InstancePtr instance,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::kill(InstancePtr instance)
|
bool Application::kill(BaseInstance* instance)
|
||||||
{
|
{
|
||||||
if (!instance->isRunning()) {
|
if (!instance->isRunning()) {
|
||||||
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
|
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
|
||||||
|
|
@ -1589,7 +1589,7 @@ bool Application::kill(InstancePtr instance)
|
||||||
QMutexLocker locker(&m_instanceExtrasMutex);
|
QMutexLocker locker(&m_instanceExtrasMutex);
|
||||||
auto& extras = m_instanceExtras[instance->id()];
|
auto& extras = m_instanceExtras[instance->id()];
|
||||||
// NOTE: copy of the shared pointer keeps it alive
|
// NOTE: copy of the shared pointer keeps it alive
|
||||||
auto controller = extras.controller;
|
auto& controller = extras.controller;
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
if (controller) {
|
if (controller) {
|
||||||
return controller->abort();
|
return controller->abort();
|
||||||
|
|
@ -1738,7 +1738,7 @@ ViewLogWindow* Application::showLogWindow()
|
||||||
return m_viewLogWindow;
|
return m_viewLogWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString page)
|
InstanceWindow* Application::showInstanceWindow(BaseInstance* instance, QString page)
|
||||||
{
|
{
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1850,22 +1850,22 @@ void Application::updateProxySettings(QString proxyTypeStr, QString addr, int po
|
||||||
qDebug() << proxyDesc;
|
qDebug() << proxyDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<HttpMetaCache> Application::metacache()
|
HttpMetaCache* Application::metacache()
|
||||||
{
|
{
|
||||||
return m_metacache;
|
return m_metacache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> Application::network()
|
QNetworkAccessManager* Application::network()
|
||||||
{
|
{
|
||||||
return m_network;
|
return m_network.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> Application::metadataIndex()
|
Meta::Index* Application::metadataIndex()
|
||||||
{
|
{
|
||||||
if (!m_metadataIndex) {
|
if (!m_metadataIndex) {
|
||||||
m_metadataIndex.reset(new Meta::Index());
|
m_metadataIndex.reset(new Meta::Index());
|
||||||
}
|
}
|
||||||
return m_metadataIndex;
|
return m_metadataIndex.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateCapabilities()
|
void Application::updateCapabilities()
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class Application : public QApplication {
|
||||||
|
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
|
|
||||||
std::shared_ptr<SettingsObject> settings() const { return m_settings; }
|
SettingsObject* settings() const { return m_settings.get(); }
|
||||||
|
|
||||||
qint64 timeSinceStart() const { return m_startTime.msecsTo(QDateTime::currentDateTime()); }
|
qint64 timeSinceStart() const { return m_startTime.msecsTo(QDateTime::currentDateTime()); }
|
||||||
|
|
||||||
|
|
@ -120,21 +120,21 @@ class Application : public QApplication {
|
||||||
|
|
||||||
ThemeManager* themeManager() { return m_themeManager.get(); }
|
ThemeManager* themeManager() { return m_themeManager.get(); }
|
||||||
|
|
||||||
shared_qobject_ptr<ExternalUpdater> updater() { return m_updater; }
|
ExternalUpdater* updater() { return m_updater.get(); }
|
||||||
|
|
||||||
void triggerUpdateCheck();
|
void triggerUpdateCheck();
|
||||||
|
|
||||||
std::shared_ptr<TranslationsModel> translations();
|
TranslationsModel* translations();
|
||||||
|
|
||||||
std::shared_ptr<JavaInstallList> javalist();
|
JavaInstallList* javalist();
|
||||||
|
|
||||||
std::shared_ptr<InstanceList> instances() const { return m_instances; }
|
InstanceList* instances() const { return m_instances.get(); }
|
||||||
|
|
||||||
std::shared_ptr<IconList> icons() const { return m_icons; }
|
IconList* icons() const { return m_icons.get(); }
|
||||||
|
|
||||||
MCEditTool* mcedit() const { return m_mcedit.get(); }
|
MCEditTool* mcedit() const { return m_mcedit.get(); }
|
||||||
|
|
||||||
shared_qobject_ptr<AccountList> accounts() const { return m_accounts; }
|
AccountList* accounts() const { return m_accounts.get(); }
|
||||||
|
|
||||||
Status status() const { return m_status; }
|
Status status() const { return m_status; }
|
||||||
|
|
||||||
|
|
@ -142,11 +142,11 @@ class Application : public QApplication {
|
||||||
|
|
||||||
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> network();
|
QNetworkAccessManager* network();
|
||||||
|
|
||||||
shared_qobject_ptr<HttpMetaCache> metacache();
|
HttpMetaCache* metacache();
|
||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> metadataIndex();
|
Meta::Index* metadataIndex();
|
||||||
|
|
||||||
void updateCapabilities();
|
void updateCapabilities();
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ class Application : public QApplication {
|
||||||
*/
|
*/
|
||||||
bool openJsonEditor(const QString& filename);
|
bool openJsonEditor(const QString& filename);
|
||||||
|
|
||||||
InstanceWindow* showInstanceWindow(InstancePtr instance, QString page = QString());
|
InstanceWindow* showInstanceWindow(BaseInstance* instance, QString page = QString());
|
||||||
MainWindow* showMainWindow(bool minimized = false);
|
MainWindow* showMainWindow(bool minimized = false);
|
||||||
ViewLogWindow* showLogWindow();
|
ViewLogWindow* showLogWindow();
|
||||||
|
|
||||||
|
|
@ -209,13 +209,13 @@ class Application : public QApplication {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool launch(InstancePtr instance,
|
bool launch(BaseInstance* instance,
|
||||||
bool online = true,
|
bool online = true,
|
||||||
bool demo = false,
|
bool demo = false,
|
||||||
MinecraftTarget::Ptr targetToJoin = nullptr,
|
MinecraftTarget::Ptr targetToJoin = nullptr,
|
||||||
MinecraftAccountPtr accountToUse = nullptr,
|
MinecraftAccountPtr accountToUse = nullptr,
|
||||||
const QString& offlineName = QString());
|
const QString& offlineName = QString());
|
||||||
bool kill(InstancePtr instance);
|
bool kill(BaseInstance* instance);
|
||||||
void closeCurrentWindow();
|
void closeCurrentWindow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
@ -238,23 +238,27 @@ class Application : public QApplication {
|
||||||
void subRunningInstance();
|
void subRunningInstance();
|
||||||
bool shouldExitNow() const;
|
bool shouldExitNow() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<QString, int> m_qsaveResources;
|
||||||
|
mutable QMutex m_qsaveResourcesMutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDateTime m_startTime;
|
QDateTime m_startTime;
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
std::unique_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
shared_qobject_ptr<ExternalUpdater> m_updater;
|
std::unique_ptr<ExternalUpdater> m_updater;
|
||||||
shared_qobject_ptr<AccountList> m_accounts;
|
std::unique_ptr<AccountList> m_accounts;
|
||||||
|
|
||||||
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
std::unique_ptr<HttpMetaCache> m_metacache;
|
||||||
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
std::unique_ptr<Meta::Index> m_metadataIndex;
|
||||||
|
|
||||||
std::shared_ptr<SettingsObject> m_settings;
|
std::unique_ptr<SettingsObject> m_settings;
|
||||||
std::shared_ptr<InstanceList> m_instances;
|
std::unique_ptr<InstanceList> m_instances;
|
||||||
std::shared_ptr<IconList> m_icons;
|
std::unique_ptr<IconList> m_icons;
|
||||||
std::shared_ptr<JavaInstallList> m_javalist;
|
std::unique_ptr<JavaInstallList> m_javalist;
|
||||||
std::shared_ptr<TranslationsModel> m_translations;
|
std::unique_ptr<TranslationsModel> m_translations;
|
||||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
std::unique_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||||
std::unique_ptr<MCEditTool> m_mcedit;
|
std::unique_ptr<MCEditTool> m_mcedit;
|
||||||
QSet<QString> m_features;
|
QSet<QString> m_features;
|
||||||
std::unique_ptr<ThemeManager> m_themeManager;
|
std::unique_ptr<ThemeManager> m_themeManager;
|
||||||
|
|
@ -279,7 +283,7 @@ class Application : public QApplication {
|
||||||
// FIXME: attach to instances instead.
|
// FIXME: attach to instances instead.
|
||||||
struct InstanceXtras {
|
struct InstanceXtras {
|
||||||
InstanceWindow* window = nullptr;
|
InstanceWindow* window = nullptr;
|
||||||
shared_qobject_ptr<LaunchController> controller;
|
std::unique_ptr<LaunchController> controller;
|
||||||
};
|
};
|
||||||
std::map<QString, InstanceXtras> m_instanceExtras;
|
std::map<QString, InstanceXtras> m_instanceExtras;
|
||||||
mutable QMutex m_instanceExtrasMutex;
|
mutable QMutex m_instanceExtrasMutex;
|
||||||
|
|
@ -313,14 +317,10 @@ class Application : public QApplication {
|
||||||
QList<QUrl> m_urlsToImport;
|
QList<QUrl> m_urlsToImport;
|
||||||
QString m_instanceIdToShowWindowOf;
|
QString m_instanceIdToShowWindowOf;
|
||||||
std::unique_ptr<QFile> logFile;
|
std::unique_ptr<QFile> logFile;
|
||||||
shared_qobject_ptr<LogModel> logModel;
|
std::unique_ptr<LogModel> logModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addQSavePath(QString);
|
void addQSavePath(QString);
|
||||||
void removeQSavePath(QString);
|
void removeQSavePath(QString);
|
||||||
bool checkQSavePath(QString);
|
bool checkQSavePath(QString);
|
||||||
|
|
||||||
private:
|
|
||||||
QHash<QString, int> m_qsaveResources;
|
|
||||||
mutable QMutex m_qsaveResourcesMutex;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
#include "launch/LaunchTask.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "settings/OverrideSetting.h"
|
#include "settings/OverrideSetting.h"
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
|
|
@ -53,7 +54,7 @@
|
||||||
#include "Commandline.h"
|
#include "Commandline.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
int getConsoleMaxLines(SettingsObjectPtr settings)
|
int getConsoleMaxLines(SettingsObject* settings)
|
||||||
{
|
{
|
||||||
auto lineSetting = settings->getSetting("ConsoleMaxLines");
|
auto lineSetting = settings->getSetting("ConsoleMaxLines");
|
||||||
bool conversionOk = false;
|
bool conversionOk = false;
|
||||||
|
|
@ -65,14 +66,14 @@ int getConsoleMaxLines(SettingsObjectPtr settings)
|
||||||
return maxLines;
|
return maxLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings)
|
bool shouldStopOnConsoleOverflow(SettingsObject* settings)
|
||||||
{
|
{
|
||||||
return settings->get("ConsoleOverflowStop").toBool();
|
return settings->get("ConsoleOverflowStop").toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir) : QObject()
|
BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir) : QObject()
|
||||||
{
|
{
|
||||||
m_settings = settings;
|
m_settings = std::move(settings);
|
||||||
m_global_settings = globalSettings;
|
m_global_settings = globalSettings;
|
||||||
m_rootDir = rootDir;
|
m_rootDir = rootDir;
|
||||||
|
|
||||||
|
|
@ -126,6 +127,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
|
||||||
m_settings->registerSetting("Profiler", "");
|
m_settings->registerSetting("Profiler", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseInstance::~BaseInstance() {}
|
||||||
|
|
||||||
QString BaseInstance::getPreLaunchCommand()
|
QString BaseInstance::getPreLaunchCommand()
|
||||||
{
|
{
|
||||||
return settings()->get("PreLaunchCommand").toString();
|
return settings()->get("PreLaunchCommand").toString();
|
||||||
|
|
@ -335,11 +338,11 @@ QString BaseInstance::instanceRoot() const
|
||||||
return m_rootDir;
|
return m_rootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsObjectPtr BaseInstance::settings()
|
SettingsObject* BaseInstance::settings()
|
||||||
{
|
{
|
||||||
loadSpecificSettings();
|
loadSpecificSettings();
|
||||||
|
|
||||||
return m_settings;
|
return m_settings.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseInstance::canLaunch() const
|
bool BaseInstance::canLaunch() const
|
||||||
|
|
@ -467,9 +470,9 @@ QStringList BaseInstance::extraArguments()
|
||||||
return Commandline::splitArgs(settings()->get("JvmArgs").toString());
|
return Commandline::splitArgs(settings()->get("JvmArgs").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<LaunchTask> BaseInstance::getLaunchTask()
|
LaunchTask* BaseInstance::getLaunchTask()
|
||||||
{
|
{
|
||||||
return m_launchProcess;
|
return m_launchProcess.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseInstance::updateRuntimeContext()
|
void BaseInstance::updateRuntimeContext()
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,6 @@ class Task;
|
||||||
class LaunchTask;
|
class LaunchTask;
|
||||||
class BaseInstance;
|
class BaseInstance;
|
||||||
|
|
||||||
// pointer for lazy people
|
|
||||||
using InstancePtr = std::shared_ptr<BaseInstance>;
|
|
||||||
|
|
||||||
/// Shortcut saving target representations
|
/// Shortcut saving target representations
|
||||||
enum class ShortcutTarget { Desktop, Applications, Other };
|
enum class ShortcutTarget { Desktop, Applications, Other };
|
||||||
|
|
||||||
|
|
@ -78,8 +75,8 @@ struct ShortcutData {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Console settings
|
/// Console settings
|
||||||
int getConsoleMaxLines(SettingsObjectPtr settings);
|
int getConsoleMaxLines(SettingsObject* settings);
|
||||||
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings);
|
bool shouldStopOnConsoleOverflow(SettingsObject* settings);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Base class for instances.
|
* \brief Base class for instances.
|
||||||
|
|
@ -89,11 +86,11 @@ bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings);
|
||||||
* To create a new instance type, create a new class inheriting from this class
|
* To create a new instance type, create a new class inheriting from this class
|
||||||
* and implement the pure virtual functions.
|
* and implement the pure virtual functions.
|
||||||
*/
|
*/
|
||||||
class BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance> {
|
class BaseInstance : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
/// no-touchy!
|
/// no-touchy!
|
||||||
BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir);
|
||||||
|
|
||||||
public: /* types */
|
public: /* types */
|
||||||
enum class Status {
|
enum class Status {
|
||||||
|
|
@ -103,7 +100,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// virtual destructor to make sure the destruction is COMPLETE
|
/// virtual destructor to make sure the destruction is COMPLETE
|
||||||
virtual ~BaseInstance() {}
|
virtual ~BaseInstance();
|
||||||
|
|
||||||
virtual void saveNow() = 0;
|
virtual void saveNow() = 0;
|
||||||
|
|
||||||
|
|
@ -193,7 +190,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
*
|
*
|
||||||
* \return A pointer to this instance's settings object.
|
* \return A pointer to this instance's settings object.
|
||||||
*/
|
*/
|
||||||
virtual SettingsObjectPtr settings();
|
virtual SettingsObject* settings();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Loads settings specific to an instance type if they're not already loaded.
|
* \brief Loads settings specific to an instance type if they're not already loaded.
|
||||||
|
|
@ -204,10 +201,10 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
virtual QList<Task::Ptr> createUpdateTask() = 0;
|
virtual QList<Task::Ptr> createUpdateTask() = 0;
|
||||||
|
|
||||||
/// returns a valid launcher (task container)
|
/// returns a valid launcher (task container)
|
||||||
virtual shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) = 0;
|
virtual LaunchTask* createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) = 0;
|
||||||
|
|
||||||
/// returns the current launch task (if any)
|
/// returns the current launch task (if any)
|
||||||
shared_qobject_ptr<LaunchTask> getLaunchTask();
|
LaunchTask* getLaunchTask();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create envrironment variables for running the instance
|
* Create envrironment variables for running the instance
|
||||||
|
|
@ -286,7 +283,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
protected:
|
protected:
|
||||||
void changeStatus(Status newStatus);
|
void changeStatus(Status newStatus);
|
||||||
|
|
||||||
SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }
|
SettingsObject* globalSettings() const { return m_global_settings; }
|
||||||
|
|
||||||
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
|
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
|
||||||
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
|
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
|
||||||
|
|
@ -297,7 +294,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
*/
|
*/
|
||||||
void propertiesChanged(BaseInstance* inst);
|
void propertiesChanged(BaseInstance* inst);
|
||||||
|
|
||||||
void launchTaskChanged(shared_qobject_ptr<LaunchTask>);
|
void launchTaskChanged(LaunchTask*);
|
||||||
|
|
||||||
void runningStatusChanged(bool running);
|
void runningStatusChanged(bool running);
|
||||||
|
|
||||||
|
|
@ -310,10 +307,10 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
QString m_rootDir;
|
QString m_rootDir;
|
||||||
SettingsObjectPtr m_settings;
|
std::unique_ptr<SettingsObject> m_settings;
|
||||||
// InstanceFlags m_flags;
|
// InstanceFlags m_flags;
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
shared_qobject_ptr<LaunchTask> m_launchProcess;
|
std::unique_ptr<LaunchTask> m_launchProcess;
|
||||||
QDateTime m_timeStarted;
|
QDateTime m_timeStarted;
|
||||||
RuntimeContext m_runtimeContext;
|
RuntimeContext m_runtimeContext;
|
||||||
|
|
||||||
|
|
@ -323,7 +320,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||||
bool m_hasUpdate = false;
|
bool m_hasUpdate = false;
|
||||||
bool m_hasBrokenVersion = false;
|
bool m_hasBrokenVersion = false;
|
||||||
|
|
||||||
SettingsObjectWeakPtr m_global_settings;
|
SettingsObject* m_global_settings;
|
||||||
bool m_specific_settings_loaded = false;
|
bool m_specific_settings_loaded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
class BaseVersion {
|
class BaseVersion {
|
||||||
public:
|
public:
|
||||||
|
// TODO: delete
|
||||||
using Ptr = std::shared_ptr<BaseVersion>;
|
using Ptr = std::shared_ptr<BaseVersion>;
|
||||||
virtual ~BaseVersion() {}
|
virtual ~BaseVersion() {}
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ set(NET_SOURCES
|
||||||
net/ChecksumValidator.h
|
net/ChecksumValidator.h
|
||||||
net/Download.cpp
|
net/Download.cpp
|
||||||
net/Download.h
|
net/Download.h
|
||||||
|
net/DummySink.h
|
||||||
net/FileSink.cpp
|
net/FileSink.cpp
|
||||||
net/FileSink.h
|
net/FileSink.h
|
||||||
net/HttpMetaCache.cpp
|
net/HttpMetaCache.cpp
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
|
InstanceCopyTask::InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs)
|
||||||
{
|
{
|
||||||
m_origInstance = origInstance;
|
m_origInstance = origInstance;
|
||||||
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
|
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
|
||||||
|
|
@ -147,9 +147,9 @@ void InstanceCopyTask::copyFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: shouldn't this be able to report errors?
|
// FIXME: shouldn't this be able to report errors?
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
||||||
|
|
||||||
InstancePtr inst(new NullInstance(m_globalSettings, instanceSettings, m_stagingPath));
|
BaseInstance* inst(new NullInstance(m_globalSettings, std::move(instanceSettings), m_stagingPath));
|
||||||
inst->setName(name());
|
inst->setName(name());
|
||||||
inst->setIconKey(m_instIcon);
|
inst->setIconKey(m_instIcon);
|
||||||
if (!m_keepPlaytime) {
|
if (!m_keepPlaytime) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
class InstanceCopyTask : public InstanceTask {
|
class InstanceCopyTask : public InstanceTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
|
explicit InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Entry point for tasks.
|
//! Entry point for tasks.
|
||||||
|
|
@ -26,7 +26,7 @@ class InstanceCopyTask : public InstanceTask {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
InstancePtr m_origInstance;
|
BaseInstance* m_origInstance;
|
||||||
QFuture<bool> m_copyFuture;
|
QFuture<bool> m_copyFuture;
|
||||||
QFutureWatcher<bool> m_copyFutureWatcher;
|
QFutureWatcher<bool> m_copyFutureWatcher;
|
||||||
Filter m_matcher;
|
Filter m_matcher;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
QString askToUpdateInstanceDirName(InstancePtr instance, const QString& oldName, const QString& newName, QWidget* parent)
|
QString askToUpdateInstanceDirName(BaseInstance* instance, const QString& oldName, const QString& newName, QWidget* parent)
|
||||||
{
|
{
|
||||||
if (oldName == newName)
|
if (oldName == newName)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
/// Update instanceRoot to make it sync with name/id; return newRoot if a directory rename happened
|
/// Update instanceRoot to make it sync with name/id; return newRoot if a directory rename happened
|
||||||
QString askToUpdateInstanceDirName(InstancePtr instance, const QString& oldName, const QString& newName, QWidget* parent);
|
QString askToUpdateInstanceDirName(BaseInstance* instance, const QString& oldName, const QString& newName, QWidget* parent);
|
||||||
|
|
||||||
/// Check if there are linked instances, and display a warning; return true if the operation should proceed
|
/// Check if there are linked instances, and display a warning; return true if the operation should proceed
|
||||||
bool checkLinkedInstances(const QString& id, QWidget* parent, const QString& verb);
|
bool checkLinkedInstances(const QString& id, QWidget* parent, const QString& verb);
|
||||||
|
|
|
||||||
|
|
@ -343,9 +343,9 @@ void InstanceImportTask::processTechnic()
|
||||||
void InstanceImportTask::processMultiMC()
|
void InstanceImportTask::processMultiMC()
|
||||||
{
|
{
|
||||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||||
|
|
||||||
NullInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
NullInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
|
|
||||||
// reset time played on import... because packs.
|
// reset time played on import... because packs.
|
||||||
instance.resetTimePlayed();
|
instance.resetTimePlayed();
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
||||||
|
|
||||||
InstanceList::InstanceList(SettingsObjectPtr settings, const QString& instDir, QObject* parent)
|
InstanceList::InstanceList(SettingsObject* settings, const QString& instDir, QObject* parent)
|
||||||
: QAbstractListModel(parent), m_globalSettings(settings)
|
: QAbstractListModel(parent), m_globalSettings(settings)
|
||||||
{
|
{
|
||||||
resumeWatch();
|
resumeWatch();
|
||||||
|
|
@ -87,7 +87,10 @@ InstanceList::InstanceList(SettingsObjectPtr settings, const QString& instDir, Q
|
||||||
m_watcher->addPath(m_instDir);
|
m_watcher->addPath(m_instDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceList::~InstanceList() {}
|
InstanceList::~InstanceList()
|
||||||
|
{
|
||||||
|
qDeleteAll(m_instances);
|
||||||
|
}
|
||||||
|
|
||||||
Qt::DropActions InstanceList::supportedDragActions() const
|
Qt::DropActions InstanceList::supportedDragActions() const
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +164,7 @@ QModelIndex InstanceList::index(int row, int column, const QModelIndex& parent)
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
if (row < 0 || row >= m_instances.size())
|
if (row < 0 || row >= m_instances.size())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
return createIndex(row, column, (void*)m_instances.at(row).get());
|
return createIndex(row, column, (void*)m_instances.at(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstanceList::data(const QModelIndex& index, int role) const
|
QVariant InstanceList::data(const QModelIndex& index, int role) const
|
||||||
|
|
@ -266,7 +269,7 @@ void InstanceList::setInstanceGroup(const InstanceId& id, GroupId name)
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
increaseGroupCount(name);
|
increaseGroupCount(name);
|
||||||
auto idx = getInstIndex(inst.get());
|
auto idx = getInstIndex(inst);
|
||||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||||
saveGroupList();
|
saveGroupList();
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +294,7 @@ void InstanceList::deleteGroup(const GroupId& name)
|
||||||
m_instanceGroupIndex.remove(instID);
|
m_instanceGroupIndex.remove(instID);
|
||||||
qDebug() << "Remove" << instID << "from group" << name;
|
qDebug() << "Remove" << instID << "from group" << name;
|
||||||
removed = true;
|
removed = true;
|
||||||
auto idx = getInstIndex(instance.get());
|
auto idx = getInstIndex(instance);
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +319,7 @@ void InstanceList::renameGroup(const QString& src, const QString& dst)
|
||||||
increaseGroupCount(dst);
|
increaseGroupCount(dst);
|
||||||
qDebug() << "Set" << instID << "group to" << dst;
|
qDebug() << "Set" << instID << "group to" << dst;
|
||||||
modified = true;
|
modified = true;
|
||||||
auto idx = getInstIndex(instance.get());
|
auto idx = getInstIndex(instance);
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||||
}
|
}
|
||||||
|
|
@ -457,11 +460,11 @@ void InstanceList::deleteInstance(const InstanceId& id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QMap<InstanceId, InstanceLocator> getIdMapping(const QList<InstancePtr>& list)
|
static QMap<InstanceId, InstanceLocator> getIdMapping(const QList<InstanceList::BaseInstanceOwner>& list)
|
||||||
{
|
{
|
||||||
QMap<InstanceId, InstanceLocator> out;
|
QMap<InstanceId, InstanceLocator> out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto& item : list) {
|
for (auto item : list) {
|
||||||
auto id = item->id();
|
auto id = item->id();
|
||||||
if (out.contains(id)) {
|
if (out.contains(id)) {
|
||||||
qWarning() << "Duplicate ID" << id << "in instance list";
|
qWarning() << "Duplicate ID" << id << "in instance list";
|
||||||
|
|
@ -504,7 +507,7 @@ InstanceList::InstListError InstanceList::loadList()
|
||||||
{
|
{
|
||||||
auto existingIds = getIdMapping(m_instances);
|
auto existingIds = getIdMapping(m_instances);
|
||||||
|
|
||||||
QList<InstancePtr> newList;
|
QList<BaseInstanceOwner> newList;
|
||||||
|
|
||||||
for (auto& id : discoverInstances()) {
|
for (auto& id : discoverInstances()) {
|
||||||
if (existingIds.contains(id)) {
|
if (existingIds.contains(id)) {
|
||||||
|
|
@ -512,7 +515,7 @@ InstanceList::InstListError InstanceList::loadList()
|
||||||
existingIds.remove(id);
|
existingIds.remove(id);
|
||||||
qInfo() << "Should keep and soft-reload" << id;
|
qInfo() << "Should keep and soft-reload" << id;
|
||||||
} else {
|
} else {
|
||||||
InstancePtr instPtr = loadInstance(id);
|
BaseInstanceOwner instPtr = loadInstance(id);
|
||||||
if (instPtr) {
|
if (instPtr) {
|
||||||
newList.append(instPtr);
|
newList.append(instPtr);
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +570,7 @@ void InstanceList::updateTotalPlayTime()
|
||||||
{
|
{
|
||||||
totalPlayTime = 0;
|
totalPlayTime = 0;
|
||||||
for (auto const& itr : m_instances) {
|
for (auto const& itr : m_instances) {
|
||||||
totalPlayTime += itr.get()->totalTimePlayed();
|
totalPlayTime += itr->totalTimePlayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -578,12 +581,12 @@ void InstanceList::saveNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceList::add(const QList<InstancePtr>& t)
|
void InstanceList::add(const QList<BaseInstanceOwner>& t)
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex(), m_instances.count(), m_instances.count() + t.size() - 1);
|
beginInsertRows(QModelIndex(), m_instances.count(), m_instances.count() + t.size() - 1);
|
||||||
m_instances.append(t);
|
m_instances.append(t);
|
||||||
for (auto& ptr : t) {
|
for (auto ptr : t) {
|
||||||
connect(ptr.get(), &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
connect(ptr, &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
||||||
}
|
}
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
@ -613,19 +616,19 @@ void InstanceList::providerUpdated()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::getInstanceById(QString instId) const
|
BaseInstance* InstanceList::getInstanceById(QString instId) const
|
||||||
{
|
{
|
||||||
if (instId.isEmpty())
|
if (instId.isEmpty())
|
||||||
return InstancePtr();
|
return nullptr;
|
||||||
for (auto& inst : m_instances) {
|
for (auto& inst : m_instances) {
|
||||||
if (inst->id() == instId) {
|
if (inst->id() == instId) {
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return InstancePtr();
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name) const
|
BaseInstance* InstanceList::getInstanceByManagedName(const QString& managed_name) const
|
||||||
{
|
{
|
||||||
if (managed_name.isEmpty())
|
if (managed_name.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -640,14 +643,14 @@ InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name)
|
||||||
|
|
||||||
QModelIndex InstanceList::getInstanceIndexById(const QString& id) const
|
QModelIndex InstanceList::getInstanceIndexById(const QString& id) const
|
||||||
{
|
{
|
||||||
return index(getInstIndex(getInstanceById(id).get()));
|
return index(getInstIndex(getInstanceById(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::getInstIndex(BaseInstance* inst) const
|
int InstanceList::getInstIndex(BaseInstance* inst) const
|
||||||
{
|
{
|
||||||
int count = m_instances.count();
|
int count = m_instances.count();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (inst == m_instances[i].get()) {
|
if (inst == m_instances[i]) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -663,15 +666,15 @@ void InstanceList::propertiesChanged(BaseInstance* inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::loadInstance(const InstanceId& id)
|
InstanceList::BaseInstanceOwner InstanceList::loadInstance(const InstanceId& id)
|
||||||
{
|
{
|
||||||
if (!m_groupsLoaded) {
|
if (!m_groupsLoaded) {
|
||||||
loadGroupList();
|
loadGroupList();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto instanceRoot = FS::PathCombine(m_instDir, id);
|
auto instanceRoot = FS::PathCombine(m_instDir, id);
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
||||||
InstancePtr inst;
|
BaseInstanceOwner inst;
|
||||||
|
|
||||||
instanceSettings->registerSetting("InstanceType", "");
|
instanceSettings->registerSetting("InstanceType", "");
|
||||||
|
|
||||||
|
|
@ -680,9 +683,9 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)
|
||||||
// NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a
|
// NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a
|
||||||
// OneSix instance
|
// OneSix instance
|
||||||
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
||||||
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
|
inst = new MinecraftInstance(m_globalSettings, std::move(instanceSettings), instanceRoot);
|
||||||
} else {
|
} else {
|
||||||
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
|
inst = new NullInstance(m_globalSettings, std::move(instanceSettings), instanceRoot);
|
||||||
}
|
}
|
||||||
qDebug() << "Loaded instance" << inst->name() << "from" << inst->instanceRoot();
|
qDebug() << "Loaded instance" << inst->name() << "from" << inst->instanceRoot();
|
||||||
|
|
||||||
|
|
@ -911,15 +914,14 @@ class InstanceStaging : public Task {
|
||||||
const unsigned maxBackoff = 16;
|
const unsigned maxBackoff = 16;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObjectPtr settings)
|
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObject* settings) : m_parent(parent), backoff(minBackoff, maxBackoff)
|
||||||
: m_parent(parent), backoff(minBackoff, maxBackoff)
|
|
||||||
{
|
{
|
||||||
m_stagingPath = parent->getStagedInstancePath();
|
m_stagingPath = parent->getStagedInstancePath();
|
||||||
|
|
||||||
m_child.reset(child);
|
m_child.reset(child);
|
||||||
|
|
||||||
m_child->setStagingPath(m_stagingPath);
|
m_child->setStagingPath(m_stagingPath);
|
||||||
m_child->setParentSettings(std::move(settings));
|
m_child->setParentSettings(settings);
|
||||||
|
|
||||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceeded);
|
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceeded);
|
||||||
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
||||||
|
|
@ -995,7 +997,7 @@ class InstanceStaging : public Task {
|
||||||
*/
|
*/
|
||||||
ExponentialSeries backoff;
|
ExponentialSeries backoff;
|
||||||
QString m_stagingPath;
|
QString m_stagingPath;
|
||||||
unique_qobject_ptr<InstanceTask> m_child;
|
std::unique_ptr<InstanceTask> m_child;
|
||||||
QTimer m_backoffTimer;
|
QTimer m_backoffTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1036,7 +1038,7 @@ bool InstanceList::commitStagedInstance(const QString& path,
|
||||||
groupName = QString();
|
groupName = QString();
|
||||||
|
|
||||||
QString instID;
|
QString instID;
|
||||||
InstancePtr inst;
|
BaseInstance* inst;
|
||||||
|
|
||||||
auto should_override = commiting.shouldOverride();
|
auto should_override = commiting.shouldOverride();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct InstanceName;
|
||||||
|
|
||||||
using InstanceId = QString;
|
using InstanceId = QString;
|
||||||
using GroupId = QString;
|
using GroupId = QString;
|
||||||
using InstanceLocator = std::pair<InstancePtr, int>;
|
using InstanceLocator = std::pair<BaseInstance*, int>;
|
||||||
|
|
||||||
enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
|
enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
|
||||||
|
|
||||||
|
|
@ -73,7 +73,9 @@ class InstanceList : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InstanceList(SettingsObjectPtr settings, const QString& instDir, QObject* parent = 0);
|
using BaseInstanceOwner = BaseInstance*;
|
||||||
|
|
||||||
|
explicit InstanceList(SettingsObject* settings, const QString& instDir, QObject* parent = 0);
|
||||||
virtual ~InstanceList();
|
virtual ~InstanceList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -96,7 +98,7 @@ class InstanceList : public QAbstractListModel {
|
||||||
*/
|
*/
|
||||||
enum InstListError { NoError = 0, UnknownError };
|
enum InstListError { NoError = 0, UnknownError };
|
||||||
|
|
||||||
InstancePtr at(int i) const { return m_instances.at(i); }
|
BaseInstance* at(int i) const { return m_instances.at(i); }
|
||||||
|
|
||||||
int count() const { return m_instances.count(); }
|
int count() const { return m_instances.count(); }
|
||||||
|
|
||||||
|
|
@ -104,9 +106,9 @@ class InstanceList : public QAbstractListModel {
|
||||||
void saveNow();
|
void saveNow();
|
||||||
|
|
||||||
/* O(n) */
|
/* O(n) */
|
||||||
InstancePtr getInstanceById(QString id) const;
|
BaseInstance* getInstanceById(QString id) const;
|
||||||
/* O(n) */
|
/* O(n) */
|
||||||
InstancePtr getInstanceByManagedName(const QString& managed_name) const;
|
BaseInstance* getInstanceByManagedName(const QString& managed_name) const;
|
||||||
QModelIndex getInstanceIndexById(const QString& id) const;
|
QModelIndex getInstanceIndexById(const QString& id) const;
|
||||||
QStringList getGroups();
|
QStringList getGroups();
|
||||||
bool isGroupCollapsed(const QString& groupName);
|
bool isGroupCollapsed(const QString& groupName);
|
||||||
|
|
@ -179,11 +181,11 @@ class InstanceList : public QAbstractListModel {
|
||||||
void updateTotalPlayTime();
|
void updateTotalPlayTime();
|
||||||
void suspendWatch();
|
void suspendWatch();
|
||||||
void resumeWatch();
|
void resumeWatch();
|
||||||
void add(const QList<InstancePtr>& list);
|
void add(const QList<BaseInstanceOwner>& list);
|
||||||
void loadGroupList();
|
void loadGroupList();
|
||||||
void saveGroupList();
|
void saveGroupList();
|
||||||
QList<InstanceId> discoverInstances();
|
QList<InstanceId> discoverInstances();
|
||||||
InstancePtr loadInstance(const InstanceId& id);
|
BaseInstanceOwner loadInstance(const InstanceId& id);
|
||||||
|
|
||||||
void increaseGroupCount(const QString& group);
|
void increaseGroupCount(const QString& group);
|
||||||
void decreaseGroupCount(const QString& group);
|
void decreaseGroupCount(const QString& group);
|
||||||
|
|
@ -192,11 +194,11 @@ class InstanceList : public QAbstractListModel {
|
||||||
int m_watchLevel = 0;
|
int m_watchLevel = 0;
|
||||||
int totalPlayTime = 0;
|
int totalPlayTime = 0;
|
||||||
bool m_dirty = false;
|
bool m_dirty = false;
|
||||||
QList<InstancePtr> m_instances;
|
QList<BaseInstanceOwner> m_instances;
|
||||||
// id -> refs
|
// id -> refs
|
||||||
QMap<QString, int> m_groupNameCache;
|
QMap<QString, int> m_groupNameCache;
|
||||||
|
|
||||||
SettingsObjectPtr m_globalSettings;
|
SettingsObject* m_globalSettings;
|
||||||
QString m_instDir;
|
QString m_instDir;
|
||||||
QFileSystemWatcher* m_watcher;
|
QFileSystemWatcher* m_watcher;
|
||||||
// FIXME: this is so inefficient that looking at it is almost painful.
|
// FIXME: this is so inefficient that looking at it is almost painful.
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,26 @@
|
||||||
class InstancePageProvider : protected QObject, public BasePageProvider {
|
class InstancePageProvider : protected QObject, public BasePageProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
|
explicit InstancePageProvider(BaseInstance* parent) { inst = parent; }
|
||||||
|
|
||||||
virtual ~InstancePageProvider() = default;
|
virtual ~InstancePageProvider() = default;
|
||||||
virtual QList<BasePage*> getPages() override
|
virtual QList<BasePage*> getPages() override
|
||||||
{
|
{
|
||||||
QList<BasePage*> values;
|
QList<BasePage*> values;
|
||||||
values.append(new LogPage(inst));
|
values.append(new LogPage(inst));
|
||||||
std::shared_ptr<MinecraftInstance> onesix = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
MinecraftInstance* onesix = dynamic_cast<MinecraftInstance*>(inst);
|
||||||
values.append(new VersionPage(onesix.get()));
|
values.append(new VersionPage(onesix));
|
||||||
values.append(ManagedPackPage::createPage(onesix.get()));
|
values.append(ManagedPackPage::createPage(onesix));
|
||||||
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList());
|
auto modsPage = new ModFolderPage(onesix, onesix->loaderModList());
|
||||||
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
|
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
|
||||||
values.append(modsPage);
|
values.append(modsPage);
|
||||||
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
|
values.append(new CoreModFolderPage(onesix, onesix->coreModList()));
|
||||||
values.append(new NilModFolderPage(onesix.get(), onesix->nilModList()));
|
values.append(new NilModFolderPage(onesix, onesix->nilModList()));
|
||||||
values.append(new ResourcePackPage(onesix.get(), onesix->resourcePackList()));
|
values.append(new ResourcePackPage(onesix, onesix->resourcePackList()));
|
||||||
values.append(new GlobalDataPackPage(onesix.get()));
|
values.append(new GlobalDataPackPage(onesix));
|
||||||
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
|
values.append(new TexturePackPage(onesix, onesix->texturePackList()));
|
||||||
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));
|
values.append(new ShaderPackPage(onesix, onesix->shaderPackList()));
|
||||||
values.append(new NotesPage(onesix.get()));
|
values.append(new NotesPage(onesix));
|
||||||
values.append(new WorldListPage(onesix, onesix->worldList()));
|
values.append(new WorldListPage(onesix, onesix->worldList()));
|
||||||
values.append(new ServersPage(onesix));
|
values.append(new ServersPage(onesix));
|
||||||
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
|
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
|
||||||
|
|
@ -52,5 +52,5 @@ class InstancePageProvider : protected QObject, public BasePageProvider {
|
||||||
virtual QString dialogTitle() override { return tr("Edit Instance (%1)").arg(inst->name()); }
|
virtual QString dialogTitle() override { return tr("Edit Instance (%1)").arg(inst->name()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
InstancePtr inst;
|
BaseInstance* inst;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||||
InstanceTask();
|
InstanceTask();
|
||||||
~InstanceTask() override = default;
|
~InstanceTask() override = default;
|
||||||
|
|
||||||
void setParentSettings(SettingsObjectPtr settings) { m_globalSettings = settings; }
|
void setParentSettings(SettingsObject* settings) { m_globalSettings = settings; }
|
||||||
|
|
||||||
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
|
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
SettingsObjectPtr m_globalSettings;
|
SettingsObject* m_globalSettings;
|
||||||
QString m_instIcon;
|
QString m_instIcon;
|
||||||
QString m_instGroup;
|
QString m_instGroup;
|
||||||
QString m_stagingPath;
|
QString m_stagingPath;
|
||||||
|
|
|
||||||
|
|
@ -403,10 +403,10 @@ void LaunchController::launchInstance()
|
||||||
if (!console && showConsole) {
|
if (!console && showConsole) {
|
||||||
APPLICATION->showInstanceWindow(m_instance);
|
APPLICATION->showInstanceWindow(m_instance);
|
||||||
}
|
}
|
||||||
connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
connect(m_launcher, &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
||||||
connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
connect(m_launcher, &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
||||||
connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
|
connect(m_launcher, &LaunchTask::failed, this, &LaunchController::onFailed);
|
||||||
connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
connect(m_launcher, &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
||||||
|
|
||||||
// Prepend Online and Auth Status
|
// Prepend Online and Auth Status
|
||||||
QString online_mode;
|
QString online_mode;
|
||||||
|
|
@ -416,19 +416,18 @@ void LaunchController::launchInstance()
|
||||||
// Prepend Server Status
|
// Prepend Server Status
|
||||||
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
||||||
|
|
||||||
m_launcher->prependStep(makeShared<PrintServers>(m_launcher.get(), servers));
|
m_launcher->prependStep(makeShared<PrintServers>(m_launcher, servers));
|
||||||
} else {
|
} else {
|
||||||
online_mode = m_demo ? "demo" : "offline";
|
online_mode = m_demo ? "demo" : "offline";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_launcher->prependStep(
|
m_launcher->prependStep(makeShared<TextPrint>(m_launcher, "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
||||||
makeShared<TextPrint>(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
|
||||||
|
|
||||||
// Prepend Version
|
// Prepend Version
|
||||||
{
|
{
|
||||||
auto versionString = QString("%1 version: %2 (%3)")
|
auto versionString = QString("%1 version: %2 (%3)")
|
||||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM);
|
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM);
|
||||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher.get(), versionString + "\n\n", MessageLevel::Launcher));
|
m_launcher->prependStep(makeShared<TextPrint>(m_launcher, versionString + "\n\n", MessageLevel::Launcher));
|
||||||
}
|
}
|
||||||
m_launcher->start();
|
m_launcher->start();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ class LaunchController : public Task {
|
||||||
LaunchController();
|
LaunchController();
|
||||||
virtual ~LaunchController() = default;
|
virtual ~LaunchController() = default;
|
||||||
|
|
||||||
void setInstance(InstancePtr instance) { m_instance = instance; }
|
void setInstance(BaseInstance* instance) { m_instance = instance; }
|
||||||
|
|
||||||
InstancePtr instance() { return m_instance; }
|
BaseInstance* instance() { return m_instance; }
|
||||||
|
|
||||||
void setOnline(bool online) { m_online = online; }
|
void setOnline(bool online) { m_online = online; }
|
||||||
|
|
||||||
|
|
@ -92,11 +92,11 @@ class LaunchController : public Task {
|
||||||
bool m_online = true;
|
bool m_online = true;
|
||||||
QString m_offlineName;
|
QString m_offlineName;
|
||||||
bool m_demo = false;
|
bool m_demo = false;
|
||||||
InstancePtr m_instance;
|
BaseInstance* m_instance;
|
||||||
QWidget* m_parentWidget = nullptr;
|
QWidget* m_parentWidget = nullptr;
|
||||||
InstanceWindow* m_console = nullptr;
|
InstanceWindow* m_console = nullptr;
|
||||||
MinecraftAccountPtr m_accountToUse = nullptr;
|
MinecraftAccountPtr m_accountToUse = nullptr;
|
||||||
AuthSessionPtr m_session;
|
AuthSessionPtr m_session;
|
||||||
shared_qobject_ptr<LaunchTask> m_launcher;
|
LaunchTask* m_launcher;
|
||||||
MinecraftTarget::Ptr m_targetToJoin;
|
MinecraftTarget::Ptr m_targetToJoin;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@
|
||||||
class NullInstance : public BaseInstance {
|
class NullInstance : public BaseInstance {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
NullInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
||||||
: BaseInstance(globalSettings, settings, rootDir)
|
: BaseInstance(globalSettings, std::move(settings), rootDir)
|
||||||
{
|
{
|
||||||
setVersionBroken(true);
|
setVersionBroken(true);
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ class NullInstance : public BaseInstance {
|
||||||
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
||||||
QSet<QString> traits() const override { return {}; };
|
QSet<QString> traits() const override { return {}; };
|
||||||
QString instanceConfigFolder() const override { return instanceRoot(); };
|
QString instanceConfigFolder() const override { return instanceRoot(); };
|
||||||
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr, MinecraftTarget::Ptr) override { return nullptr; }
|
LaunchTask* createLaunchTask(AuthSessionPtr, MinecraftTarget::Ptr) override { return nullptr; }
|
||||||
QList<Task::Ptr> createUpdateTask() override { return {}; }
|
QList<Task::Ptr> createUpdateTask() override { return {}; }
|
||||||
QProcessEnvironment createEnvironment() override { return QProcessEnvironment(); }
|
QProcessEnvironment createEnvironment() override { return QProcessEnvironment(); }
|
||||||
QProcessEnvironment createLaunchEnvironment() override { return QProcessEnvironment(); }
|
QProcessEnvironment createLaunchEnvironment() override { return QProcessEnvironment(); }
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||||
ModPlatform::IndexedVersion version,
|
ModPlatform::IndexedVersion version,
|
||||||
const std::shared_ptr<ResourceFolderModel> packs,
|
ResourceFolderModel* packs,
|
||||||
bool is_indexed)
|
bool is_indexed)
|
||||||
: m_pack(std::move(pack)), m_pack_version(std::move(version)), m_pack_model(packs)
|
: m_pack(std::move(pack)), m_pack_version(std::move(version)), m_pack_model(packs)
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +88,7 @@ void ResourceDownloadTask::downloadSucceeded()
|
||||||
m_pack_model->uninstallResource(oldFilename, true);
|
m_pack_model->uninstallResource(oldFilename, true);
|
||||||
|
|
||||||
// also rename the shader config file
|
// also rename the shader config file
|
||||||
if (dynamic_cast<ShaderPackFolderModel*>(m_pack_model.get()) != nullptr) {
|
if (dynamic_cast<ShaderPackFolderModel*>(m_pack_model) != nullptr) {
|
||||||
QFileInfo oldConfig(m_pack_model->dir(), oldFilename + ".txt");
|
QFileInfo oldConfig(m_pack_model->dir(), oldFilename + ".txt");
|
||||||
QFileInfo newConfig(m_pack_model->dir(), getFilename() + ".txt");
|
QFileInfo newConfig(m_pack_model->dir(), getFilename() + ".txt");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class ResourceDownloadTask : public SequentialTask {
|
||||||
public:
|
public:
|
||||||
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||||
ModPlatform::IndexedVersion version,
|
ModPlatform::IndexedVersion version,
|
||||||
std::shared_ptr<ResourceFolderModel> packs,
|
ResourceFolderModel* packs,
|
||||||
bool is_indexed = true);
|
bool is_indexed = true);
|
||||||
const QString& getFilename() const { return m_pack_version.fileName; }
|
const QString& getFilename() const { return m_pack_version.fileName; }
|
||||||
const QVariant& getVersionID() const { return m_pack_version.fileId; }
|
const QVariant& getVersionID() const { return m_pack_version.fileId; }
|
||||||
|
|
@ -44,7 +44,7 @@ class ResourceDownloadTask : public SequentialTask {
|
||||||
private:
|
private:
|
||||||
ModPlatform::IndexedPack::Ptr m_pack;
|
ModPlatform::IndexedPack::Ptr m_pack;
|
||||||
ModPlatform::IndexedVersion m_pack_version;
|
ModPlatform::IndexedVersion m_pack_version;
|
||||||
const std::shared_ptr<ResourceFolderModel> m_pack_model;
|
ResourceFolderModel* m_pack_model;
|
||||||
|
|
||||||
NetJob::Ptr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
LocalResourceUpdateTask::Ptr m_update_task;
|
LocalResourceUpdateTask::Ptr m_update_task;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ struct RuntimeContext {
|
||||||
return javaRealArchitecture;
|
return javaRealArchitecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFromInstanceSettings(SettingsObjectPtr instanceSettings)
|
void updateFromInstanceSettings(SettingsObject* instanceSettings)
|
||||||
{
|
{
|
||||||
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
||||||
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Usable {
|
||||||
*/
|
*/
|
||||||
class UseLock {
|
class UseLock {
|
||||||
public:
|
public:
|
||||||
UseLock(shared_qobject_ptr<Usable> usable) : m_usable(usable)
|
UseLock(Usable* usable) : m_usable(usable)
|
||||||
{
|
{
|
||||||
// this doesn't use shared pointer use count, because that wouldn't be correct. this count is separate.
|
// this doesn't use shared pointer use count, because that wouldn't be correct. this count is separate.
|
||||||
m_usable->incrementUses();
|
m_usable->incrementUses();
|
||||||
|
|
@ -44,5 +44,5 @@ class UseLock {
|
||||||
~UseLock() { m_usable->decrementUses(); }
|
~UseLock() { m_usable->decrementUses(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<Usable> m_usable;
|
Usable* m_usable;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ void ManifestDownloadTask::executeTask()
|
||||||
auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network());
|
auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network());
|
||||||
auto files = std::make_shared<QByteArray>();
|
auto files = std::make_shared<QByteArray>();
|
||||||
|
|
||||||
auto action = Net::Download::makeByteArray(m_url, files);
|
auto action = Net::Download::makeByteArray(m_url, files.get());
|
||||||
if (!m_checksum_hash.isEmpty() && !m_checksum_type.isEmpty()) {
|
if (!m_checksum_hash.isEmpty() && !m_checksum_type.isEmpty()) {
|
||||||
auto hashType = QCryptographicHash::Algorithm::Sha1;
|
auto hashType = QCryptographicHash::Algorithm::Sha1;
|
||||||
if (m_checksum_type == "sha256") {
|
if (m_checksum_type == "sha256") {
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,14 @@ void LaunchTask::init()
|
||||||
m_instance->setRunning(true);
|
m_instance->setRunning(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<LaunchTask> LaunchTask::create(MinecraftInstancePtr inst)
|
std::unique_ptr<LaunchTask> LaunchTask::create(MinecraftInstance* inst)
|
||||||
{
|
{
|
||||||
shared_qobject_ptr<LaunchTask> proc(new LaunchTask(inst));
|
auto task = std::unique_ptr<LaunchTask>(new LaunchTask(inst));
|
||||||
proc->init();
|
task->init();
|
||||||
return proc;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchTask::LaunchTask(MinecraftInstancePtr instance) : m_instance(instance) {}
|
LaunchTask::LaunchTask(MinecraftInstance* instance) : m_instance(instance) {}
|
||||||
|
|
||||||
void LaunchTask::appendStep(shared_qobject_ptr<LaunchStep> step)
|
void LaunchTask::appendStep(shared_qobject_ptr<LaunchStep> step)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@
|
||||||
#include <QObjectPtr.h>
|
#include <QObjectPtr.h>
|
||||||
#include <minecraft/MinecraftInstance.h>
|
#include <minecraft/MinecraftInstance.h>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include "BaseInstance.h"
|
|
||||||
#include "LaunchStep.h"
|
#include "LaunchStep.h"
|
||||||
#include "LogModel.h"
|
#include "LogModel.h"
|
||||||
#include "MessageLevel.h"
|
#include "MessageLevel.h"
|
||||||
|
|
@ -48,21 +47,21 @@
|
||||||
class LaunchTask : public Task {
|
class LaunchTask : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
explicit LaunchTask(MinecraftInstancePtr instance);
|
explicit LaunchTask(MinecraftInstance* instance);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum State { NotStarted, Running, Waiting, Failed, Aborted, Finished };
|
enum State { NotStarted, Running, Waiting, Failed, Aborted, Finished };
|
||||||
|
|
||||||
public: /* methods */
|
public: /* methods */
|
||||||
static shared_qobject_ptr<LaunchTask> create(MinecraftInstancePtr inst);
|
static std::unique_ptr<LaunchTask> create(MinecraftInstance* inst);
|
||||||
virtual ~LaunchTask() = default;
|
virtual ~LaunchTask() = default;
|
||||||
|
|
||||||
void appendStep(shared_qobject_ptr<LaunchStep> step);
|
void appendStep(shared_qobject_ptr<LaunchStep> step);
|
||||||
void prependStep(shared_qobject_ptr<LaunchStep> step);
|
void prependStep(shared_qobject_ptr<LaunchStep> step);
|
||||||
void setCensorFilter(QMap<QString, QString> filter);
|
void setCensorFilter(QMap<QString, QString> filter);
|
||||||
|
|
||||||
MinecraftInstancePtr instance() { return m_instance; }
|
MinecraftInstance* instance() { return m_instance; }
|
||||||
|
|
||||||
void setPid(qint64 pid) { m_pid = pid; }
|
void setPid(qint64 pid) { m_pid = pid; }
|
||||||
|
|
||||||
|
|
@ -119,7 +118,7 @@ class LaunchTask : public Task {
|
||||||
bool parseXmlLogs(QString const& line, MessageLevel level);
|
bool parseXmlLogs(QString const& line, MessageLevel level);
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
MinecraftInstancePtr m_instance;
|
MinecraftInstance* m_instance;
|
||||||
shared_qobject_ptr<LogModel> m_logModel;
|
shared_qobject_ptr<LogModel> m_logModel;
|
||||||
QList<shared_qobject_ptr<LaunchStep>> m_steps;
|
QList<shared_qobject_ptr<LaunchStep>> m_steps;
|
||||||
QMap<QString, QString> m_censorFilter;
|
QMap<QString, QString> m_censorFilter;
|
||||||
|
|
|
||||||
|
|
@ -160,12 +160,14 @@ class OrSetting : public Setting {
|
||||||
std::shared_ptr<Setting> m_b;
|
std::shared_ptr<Setting> m_b;
|
||||||
};
|
};
|
||||||
|
|
||||||
MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
MinecraftInstance::MinecraftInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
||||||
: BaseInstance(globalSettings, settings, rootDir)
|
: BaseInstance(globalSettings, std::move(settings), rootDir)
|
||||||
{
|
{
|
||||||
m_components.reset(new PackProfile(this));
|
m_components.reset(new PackProfile(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MinecraftInstance::~MinecraftInstance() {}
|
||||||
|
|
||||||
void MinecraftInstance::saveNow()
|
void MinecraftInstance::saveNow()
|
||||||
{
|
{
|
||||||
m_components->saveNow();
|
m_components->saveNow();
|
||||||
|
|
@ -269,7 +271,7 @@ void MinecraftInstance::loadSpecificSettings()
|
||||||
|
|
||||||
void MinecraftInstance::updateRuntimeContext()
|
void MinecraftInstance::updateRuntimeContext()
|
||||||
{
|
{
|
||||||
m_runtimeContext.updateFromInstanceSettings(m_settings);
|
m_runtimeContext.updateFromInstanceSettings(m_settings.get());
|
||||||
m_components->invalidateLaunchProfile();
|
m_components->invalidateLaunchProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,9 +280,9 @@ QString MinecraftInstance::typeName() const
|
||||||
return "Minecraft";
|
return "Minecraft";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<PackProfile> MinecraftInstance::getPackProfile() const
|
PackProfile* MinecraftInstance::getPackProfile() const
|
||||||
{
|
{
|
||||||
return m_components;
|
return m_components.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> MinecraftInstance::traits() const
|
QSet<QString> MinecraftInstance::traits() const
|
||||||
|
|
@ -308,9 +310,9 @@ void MinecraftInstance::populateLaunchMenu(QMenu* menu)
|
||||||
|
|
||||||
normalLaunchDemo->setEnabled(supportsDemo());
|
normalLaunchDemo->setEnabled(supportsDemo());
|
||||||
|
|
||||||
connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this()); });
|
connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(this); });
|
||||||
connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, false); });
|
connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(this, false, false); });
|
||||||
connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, true); });
|
connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(this, false, true); });
|
||||||
|
|
||||||
QString profilersTitle = tr("Profilers");
|
QString profilersTitle = tr("Profilers");
|
||||||
menu->addSeparator()->setText(profilersTitle);
|
menu->addSeparator()->setText(profilersTitle);
|
||||||
|
|
@ -964,8 +966,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
printModList("Mods", *(loaderModList().get()));
|
printModList("Mods", *loaderModList());
|
||||||
printModList("Core Mods", *(coreModList().get()));
|
printModList("Core Mods", *coreModList());
|
||||||
|
|
||||||
// jar mods
|
// jar mods
|
||||||
auto& jarMods = profile->getJarMods();
|
auto& jarMods = profile->getJarMods();
|
||||||
|
|
@ -1106,11 +1108,10 @@ QList<LaunchStep::Ptr> MinecraftInstance::createUpdateTask()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin)
|
LaunchTask* MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin)
|
||||||
{
|
{
|
||||||
updateRuntimeContext();
|
updateRuntimeContext();
|
||||||
// FIXME: get rid of shared_from_this ...
|
auto process = LaunchTask::create(this);
|
||||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
|
||||||
auto pptr = process.get();
|
auto pptr = process.get();
|
||||||
|
|
||||||
APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
|
APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
|
||||||
|
|
@ -1225,9 +1226,9 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
||||||
if (m_settings->get("QuitAfterGameStop").toBool()) {
|
if (m_settings->get("QuitAfterGameStop").toBool()) {
|
||||||
process->appendStep(makeShared<QuitAfterGameStop>(pptr));
|
process->appendStep(makeShared<QuitAfterGameStop>(pptr));
|
||||||
}
|
}
|
||||||
m_launchProcess = process;
|
m_launchProcess = std::move(process);
|
||||||
emit launchTaskChanged(m_launchProcess);
|
emit launchTaskChanged(m_launchProcess.get());
|
||||||
return m_launchProcess;
|
return m_launchProcess.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaVersion MinecraftInstance::getJavaVersion()
|
JavaVersion MinecraftInstance::getJavaVersion()
|
||||||
|
|
@ -1235,80 +1236,80 @@ JavaVersion MinecraftInstance::getJavaVersion()
|
||||||
return JavaVersion(settings()->get("JavaVersion").toString());
|
return JavaVersion(settings()->get("JavaVersion").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList()
|
ModFolderModel* MinecraftInstance::loaderModList()
|
||||||
{
|
{
|
||||||
if (!m_loader_mod_list) {
|
if (!m_loader_mod_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed, true));
|
m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed, true));
|
||||||
}
|
}
|
||||||
return m_loader_mod_list;
|
return m_loader_mod_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList()
|
ModFolderModel* MinecraftInstance::coreModList()
|
||||||
{
|
{
|
||||||
if (!m_core_mod_list) {
|
if (!m_core_mod_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed, true));
|
m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed, true));
|
||||||
}
|
}
|
||||||
return m_core_mod_list;
|
return m_core_mod_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::nilModList()
|
ModFolderModel* MinecraftInstance::nilModList()
|
||||||
{
|
{
|
||||||
if (!m_nil_mod_list) {
|
if (!m_nil_mod_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false));
|
m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false));
|
||||||
}
|
}
|
||||||
return m_nil_mod_list;
|
return m_nil_mod_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ResourcePackFolderModel> MinecraftInstance::resourcePackList()
|
ResourcePackFolderModel* MinecraftInstance::resourcePackList()
|
||||||
{
|
{
|
||||||
if (!m_resource_pack_list) {
|
if (!m_resource_pack_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir(), this, is_indexed, true));
|
m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir(), this, is_indexed, true));
|
||||||
}
|
}
|
||||||
return m_resource_pack_list;
|
return m_resource_pack_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TexturePackFolderModel> MinecraftInstance::texturePackList()
|
TexturePackFolderModel* MinecraftInstance::texturePackList()
|
||||||
{
|
{
|
||||||
if (!m_texture_pack_list) {
|
if (!m_texture_pack_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir(), this, is_indexed, true));
|
m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir(), this, is_indexed, true));
|
||||||
}
|
}
|
||||||
return m_texture_pack_list;
|
return m_texture_pack_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ShaderPackFolderModel> MinecraftInstance::shaderPackList()
|
ShaderPackFolderModel* MinecraftInstance::shaderPackList()
|
||||||
{
|
{
|
||||||
if (!m_shader_pack_list) {
|
if (!m_shader_pack_list) {
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir(), this, is_indexed, true));
|
m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir(), this, is_indexed, true));
|
||||||
}
|
}
|
||||||
return m_shader_pack_list;
|
return m_shader_pack_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DataPackFolderModel> MinecraftInstance::dataPackList()
|
DataPackFolderModel* MinecraftInstance::dataPackList()
|
||||||
{
|
{
|
||||||
if (!m_data_pack_list && settings()->get("GlobalDataPacksEnabled").toBool()) {
|
if (!m_data_pack_list && settings()->get("GlobalDataPacksEnabled").toBool()) {
|
||||||
bool isIndexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool isIndexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_data_pack_list.reset(new DataPackFolderModel(dataPacksDir(), this, isIndexed, true));
|
m_data_pack_list.reset(new DataPackFolderModel(dataPacksDir(), this, isIndexed, true));
|
||||||
}
|
}
|
||||||
return m_data_pack_list;
|
return m_data_pack_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<ResourceFolderModel>> MinecraftInstance::resourceLists()
|
QList<ResourceFolderModel*> MinecraftInstance::resourceLists()
|
||||||
{
|
{
|
||||||
return { loaderModList(), coreModList(), nilModList(), resourcePackList(), texturePackList(), shaderPackList(), dataPackList() };
|
return { loaderModList(), coreModList(), nilModList(), resourcePackList(), texturePackList(), shaderPackList(), dataPackList() };
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<WorldList> MinecraftInstance::worldList()
|
WorldList* MinecraftInstance::worldList()
|
||||||
{
|
{
|
||||||
if (!m_world_list) {
|
if (!m_world_list) {
|
||||||
m_world_list.reset(new WorldList(worldDir(), this));
|
m_world_list.reset(new WorldList(worldDir(), this));
|
||||||
}
|
}
|
||||||
return m_world_list;
|
return m_world_list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Mod*> MinecraftInstance::getJarMods() const
|
QList<Mod*> MinecraftInstance::getJarMods() const
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ class PackProfile;
|
||||||
class MinecraftInstance : public BaseInstance {
|
class MinecraftInstance : public BaseInstance {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
MinecraftInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir);
|
||||||
virtual ~MinecraftInstance() = default;
|
virtual ~MinecraftInstance();
|
||||||
virtual void saveNow() override;
|
virtual void saveNow() override;
|
||||||
|
|
||||||
void loadSpecificSettings() override;
|
void loadSpecificSettings() override;
|
||||||
|
|
@ -109,22 +109,22 @@ class MinecraftInstance : public BaseInstance {
|
||||||
void updateRuntimeContext() override;
|
void updateRuntimeContext() override;
|
||||||
|
|
||||||
////// Profile management //////
|
////// Profile management //////
|
||||||
std::shared_ptr<PackProfile> getPackProfile() const;
|
PackProfile* getPackProfile() const;
|
||||||
|
|
||||||
////// Mod Lists //////
|
////// Mod Lists //////
|
||||||
std::shared_ptr<ModFolderModel> loaderModList();
|
ModFolderModel* loaderModList();
|
||||||
std::shared_ptr<ModFolderModel> coreModList();
|
ModFolderModel* coreModList();
|
||||||
std::shared_ptr<ModFolderModel> nilModList();
|
ModFolderModel* nilModList();
|
||||||
std::shared_ptr<ResourcePackFolderModel> resourcePackList();
|
ResourcePackFolderModel* resourcePackList();
|
||||||
std::shared_ptr<TexturePackFolderModel> texturePackList();
|
TexturePackFolderModel* texturePackList();
|
||||||
std::shared_ptr<ShaderPackFolderModel> shaderPackList();
|
ShaderPackFolderModel* shaderPackList();
|
||||||
std::shared_ptr<DataPackFolderModel> dataPackList();
|
DataPackFolderModel* dataPackList();
|
||||||
QList<std::shared_ptr<ResourceFolderModel>> resourceLists();
|
QList<ResourceFolderModel*> resourceLists();
|
||||||
std::shared_ptr<WorldList> worldList();
|
WorldList* worldList();
|
||||||
|
|
||||||
////// Launch stuff //////
|
////// Launch stuff //////
|
||||||
QList<Task::Ptr> createUpdateTask() override;
|
QList<Task::Ptr> createUpdateTask() override;
|
||||||
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) override;
|
LaunchTask* createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) override;
|
||||||
QStringList extraArguments() override;
|
QStringList extraArguments() override;
|
||||||
QStringList verboseDescription(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) override;
|
QStringList verboseDescription(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) override;
|
||||||
QList<Mod*> getJarMods() const;
|
QList<Mod*> getJarMods() const;
|
||||||
|
|
@ -162,15 +162,13 @@ class MinecraftInstance : public BaseInstance {
|
||||||
QMap<QString, QString> makeProfileVarMapping(std::shared_ptr<LaunchProfile> profile) const;
|
QMap<QString, QString> makeProfileVarMapping(std::shared_ptr<LaunchProfile> profile) const;
|
||||||
|
|
||||||
protected: // data
|
protected: // data
|
||||||
std::shared_ptr<PackProfile> m_components;
|
std::unique_ptr<PackProfile> m_components;
|
||||||
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
|
std::unique_ptr<ModFolderModel> m_loader_mod_list;
|
||||||
mutable std::shared_ptr<ModFolderModel> m_core_mod_list;
|
std::unique_ptr<ModFolderModel> m_core_mod_list;
|
||||||
mutable std::shared_ptr<ModFolderModel> m_nil_mod_list;
|
std::unique_ptr<ModFolderModel> m_nil_mod_list;
|
||||||
mutable std::shared_ptr<ResourcePackFolderModel> m_resource_pack_list;
|
std::unique_ptr<ResourcePackFolderModel> m_resource_pack_list;
|
||||||
mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list;
|
std::unique_ptr<ShaderPackFolderModel> m_shader_pack_list;
|
||||||
mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list;
|
std::unique_ptr<TexturePackFolderModel> m_texture_pack_list;
|
||||||
mutable std::shared_ptr<DataPackFolderModel> m_data_pack_list;
|
std::unique_ptr<DataPackFolderModel> m_data_pack_list;
|
||||||
mutable std::shared_ptr<WorldList> m_world_list;
|
std::unique_ptr<WorldList> m_world_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
using MinecraftInstancePtr = std::shared_ptr<MinecraftInstance>;
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ bool VanillaCreationTask::createInstance()
|
||||||
{
|
{
|
||||||
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
|
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
|
||||||
|
|
||||||
auto instance_settings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
auto instance_settings = std::make_unique<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
||||||
instance_settings->suspendSave();
|
instance_settings->suspendSave();
|
||||||
{
|
{
|
||||||
MinecraftInstance inst(m_globalSettings, instance_settings, m_stagingPath);
|
MinecraftInstance inst(m_globalSettings, std::move(instance_settings), m_stagingPath);
|
||||||
auto components = inst.getPackProfile();
|
auto components = inst.getPackProfile();
|
||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
|
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
|
||||||
|
|
@ -31,8 +31,9 @@ bool VanillaCreationTask::createInstance()
|
||||||
|
|
||||||
inst.setName(name());
|
inst.setName(name());
|
||||||
inst.setIconKey(m_instIcon);
|
inst.setIconKey(m_instIcon);
|
||||||
|
|
||||||
|
inst.settings()->resumeSave();
|
||||||
}
|
}
|
||||||
instance_settings->resumeSave();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ void EntitlementsStep::perform()
|
||||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("EntitlementsStep", APPLICATION->network()));
|
m_task.reset(new NetJob("EntitlementsStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class EntitlementsStep : public AuthStep {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_entitlements_request_id;
|
QString m_entitlements_request_id;
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_request;
|
Net::Download::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ void GetSkinStep::perform()
|
||||||
QUrl url(m_data->minecraftProfile.skin.url);
|
QUrl url(m_data->minecraftProfile.skin.url);
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||||
|
|
||||||
m_task.reset(new NetJob("GetSkinStep", APPLICATION->network()));
|
m_task.reset(new NetJob("GetSkinStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class GetSkinStep : public AuthStep {
|
||||||
void onRequestDone();
|
void onRequestDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_request;
|
Net::Download::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ void LauncherLoginStep::perform()
|
||||||
};
|
};
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Upload::makeByteArray(url, m_response, requestBody.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response.get(), requestBody.toUtf8());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("LauncherLoginStep", APPLICATION->network()));
|
m_task.reset(new NetJob("LauncherLoginStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class LauncherLoginStep : public AuthStep {
|
||||||
void onRequestDone();
|
void onRequestDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_request;
|
Net::Upload::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ void MSADeviceCodeStep::perform()
|
||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("MSADeviceCodeStep", APPLICATION->network()));
|
m_task.reset(new NetJob("MSADeviceCodeStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
@ -181,8 +181,8 @@ void MSADeviceCodeStep::authenticateUser()
|
||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class MSADeviceCodeStep : public AuthStep {
|
||||||
QTimer m_pool_timer;
|
QTimer m_pool_timer;
|
||||||
QTimer m_expiration_timer;
|
QTimer m_expiration_timer;
|
||||||
|
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_request;
|
Net::Upload::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
|
||||||
m_oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
|
m_oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
|
||||||
m_oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
|
m_oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
|
||||||
m_oauth2.setClientIdentifier(m_clientId);
|
m_oauth2.setClientIdentifier(m_clientId);
|
||||||
m_oauth2.setNetworkAccessManager(APPLICATION->network().get());
|
m_oauth2.setNetworkAccessManager(APPLICATION->network());
|
||||||
|
|
||||||
connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::granted, this, [this] {
|
connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::granted, this, [this] {
|
||||||
m_data->msaClientID = m_oauth2.clientIdentifier();
|
m_data->msaClientID = m_oauth2.clientIdentifier();
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ void MinecraftProfileStep::perform()
|
||||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("MinecraftProfileStep", APPLICATION->network()));
|
m_task.reset(new NetJob("MinecraftProfileStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class MinecraftProfileStep : public AuthStep {
|
||||||
void onRequestDone();
|
void onRequestDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_request;
|
Net::Download::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ void XboxAuthorizationStep::perform()
|
||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response.get(), xbox_auth_data.toUtf8());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("XboxAuthorizationStep", APPLICATION->network()));
|
m_task.reset(new NetJob("XboxAuthorizationStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class XboxAuthorizationStep : public AuthStep {
|
||||||
QString m_relyingParty;
|
QString m_relyingParty;
|
||||||
QString m_authorizationKind;
|
QString m_authorizationKind;
|
||||||
|
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_request;
|
Net::Upload::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ void XboxProfileStep::perform()
|
||||||
};
|
};
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("XboxProfileStep", APPLICATION->network()));
|
m_task.reset(new NetJob("XboxProfileStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class XboxProfileStep : public AuthStep {
|
||||||
void onRequestDone();
|
void onRequestDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_request;
|
Net::Download::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ void XboxUserStep::perform()
|
||||||
{ "x-xbl-contract-version", "1" }
|
{ "x-xbl-contract-version", "1" }
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response.get(), xbox_auth_data.toUtf8());
|
||||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||||
|
|
||||||
m_task.reset(new NetJob("XboxUserStep", APPLICATION->network()));
|
m_task.reset(new NetJob("XboxUserStep", APPLICATION->network()));
|
||||||
m_task->setAskRetry(false);
|
m_task->setAskRetry(false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class XboxUserStep : public AuthStep {
|
||||||
void onRequestDone();
|
void onRequestDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::unique_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_request;
|
Net::Upload::Ptr m_request;
|
||||||
NetJob::Ptr m_task;
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class AutoInstallJava : public LaunchStep {
|
||||||
void tryNextMajorJava();
|
void tryNextMajorJava();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftInstancePtr m_instance;
|
MinecraftInstance* m_instance;
|
||||||
Task::Ptr m_current_task;
|
Task::Ptr m_current_task;
|
||||||
|
|
||||||
qsizetype m_majorJavaVersionIndex = 0;
|
qsizetype m_majorJavaVersionIndex = 0;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ ClaimAccount::ClaimAccount(LaunchTask* parent, AuthSessionPtr session) : LaunchS
|
||||||
void ClaimAccount::executeTask()
|
void ClaimAccount::executeTask()
|
||||||
{
|
{
|
||||||
if (m_account) {
|
if (m_account) {
|
||||||
lock.reset(new UseLock(m_account));
|
lock.reset(new UseLock(m_account.get()));
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,19 +45,19 @@ void ScanModFolders::executeTask()
|
||||||
auto m_inst = m_parent->instance();
|
auto m_inst = m_parent->instance();
|
||||||
|
|
||||||
auto loaders = m_inst->loaderModList();
|
auto loaders = m_inst->loaderModList();
|
||||||
connect(loaders.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
connect(loaders, &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||||
if (!loaders->update()) {
|
if (!loaders->update()) {
|
||||||
m_modsDone = true;
|
m_modsDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cores = m_inst->coreModList();
|
auto cores = m_inst->coreModList();
|
||||||
connect(cores.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
connect(cores, &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||||
if (!cores->update()) {
|
if (!cores->update()) {
|
||||||
m_coreModsDone = true;
|
m_coreModsDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nils = m_inst->nilModList();
|
auto nils = m_inst->nilModList();
|
||||||
connect(nils.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
connect(nils, &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||||
if (!nils->update()) {
|
if (!nils->update()) {
|
||||||
m_nilModsDone = true;
|
m_nilModsDone = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ void ResourceFolderModel::installResourceWithFlameMetadata(QString path, ModPlat
|
||||||
};
|
};
|
||||||
|
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
auto job = FlameAPI().getProject(vers.addonId.toString(), response);
|
auto job = FlameAPI().getProject(vers.addonId.toString(), response.get());
|
||||||
connect(job.get(), &Task::failed, this, install);
|
connect(job.get(), &Task::failed, this, install);
|
||||||
connect(job.get(), &Task::aborted, this, install);
|
connect(job.get(), &Task::aborted, this, install);
|
||||||
connect(job.get(), &Task::succeeded, [response, this, &vers, install, &pack] {
|
connect(job.get(), &Task::succeeded, [response, this, &vers, install, &pack] {
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ Task::Ptr GetModDependenciesTask::getProjectInfoTask(std::shared_ptr<PackDepende
|
||||||
{
|
{
|
||||||
auto provider = pDep->pack->provider;
|
auto provider = pDep->pack->provider;
|
||||||
auto responseInfo = std::make_shared<QByteArray>();
|
auto responseInfo = std::make_shared<QByteArray>();
|
||||||
auto info = getAPI(provider)->getProject(pDep->pack->addonId.toString(), responseInfo);
|
auto info = getAPI(provider)->getProject(pDep->pack->addonId.toString(), responseInfo.get());
|
||||||
connect(info.get(), &NetJob::succeeded, [this, responseInfo, provider, pDep] {
|
connect(info.get(), &NetJob::succeeded, [this, responseInfo, provider, pDep] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error);
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@ CapeChange::Ptr CapeChange::make(QString token, QString capeId)
|
||||||
auto up = makeShared<CapeChange>(capeId);
|
auto up = makeShared<CapeChange>(capeId);
|
||||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active");
|
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active");
|
||||||
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
||||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
up->m_sink.reset(new Net::ByteArraySink(new QByteArray()));
|
||||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||||
}));
|
}));
|
||||||
return up;
|
return up;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include "SkinDelete.h"
|
#include "SkinDelete.h"
|
||||||
|
|
||||||
#include "net/ByteArraySink.h"
|
#include <net/DummySink.h>
|
||||||
#include "net/RawHeaderProxy.h"
|
#include "net/RawHeaderProxy.h"
|
||||||
|
|
||||||
SkinDelete::SkinDelete() : NetRequest()
|
SkinDelete::SkinDelete() : NetRequest()
|
||||||
|
|
@ -54,8 +54,8 @@ SkinDelete::Ptr SkinDelete::make(QString token)
|
||||||
{
|
{
|
||||||
auto up = makeShared<SkinDelete>();
|
auto up = makeShared<SkinDelete>();
|
||||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins/active");
|
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins/active");
|
||||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
up->m_sink.reset(new Net::DummySink());
|
||||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||||
}));
|
}));
|
||||||
return up;
|
return up;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "net/ByteArraySink.h"
|
#include "net/DummySink.h"
|
||||||
#include "net/RawHeaderProxy.h"
|
#include "net/RawHeaderProxy.h"
|
||||||
|
|
||||||
SkinUpload::SkinUpload(QString path, QString variant) : NetRequest(), m_path(path), m_variant(variant)
|
SkinUpload::SkinUpload(QString path, QString variant) : NetRequest(), m_path(path), m_variant(variant)
|
||||||
|
|
@ -72,8 +72,8 @@ SkinUpload::Ptr SkinUpload::make(QString token, QString path, QString variant)
|
||||||
auto up = makeShared<SkinUpload>(path, variant);
|
auto up = makeShared<SkinUpload>(path, variant);
|
||||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins");
|
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins");
|
||||||
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
||||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
up->m_sink.reset(new Net::DummySink());
|
||||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||||
}));
|
}));
|
||||||
return up;
|
return up;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ void LibrariesTask::executeTask()
|
||||||
emitFailed(tr("Null jar is specified in the metadata, aborting."));
|
emitFailed(tr("Null jar is specified in the metadata, aborting."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath);
|
auto dls = lib->getDownloads(inst->runtimeContext(), metacache, errors, localPath);
|
||||||
for (auto dl : dls) {
|
for (auto dl : dls) {
|
||||||
downloadJob->addNetAction(dl);
|
downloadJob->addNetAction(dl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ class CheckUpdateTask : public Task {
|
||||||
CheckUpdateTask(QList<Resource*>& resources,
|
CheckUpdateTask(QList<Resource*>& resources,
|
||||||
std::list<Version>& mcVersions,
|
std::list<Version>& mcVersions,
|
||||||
QList<ModPlatform::ModLoaderType> loadersList,
|
QList<ModPlatform::ModLoaderType> loadersList,
|
||||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
ResourceFolderModel* resourceModel)
|
||||||
: Task()
|
: Task()
|
||||||
, m_resources(resources)
|
, m_resources(resources)
|
||||||
, m_gameVersions(mcVersions)
|
, m_gameVersions(mcVersions)
|
||||||
, m_loadersList(std::move(loadersList))
|
, m_loadersList(std::move(loadersList))
|
||||||
, m_resourceModel(std::move(resourceModel))
|
, m_resourceModel(resourceModel)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
struct Update {
|
struct Update {
|
||||||
|
|
@ -71,7 +71,7 @@ class CheckUpdateTask : public Task {
|
||||||
QList<Resource*>& m_resources;
|
QList<Resource*>& m_resources;
|
||||||
std::list<Version>& m_gameVersions;
|
std::list<Version>& m_gameVersions;
|
||||||
QList<ModPlatform::ModLoaderType> m_loadersList;
|
QList<ModPlatform::ModLoaderType> m_loadersList;
|
||||||
std::shared_ptr<ResourceFolderModel> m_resourceModel;
|
ResourceFolderModel* m_resourceModel;
|
||||||
|
|
||||||
std::vector<Update> m_updates;
|
std::vector<Update> m_updates;
|
||||||
QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> m_deps;
|
QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> m_deps;
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ Task::Ptr EnsureMetadataTask::modrinthVersionsTask()
|
||||||
auto hash_type = ModPlatform::ProviderCapabilities::hashType(ModPlatform::ResourceProvider::MODRINTH).first();
|
auto hash_type = ModPlatform::ProviderCapabilities::hashType(ModPlatform::ResourceProvider::MODRINTH).first();
|
||||||
|
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
auto ver_task = modrinth_api.currentVersions(m_resources.keys(), hash_type, response);
|
auto ver_task = modrinth_api.currentVersions(m_resources.keys(), hash_type, response.get());
|
||||||
|
|
||||||
// Prevents unfortunate timings when aborting the task
|
// Prevents unfortunate timings when aborting the task
|
||||||
if (!ver_task)
|
if (!ver_task)
|
||||||
|
|
@ -273,9 +273,9 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
||||||
if (addonIds.isEmpty()) {
|
if (addonIds.isEmpty()) {
|
||||||
qWarning() << "No addonId found!";
|
qWarning() << "No addonId found!";
|
||||||
} else if (addonIds.size() == 1) {
|
} else if (addonIds.size() == 1) {
|
||||||
proj_task = modrinth_api.getProject(*addonIds.keyBegin(), response);
|
proj_task = modrinth_api.getProject(*addonIds.keyBegin(), response.get());
|
||||||
} else {
|
} else {
|
||||||
proj_task = modrinth_api.getProjects(addonIds.keys(), response);
|
proj_task = modrinth_api.getProjects(addonIds.keys(), response.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevents unfortunate timings when aborting the task
|
// Prevents unfortunate timings when aborting the task
|
||||||
|
|
@ -348,7 +348,7 @@ Task::Ptr EnsureMetadataTask::flameVersionsTask()
|
||||||
fingerprints.push_back(murmur.toUInt());
|
fingerprints.push_back(murmur.toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ver_task = flame_api.matchFingerprints(fingerprints, response);
|
auto ver_task = flame_api.matchFingerprints(fingerprints, response.get());
|
||||||
|
|
||||||
connect(ver_task.get(), &Task::succeeded, this, [this, response] {
|
connect(ver_task.get(), &Task::succeeded, this, [this, response] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -423,9 +423,9 @@ Task::Ptr EnsureMetadataTask::flameProjectsTask()
|
||||||
if (addonIds.isEmpty()) {
|
if (addonIds.isEmpty()) {
|
||||||
qWarning() << "No addonId found!";
|
qWarning() << "No addonId found!";
|
||||||
} else if (addonIds.size() == 1) {
|
} else if (addonIds.size() == 1) {
|
||||||
proj_task = flame_api.getProject(*addonIds.keyBegin(), response);
|
proj_task = flame_api.getProject(*addonIds.keyBegin(), response.get());
|
||||||
} else {
|
} else {
|
||||||
proj_task = flame_api.getProjects(addonIds.keys(), response);
|
proj_task = flame_api.getProjects(addonIds.keys(), response.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevents unfortunate timings when aborting the task
|
// Prevents unfortunate timings when aborting the task
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ Task::Ptr ResourceAPI::searchProjects(SearchArgs&& args, Callback<QList<ModPlatf
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
auto netJob = makeShared<NetJob>(QString("%1::Search").arg(debugName()), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("%1::Search").arg(debugName()), APPLICATION->network());
|
||||||
|
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(search_url), response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(search_url), response.get()));
|
||||||
|
|
||||||
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks] {
|
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -86,7 +86,7 @@ Task::Ptr ResourceAPI::getProjectVersions(VersionSearchArgs&& args, Callback<QVe
|
||||||
auto netJob = makeShared<NetJob>(QString("%1::Versions").arg(args.pack->name), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("%1::Versions").arg(args.pack->name), APPLICATION->network());
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
|
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(versions_url, response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(versions_url, response.get()));
|
||||||
|
|
||||||
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -149,7 +149,7 @@ Task::Ptr ResourceAPI::getProjectVersions(VersionSearchArgs&& args, Callback<QVe
|
||||||
Task::Ptr ResourceAPI::getProjectInfo(ProjectInfoArgs&& args, Callback<ModPlatform::IndexedPack::Ptr>&& callbacks) const
|
Task::Ptr ResourceAPI::getProjectInfo(ProjectInfoArgs&& args, Callback<ModPlatform::IndexedPack::Ptr>&& callbacks) const
|
||||||
{
|
{
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
auto job = getProject(args.pack->addonId.toString(), response);
|
auto job = getProject(args.pack->addonId.toString(), response.get());
|
||||||
|
|
||||||
QObject::connect(job.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
QObject::connect(job.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
||||||
auto pack = args.pack;
|
auto pack = args.pack;
|
||||||
|
|
@ -206,7 +206,7 @@ Task::Ptr ResourceAPI::getDependencyVersion(DependencySearchArgs&& args, Callbac
|
||||||
auto netJob = makeShared<NetJob>(QString("%1::Dependency").arg(args.dependency.addonId.toString()), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("%1::Dependency").arg(args.dependency.addonId.toString()), APPLICATION->network());
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
|
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(versions_url, response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(versions_url, response.get()));
|
||||||
|
|
||||||
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
QObject::connect(netJob.get(), &NetJob::succeeded, [this, response, callbacks, args] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -284,7 +284,7 @@ QString ResourceAPI::mapMCVersionToModrinth(Version v) const
|
||||||
return verStr;
|
return verStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr ResourceAPI::getProject(QString addonId, std::shared_ptr<QByteArray> response) const
|
Task::Ptr ResourceAPI::getProject(QString addonId, QByteArray* response) const
|
||||||
{
|
{
|
||||||
auto project_url_optional = getInfoURL(addonId);
|
auto project_url_optional = getInfoURL(addonId);
|
||||||
if (!project_url_optional.has_value())
|
if (!project_url_optional.has_value())
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,8 @@ class ResourceAPI {
|
||||||
public slots:
|
public slots:
|
||||||
virtual Task::Ptr searchProjects(SearchArgs&&, Callback<QList<ModPlatform::IndexedPack::Ptr>>&&) const;
|
virtual Task::Ptr searchProjects(SearchArgs&&, Callback<QList<ModPlatform::IndexedPack::Ptr>>&&) const;
|
||||||
|
|
||||||
virtual Task::Ptr getProject(QString addonId, std::shared_ptr<QByteArray> response) const;
|
virtual Task::Ptr getProject(QString addonId, QByteArray* response) const;
|
||||||
virtual Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const = 0;
|
virtual Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const = 0;
|
||||||
|
|
||||||
virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, Callback<ModPlatform::IndexedPack::Ptr>&&) const;
|
virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, Callback<ModPlatform::IndexedPack::Ptr>&&) const;
|
||||||
Task::Ptr getProjectVersions(VersionSearchArgs&& args, Callback<QVector<ModPlatform::IndexedVersion>>&& callbacks) const;
|
Task::Ptr getProjectVersions(VersionSearchArgs&& args, Callback<QVector<ModPlatform::IndexedVersion>>&& callbacks) const;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ void PackInstallTask::executeTask()
|
||||||
NetJob::Ptr netJob{ new NetJob("ATLauncher::VersionFetch", APPLICATION->network()) };
|
NetJob::Ptr netJob{ new NetJob("ATLauncher::VersionFetch", APPLICATION->network()) };
|
||||||
auto searchUrl =
|
auto searchUrl =
|
||||||
QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.json").arg(m_pack_safe_name).arg(m_version_name);
|
QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.json").arg(m_pack_safe_name).arg(m_version_name);
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl), response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl), response.get()));
|
||||||
|
|
||||||
connect(netJob.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
connect(netJob.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
connect(netJob.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
connect(netJob.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
|
|
@ -423,7 +423,7 @@ QString PackInstallTask::detectLibrary(const VersionLibrary& library)
|
||||||
return "org.multimc.atlauncher:" + library.md5 + ":1";
|
return "org.multimc.atlauncher:" + library.md5 + ":1";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
|
bool PackInstallTask::createLibrariesComponent(QString instanceRoot, PackProfile* profile)
|
||||||
{
|
{
|
||||||
if (m_version.libraries.isEmpty()) {
|
if (m_version.libraries.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -532,11 +532,11 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared
|
||||||
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
profile->appendComponent(ComponentPtr{ new Component(profile.get(), target_id, f) });
|
profile->appendComponent(ComponentPtr{ new Component(profile, target_id, f) });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
|
bool PackInstallTask::createPackComponent(QString instanceRoot, PackProfile* profile)
|
||||||
{
|
{
|
||||||
if (m_version.mainClass.mainClass.isEmpty() && m_version.extraArguments.arguments.isEmpty()) {
|
if (m_version.mainClass.mainClass.isEmpty() && m_version.extraArguments.arguments.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -621,7 +621,7 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
||||||
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
profile->appendComponent(ComponentPtr{ new Component(profile.get(), target_id, f) });
|
profile->appendComponent(ComponentPtr{ new Component(profile, target_id, f) });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -988,10 +988,10 @@ void PackInstallTask::install()
|
||||||
setStatus(tr("Installing modpack"));
|
setStatus(tr("Installing modpack"));
|
||||||
|
|
||||||
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||||
instanceSettings->suspendSave();
|
instanceSettings->suspendSave();
|
||||||
|
|
||||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
auto components = instance.getPackProfile();
|
auto components = instance.getPackProfile();
|
||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ void PackInstallTask::install()
|
||||||
instance.setName(name());
|
instance.setName(name());
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
instance.setManagedPack("atlauncher", m_pack_safe_name, m_pack_name, m_version_name, m_version_name);
|
instance.setManagedPack("atlauncher", m_pack_safe_name, m_pack_name, m_version_name, m_version_name);
|
||||||
instanceSettings->resumeSave();
|
instance.settings()->resumeSave();
|
||||||
|
|
||||||
jarmods.clear();
|
jarmods.clear();
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,8 @@ class PackInstallTask : public InstanceTask {
|
||||||
QString getVersionForLoader(QString uid);
|
QString getVersionForLoader(QString uid);
|
||||||
QString detectLibrary(const VersionLibrary& library);
|
QString detectLibrary(const VersionLibrary& library);
|
||||||
|
|
||||||
bool createLibrariesComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile);
|
bool createLibrariesComponent(QString instanceRoot, PackProfile* profile);
|
||||||
bool createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile);
|
bool createPackComponent(QString instanceRoot, PackProfile* profile);
|
||||||
|
|
||||||
void deleteExistingFiles();
|
void deleteExistingFiles();
|
||||||
void installConfigs();
|
void installConfigs();
|
||||||
|
|
@ -125,7 +125,7 @@ class PackInstallTask : public InstanceTask {
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
|
|
||||||
NetJob::Ptr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
|
std::unique_ptr<QByteArray> response = std::make_unique<QByteArray>();
|
||||||
|
|
||||||
InstallMode m_install_mode;
|
InstallMode m_install_mode;
|
||||||
QString m_pack_name;
|
QString m_pack_name;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ void Flame::FileResolvingTask::executeTask()
|
||||||
for (auto file : m_manifest.files) {
|
for (auto file : m_manifest.files) {
|
||||||
fileIds.push_back(QString::number(file.fileId));
|
fileIds.push_back(QString::number(file.fileId));
|
||||||
}
|
}
|
||||||
m_task = flameAPI.getFiles(fileIds, m_result);
|
m_task = flameAPI.getFiles(fileIds, m_result.get());
|
||||||
|
|
||||||
auto step_progress = std::make_shared<TaskStepProgress>();
|
auto step_progress = std::make_shared<TaskStepProgress>();
|
||||||
connect(m_task.get(), &Task::finished, this, [this, step_progress]() {
|
connect(m_task.get(), &Task::finished, this, [this, step_progress]() {
|
||||||
|
|
@ -154,7 +154,7 @@ void Flame::FileResolvingTask::netJobFinished()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_result.reset(new QByteArray());
|
m_result.reset(new QByteArray());
|
||||||
m_task = modrinthAPI.currentVersions(hashes, "sha1", m_result);
|
m_task = modrinthAPI.currentVersions(hashes, "sha1", m_result.get());
|
||||||
(dynamic_cast<NetJob*>(m_task.get()))->setAskRetry(false);
|
(dynamic_cast<NetJob*>(m_task.get()))->setAskRetry(false);
|
||||||
auto step_progress = std::make_shared<TaskStepProgress>();
|
auto step_progress = std::make_shared<TaskStepProgress>();
|
||||||
connect(m_task.get(), &Task::finished, this, [this, step_progress]() {
|
connect(m_task.get(), &Task::finished, this, [this, step_progress]() {
|
||||||
|
|
@ -227,7 +227,7 @@ void Flame::FileResolvingTask::getFlameProjects()
|
||||||
addonIds.push_back(QString::number(file.projectId));
|
addonIds.push_back(QString::number(file.projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_task = flameAPI.getProjects(addonIds, m_result);
|
m_task = flameAPI.getProjects(addonIds, m_result.get());
|
||||||
|
|
||||||
auto step_progress = std::make_shared<TaskStepProgress>();
|
auto step_progress = std::make_shared<TaskStepProgress>();
|
||||||
connect(m_task.get(), &Task::succeeded, this, [this, step_progress] {
|
connect(m_task.get(), &Task::succeeded, this, [this, step_progress] {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class FileResolvingTask : public Task {
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
Flame::Manifest m_manifest;
|
Flame::Manifest m_manifest;
|
||||||
std::shared_ptr<QByteArray> m_result;
|
std::unique_ptr<QByteArray> m_result;
|
||||||
Task::Ptr m_task;
|
Task::Ptr m_task;
|
||||||
};
|
};
|
||||||
} // namespace Flame
|
} // namespace Flame
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "net/ApiUpload.h"
|
#include "net/ApiUpload.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
Task::Ptr FlameAPI::matchFingerprints(const QList<uint>& fingerprints, std::shared_ptr<QByteArray> response)
|
Task::Ptr FlameAPI::matchFingerprints(const QList<uint>& fingerprints, QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::MatchFingerprints"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::MatchFingerprints"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ QString FlameAPI::getModFileChangelog(int modId, int fileId)
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||||
QString(BuildConfig.FLAME_BASE_URL + "/mods/%1/files/%2/changelog")
|
QString(BuildConfig.FLAME_BASE_URL + "/mods/%1/files/%2/changelog")
|
||||||
.arg(QString::fromStdString(std::to_string(modId)), QString::fromStdString(std::to_string(fileId))),
|
.arg(QString::fromStdString(std::to_string(modId)), QString::fromStdString(std::to_string(fileId))),
|
||||||
response));
|
response.get()));
|
||||||
|
|
||||||
QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &changelog] {
|
QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &changelog] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -78,7 +78,7 @@ QString FlameAPI::getModDescription(int modId)
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::ModDescription"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::ModDescription"), APPLICATION->network());
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||||
QString(BuildConfig.FLAME_BASE_URL + "/mods/%1/description").arg(QString::number(modId)), response));
|
QString(BuildConfig.FLAME_BASE_URL + "/mods/%1/description").arg(QString::number(modId)), response.get()));
|
||||||
|
|
||||||
QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &description] {
|
QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &description] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -103,7 +103,7 @@ QString FlameAPI::getModDescription(int modId)
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr FlameAPI::getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const
|
Task::Ptr FlameAPI::getProjects(QStringList addonIds, QByteArray* response) const
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::GetProjects"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::GetProjects"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ Task::Ptr FlameAPI::getProjects(QStringList addonIds, std::shared_ptr<QByteArray
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr FlameAPI::getFiles(const QStringList& fileIds, std::shared_ptr<QByteArray> response) const
|
Task::Ptr FlameAPI::getFiles(const QStringList& fileIds, QByteArray* response) const
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::GetFiles"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::GetFiles"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ Task::Ptr FlameAPI::getFiles(const QStringList& fileIds, std::shared_ptr<QByteAr
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr FlameAPI::getFile(const QString& addonId, const QString& fileId, std::shared_ptr<QByteArray> response) const
|
Task::Ptr FlameAPI::getFile(const QString& addonId, const QString& fileId, QByteArray* response) const
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::GetFile"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::GetFile"), APPLICATION->network());
|
||||||
netJob->addNetAction(
|
netJob->addNetAction(
|
||||||
|
|
@ -171,7 +171,7 @@ QList<ResourceAPI::SortingMethod> FlameAPI::getSortingMethods() const
|
||||||
{ 8, "GameVersion", QObject::tr("Sort by Game Version") } };
|
{ 8, "GameVersion", QObject::tr("Sort by Game Version") } };
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr FlameAPI::getCategories(std::shared_ptr<QByteArray> response, ModPlatform::ResourceType type)
|
Task::Ptr FlameAPI::getCategories(QByteArray* response, ModPlatform::ResourceType type)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Flame::GetCategories"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Flame::GetCategories"), APPLICATION->network());
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||||
|
|
@ -180,12 +180,12 @@ Task::Ptr FlameAPI::getCategories(std::shared_ptr<QByteArray> response, ModPlatf
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr FlameAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
Task::Ptr FlameAPI::getModCategories(QByteArray* response)
|
||||||
{
|
{
|
||||||
return getCategories(response, ModPlatform::ResourceType::Mod);
|
return getCategories(response, ModPlatform::ResourceType::Mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ModPlatform::Category> FlameAPI::loadModCategories(std::shared_ptr<QByteArray> response)
|
QList<ModPlatform::Category> FlameAPI::loadModCategories(QByteArray* response)
|
||||||
{
|
{
|
||||||
QList<ModPlatform::Category> categories;
|
QList<ModPlatform::Category> categories;
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,14 @@ class FlameAPI : public ResourceAPI {
|
||||||
ModPlatform::ModLoaderTypes fallback,
|
ModPlatform::ModLoaderTypes fallback,
|
||||||
bool checkLoaders);
|
bool checkLoaders);
|
||||||
|
|
||||||
Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const override;
|
Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const override;
|
||||||
Task::Ptr matchFingerprints(const QList<uint>& fingerprints, std::shared_ptr<QByteArray> response);
|
Task::Ptr matchFingerprints(const QList<uint>& fingerprints, QByteArray* response);
|
||||||
Task::Ptr getFiles(const QStringList& fileIds, std::shared_ptr<QByteArray> response) const;
|
Task::Ptr getFiles(const QStringList& fileIds, QByteArray* response) const;
|
||||||
Task::Ptr getFile(const QString& addonId, const QString& fileId, std::shared_ptr<QByteArray> response) const;
|
Task::Ptr getFile(const QString& addonId, const QString& fileId, QByteArray* response) const;
|
||||||
|
|
||||||
static Task::Ptr getCategories(std::shared_ptr<QByteArray> response, ModPlatform::ResourceType type);
|
static Task::Ptr getCategories(QByteArray* response, ModPlatform::ResourceType type);
|
||||||
static Task::Ptr getModCategories(std::shared_ptr<QByteArray> response);
|
static Task::Ptr getModCategories(QByteArray* response);
|
||||||
static QList<ModPlatform::Category> loadModCategories(std::shared_ptr<QByteArray> response);
|
static QList<ModPlatform::Category> loadModCategories(QByteArray* response);
|
||||||
|
|
||||||
QList<ResourceAPI::SortingMethod> getSortingMethods() const override;
|
QList<ResourceAPI::SortingMethod> getSortingMethods() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,16 +53,16 @@ void FlameCheckUpdate::executeTask()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
auto task = Net::ApiDownload::makeByteArray(versionsUrlOptional.value(), response);
|
auto task = Net::ApiDownload::makeByteArray(versionsUrlOptional.value(), response.get());
|
||||||
|
|
||||||
connect(task.get(), &Task::succeeded, this, [this, resource, response] { getLatestVersionCallback(resource, response); });
|
connect(task.get(), &Task::succeeded, this, [this, resource, response] { getLatestVersionCallback(resource, response.get()); });
|
||||||
netJob->addNetAction(task);
|
netJob->addNetAction(task);
|
||||||
}
|
}
|
||||||
m_task.reset(netJob);
|
m_task.reset(netJob);
|
||||||
m_task->start();
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, std::shared_ptr<QByteArray> response)
|
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* response)
|
||||||
{
|
{
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
||||||
|
|
@ -146,9 +146,9 @@ void FlameCheckUpdate::collectBlockedMods()
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
} else if (addonIds.size() == 1) {
|
} else if (addonIds.size() == 1) {
|
||||||
projTask = api.getProject(*addonIds.begin(), response);
|
projTask = api.getProject(*addonIds.begin(), response.get());
|
||||||
} else {
|
} else {
|
||||||
projTask = api.getProjects(addonIds, response);
|
projTask = api.getProjects(addonIds, response.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds, quickSearch] {
|
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds, quickSearch] {
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ class FlameCheckUpdate : public CheckUpdateTask {
|
||||||
FlameCheckUpdate(QList<Resource*>& resources,
|
FlameCheckUpdate(QList<Resource*>& resources,
|
||||||
std::list<Version>& mcVersions,
|
std::list<Version>& mcVersions,
|
||||||
QList<ModPlatform::ModLoaderType> loadersList,
|
QList<ModPlatform::ModLoaderType> loadersList,
|
||||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
ResourceFolderModel* resourceModel)
|
||||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), std::move(resourceModel))
|
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), resourceModel)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
@ -19,7 +19,7 @@ class FlameCheckUpdate : public CheckUpdateTask {
|
||||||
protected slots:
|
protected slots:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
private slots:
|
private slots:
|
||||||
void getLatestVersionCallback(Resource* resource, std::shared_ptr<QByteArray> response);
|
void getLatestVersionCallback(Resource* resource, QByteArray* response);
|
||||||
void collectBlockedMods();
|
void collectBlockedMods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ bool FlameCreationTask::updateInstance()
|
||||||
auto instance_list = APPLICATION->instances();
|
auto instance_list = APPLICATION->instances();
|
||||||
|
|
||||||
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
||||||
InstancePtr inst;
|
BaseInstance* inst;
|
||||||
if (auto original_id = originalInstanceID(); !original_id.isEmpty()) {
|
if (auto original_id = originalInstanceID(); !original_id.isEmpty()) {
|
||||||
inst = instance_list->getInstanceById(original_id);
|
inst = instance_list->getInstanceById(original_id);
|
||||||
Q_ASSERT(inst);
|
Q_ASSERT(inst);
|
||||||
|
|
@ -185,7 +185,7 @@ bool FlameCreationTask::updateInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto raw_response = std::make_shared<QByteArray>();
|
auto raw_response = std::make_shared<QByteArray>();
|
||||||
auto job = api.getFiles(fileIds, raw_response);
|
auto job = api.getFiles(fileIds, raw_response.get());
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
|
|
||||||
|
|
@ -386,8 +386,8 @@ bool FlameCreationTask::createInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
auto mcVersion = m_pack.minecraft.version;
|
auto mcVersion = m_pack.minecraft.version;
|
||||||
|
|
||||||
// Hack to correct some 'special sauce'...
|
// Hack to correct some 'special sauce'...
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlameCreationTask(const QString& staging_path,
|
FlameCreationTask(const QString& staging_path,
|
||||||
SettingsObjectPtr global_settings,
|
SettingsObject* global_settings,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
QString id,
|
QString id,
|
||||||
QString version_id,
|
QString version_id,
|
||||||
|
|
@ -91,7 +91,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
||||||
|
|
||||||
QList<std::pair<QString, QString>> m_otherResources;
|
QList<std::pair<QString, QString>> m_otherResources;
|
||||||
|
|
||||||
std::optional<InstancePtr> m_instance;
|
std::optional<BaseInstance*> m_instance;
|
||||||
|
|
||||||
QStringList m_selectedOptionalMods;
|
QStringList m_selectedOptionalMods;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ void FlamePackExportTask::collectFiles()
|
||||||
resolvedFiles.clear();
|
resolvedFiles.clear();
|
||||||
|
|
||||||
m_options.instance->loaderModList()->update();
|
m_options.instance->loaderModList()->update();
|
||||||
connect(m_options.instance->loaderModList().get(), &ModFolderModel::updateFinished, this, &FlamePackExportTask::collectHashes);
|
connect(m_options.instance->loaderModList(), &ModFolderModel::updateFinished, this, &FlamePackExportTask::collectHashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlamePackExportTask::collectHashes()
|
void FlamePackExportTask::collectHashes()
|
||||||
|
|
@ -174,7 +174,7 @@ void FlamePackExportTask::makeApiRequest()
|
||||||
fingerprints.push_back(murmur.toUInt());
|
fingerprints.push_back(murmur.toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
task.reset(api.matchFingerprints(fingerprints, response));
|
task.reset(api.matchFingerprints(fingerprints, response.get()));
|
||||||
|
|
||||||
connect(task.get(), &Task::succeeded, this, [this, response] {
|
connect(task.get(), &Task::succeeded, this, [this, response] {
|
||||||
QJsonParseError parseError{};
|
QJsonParseError parseError{};
|
||||||
|
|
@ -252,9 +252,9 @@ void FlamePackExportTask::getProjectsInfo()
|
||||||
buildZip();
|
buildZip();
|
||||||
return;
|
return;
|
||||||
} else if (addonIds.size() == 1) {
|
} else if (addonIds.size() == 1) {
|
||||||
projTask = api.getProject(*addonIds.begin(), response);
|
projTask = api.getProject(*addonIds.begin(), response.get());
|
||||||
} else {
|
} else {
|
||||||
projTask = api.getProjects(addonIds, response);
|
projTask = api.getProjects(addonIds, response.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds] {
|
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds] {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ struct FlamePackExportOptions {
|
||||||
QString version;
|
QString version;
|
||||||
QString author;
|
QString author;
|
||||||
bool optionalFiles;
|
bool optionalFiles;
|
||||||
MinecraftInstancePtr instance;
|
MinecraftInstance* instance;
|
||||||
QString output;
|
QString output;
|
||||||
MMCZip::FilterFileFunction filter;
|
MMCZip::FilterFileFunction filter;
|
||||||
int recommendedRAM;
|
int recommendedRAM;
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ void PackInstallTask::copySettings()
|
||||||
setStatus(tr("Copying settings..."));
|
setStatus(tr("Copying settings..."));
|
||||||
progress(2, 2);
|
progress(2, 2);
|
||||||
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||||
instanceSettings->suspendSave();
|
instanceSettings->suspendSave();
|
||||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
instance.settings()->set("InstanceType", "OneSix");
|
instance.settings()->set("InstanceType", "OneSix");
|
||||||
instance.settings()->set("totalTimePlayed", m_pack.totalPlayTime / 1000);
|
instance.settings()->set("totalTimePlayed", m_pack.totalPlayTime / 1000);
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ void PackInstallTask::copySettings()
|
||||||
if (m_instIcon == "default")
|
if (m_instIcon == "default")
|
||||||
m_instIcon = "ftb_logo";
|
m_instIcon = "ftb_logo";
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
instanceSettings->resumeSave();
|
instance.settings()->resumeSave();
|
||||||
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ void PackFetchTask::fetch()
|
||||||
|
|
||||||
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
|
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
|
||||||
qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
|
qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
|
||||||
jobPtr->addNetAction(Net::ApiDownload::makeByteArray(publicPacksUrl, publicModpacksXmlFileData));
|
jobPtr->addNetAction(Net::ApiDownload::makeByteArray(publicPacksUrl, publicModpacksXmlFileData.get()));
|
||||||
|
|
||||||
QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml");
|
QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml");
|
||||||
qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString();
|
qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString();
|
||||||
jobPtr->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, thirdPartyModpacksXmlFileData));
|
jobPtr->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, thirdPartyModpacksXmlFileData.get()));
|
||||||
|
|
||||||
connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
||||||
connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
||||||
|
|
@ -73,7 +73,7 @@ void PackFetchTask::fetchPrivate(const QStringList& toFetch)
|
||||||
for (auto& packCode : toFetch) {
|
for (auto& packCode : toFetch) {
|
||||||
auto data = std::make_shared<QByteArray>();
|
auto data = std::make_shared<QByteArray>();
|
||||||
NetJob* job = new NetJob("Fetching private pack", m_network);
|
NetJob* job = new NetJob("Fetching private pack", m_network);
|
||||||
job->addNetAction(Net::ApiDownload::makeByteArray(privatePackBaseUrl.arg(packCode), data));
|
job->addNetAction(Net::ApiDownload::makeByteArray(privatePackBaseUrl.arg(packCode), data.get()));
|
||||||
job->setAskRetry(false);
|
job->setAskRetry(false);
|
||||||
|
|
||||||
connect(job, &NetJob::succeeded, this, [this, job, data, packCode] {
|
connect(job, &NetJob::succeeded, this, [this, job, data, packCode] {
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,18 @@ class PackFetchTask : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network) {};
|
PackFetchTask(QNetworkAccessManager* network) : QObject(nullptr), m_network(network) {};
|
||||||
virtual ~PackFetchTask() = default;
|
virtual ~PackFetchTask() = default;
|
||||||
|
|
||||||
void fetch();
|
void fetch();
|
||||||
void fetchPrivate(const QStringList& toFetch);
|
void fetchPrivate(const QStringList& toFetch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
QNetworkAccessManager* m_network;
|
||||||
NetJob::Ptr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
|
|
||||||
std::shared_ptr<QByteArray> publicModpacksXmlFileData = std::make_shared<QByteArray>();
|
std::unique_ptr<QByteArray> publicModpacksXmlFileData = std::make_unique<QByteArray>();
|
||||||
std::shared_ptr<QByteArray> thirdPartyModpacksXmlFileData = std::make_shared<QByteArray>();
|
std::unique_ptr<QByteArray> thirdPartyModpacksXmlFileData = std::make_unique<QByteArray>();
|
||||||
|
|
||||||
bool parseAndAddPacks(QByteArray& data, PackType packType, ModpackList& list);
|
bool parseAndAddPacks(QByteArray& data, PackType packType, ModpackList& list);
|
||||||
ModpackList publicPacks;
|
ModpackList publicPacks;
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
PackInstallTask::PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const Modpack& pack, QString version)
|
PackInstallTask::PackInstallTask(QNetworkAccessManager* network, const Modpack& pack, QString version)
|
||||||
{
|
{
|
||||||
m_pack = pack;
|
m_pack = pack;
|
||||||
m_version = version;
|
m_version = version;
|
||||||
|
|
@ -133,10 +133,10 @@ void PackInstallTask::install()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||||
instanceSettings->suspendSave();
|
instanceSettings->suspendSave();
|
||||||
|
|
||||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
auto components = instance.getPackProfile();
|
auto components = instance.getPackProfile();
|
||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
|
components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
|
||||||
|
|
@ -204,7 +204,7 @@ void PackInstallTask::install()
|
||||||
m_instIcon = "ftb_logo";
|
m_instIcon = "ftb_logo";
|
||||||
}
|
}
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
instanceSettings->resumeSave();
|
instance.settings()->resumeSave();
|
||||||
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class PackInstallTask : public InstanceTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const Modpack& pack, QString version);
|
explicit PackInstallTask(QNetworkAccessManager* network, const Modpack& pack, QString version);
|
||||||
virtual ~PackInstallTask() {}
|
virtual ~PackInstallTask() {}
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
|
|
@ -35,7 +35,7 @@ class PackInstallTask : public InstanceTask {
|
||||||
void onUnzipCanceled();
|
void onUnzipCanceled();
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
QNetworkAccessManager* m_network;
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
QFuture<std::optional<QStringList>> m_extractFuture;
|
QFuture<std::optional<QStringList>> m_extractFuture;
|
||||||
QFutureWatcher<std::optional<QStringList>> m_extractFutureWatcher;
|
QFutureWatcher<std::optional<QStringList>> m_extractFutureWatcher;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
Task::Ptr ModrinthAPI::currentVersion(QString hash, QString hash_format, std::shared_ptr<QByteArray> response)
|
Task::Ptr ModrinthAPI::currentVersion(QString hash, QString hash_format, QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCurrentVersion"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCurrentVersion"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ Task::Ptr ModrinthAPI::currentVersion(QString hash, QString hash_format, std::sh
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr ModrinthAPI::currentVersions(const QStringList& hashes, QString hash_format, std::shared_ptr<QByteArray> response)
|
Task::Ptr ModrinthAPI::currentVersions(const QStringList& hashes, QString hash_format, QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCurrentVersions"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCurrentVersions"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ Task::Ptr ModrinthAPI::latestVersion(QString hash,
|
||||||
QString hash_format,
|
QString hash_format,
|
||||||
std::optional<std::list<Version>> mcVersions,
|
std::optional<std::list<Version>> mcVersions,
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||||
std::shared_ptr<QByteArray> response)
|
QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersion"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersion"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ Task::Ptr ModrinthAPI::latestVersions(const QStringList& hashes,
|
||||||
QString hash_format,
|
QString hash_format,
|
||||||
std::optional<std::list<Version>> mcVersions,
|
std::optional<std::list<Version>> mcVersions,
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||||
std::shared_ptr<QByteArray> response)
|
QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersions"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersions"), APPLICATION->network());
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ Task::Ptr ModrinthAPI::latestVersions(const QStringList& hashes,
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr ModrinthAPI::getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const
|
Task::Ptr ModrinthAPI::getProjects(QStringList addonIds, QByteArray* response) const
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetProjects"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetProjects"), APPLICATION->network());
|
||||||
auto searchUrl = getMultipleModInfoURL(addonIds);
|
auto searchUrl = getMultipleModInfoURL(addonIds);
|
||||||
|
|
@ -121,7 +121,7 @@ QList<ResourceAPI::SortingMethod> ModrinthAPI::getSortingMethods() const
|
||||||
{ 5, "updated", QObject::tr("Sort by Last Updated") } };
|
{ 5, "updated", QObject::tr("Sort by Last Updated") } };
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr ModrinthAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
Task::Ptr ModrinthAPI::getModCategories(QByteArray* response)
|
||||||
{
|
{
|
||||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCategories"), APPLICATION->network());
|
auto netJob = makeShared<NetJob>(QString("Modrinth::GetCategories"), APPLICATION->network());
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(BuildConfig.MODRINTH_PROD_URL + "/tag/category"), response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(BuildConfig.MODRINTH_PROD_URL + "/tag/category"), response));
|
||||||
|
|
@ -129,7 +129,7 @@ Task::Ptr ModrinthAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ModPlatform::Category> ModrinthAPI::loadCategories(std::shared_ptr<QByteArray> response, QString projectType)
|
QList<ModPlatform::Category> ModrinthAPI::loadCategories(QByteArray* response, QString projectType)
|
||||||
{
|
{
|
||||||
QList<ModPlatform::Category> categories;
|
QList<ModPlatform::Category> categories;
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
|
|
@ -159,7 +159,7 @@ QList<ModPlatform::Category> ModrinthAPI::loadCategories(std::shared_ptr<QByteAr
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ModPlatform::Category> ModrinthAPI::loadModCategories(std::shared_ptr<QByteArray> response)
|
QList<ModPlatform::Category> ModrinthAPI::loadModCategories(QByteArray* response)
|
||||||
{
|
{
|
||||||
return loadCategories(response, "mod");
|
return loadCategories(response, "mod");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,27 +14,27 @@
|
||||||
|
|
||||||
class ModrinthAPI : public ResourceAPI {
|
class ModrinthAPI : public ResourceAPI {
|
||||||
public:
|
public:
|
||||||
Task::Ptr currentVersion(QString hash, QString hash_format, std::shared_ptr<QByteArray> response);
|
Task::Ptr currentVersion(QString hash, QString hash_format, QByteArray* response);
|
||||||
|
|
||||||
Task::Ptr currentVersions(const QStringList& hashes, QString hash_format, std::shared_ptr<QByteArray> response);
|
Task::Ptr currentVersions(const QStringList& hashes, QString hash_format, QByteArray* response);
|
||||||
|
|
||||||
Task::Ptr latestVersion(QString hash,
|
Task::Ptr latestVersion(QString hash,
|
||||||
QString hash_format,
|
QString hash_format,
|
||||||
std::optional<std::list<Version>> mcVersions,
|
std::optional<std::list<Version>> mcVersions,
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||||
std::shared_ptr<QByteArray> response);
|
QByteArray* response);
|
||||||
|
|
||||||
Task::Ptr latestVersions(const QStringList& hashes,
|
Task::Ptr latestVersions(const QStringList& hashes,
|
||||||
QString hash_format,
|
QString hash_format,
|
||||||
std::optional<std::list<Version>> mcVersions,
|
std::optional<std::list<Version>> mcVersions,
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||||
std::shared_ptr<QByteArray> response);
|
QByteArray* response);
|
||||||
|
|
||||||
Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const override;
|
Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const override;
|
||||||
|
|
||||||
static Task::Ptr getModCategories(std::shared_ptr<QByteArray> response);
|
static Task::Ptr getModCategories(QByteArray* response);
|
||||||
static QList<ModPlatform::Category> loadCategories(std::shared_ptr<QByteArray> response, QString projectType);
|
static QList<ModPlatform::Category> loadCategories(QByteArray* response, QString projectType);
|
||||||
static QList<ModPlatform::Category> loadModCategories(std::shared_ptr<QByteArray> response);
|
static QList<ModPlatform::Category> loadModCategories(QByteArray* response);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto getSortingMethods() const -> QList<ResourceAPI::SortingMethod> override;
|
auto getSortingMethods() const -> QList<ResourceAPI::SortingMethod> override;
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ static ModrinthAPI api;
|
||||||
ModrinthCheckUpdate::ModrinthCheckUpdate(QList<Resource*>& resources,
|
ModrinthCheckUpdate::ModrinthCheckUpdate(QList<Resource*>& resources,
|
||||||
std::list<Version>& mcVersions,
|
std::list<Version>& mcVersions,
|
||||||
QList<ModPlatform::ModLoaderType> loadersList,
|
QList<ModPlatform::ModLoaderType> loadersList,
|
||||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
ResourceFolderModel* resourceModel)
|
||||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), std::move(resourceModel))
|
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), resourceModel)
|
||||||
, m_hashType(ModPlatform::ProviderCapabilities::hashType(ModPlatform::ResourceProvider::MODRINTH).first())
|
, m_hashType(ModPlatform::ProviderCapabilities::hashType(ModPlatform::ResourceProvider::MODRINTH).first())
|
||||||
{
|
{
|
||||||
if (!m_loadersList.isEmpty()) { // this is for mods so append all the other posible loaders to the initial list
|
if (!m_loadersList.isEmpty()) { // this is for mods so append all the other posible loaders to the initial list
|
||||||
|
|
@ -97,9 +97,9 @@ void ModrinthCheckUpdate::getUpdateModsForLoader(std::optional<ModPlatform::ModL
|
||||||
} else {
|
} else {
|
||||||
hashes = m_mappings.keys();
|
hashes = m_mappings.keys();
|
||||||
}
|
}
|
||||||
auto job = api.latestVersions(hashes, m_hashType, m_gameVersions, loader, response);
|
auto job = api.latestVersions(hashes, m_hashType, m_gameVersions, loader, response.get());
|
||||||
|
|
||||||
connect(job.get(), &Task::succeeded, this, [this, response, loader] { checkVersionsResponse(response, loader); });
|
connect(job.get(), &Task::succeeded, this, [this, response, loader] { checkVersionsResponse(response.get(), loader); });
|
||||||
|
|
||||||
connect(job.get(), &Task::failed, this, &ModrinthCheckUpdate::checkNextLoader);
|
connect(job.get(), &Task::failed, this, &ModrinthCheckUpdate::checkNextLoader);
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ void ModrinthCheckUpdate::getUpdateModsForLoader(std::optional<ModPlatform::ModL
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModrinthCheckUpdate::checkVersionsResponse(std::shared_ptr<QByteArray> response, std::optional<ModPlatform::ModLoaderTypes> loader)
|
void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optional<ModPlatform::ModLoaderTypes> loader)
|
||||||
{
|
{
|
||||||
setStatus(tr("Parsing the API response from Modrinth..."));
|
setStatus(tr("Parsing the API response from Modrinth..."));
|
||||||
setProgress(m_progress + 1, m_progressTotal);
|
setProgress(m_progress + 1, m_progressTotal);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class ModrinthCheckUpdate : public CheckUpdateTask {
|
||||||
ModrinthCheckUpdate(QList<Resource*>& resources,
|
ModrinthCheckUpdate(QList<Resource*>& resources,
|
||||||
std::list<Version>& mcVersions,
|
std::list<Version>& mcVersions,
|
||||||
QList<ModPlatform::ModLoaderType> loadersList,
|
QList<ModPlatform::ModLoaderType> loadersList,
|
||||||
std::shared_ptr<ResourceFolderModel> resourceModel);
|
ResourceFolderModel* resourceModel);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
|
@ -17,7 +17,7 @@ class ModrinthCheckUpdate : public CheckUpdateTask {
|
||||||
protected slots:
|
protected slots:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
void getUpdateModsForLoader(std::optional<ModPlatform::ModLoaderTypes> loader = {}, bool forceModLoaderCheck = false);
|
void getUpdateModsForLoader(std::optional<ModPlatform::ModLoaderTypes> loader = {}, bool forceModLoaderCheck = false);
|
||||||
void checkVersionsResponse(std::shared_ptr<QByteArray> response, std::optional<ModPlatform::ModLoaderTypes> loader);
|
void checkVersionsResponse(QByteArray* response, std::optional<ModPlatform::ModLoaderTypes> loader);
|
||||||
void checkNextLoader();
|
void checkNextLoader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ bool ModrinthCreationTask::updateInstance()
|
||||||
auto instance_list = APPLICATION->instances();
|
auto instance_list = APPLICATION->instances();
|
||||||
|
|
||||||
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
||||||
InstancePtr inst;
|
BaseInstance* inst;
|
||||||
if (auto original_id = originalInstanceID(); !original_id.isEmpty()) {
|
if (auto original_id = originalInstanceID(); !original_id.isEmpty()) {
|
||||||
inst = instance_list->getInstanceById(original_id);
|
inst = instance_list->getInstanceById(original_id);
|
||||||
Q_ASSERT(inst);
|
Q_ASSERT(inst);
|
||||||
|
|
@ -212,8 +212,8 @@ bool ModrinthCreationTask::createInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||||
|
|
||||||
auto components = instance.getPackProfile();
|
auto components = instance.getPackProfile();
|
||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModrinthCreationTask(QString staging_path,
|
ModrinthCreationTask(QString staging_path,
|
||||||
SettingsObjectPtr global_settings,
|
SettingsObject* global_settings,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
QString id,
|
QString id,
|
||||||
QString version_id = {},
|
QString version_id = {},
|
||||||
|
|
@ -55,7 +55,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
|
||||||
std::vector<File> m_files;
|
std::vector<File> m_files;
|
||||||
Task::Ptr m_task;
|
Task::Ptr m_task;
|
||||||
|
|
||||||
std::optional<InstancePtr> m_instance;
|
std::optional<BaseInstance*> m_instance;
|
||||||
|
|
||||||
QString m_root_path = "minecraft";
|
QString m_root_path = "minecraft";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||||
const QString& version,
|
const QString& version,
|
||||||
const QString& summary,
|
const QString& summary,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
BaseInstance* instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFileFunction filter)
|
MMCZip::FilterFileFunction filter)
|
||||||
: name(name)
|
: name(name)
|
||||||
|
|
@ -48,7 +48,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||||
, summary(summary)
|
, summary(summary)
|
||||||
, optionalFiles(optionalFiles)
|
, optionalFiles(optionalFiles)
|
||||||
, instance(instance)
|
, instance(instance)
|
||||||
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
, mcInstance(dynamic_cast<MinecraftInstance*>(instance))
|
||||||
, gameRoot(instance->gameRoot())
|
, gameRoot(instance->gameRoot())
|
||||||
, output(output)
|
, output(output)
|
||||||
, filter(filter)
|
, filter(filter)
|
||||||
|
|
@ -86,7 +86,7 @@ void ModrinthPackExportTask::collectFiles()
|
||||||
|
|
||||||
if (mcInstance) {
|
if (mcInstance) {
|
||||||
mcInstance->loaderModList()->update();
|
mcInstance->loaderModList()->update();
|
||||||
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
|
connect(mcInstance->loaderModList(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
|
||||||
} else
|
} else
|
||||||
collectHashes();
|
collectHashes();
|
||||||
}
|
}
|
||||||
|
|
@ -156,15 +156,15 @@ void ModrinthPackExportTask::makeApiRequest()
|
||||||
else {
|
else {
|
||||||
setStatus(tr("Finding versions for hashes..."));
|
setStatus(tr("Finding versions for hashes..."));
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
task = api.currentVersions(pendingHashes.values(), "sha512", response.get());
|
||||||
connect(task.get(), &Task::succeeded, [this, response]() { parseApiResponse(response); });
|
connect(task.get(), &Task::succeeded, [this, response]() { parseApiResponse(response.get()); });
|
||||||
connect(task.get(), &Task::failed, this, &ModrinthPackExportTask::emitFailed);
|
connect(task.get(), &Task::failed, this, &ModrinthPackExportTask::emitFailed);
|
||||||
connect(task.get(), &Task::aborted, this, &ModrinthPackExportTask::emitAborted);
|
connect(task.get(), &Task::aborted, this, &ModrinthPackExportTask::emitAborted);
|
||||||
task->start();
|
task->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModrinthPackExportTask::parseApiResponse(const std::shared_ptr<QByteArray> response)
|
void ModrinthPackExportTask::parseApiResponse(QByteArray* response)
|
||||||
{
|
{
|
||||||
task = nullptr;
|
task = nullptr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class ModrinthPackExportTask : public Task {
|
||||||
const QString& version,
|
const QString& version,
|
||||||
const QString& summary,
|
const QString& summary,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
BaseInstance* instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFileFunction filter);
|
MMCZip::FilterFileFunction filter);
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ModrinthPackExportTask : public Task {
|
||||||
// inputs
|
// inputs
|
||||||
const QString name, version, summary;
|
const QString name, version, summary;
|
||||||
const bool optionalFiles;
|
const bool optionalFiles;
|
||||||
const InstancePtr instance;
|
const BaseInstance* instance;
|
||||||
MinecraftInstance* mcInstance;
|
MinecraftInstance* mcInstance;
|
||||||
const QDir gameRoot;
|
const QDir gameRoot;
|
||||||
const QString output;
|
const QString output;
|
||||||
|
|
@ -70,7 +70,7 @@ class ModrinthPackExportTask : public Task {
|
||||||
void collectFiles();
|
void collectFiles();
|
||||||
void collectHashes();
|
void collectHashes();
|
||||||
void makeApiRequest();
|
void makeApiRequest();
|
||||||
void parseApiResponse(std::shared_ptr<QByteArray> response);
|
void parseApiResponse(QByteArray* response);
|
||||||
void buildZip();
|
void buildZip();
|
||||||
|
|
||||||
QByteArray generateIndex();
|
QByteArray generateIndex();
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
#include "net/ApiDownload.h"
|
#include "net/ApiDownload.h"
|
||||||
#include "net/ChecksumValidator.h"
|
#include "net/ChecksumValidator.h"
|
||||||
|
|
||||||
Technic::SolderPackInstallTask::SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network,
|
Technic::SolderPackInstallTask::SolderPackInstallTask(QNetworkAccessManager* network,
|
||||||
const QUrl& solderUrl,
|
const QUrl& solderUrl,
|
||||||
const QString& pack,
|
const QString& pack,
|
||||||
const QString& version,
|
const QString& version,
|
||||||
|
|
@ -72,7 +72,7 @@ void Technic::SolderPackInstallTask::executeTask()
|
||||||
|
|
||||||
m_filesNetJob.reset(new NetJob(tr("Resolving modpack files"), m_network));
|
m_filesNetJob.reset(new NetJob(tr("Resolving modpack files"), m_network));
|
||||||
auto sourceUrl = QString("%1/modpack/%2/%3").arg(m_solderUrl.toString(), m_pack, m_version);
|
auto sourceUrl = QString("%1/modpack/%2/%3").arg(m_solderUrl.toString(), m_pack, m_version);
|
||||||
m_filesNetJob->addNetAction(Net::ApiDownload::makeByteArray(sourceUrl, m_response));
|
m_filesNetJob->addNetAction(Net::ApiDownload::makeByteArray(sourceUrl, m_response.get()));
|
||||||
|
|
||||||
auto job = m_filesNetJob.get();
|
auto job = m_filesNetJob.get();
|
||||||
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Technic {
|
||||||
class SolderPackInstallTask : public InstanceTask {
|
class SolderPackInstallTask : public InstanceTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network,
|
explicit SolderPackInstallTask(QNetworkAccessManager* network,
|
||||||
const QUrl& solderUrl,
|
const QUrl& solderUrl,
|
||||||
const QString& pack,
|
const QString& pack,
|
||||||
const QString& version,
|
const QString& version,
|
||||||
|
|
@ -71,14 +71,14 @@ class SolderPackInstallTask : public InstanceTask {
|
||||||
private:
|
private:
|
||||||
bool m_abortable = false;
|
bool m_abortable = false;
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
QNetworkAccessManager* m_network;
|
||||||
|
|
||||||
NetJob::Ptr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
QUrl m_solderUrl;
|
QUrl m_solderUrl;
|
||||||
QString m_pack;
|
QString m_pack;
|
||||||
QString m_version;
|
QString m_version;
|
||||||
QString m_minecraftVersion;
|
QString m_minecraftVersion;
|
||||||
std::shared_ptr<QByteArray> m_response = std::make_shared<QByteArray>();
|
std::unique_ptr<QByteArray> m_response = std::make_unique<QByteArray>();
|
||||||
QTemporaryDir m_outputDir;
|
QTemporaryDir m_outputDir;
|
||||||
int m_modCount;
|
int m_modCount;
|
||||||
QFuture<bool> m_extractFuture;
|
QFuture<bool> m_extractFuture;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "archive/ArchiveReader.h"
|
#include "archive/ArchiveReader.h"
|
||||||
|
|
||||||
void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings,
|
void Technic::TechnicPackProcessor::run(SettingsObject* globalSettings,
|
||||||
const QString& instName,
|
const QString& instName,
|
||||||
const QString& instIcon,
|
const QString& instIcon,
|
||||||
const QString& stagingPath,
|
const QString& stagingPath,
|
||||||
|
|
@ -33,8 +33,8 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings,
|
||||||
{
|
{
|
||||||
QString minecraftPath = FS::PathCombine(stagingPath, "minecraft");
|
QString minecraftPath = FS::PathCombine(stagingPath, "minecraft");
|
||||||
QString configPath = FS::PathCombine(stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||||
MinecraftInstance instance(globalSettings, instanceSettings, stagingPath);
|
MinecraftInstance instance(globalSettings, std::move(instanceSettings), stagingPath);
|
||||||
|
|
||||||
instance.setName(instName);
|
instance.setName(instName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class TechnicPackProcessor : public QObject {
|
||||||
void failed(QString reason);
|
void failed(QString reason);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void run(SettingsObjectPtr globalSettings,
|
void run(SettingsObject* globalSettings,
|
||||||
const QString& instName,
|
const QString& instName,
|
||||||
const QString& instIcon,
|
const QString& instIcon,
|
||||||
const QString& stagingPath,
|
const QString& stagingPath,
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,21 @@ namespace Net {
|
||||||
Download::Ptr ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Download::Options options)
|
Download::Ptr ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Download::Options options)
|
||||||
{
|
{
|
||||||
auto dl = Download::makeCached(url, entry, options);
|
auto dl = Download::makeCached(url, entry, options);
|
||||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||||
return dl;
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Download::Ptr ApiDownload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Download::Options options)
|
Download::Ptr ApiDownload::makeByteArray(QUrl url, QByteArray* output, Download::Options options)
|
||||||
{
|
{
|
||||||
auto dl = Download::makeByteArray(url, output, options);
|
auto dl = Download::makeByteArray(url, output, options);
|
||||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||||
return dl;
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Download::Ptr ApiDownload::makeFile(QUrl url, QString path, Download::Options options)
|
Download::Ptr ApiDownload::makeFile(QUrl url, QString path, Download::Options options)
|
||||||
{
|
{
|
||||||
auto dl = Download::makeFile(url, path, options);
|
auto dl = Download::makeFile(url, path, options);
|
||||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||||
return dl;
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Net {
|
||||||
|
|
||||||
namespace ApiDownload {
|
namespace ApiDownload {
|
||||||
Download::Ptr makeCached(QUrl url, MetaEntryPtr entry, Download::Options options = Download::Option::NoOptions);
|
Download::Ptr makeCached(QUrl url, MetaEntryPtr entry, Download::Options options = Download::Option::NoOptions);
|
||||||
Download::Ptr makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Download::Options options = Download::Option::NoOptions);
|
Download::Ptr makeByteArray(QUrl url, QByteArray* output, Download::Options options = Download::Option::NoOptions);
|
||||||
Download::Ptr makeFile(QUrl url, QString path, Download::Options options = Download::Option::NoOptions);
|
Download::Ptr makeFile(QUrl url, QString path, Download::Options options = Download::Option::NoOptions);
|
||||||
}; // namespace ApiDownload
|
}; // namespace ApiDownload
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
Upload::Ptr ApiUpload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data)
|
Upload::Ptr ApiUpload::makeByteArray(QUrl url, QByteArray* output, QByteArray m_post_data)
|
||||||
{
|
{
|
||||||
auto up = Upload::makeByteArray(url, output, m_post_data);
|
auto up = Upload::makeByteArray(url, output, m_post_data);
|
||||||
up->addHeaderProxy(new ApiHeaderProxy());
|
up->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
namespace ApiUpload {
|
namespace ApiUpload {
|
||||||
Upload::Ptr makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, QByteArray m_post_data);
|
Upload::Ptr makeByteArray(QUrl url, QByteArray* output, QByteArray m_post_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Net
|
} // namespace Net
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Net {
|
||||||
*/
|
*/
|
||||||
class ByteArraySink : public Sink {
|
class ByteArraySink : public Sink {
|
||||||
public:
|
public:
|
||||||
ByteArraySink(std::shared_ptr<QByteArray> output) : m_output(output) {};
|
ByteArraySink(QByteArray* output) : m_output(output) {}
|
||||||
|
|
||||||
virtual ~ByteArraySink() = default;
|
virtual ~ByteArraySink() = default;
|
||||||
|
|
||||||
|
|
@ -92,6 +92,6 @@ class ByteArraySink : public Sink {
|
||||||
auto hasLocalData() -> bool override { return false; }
|
auto hasLocalData() -> bool override { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<QByteArray> m_output;
|
QByteArray* m_output;
|
||||||
};
|
};
|
||||||
} // namespace Net
|
} // namespace Net
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Down
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto Download::makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options) -> Download::Ptr
|
auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> Download::Ptr
|
||||||
{
|
{
|
||||||
auto dl = makeShared<Download>();
|
auto dl = makeShared<Download>();
|
||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Download : public NetRequest {
|
||||||
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static auto makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeByteArray(QUrl url, QByteArray* output, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
|
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
34
launcher/net/DummySink.h
Normal file
34
launcher/net/DummySink.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (c) 2025 Octol1ttle <l1ttleofficial@outlook.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Net {
|
||||||
|
|
||||||
|
class DummySink : public Sink {
|
||||||
|
public:
|
||||||
|
explicit DummySink() {}
|
||||||
|
~DummySink() override {}
|
||||||
|
auto init(QNetworkRequest& request) -> Task::State override { return Task::State::Running; }
|
||||||
|
auto write(QByteArray& data) -> Task::State override { return Task::State::Succeeded; }
|
||||||
|
auto abort() -> Task::State override { return Task::State::AbortedByUser; }
|
||||||
|
auto finalize(QNetworkReply& reply) -> Task::State override { return Task::State::Succeeded; }
|
||||||
|
auto hasLocalData() -> bool override { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Net
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NetJob::NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network, int max_concurrent)
|
NetJob::NetJob(QString job_name, QNetworkAccessManager* network, int max_concurrent)
|
||||||
: ConcurrentTask(job_name), m_network(network)
|
: ConcurrentTask(job_name), m_network(network)
|
||||||
{
|
{
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ class NetJob : public ConcurrentTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// TODO: delete
|
||||||
using Ptr = shared_qobject_ptr<NetJob>;
|
using Ptr = shared_qobject_ptr<NetJob>;
|
||||||
|
|
||||||
explicit NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network, int max_concurrent = -1);
|
explicit NetJob(QString job_name, QNetworkAccessManager* network, int max_concurrent = -1);
|
||||||
~NetJob() override = default;
|
~NetJob() override = default;
|
||||||
|
|
||||||
auto size() const -> int;
|
auto size() const -> int;
|
||||||
|
|
@ -77,7 +78,7 @@ class NetJob : public ConcurrentTask {
|
||||||
bool isOnline();
|
bool isOnline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
QNetworkAccessManager* m_network;
|
||||||
|
|
||||||
int m_try = 1;
|
int m_try = 1;
|
||||||
bool m_ask_retry = true;
|
bool m_ask_retry = true;
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,8 @@ class NetRequest : public Task {
|
||||||
auto abort() -> bool override;
|
auto abort() -> bool override;
|
||||||
auto canAbort() const -> bool override { return true; }
|
auto canAbort() const -> bool override { return true; }
|
||||||
|
|
||||||
void setNetwork(shared_qobject_ptr<QNetworkAccessManager> network) { m_network = network; }
|
void setNetwork(QNetworkAccessManager* network) { m_network = network; }
|
||||||
void addHeaderProxy(Net::HeaderProxy* proxy) { m_headerProxies.push_back(std::shared_ptr<Net::HeaderProxy>(proxy)); }
|
void addHeaderProxy(std::unique_ptr<Net::HeaderProxy> proxy) { m_headerProxies.push_back(std::move(proxy)); }
|
||||||
|
|
||||||
QUrl url() const;
|
QUrl url() const;
|
||||||
void setUrl(QUrl url) { m_url = url; }
|
void setUrl(QUrl url) { m_url = url; }
|
||||||
|
|
@ -100,15 +100,15 @@ class NetRequest : public Task {
|
||||||
std::chrono::time_point<std::chrono::steady_clock> m_last_progress_time;
|
std::chrono::time_point<std::chrono::steady_clock> m_last_progress_time;
|
||||||
qint64 m_last_progress_bytes;
|
qint64 m_last_progress_bytes;
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
QNetworkAccessManager* m_network;
|
||||||
|
|
||||||
/// the network reply
|
/// the network reply
|
||||||
unique_qobject_ptr<QNetworkReply> m_reply;
|
std::unique_ptr<QNetworkReply> m_reply;
|
||||||
QByteArray m_errorResponse;
|
QByteArray m_errorResponse;
|
||||||
|
|
||||||
/// source URL
|
/// source URL
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
std::vector<std::shared_ptr<Net::HeaderProxy>> m_headerProxies;
|
std::vector<std::unique_ptr<Net::HeaderProxy>> m_headerProxies;
|
||||||
};
|
};
|
||||||
} // namespace Net
|
} // namespace Net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,5 +214,5 @@ PasteUpload::PasteUpload(const QString& log, QString url, PasteType pasteType) :
|
||||||
else
|
else
|
||||||
m_url = m_baseUrl + base.endpointPath;
|
m_url = m_baseUrl + base.endpointPath;
|
||||||
|
|
||||||
m_sink.reset(new Sink(this));
|
m_sink.reset(new Sink(this, m_output.get()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class PasteUpload : public Net::NetRequest {
|
||||||
|
|
||||||
class Sink : public Net::ByteArraySink {
|
class Sink : public Net::ByteArraySink {
|
||||||
public:
|
public:
|
||||||
Sink(PasteUpload* p) : Net::ByteArraySink(std::make_shared<QByteArray>()), m_d(p) {};
|
Sink(PasteUpload* p, QByteArray* output) : Net::ByteArraySink(output), m_d(p) {};
|
||||||
virtual ~Sink() = default;
|
virtual ~Sink() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -93,4 +93,5 @@ class PasteUpload : public Net::NetRequest {
|
||||||
QString m_pasteLink;
|
QString m_pasteLink;
|
||||||
QString m_baseUrl;
|
QString m_baseUrl;
|
||||||
const PasteType m_paste_type;
|
const PasteType m_paste_type;
|
||||||
|
std::unique_ptr<QByteArray> m_output = std::make_unique<QByteArray>();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue