refactor!!!: migrate from shared pointers
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
@@ -911,7 +911,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
|
||||
// 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<LanguagePage>();
|
||||
m_globalSettingsProvider->addPage<AppearancePage>();
|
||||
@@ -992,7 +992,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
if (FS::checkProblemticPathJava(QDir(instDir))) {
|
||||
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);
|
||||
qInfo() << "Loading Instances...";
|
||||
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("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
|
||||
for (auto profiler : m_profilers.values()) {
|
||||
profiler->registerSettings(m_settings);
|
||||
profiler->registerSettings(m_settings.get());
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -1469,7 +1469,7 @@ void Application::messageReceived(const QByteArray& message)
|
||||
bool offline = received.args["offline_enabled"] == "true";
|
||||
QString offlineName = received.args["offline_name"];
|
||||
|
||||
InstancePtr instance;
|
||||
BaseInstance* instance;
|
||||
if (!id.isEmpty()) {
|
||||
instance = instances()->getInstanceById(id);
|
||||
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) {
|
||||
m_javalist.reset(new JavaInstallList());
|
||||
}
|
||||
return m_javalist;
|
||||
return m_javalist.get();
|
||||
}
|
||||
|
||||
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 demo,
|
||||
MinecraftTarget::Ptr targetToJoin,
|
||||
@@ -1580,7 +1580,7 @@ bool Application::launch(InstancePtr instance,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Application::kill(InstancePtr instance)
|
||||
bool Application::kill(BaseInstance* instance)
|
||||
{
|
||||
if (!instance->isRunning()) {
|
||||
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
|
||||
@@ -1589,7 +1589,7 @@ bool Application::kill(InstancePtr instance)
|
||||
QMutexLocker locker(&m_instanceExtrasMutex);
|
||||
auto& extras = m_instanceExtras[instance->id()];
|
||||
// NOTE: copy of the shared pointer keeps it alive
|
||||
auto controller = extras.controller;
|
||||
auto& controller = extras.controller;
|
||||
locker.unlock();
|
||||
if (controller) {
|
||||
return controller->abort();
|
||||
@@ -1738,7 +1738,7 @@ ViewLogWindow* Application::showLogWindow()
|
||||
return m_viewLogWindow;
|
||||
}
|
||||
|
||||
InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString page)
|
||||
InstanceWindow* Application::showInstanceWindow(BaseInstance* instance, QString page)
|
||||
{
|
||||
if (!instance)
|
||||
return nullptr;
|
||||
@@ -1850,22 +1850,22 @@ void Application::updateProxySettings(QString proxyTypeStr, QString addr, int po
|
||||
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) {
|
||||
m_metadataIndex.reset(new Meta::Index());
|
||||
}
|
||||
return m_metadataIndex;
|
||||
return m_metadataIndex.get();
|
||||
}
|
||||
|
||||
void Application::updateCapabilities()
|
||||
|
||||
@@ -112,7 +112,7 @@ class Application : public QApplication {
|
||||
|
||||
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()); }
|
||||
|
||||
@@ -120,21 +120,21 @@ class Application : public QApplication {
|
||||
|
||||
ThemeManager* themeManager() { return m_themeManager.get(); }
|
||||
|
||||
shared_qobject_ptr<ExternalUpdater> updater() { return m_updater; }
|
||||
ExternalUpdater* updater() { return m_updater.get(); }
|
||||
|
||||
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(); }
|
||||
|
||||
shared_qobject_ptr<AccountList> accounts() const { return m_accounts; }
|
||||
AccountList* accounts() const { return m_accounts.get(); }
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
@@ -182,7 +182,7 @@ class Application : public QApplication {
|
||||
*/
|
||||
bool openJsonEditor(const QString& filename);
|
||||
|
||||
InstanceWindow* showInstanceWindow(InstancePtr instance, QString page = QString());
|
||||
InstanceWindow* showInstanceWindow(BaseInstance* instance, QString page = QString());
|
||||
MainWindow* showMainWindow(bool minimized = false);
|
||||
ViewLogWindow* showLogWindow();
|
||||
|
||||
@@ -209,13 +209,13 @@ class Application : public QApplication {
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
bool launch(InstancePtr instance,
|
||||
bool launch(BaseInstance* instance,
|
||||
bool online = true,
|
||||
bool demo = false,
|
||||
MinecraftTarget::Ptr targetToJoin = nullptr,
|
||||
MinecraftAccountPtr accountToUse = nullptr,
|
||||
const QString& offlineName = QString());
|
||||
bool kill(InstancePtr instance);
|
||||
bool kill(BaseInstance* instance);
|
||||
void closeCurrentWindow();
|
||||
|
||||
private slots:
|
||||
@@ -238,23 +238,27 @@ class Application : public QApplication {
|
||||
void subRunningInstance();
|
||||
bool shouldExitNow() const;
|
||||
|
||||
private:
|
||||
QHash<QString, int> m_qsaveResources;
|
||||
mutable QMutex m_qsaveResourcesMutex;
|
||||
|
||||
private:
|
||||
QDateTime m_startTime;
|
||||
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
std::unique_ptr<QNetworkAccessManager> m_network;
|
||||
|
||||
shared_qobject_ptr<ExternalUpdater> m_updater;
|
||||
shared_qobject_ptr<AccountList> m_accounts;
|
||||
std::unique_ptr<ExternalUpdater> m_updater;
|
||||
std::unique_ptr<AccountList> m_accounts;
|
||||
|
||||
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
||||
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
||||
std::unique_ptr<HttpMetaCache> m_metacache;
|
||||
std::unique_ptr<Meta::Index> m_metadataIndex;
|
||||
|
||||
std::shared_ptr<SettingsObject> m_settings;
|
||||
std::shared_ptr<InstanceList> m_instances;
|
||||
std::shared_ptr<IconList> m_icons;
|
||||
std::shared_ptr<JavaInstallList> m_javalist;
|
||||
std::shared_ptr<TranslationsModel> m_translations;
|
||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||
std::unique_ptr<SettingsObject> m_settings;
|
||||
std::unique_ptr<InstanceList> m_instances;
|
||||
std::unique_ptr<IconList> m_icons;
|
||||
std::unique_ptr<JavaInstallList> m_javalist;
|
||||
std::unique_ptr<TranslationsModel> m_translations;
|
||||
std::unique_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||
std::unique_ptr<MCEditTool> m_mcedit;
|
||||
QSet<QString> m_features;
|
||||
std::unique_ptr<ThemeManager> m_themeManager;
|
||||
@@ -279,7 +283,7 @@ class Application : public QApplication {
|
||||
// FIXME: attach to instances instead.
|
||||
struct InstanceXtras {
|
||||
InstanceWindow* window = nullptr;
|
||||
shared_qobject_ptr<LaunchController> controller;
|
||||
std::unique_ptr<LaunchController> controller;
|
||||
};
|
||||
std::map<QString, InstanceXtras> m_instanceExtras;
|
||||
mutable QMutex m_instanceExtrasMutex;
|
||||
@@ -313,14 +317,10 @@ class Application : public QApplication {
|
||||
QList<QUrl> m_urlsToImport;
|
||||
QString m_instanceIdToShowWindowOf;
|
||||
std::unique_ptr<QFile> logFile;
|
||||
shared_qobject_ptr<LogModel> logModel;
|
||||
std::unique_ptr<LogModel> logModel;
|
||||
|
||||
public:
|
||||
void addQSavePath(QString);
|
||||
void removeQSavePath(QString);
|
||||
bool checkQSavePath(QString);
|
||||
|
||||
private:
|
||||
QHash<QString, int> m_qsaveResources;
|
||||
mutable QMutex m_qsaveResourcesMutex;
|
||||
};
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "Json.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "settings/INISettingsObject.h"
|
||||
#include "settings/OverrideSetting.h"
|
||||
#include "settings/Setting.h"
|
||||
@@ -53,7 +54,7 @@
|
||||
#include "Commandline.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
int getConsoleMaxLines(SettingsObjectPtr settings)
|
||||
int getConsoleMaxLines(SettingsObject* settings)
|
||||
{
|
||||
auto lineSetting = settings->getSetting("ConsoleMaxLines");
|
||||
bool conversionOk = false;
|
||||
@@ -65,14 +66,14 @@ int getConsoleMaxLines(SettingsObjectPtr settings)
|
||||
return maxLines;
|
||||
}
|
||||
|
||||
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings)
|
||||
bool shouldStopOnConsoleOverflow(SettingsObject* settings)
|
||||
{
|
||||
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_rootDir = rootDir;
|
||||
|
||||
@@ -126,6 +127,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
|
||||
m_settings->registerSetting("Profiler", "");
|
||||
}
|
||||
|
||||
BaseInstance::~BaseInstance() {}
|
||||
|
||||
QString BaseInstance::getPreLaunchCommand()
|
||||
{
|
||||
return settings()->get("PreLaunchCommand").toString();
|
||||
@@ -335,11 +338,11 @@ QString BaseInstance::instanceRoot() const
|
||||
return m_rootDir;
|
||||
}
|
||||
|
||||
SettingsObjectPtr BaseInstance::settings()
|
||||
SettingsObject* BaseInstance::settings()
|
||||
{
|
||||
loadSpecificSettings();
|
||||
|
||||
return m_settings;
|
||||
return m_settings.get();
|
||||
}
|
||||
|
||||
bool BaseInstance::canLaunch() const
|
||||
@@ -467,9 +470,9 @@ QStringList BaseInstance::extraArguments()
|
||||
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()
|
||||
|
||||
@@ -64,9 +64,6 @@ class Task;
|
||||
class LaunchTask;
|
||||
class BaseInstance;
|
||||
|
||||
// pointer for lazy people
|
||||
using InstancePtr = std::shared_ptr<BaseInstance>;
|
||||
|
||||
/// Shortcut saving target representations
|
||||
enum class ShortcutTarget { Desktop, Applications, Other };
|
||||
|
||||
@@ -78,8 +75,8 @@ struct ShortcutData {
|
||||
};
|
||||
|
||||
/// Console settings
|
||||
int getConsoleMaxLines(SettingsObjectPtr settings);
|
||||
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings);
|
||||
int getConsoleMaxLines(SettingsObject* settings);
|
||||
bool shouldStopOnConsoleOverflow(SettingsObject* settings);
|
||||
|
||||
/*!
|
||||
* \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
|
||||
* and implement the pure virtual functions.
|
||||
*/
|
||||
class BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance> {
|
||||
class BaseInstance : public QObject {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
/// no-touchy!
|
||||
BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
||||
BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir);
|
||||
|
||||
public: /* types */
|
||||
enum class Status {
|
||||
@@ -103,7 +100,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||
|
||||
public:
|
||||
/// virtual destructor to make sure the destruction is COMPLETE
|
||||
virtual ~BaseInstance() {}
|
||||
virtual ~BaseInstance();
|
||||
|
||||
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.
|
||||
*/
|
||||
virtual SettingsObjectPtr settings();
|
||||
virtual SettingsObject* settings();
|
||||
|
||||
/*!
|
||||
* \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;
|
||||
|
||||
/// 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)
|
||||
shared_qobject_ptr<LaunchTask> getLaunchTask();
|
||||
LaunchTask* getLaunchTask();
|
||||
|
||||
/*!
|
||||
* Create envrironment variables for running the instance
|
||||
@@ -286,7 +283,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||
protected:
|
||||
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; }
|
||||
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 launchTaskChanged(shared_qobject_ptr<LaunchTask>);
|
||||
void launchTaskChanged(LaunchTask*);
|
||||
|
||||
void runningStatusChanged(bool running);
|
||||
|
||||
@@ -310,10 +307,10 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||
|
||||
protected: /* data */
|
||||
QString m_rootDir;
|
||||
SettingsObjectPtr m_settings;
|
||||
std::unique_ptr<SettingsObject> m_settings;
|
||||
// InstanceFlags m_flags;
|
||||
bool m_isRunning = false;
|
||||
shared_qobject_ptr<LaunchTask> m_launchProcess;
|
||||
std::unique_ptr<LaunchTask> m_launchProcess;
|
||||
QDateTime m_timeStarted;
|
||||
RuntimeContext m_runtimeContext;
|
||||
|
||||
@@ -323,7 +320,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||
bool m_hasUpdate = false;
|
||||
bool m_hasBrokenVersion = false;
|
||||
|
||||
SettingsObjectWeakPtr m_global_settings;
|
||||
SettingsObject* m_global_settings;
|
||||
bool m_specific_settings_loaded = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
class BaseVersion {
|
||||
public:
|
||||
// TODO: delete
|
||||
using Ptr = std::shared_ptr<BaseVersion>;
|
||||
virtual ~BaseVersion() {}
|
||||
/*!
|
||||
|
||||
@@ -119,6 +119,7 @@ set(NET_SOURCES
|
||||
net/ChecksumValidator.h
|
||||
net/Download.cpp
|
||||
net/Download.h
|
||||
net/DummySink.h
|
||||
net/FileSink.cpp
|
||||
net/FileSink.h
|
||||
net/HttpMetaCache.cpp
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "settings/INISettingsObject.h"
|
||||
#include "tasks/Task.h"
|
||||
|
||||
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
|
||||
InstanceCopyTask::InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs)
|
||||
{
|
||||
m_origInstance = origInstance;
|
||||
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
|
||||
@@ -147,9 +147,9 @@ void InstanceCopyTask::copyFinished()
|
||||
}
|
||||
|
||||
// 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->setIconKey(m_instIcon);
|
||||
if (!m_keepPlaytime) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class InstanceCopyTask : public InstanceTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
|
||||
explicit InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs);
|
||||
|
||||
protected:
|
||||
//! Entry point for tasks.
|
||||
@@ -26,7 +26,7 @@ class InstanceCopyTask : public InstanceTask {
|
||||
|
||||
private:
|
||||
/* data */
|
||||
InstancePtr m_origInstance;
|
||||
BaseInstance* m_origInstance;
|
||||
QFuture<bool> m_copyFuture;
|
||||
QFutureWatcher<bool> m_copyFutureWatcher;
|
||||
Filter m_matcher;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "InstanceList.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)
|
||||
return QString();
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "BaseInstance.h"
|
||||
|
||||
/// 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
|
||||
bool checkLinkedInstances(const QString& id, QWidget* parent, const QString& verb);
|
||||
|
||||
@@ -343,9 +343,9 @@ void InstanceImportTask::processTechnic()
|
||||
void InstanceImportTask::processMultiMC()
|
||||
{
|
||||
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.
|
||||
instance.resetTimePlayed();
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
resumeWatch();
|
||||
@@ -87,7 +87,10 @@ InstanceList::InstanceList(SettingsObjectPtr settings, const QString& instDir, Q
|
||||
m_watcher->addPath(m_instDir);
|
||||
}
|
||||
|
||||
InstanceList::~InstanceList() {}
|
||||
InstanceList::~InstanceList()
|
||||
{
|
||||
qDeleteAll(m_instances);
|
||||
}
|
||||
|
||||
Qt::DropActions InstanceList::supportedDragActions() const
|
||||
{
|
||||
@@ -161,7 +164,7 @@ QModelIndex InstanceList::index(int row, int column, const QModelIndex& parent)
|
||||
Q_UNUSED(parent);
|
||||
if (row < 0 || row >= m_instances.size())
|
||||
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
|
||||
@@ -266,7 +269,7 @@ void InstanceList::setInstanceGroup(const InstanceId& id, GroupId name)
|
||||
|
||||
if (changed) {
|
||||
increaseGroupCount(name);
|
||||
auto idx = getInstIndex(inst.get());
|
||||
auto idx = getInstIndex(inst);
|
||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||
saveGroupList();
|
||||
}
|
||||
@@ -291,7 +294,7 @@ void InstanceList::deleteGroup(const GroupId& name)
|
||||
m_instanceGroupIndex.remove(instID);
|
||||
qDebug() << "Remove" << instID << "from group" << name;
|
||||
removed = true;
|
||||
auto idx = getInstIndex(instance.get());
|
||||
auto idx = getInstIndex(instance);
|
||||
if (idx >= 0)
|
||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||
}
|
||||
@@ -316,7 +319,7 @@ void InstanceList::renameGroup(const QString& src, const QString& dst)
|
||||
increaseGroupCount(dst);
|
||||
qDebug() << "Set" << instID << "group to" << dst;
|
||||
modified = true;
|
||||
auto idx = getInstIndex(instance.get());
|
||||
auto idx = getInstIndex(instance);
|
||||
if (idx >= 0)
|
||||
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;
|
||||
int i = 0;
|
||||
for (auto& item : list) {
|
||||
for (auto item : list) {
|
||||
auto id = item->id();
|
||||
if (out.contains(id)) {
|
||||
qWarning() << "Duplicate ID" << id << "in instance list";
|
||||
@@ -504,7 +507,7 @@ InstanceList::InstListError InstanceList::loadList()
|
||||
{
|
||||
auto existingIds = getIdMapping(m_instances);
|
||||
|
||||
QList<InstancePtr> newList;
|
||||
QList<BaseInstanceOwner> newList;
|
||||
|
||||
for (auto& id : discoverInstances()) {
|
||||
if (existingIds.contains(id)) {
|
||||
@@ -512,7 +515,7 @@ InstanceList::InstListError InstanceList::loadList()
|
||||
existingIds.remove(id);
|
||||
qInfo() << "Should keep and soft-reload" << id;
|
||||
} else {
|
||||
InstancePtr instPtr = loadInstance(id);
|
||||
BaseInstanceOwner instPtr = loadInstance(id);
|
||||
if (instPtr) {
|
||||
newList.append(instPtr);
|
||||
}
|
||||
@@ -567,7 +570,7 @@ void InstanceList::updateTotalPlayTime()
|
||||
{
|
||||
totalPlayTime = 0;
|
||||
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);
|
||||
m_instances.append(t);
|
||||
for (auto& ptr : t) {
|
||||
connect(ptr.get(), &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
||||
for (auto ptr : t) {
|
||||
connect(ptr, &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
@@ -613,19 +616,19 @@ void InstanceList::providerUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
InstancePtr InstanceList::getInstanceById(QString instId) const
|
||||
BaseInstance* InstanceList::getInstanceById(QString instId) const
|
||||
{
|
||||
if (instId.isEmpty())
|
||||
return InstancePtr();
|
||||
return nullptr;
|
||||
for (auto& inst : m_instances) {
|
||||
if (inst->id() == instId) {
|
||||
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())
|
||||
return {};
|
||||
@@ -640,14 +643,14 @@ InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name)
|
||||
|
||||
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 count = m_instances.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (inst == m_instances[i].get()) {
|
||||
if (inst == m_instances[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) {
|
||||
loadGroupList();
|
||||
}
|
||||
|
||||
auto instanceRoot = FS::PathCombine(m_instDir, id);
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
||||
InstancePtr inst;
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
||||
BaseInstanceOwner inst;
|
||||
|
||||
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
|
||||
// OneSix instance
|
||||
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 {
|
||||
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();
|
||||
|
||||
@@ -911,15 +914,14 @@ class InstanceStaging : public Task {
|
||||
const unsigned maxBackoff = 16;
|
||||
|
||||
public:
|
||||
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObjectPtr settings)
|
||||
: m_parent(parent), backoff(minBackoff, maxBackoff)
|
||||
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObject* settings) : m_parent(parent), backoff(minBackoff, maxBackoff)
|
||||
{
|
||||
m_stagingPath = parent->getStagedInstancePath();
|
||||
|
||||
m_child.reset(child);
|
||||
|
||||
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::failed, this, &InstanceStaging::childFailed);
|
||||
@@ -995,7 +997,7 @@ class InstanceStaging : public Task {
|
||||
*/
|
||||
ExponentialSeries backoff;
|
||||
QString m_stagingPath;
|
||||
unique_qobject_ptr<InstanceTask> m_child;
|
||||
std::unique_ptr<InstanceTask> m_child;
|
||||
QTimer m_backoffTimer;
|
||||
};
|
||||
|
||||
@@ -1036,7 +1038,7 @@ bool InstanceList::commitStagedInstance(const QString& path,
|
||||
groupName = QString();
|
||||
|
||||
QString instID;
|
||||
InstancePtr inst;
|
||||
BaseInstance* inst;
|
||||
|
||||
auto should_override = commiting.shouldOverride();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ struct InstanceName;
|
||||
|
||||
using InstanceId = 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 };
|
||||
|
||||
@@ -73,7 +73,9 @@ class InstanceList : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
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();
|
||||
|
||||
public:
|
||||
@@ -96,7 +98,7 @@ class InstanceList : public QAbstractListModel {
|
||||
*/
|
||||
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(); }
|
||||
|
||||
@@ -104,9 +106,9 @@ class InstanceList : public QAbstractListModel {
|
||||
void saveNow();
|
||||
|
||||
/* O(n) */
|
||||
InstancePtr getInstanceById(QString id) const;
|
||||
BaseInstance* getInstanceById(QString id) const;
|
||||
/* O(n) */
|
||||
InstancePtr getInstanceByManagedName(const QString& managed_name) const;
|
||||
BaseInstance* getInstanceByManagedName(const QString& managed_name) const;
|
||||
QModelIndex getInstanceIndexById(const QString& id) const;
|
||||
QStringList getGroups();
|
||||
bool isGroupCollapsed(const QString& groupName);
|
||||
@@ -179,11 +181,11 @@ class InstanceList : public QAbstractListModel {
|
||||
void updateTotalPlayTime();
|
||||
void suspendWatch();
|
||||
void resumeWatch();
|
||||
void add(const QList<InstancePtr>& list);
|
||||
void add(const QList<BaseInstanceOwner>& list);
|
||||
void loadGroupList();
|
||||
void saveGroupList();
|
||||
QList<InstanceId> discoverInstances();
|
||||
InstancePtr loadInstance(const InstanceId& id);
|
||||
BaseInstanceOwner loadInstance(const InstanceId& id);
|
||||
|
||||
void increaseGroupCount(const QString& group);
|
||||
void decreaseGroupCount(const QString& group);
|
||||
@@ -192,11 +194,11 @@ class InstanceList : public QAbstractListModel {
|
||||
int m_watchLevel = 0;
|
||||
int totalPlayTime = 0;
|
||||
bool m_dirty = false;
|
||||
QList<InstancePtr> m_instances;
|
||||
QList<BaseInstanceOwner> m_instances;
|
||||
// id -> refs
|
||||
QMap<QString, int> m_groupNameCache;
|
||||
|
||||
SettingsObjectPtr m_globalSettings;
|
||||
SettingsObject* m_globalSettings;
|
||||
QString m_instDir;
|
||||
QFileSystemWatcher* m_watcher;
|
||||
// FIXME: this is so inefficient that looking at it is almost painful.
|
||||
|
||||
@@ -21,26 +21,26 @@
|
||||
class InstancePageProvider : protected QObject, public BasePageProvider {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
|
||||
explicit InstancePageProvider(BaseInstance* parent) { inst = parent; }
|
||||
|
||||
virtual ~InstancePageProvider() = default;
|
||||
virtual QList<BasePage*> getPages() override
|
||||
{
|
||||
QList<BasePage*> values;
|
||||
values.append(new LogPage(inst));
|
||||
std::shared_ptr<MinecraftInstance> onesix = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
||||
values.append(new VersionPage(onesix.get()));
|
||||
values.append(ManagedPackPage::createPage(onesix.get()));
|
||||
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList());
|
||||
MinecraftInstance* onesix = dynamic_cast<MinecraftInstance*>(inst);
|
||||
values.append(new VersionPage(onesix));
|
||||
values.append(ManagedPackPage::createPage(onesix));
|
||||
auto modsPage = new ModFolderPage(onesix, onesix->loaderModList());
|
||||
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
|
||||
values.append(modsPage);
|
||||
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
|
||||
values.append(new NilModFolderPage(onesix.get(), onesix->nilModList()));
|
||||
values.append(new ResourcePackPage(onesix.get(), onesix->resourcePackList()));
|
||||
values.append(new GlobalDataPackPage(onesix.get()));
|
||||
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
|
||||
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));
|
||||
values.append(new NotesPage(onesix.get()));
|
||||
values.append(new CoreModFolderPage(onesix, onesix->coreModList()));
|
||||
values.append(new NilModFolderPage(onesix, onesix->nilModList()));
|
||||
values.append(new ResourcePackPage(onesix, onesix->resourcePackList()));
|
||||
values.append(new GlobalDataPackPage(onesix));
|
||||
values.append(new TexturePackPage(onesix, onesix->texturePackList()));
|
||||
values.append(new ShaderPackPage(onesix, onesix->shaderPackList()));
|
||||
values.append(new NotesPage(onesix));
|
||||
values.append(new WorldListPage(onesix, onesix->worldList()));
|
||||
values.append(new ServersPage(onesix));
|
||||
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()); }
|
||||
|
||||
protected:
|
||||
InstancePtr inst;
|
||||
BaseInstance* inst;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||
InstanceTask();
|
||||
~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; }
|
||||
|
||||
@@ -60,7 +60,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||
}
|
||||
|
||||
protected: /* data */
|
||||
SettingsObjectPtr m_globalSettings;
|
||||
SettingsObject* m_globalSettings;
|
||||
QString m_instIcon;
|
||||
QString m_instGroup;
|
||||
QString m_stagingPath;
|
||||
|
||||
@@ -403,10 +403,10 @@ void LaunchController::launchInstance()
|
||||
if (!console && showConsole) {
|
||||
APPLICATION->showInstanceWindow(m_instance);
|
||||
}
|
||||
connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
||||
connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
||||
connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
|
||||
connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
||||
connect(m_launcher, &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
||||
connect(m_launcher, &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
||||
connect(m_launcher, &LaunchTask::failed, this, &LaunchController::onFailed);
|
||||
connect(m_launcher, &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
||||
|
||||
// Prepend Online and Auth Status
|
||||
QString online_mode;
|
||||
@@ -416,19 +416,18 @@ void LaunchController::launchInstance()
|
||||
// Prepend Server Status
|
||||
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 {
|
||||
online_mode = m_demo ? "demo" : "offline";
|
||||
}
|
||||
|
||||
m_launcher->prependStep(
|
||||
makeShared<TextPrint>(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher, "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
||||
|
||||
// Prepend Version
|
||||
{
|
||||
auto versionString = QString("%1 version: %2 (%3)")
|
||||
.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();
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ class LaunchController : public Task {
|
||||
LaunchController();
|
||||
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; }
|
||||
|
||||
@@ -92,11 +92,11 @@ class LaunchController : public Task {
|
||||
bool m_online = true;
|
||||
QString m_offlineName;
|
||||
bool m_demo = false;
|
||||
InstancePtr m_instance;
|
||||
BaseInstance* m_instance;
|
||||
QWidget* m_parentWidget = nullptr;
|
||||
InstanceWindow* m_console = nullptr;
|
||||
MinecraftAccountPtr m_accountToUse = nullptr;
|
||||
AuthSessionPtr m_session;
|
||||
shared_qobject_ptr<LaunchTask> m_launcher;
|
||||
LaunchTask* m_launcher;
|
||||
MinecraftTarget::Ptr m_targetToJoin;
|
||||
};
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
class NullInstance : public BaseInstance {
|
||||
Q_OBJECT
|
||||
public:
|
||||
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
||||
: BaseInstance(globalSettings, settings, rootDir)
|
||||
NullInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
||||
: BaseInstance(globalSettings, std::move(settings), rootDir)
|
||||
{
|
||||
setVersionBroken(true);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class NullInstance : public BaseInstance {
|
||||
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
||||
QSet<QString> traits() const override { return {}; };
|
||||
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 {}; }
|
||||
QProcessEnvironment createEnvironment() override { return QProcessEnvironment(); }
|
||||
QProcessEnvironment createLaunchEnvironment() override { return QProcessEnvironment(); }
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||
ModPlatform::IndexedVersion version,
|
||||
const std::shared_ptr<ResourceFolderModel> packs,
|
||||
ResourceFolderModel* packs,
|
||||
bool is_indexed)
|
||||
: 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);
|
||||
|
||||
// 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 newConfig(m_pack_model->dir(), getFilename() + ".txt");
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class ResourceDownloadTask : public SequentialTask {
|
||||
public:
|
||||
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||
ModPlatform::IndexedVersion version,
|
||||
std::shared_ptr<ResourceFolderModel> packs,
|
||||
ResourceFolderModel* packs,
|
||||
bool is_indexed = true);
|
||||
const QString& getFilename() const { return m_pack_version.fileName; }
|
||||
const QVariant& getVersionID() const { return m_pack_version.fileId; }
|
||||
@@ -44,7 +44,7 @@ class ResourceDownloadTask : public SequentialTask {
|
||||
private:
|
||||
ModPlatform::IndexedPack::Ptr m_pack;
|
||||
ModPlatform::IndexedVersion m_pack_version;
|
||||
const std::shared_ptr<ResourceFolderModel> m_pack_model;
|
||||
ResourceFolderModel* m_pack_model;
|
||||
|
||||
NetJob::Ptr m_filesNetJob;
|
||||
LocalResourceUpdateTask::Ptr m_update_task;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct RuntimeContext {
|
||||
return javaRealArchitecture;
|
||||
}
|
||||
|
||||
void updateFromInstanceSettings(SettingsObjectPtr instanceSettings)
|
||||
void updateFromInstanceSettings(SettingsObject* instanceSettings)
|
||||
{
|
||||
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
||||
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
||||
|
||||
@@ -36,7 +36,7 @@ class Usable {
|
||||
*/
|
||||
class UseLock {
|
||||
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.
|
||||
m_usable->incrementUses();
|
||||
@@ -44,5 +44,5 @@ class UseLock {
|
||||
~UseLock() { m_usable->decrementUses(); }
|
||||
|
||||
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 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()) {
|
||||
auto hashType = QCryptographicHash::Algorithm::Sha1;
|
||||
if (m_checksum_type == "sha256") {
|
||||
|
||||
@@ -51,14 +51,14 @@ void LaunchTask::init()
|
||||
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));
|
||||
proc->init();
|
||||
return proc;
|
||||
auto task = std::unique_ptr<LaunchTask>(new LaunchTask(inst));
|
||||
task->init();
|
||||
return task;
|
||||
}
|
||||
|
||||
LaunchTask::LaunchTask(MinecraftInstancePtr instance) : m_instance(instance) {}
|
||||
LaunchTask::LaunchTask(MinecraftInstance* instance) : m_instance(instance) {}
|
||||
|
||||
void LaunchTask::appendStep(shared_qobject_ptr<LaunchStep> step)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <QObjectPtr.h>
|
||||
#include <minecraft/MinecraftInstance.h>
|
||||
#include <QProcess>
|
||||
#include "BaseInstance.h"
|
||||
#include "LaunchStep.h"
|
||||
#include "LogModel.h"
|
||||
#include "MessageLevel.h"
|
||||
@@ -48,21 +47,21 @@
|
||||
class LaunchTask : public Task {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
explicit LaunchTask(MinecraftInstancePtr instance);
|
||||
explicit LaunchTask(MinecraftInstance* instance);
|
||||
void init();
|
||||
|
||||
public:
|
||||
enum State { NotStarted, Running, Waiting, Failed, Aborted, Finished };
|
||||
|
||||
public: /* methods */
|
||||
static shared_qobject_ptr<LaunchTask> create(MinecraftInstancePtr inst);
|
||||
static std::unique_ptr<LaunchTask> create(MinecraftInstance* inst);
|
||||
virtual ~LaunchTask() = default;
|
||||
|
||||
void appendStep(shared_qobject_ptr<LaunchStep> step);
|
||||
void prependStep(shared_qobject_ptr<LaunchStep> step);
|
||||
void setCensorFilter(QMap<QString, QString> filter);
|
||||
|
||||
MinecraftInstancePtr instance() { return m_instance; }
|
||||
MinecraftInstance* instance() { return m_instance; }
|
||||
|
||||
void setPid(qint64 pid) { m_pid = pid; }
|
||||
|
||||
@@ -119,7 +118,7 @@ class LaunchTask : public Task {
|
||||
bool parseXmlLogs(QString const& line, MessageLevel level);
|
||||
|
||||
protected: /* data */
|
||||
MinecraftInstancePtr m_instance;
|
||||
MinecraftInstance* m_instance;
|
||||
shared_qobject_ptr<LogModel> m_logModel;
|
||||
QList<shared_qobject_ptr<LaunchStep>> m_steps;
|
||||
QMap<QString, QString> m_censorFilter;
|
||||
|
||||
@@ -160,12 +160,14 @@ class OrSetting : public Setting {
|
||||
std::shared_ptr<Setting> m_b;
|
||||
};
|
||||
|
||||
MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
||||
: BaseInstance(globalSettings, settings, rootDir)
|
||||
MinecraftInstance::MinecraftInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
||||
: BaseInstance(globalSettings, std::move(settings), rootDir)
|
||||
{
|
||||
m_components.reset(new PackProfile(this));
|
||||
}
|
||||
|
||||
MinecraftInstance::~MinecraftInstance() {}
|
||||
|
||||
void MinecraftInstance::saveNow()
|
||||
{
|
||||
m_components->saveNow();
|
||||
@@ -269,7 +271,7 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
|
||||
void MinecraftInstance::updateRuntimeContext()
|
||||
{
|
||||
m_runtimeContext.updateFromInstanceSettings(m_settings);
|
||||
m_runtimeContext.updateFromInstanceSettings(m_settings.get());
|
||||
m_components->invalidateLaunchProfile();
|
||||
}
|
||||
|
||||
@@ -278,9 +280,9 @@ QString MinecraftInstance::typeName() const
|
||||
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
|
||||
@@ -308,9 +310,9 @@ void MinecraftInstance::populateLaunchMenu(QMenu* menu)
|
||||
|
||||
normalLaunchDemo->setEnabled(supportsDemo());
|
||||
|
||||
connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this()); });
|
||||
connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, false); });
|
||||
connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, true); });
|
||||
connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(this); });
|
||||
connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(this, false, false); });
|
||||
connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(this, false, true); });
|
||||
|
||||
QString profilersTitle = tr("Profilers");
|
||||
menu->addSeparator()->setText(profilersTitle);
|
||||
@@ -964,8 +966,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
||||
}
|
||||
};
|
||||
|
||||
printModList("Mods", *(loaderModList().get()));
|
||||
printModList("Core Mods", *(coreModList().get()));
|
||||
printModList("Mods", *loaderModList());
|
||||
printModList("Core Mods", *coreModList());
|
||||
|
||||
// jar mods
|
||||
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();
|
||||
// FIXME: get rid of shared_from_this ...
|
||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
||||
auto process = LaunchTask::create(this);
|
||||
auto pptr = process.get();
|
||||
|
||||
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()) {
|
||||
process->appendStep(makeShared<QuitAfterGameStop>(pptr));
|
||||
}
|
||||
m_launchProcess = process;
|
||||
emit launchTaskChanged(m_launchProcess);
|
||||
return m_launchProcess;
|
||||
m_launchProcess = std::move(process);
|
||||
emit launchTaskChanged(m_launchProcess.get());
|
||||
return m_launchProcess.get();
|
||||
}
|
||||
|
||||
JavaVersion MinecraftInstance::getJavaVersion()
|
||||
@@ -1235,80 +1236,80 @@ JavaVersion MinecraftInstance::getJavaVersion()
|
||||
return JavaVersion(settings()->get("JavaVersion").toString());
|
||||
}
|
||||
|
||||
std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList()
|
||||
ModFolderModel* MinecraftInstance::loaderModList()
|
||||
{
|
||||
if (!m_loader_mod_list) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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) {
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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()) {
|
||||
bool isIndexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
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() };
|
||||
}
|
||||
|
||||
std::shared_ptr<WorldList> MinecraftInstance::worldList()
|
||||
WorldList* MinecraftInstance::worldList()
|
||||
{
|
||||
if (!m_world_list) {
|
||||
m_world_list.reset(new WorldList(worldDir(), this));
|
||||
}
|
||||
return m_world_list;
|
||||
return m_world_list.get();
|
||||
}
|
||||
|
||||
QList<Mod*> MinecraftInstance::getJarMods() const
|
||||
|
||||
@@ -56,8 +56,8 @@ class PackProfile;
|
||||
class MinecraftInstance : public BaseInstance {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
||||
virtual ~MinecraftInstance() = default;
|
||||
MinecraftInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir);
|
||||
virtual ~MinecraftInstance();
|
||||
virtual void saveNow() override;
|
||||
|
||||
void loadSpecificSettings() override;
|
||||
@@ -109,22 +109,22 @@ class MinecraftInstance : public BaseInstance {
|
||||
void updateRuntimeContext() override;
|
||||
|
||||
////// Profile management //////
|
||||
std::shared_ptr<PackProfile> getPackProfile() const;
|
||||
PackProfile* getPackProfile() const;
|
||||
|
||||
////// Mod Lists //////
|
||||
std::shared_ptr<ModFolderModel> loaderModList();
|
||||
std::shared_ptr<ModFolderModel> coreModList();
|
||||
std::shared_ptr<ModFolderModel> nilModList();
|
||||
std::shared_ptr<ResourcePackFolderModel> resourcePackList();
|
||||
std::shared_ptr<TexturePackFolderModel> texturePackList();
|
||||
std::shared_ptr<ShaderPackFolderModel> shaderPackList();
|
||||
std::shared_ptr<DataPackFolderModel> dataPackList();
|
||||
QList<std::shared_ptr<ResourceFolderModel>> resourceLists();
|
||||
std::shared_ptr<WorldList> worldList();
|
||||
ModFolderModel* loaderModList();
|
||||
ModFolderModel* coreModList();
|
||||
ModFolderModel* nilModList();
|
||||
ResourcePackFolderModel* resourcePackList();
|
||||
TexturePackFolderModel* texturePackList();
|
||||
ShaderPackFolderModel* shaderPackList();
|
||||
DataPackFolderModel* dataPackList();
|
||||
QList<ResourceFolderModel*> resourceLists();
|
||||
WorldList* worldList();
|
||||
|
||||
////// Launch stuff //////
|
||||
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 verboseDescription(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) override;
|
||||
QList<Mod*> getJarMods() const;
|
||||
@@ -162,15 +162,13 @@ class MinecraftInstance : public BaseInstance {
|
||||
QMap<QString, QString> makeProfileVarMapping(std::shared_ptr<LaunchProfile> profile) const;
|
||||
|
||||
protected: // data
|
||||
std::shared_ptr<PackProfile> m_components;
|
||||
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
|
||||
mutable std::shared_ptr<ModFolderModel> m_core_mod_list;
|
||||
mutable std::shared_ptr<ModFolderModel> m_nil_mod_list;
|
||||
mutable std::shared_ptr<ResourcePackFolderModel> m_resource_pack_list;
|
||||
mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list;
|
||||
mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list;
|
||||
mutable std::shared_ptr<DataPackFolderModel> m_data_pack_list;
|
||||
mutable std::shared_ptr<WorldList> m_world_list;
|
||||
};
|
||||
|
||||
using MinecraftInstancePtr = std::shared_ptr<MinecraftInstance>;
|
||||
std::unique_ptr<PackProfile> m_components;
|
||||
std::unique_ptr<ModFolderModel> m_loader_mod_list;
|
||||
std::unique_ptr<ModFolderModel> m_core_mod_list;
|
||||
std::unique_ptr<ModFolderModel> m_nil_mod_list;
|
||||
std::unique_ptr<ResourcePackFolderModel> m_resource_pack_list;
|
||||
std::unique_ptr<ShaderPackFolderModel> m_shader_pack_list;
|
||||
std::unique_ptr<TexturePackFolderModel> m_texture_pack_list;
|
||||
std::unique_ptr<DataPackFolderModel> m_data_pack_list;
|
||||
std::unique_ptr<WorldList> m_world_list;
|
||||
};
|
||||
@@ -19,10 +19,10 @@ bool VanillaCreationTask::createInstance()
|
||||
{
|
||||
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();
|
||||
{
|
||||
MinecraftInstance inst(m_globalSettings, instance_settings, m_stagingPath);
|
||||
MinecraftInstance inst(m_globalSettings, std::move(instance_settings), m_stagingPath);
|
||||
auto components = inst.getPackProfile();
|
||||
components->buildingFromScratch();
|
||||
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
|
||||
@@ -31,8 +31,9 @@ bool VanillaCreationTask::createInstance()
|
||||
|
||||
inst.setName(name());
|
||||
inst.setIconKey(m_instIcon);
|
||||
|
||||
inst.settings()->resumeSave();
|
||||
}
|
||||
instance_settings->resumeSave();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ void EntitlementsStep::perform()
|
||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Download::makeByteArray(url, m_response);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("EntitlementsStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -22,7 +22,7 @@ class EntitlementsStep : public AuthStep {
|
||||
|
||||
private:
|
||||
QString m_entitlements_request_id;
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Download::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ void GetSkinStep::perform()
|
||||
QUrl url(m_data->minecraftProfile.skin.url);
|
||||
|
||||
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->setAskRetry(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ class GetSkinStep : public AuthStep {
|
||||
void onRequestDone();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Download::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -37,8 +37,8 @@ void LauncherLoginStep::perform()
|
||||
};
|
||||
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, requestBody.toUtf8());
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), requestBody.toUtf8());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("LauncherLoginStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ class LauncherLoginStep : public AuthStep {
|
||||
void onRequestDone();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Upload::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -67,8 +67,8 @@ void MSADeviceCodeStep::perform()
|
||||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("MSADeviceCodeStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
@@ -181,8 +181,8 @@ void MSADeviceCodeStep::authenticateUser()
|
||||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class MSADeviceCodeStep : public AuthStep {
|
||||
QTimer m_pool_timer;
|
||||
QTimer m_expiration_timer;
|
||||
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Upload::Ptr m_request;
|
||||
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.setScope("XboxLive.SignIn XboxLive.offline_access");
|
||||
m_oauth2.setClientIdentifier(m_clientId);
|
||||
m_oauth2.setNetworkAccessManager(APPLICATION->network().get());
|
||||
m_oauth2.setNetworkAccessManager(APPLICATION->network());
|
||||
|
||||
connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::granted, this, [this] {
|
||||
m_data->msaClientID = m_oauth2.clientIdentifier();
|
||||
|
||||
@@ -22,8 +22,8 @@ void MinecraftProfileStep::perform()
|
||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Download::makeByteArray(url, m_response);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("MinecraftProfileStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ class MinecraftProfileStep : public AuthStep {
|
||||
void onRequestDone();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Download::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -42,8 +42,8 @@ void XboxAuthorizationStep::perform()
|
||||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), xbox_auth_data.toUtf8());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("XboxAuthorizationStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -28,7 +28,7 @@ class XboxAuthorizationStep : public AuthStep {
|
||||
QString m_relyingParty;
|
||||
QString m_authorizationKind;
|
||||
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Upload::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -34,8 +34,8 @@ void XboxProfileStep::perform()
|
||||
};
|
||||
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Download::makeByteArray(url, m_response);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Download::makeByteArray(url, m_response.get());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("XboxProfileStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ class XboxProfileStep : public AuthStep {
|
||||
void onRequestDone();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Download::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -38,8 +38,8 @@ void XboxUserStep::perform()
|
||||
{ "x-xbl-contract-version", "1" }
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), xbox_auth_data.toUtf8());
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
m_task.reset(new NetJob("XboxUserStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ class XboxUserStep : public AuthStep {
|
||||
void onRequestDone();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QByteArray> m_response;
|
||||
std::unique_ptr<QByteArray> m_response;
|
||||
Net::Upload::Ptr m_request;
|
||||
NetJob::Ptr m_task;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ class AutoInstallJava : public LaunchStep {
|
||||
void tryNextMajorJava();
|
||||
|
||||
private:
|
||||
MinecraftInstancePtr m_instance;
|
||||
MinecraftInstance* m_instance;
|
||||
Task::Ptr m_current_task;
|
||||
|
||||
qsizetype m_majorJavaVersionIndex = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ ClaimAccount::ClaimAccount(LaunchTask* parent, AuthSessionPtr session) : LaunchS
|
||||
void ClaimAccount::executeTask()
|
||||
{
|
||||
if (m_account) {
|
||||
lock.reset(new UseLock(m_account));
|
||||
lock.reset(new UseLock(m_account.get()));
|
||||
emitSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,19 +45,19 @@ void ScanModFolders::executeTask()
|
||||
auto m_inst = m_parent->instance();
|
||||
|
||||
auto loaders = m_inst->loaderModList();
|
||||
connect(loaders.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||
connect(loaders, &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||
if (!loaders->update()) {
|
||||
m_modsDone = true;
|
||||
}
|
||||
|
||||
auto cores = m_inst->coreModList();
|
||||
connect(cores.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||
connect(cores, &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||
if (!cores->update()) {
|
||||
m_coreModsDone = true;
|
||||
}
|
||||
|
||||
auto nils = m_inst->nilModList();
|
||||
connect(nils.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||
connect(nils, &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||
if (!nils->update()) {
|
||||
m_nilModsDone = true;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ void ResourceFolderModel::installResourceWithFlameMetadata(QString path, ModPlat
|
||||
};
|
||||
|
||||
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::aborted, this, install);
|
||||
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 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] {
|
||||
QJsonParseError 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);
|
||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active");
|
||||
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
||||
up->m_sink.reset(new Net::ByteArraySink(new QByteArray()));
|
||||
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||
}));
|
||||
return up;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "SkinDelete.h"
|
||||
|
||||
#include "net/ByteArraySink.h"
|
||||
#include <net/DummySink.h>
|
||||
#include "net/RawHeaderProxy.h"
|
||||
|
||||
SkinDelete::SkinDelete() : NetRequest()
|
||||
@@ -54,8 +54,8 @@ SkinDelete::Ptr SkinDelete::make(QString token)
|
||||
{
|
||||
auto up = makeShared<SkinDelete>();
|
||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins/active");
|
||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
||||
up->m_sink.reset(new Net::DummySink());
|
||||
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||
}));
|
||||
return up;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <QHttpMultiPart>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "net/ByteArraySink.h"
|
||||
#include "net/DummySink.h"
|
||||
#include "net/RawHeaderProxy.h"
|
||||
|
||||
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);
|
||||
up->m_url = QUrl("https://api.minecraftservices.com/minecraft/profile/skins");
|
||||
up->setObjectName(QString("BYTES:") + up->m_url.toString());
|
||||
up->m_sink.reset(new Net::ByteArraySink(std::make_shared<QByteArray>()));
|
||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
||||
up->m_sink.reset(new Net::DummySink());
|
||||
up->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(QList<Net::HeaderPair>{
|
||||
{ "Authorization", QString("Bearer %1").arg(token).toLocal8Bit() },
|
||||
}));
|
||||
return up;
|
||||
|
||||
@@ -31,7 +31,7 @@ void LibrariesTask::executeTask()
|
||||
emitFailed(tr("Null jar is specified in the metadata, aborting."));
|
||||
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) {
|
||||
downloadJob->addNetAction(dl);
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ class CheckUpdateTask : public Task {
|
||||
CheckUpdateTask(QList<Resource*>& resources,
|
||||
std::list<Version>& mcVersions,
|
||||
QList<ModPlatform::ModLoaderType> loadersList,
|
||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
||||
ResourceFolderModel* resourceModel)
|
||||
: Task()
|
||||
, m_resources(resources)
|
||||
, m_gameVersions(mcVersions)
|
||||
, m_loadersList(std::move(loadersList))
|
||||
, m_resourceModel(std::move(resourceModel))
|
||||
, m_resourceModel(resourceModel)
|
||||
{}
|
||||
|
||||
struct Update {
|
||||
@@ -71,7 +71,7 @@ class CheckUpdateTask : public Task {
|
||||
QList<Resource*>& m_resources;
|
||||
std::list<Version>& m_gameVersions;
|
||||
QList<ModPlatform::ModLoaderType> m_loadersList;
|
||||
std::shared_ptr<ResourceFolderModel> m_resourceModel;
|
||||
ResourceFolderModel* m_resourceModel;
|
||||
|
||||
std::vector<Update> m_updates;
|
||||
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 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
|
||||
if (!ver_task)
|
||||
@@ -273,9 +273,9 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
||||
if (addonIds.isEmpty()) {
|
||||
qWarning() << "No addonId found!";
|
||||
} else if (addonIds.size() == 1) {
|
||||
proj_task = modrinth_api.getProject(*addonIds.keyBegin(), response);
|
||||
proj_task = modrinth_api.getProject(*addonIds.keyBegin(), response.get());
|
||||
} 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
|
||||
@@ -348,7 +348,7 @@ Task::Ptr EnsureMetadataTask::flameVersionsTask()
|
||||
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] {
|
||||
QJsonParseError parse_error{};
|
||||
@@ -423,9 +423,9 @@ Task::Ptr EnsureMetadataTask::flameProjectsTask()
|
||||
if (addonIds.isEmpty()) {
|
||||
qWarning() << "No addonId found!";
|
||||
} else if (addonIds.size() == 1) {
|
||||
proj_task = flame_api.getProject(*addonIds.keyBegin(), response);
|
||||
proj_task = flame_api.getProject(*addonIds.keyBegin(), response.get());
|
||||
} 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
|
||||
|
||||
@@ -21,7 +21,7 @@ Task::Ptr ResourceAPI::searchProjects(SearchArgs&& args, Callback<QList<ModPlatf
|
||||
auto response = std::make_shared<QByteArray>();
|
||||
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] {
|
||||
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 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] {
|
||||
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
|
||||
{
|
||||
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] {
|
||||
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 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] {
|
||||
QJsonParseError parse_error{};
|
||||
@@ -284,7 +284,7 @@ QString ResourceAPI::mapMCVersionToModrinth(Version v) const
|
||||
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);
|
||||
if (!project_url_optional.has_value())
|
||||
|
||||
@@ -112,8 +112,8 @@ class ResourceAPI {
|
||||
public slots:
|
||||
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 getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const = 0;
|
||||
virtual Task::Ptr getProject(QString addonId, QByteArray* response) const;
|
||||
virtual Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const = 0;
|
||||
|
||||
virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, Callback<ModPlatform::IndexedPack::Ptr>&&) 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()) };
|
||||
auto searchUrl =
|
||||
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::failed, this, &PackInstallTask::onDownloadFailed);
|
||||
@@ -423,7 +423,7 @@ QString PackInstallTask::detectLibrary(const VersionLibrary& library)
|
||||
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()) {
|
||||
return true;
|
||||
@@ -532,11 +532,11 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared
|
||||
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
||||
file.close();
|
||||
|
||||
profile->appendComponent(ComponentPtr{ new Component(profile.get(), target_id, f) });
|
||||
profile->appendComponent(ComponentPtr{ new Component(profile, target_id, f) });
|
||||
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()) {
|
||||
return true;
|
||||
@@ -621,7 +621,7 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
||||
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
|
||||
file.close();
|
||||
|
||||
profile->appendComponent(ComponentPtr{ new Component(profile.get(), target_id, f) });
|
||||
profile->appendComponent(ComponentPtr{ new Component(profile, target_id, f) });
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -988,10 +988,10 @@ void PackInstallTask::install()
|
||||
setStatus(tr("Installing modpack"));
|
||||
|
||||
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||
instanceSettings->suspendSave();
|
||||
|
||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
||||
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||
auto components = instance.getPackProfile();
|
||||
components->buildingFromScratch();
|
||||
|
||||
@@ -1047,7 +1047,7 @@ void PackInstallTask::install()
|
||||
instance.setName(name());
|
||||
instance.setIconKey(m_instIcon);
|
||||
instance.setManagedPack("atlauncher", m_pack_safe_name, m_pack_name, m_version_name, m_version_name);
|
||||
instanceSettings->resumeSave();
|
||||
instance.settings()->resumeSave();
|
||||
|
||||
jarmods.clear();
|
||||
emitSucceeded();
|
||||
|
||||
@@ -107,8 +107,8 @@ class PackInstallTask : public InstanceTask {
|
||||
QString getVersionForLoader(QString uid);
|
||||
QString detectLibrary(const VersionLibrary& library);
|
||||
|
||||
bool createLibrariesComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile);
|
||||
bool createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile);
|
||||
bool createLibrariesComponent(QString instanceRoot, PackProfile* profile);
|
||||
bool createPackComponent(QString instanceRoot, PackProfile* profile);
|
||||
|
||||
void deleteExistingFiles();
|
||||
void installConfigs();
|
||||
@@ -125,7 +125,7 @@ class PackInstallTask : public InstanceTask {
|
||||
bool abortable = false;
|
||||
|
||||
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;
|
||||
QString m_pack_name;
|
||||
|
||||
@@ -57,7 +57,7 @@ void Flame::FileResolvingTask::executeTask()
|
||||
for (auto file : m_manifest.files) {
|
||||
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>();
|
||||
connect(m_task.get(), &Task::finished, this, [this, step_progress]() {
|
||||
@@ -154,7 +154,7 @@ void Flame::FileResolvingTask::netJobFinished()
|
||||
return;
|
||||
}
|
||||
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);
|
||||
auto step_progress = std::make_shared<TaskStepProgress>();
|
||||
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));
|
||||
}
|
||||
|
||||
m_task = flameAPI.getProjects(addonIds, m_result);
|
||||
m_task = flameAPI.getProjects(addonIds, m_result.get());
|
||||
|
||||
auto step_progress = std::make_shared<TaskStepProgress>();
|
||||
connect(m_task.get(), &Task::succeeded, this, [this, step_progress] {
|
||||
|
||||
@@ -43,7 +43,7 @@ class FileResolvingTask : public Task {
|
||||
|
||||
private: /* data */
|
||||
Flame::Manifest m_manifest;
|
||||
std::shared_ptr<QByteArray> m_result;
|
||||
std::unique_ptr<QByteArray> m_result;
|
||||
Task::Ptr m_task;
|
||||
};
|
||||
} // namespace Flame
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "net/ApiUpload.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());
|
||||
|
||||
@@ -45,7 +45,7 @@ QString FlameAPI::getModFileChangelog(int modId, int fileId)
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||
QString(BuildConfig.FLAME_BASE_URL + "/mods/%1/files/%2/changelog")
|
||||
.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] {
|
||||
QJsonParseError parse_error{};
|
||||
@@ -78,7 +78,7 @@ QString FlameAPI::getModDescription(int modId)
|
||||
auto netJob = makeShared<NetJob>(QString("Flame::ModDescription"), APPLICATION->network());
|
||||
auto response = std::make_shared<QByteArray>();
|
||||
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] {
|
||||
QJsonParseError parse_error{};
|
||||
@@ -103,7 +103,7 @@ QString FlameAPI::getModDescription(int modId)
|
||||
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());
|
||||
|
||||
@@ -125,7 +125,7 @@ Task::Ptr FlameAPI::getProjects(QStringList addonIds, std::shared_ptr<QByteArray
|
||||
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());
|
||||
|
||||
@@ -147,7 +147,7 @@ Task::Ptr FlameAPI::getFiles(const QStringList& fileIds, std::shared_ptr<QByteAr
|
||||
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());
|
||||
netJob->addNetAction(
|
||||
@@ -171,7 +171,7 @@ QList<ResourceAPI::SortingMethod> FlameAPI::getSortingMethods() const
|
||||
{ 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());
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||
@@ -180,12 +180,12 @@ Task::Ptr FlameAPI::getCategories(std::shared_ptr<QByteArray> response, ModPlatf
|
||||
return netJob;
|
||||
}
|
||||
|
||||
Task::Ptr FlameAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
||||
Task::Ptr FlameAPI::getModCategories(QByteArray* response)
|
||||
{
|
||||
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;
|
||||
QJsonParseError parse_error{};
|
||||
|
||||
@@ -23,14 +23,14 @@ class FlameAPI : public ResourceAPI {
|
||||
ModPlatform::ModLoaderTypes fallback,
|
||||
bool checkLoaders);
|
||||
|
||||
Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const override;
|
||||
Task::Ptr matchFingerprints(const QList<uint>& fingerprints, std::shared_ptr<QByteArray> response);
|
||||
Task::Ptr getFiles(const QStringList& fileIds, std::shared_ptr<QByteArray> response) const;
|
||||
Task::Ptr getFile(const QString& addonId, const QString& fileId, std::shared_ptr<QByteArray> response) const;
|
||||
Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const override;
|
||||
Task::Ptr matchFingerprints(const QList<uint>& fingerprints, QByteArray* response);
|
||||
Task::Ptr getFiles(const QStringList& fileIds, 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 getModCategories(std::shared_ptr<QByteArray> response);
|
||||
static QList<ModPlatform::Category> loadModCategories(std::shared_ptr<QByteArray> response);
|
||||
static Task::Ptr getCategories(QByteArray* response, ModPlatform::ResourceType type);
|
||||
static Task::Ptr getModCategories(QByteArray* response);
|
||||
static QList<ModPlatform::Category> loadModCategories(QByteArray* response);
|
||||
|
||||
QList<ResourceAPI::SortingMethod> getSortingMethods() const override;
|
||||
|
||||
|
||||
@@ -53,16 +53,16 @@ void FlameCheckUpdate::executeTask()
|
||||
continue;
|
||||
|
||||
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);
|
||||
}
|
||||
m_task.reset(netJob);
|
||||
m_task->start();
|
||||
}
|
||||
|
||||
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, std::shared_ptr<QByteArray> response)
|
||||
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* response)
|
||||
{
|
||||
QJsonParseError parse_error{};
|
||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
||||
@@ -146,9 +146,9 @@ void FlameCheckUpdate::collectBlockedMods()
|
||||
emitSucceeded();
|
||||
return;
|
||||
} else if (addonIds.size() == 1) {
|
||||
projTask = api.getProject(*addonIds.begin(), response);
|
||||
projTask = api.getProject(*addonIds.begin(), response.get());
|
||||
} else {
|
||||
projTask = api.getProjects(addonIds, response);
|
||||
projTask = api.getProjects(addonIds, response.get());
|
||||
}
|
||||
|
||||
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds, quickSearch] {
|
||||
@@ -200,4 +200,4 @@ void FlameCheckUpdate::collectBlockedMods()
|
||||
connect(projTask.get(), &Task::details, this, &FlameCheckUpdate::setDetails);
|
||||
m_task.reset(projTask);
|
||||
m_task->start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ class FlameCheckUpdate : public CheckUpdateTask {
|
||||
FlameCheckUpdate(QList<Resource*>& resources,
|
||||
std::list<Version>& mcVersions,
|
||||
QList<ModPlatform::ModLoaderType> loadersList,
|
||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), std::move(resourceModel))
|
||||
ResourceFolderModel* resourceModel)
|
||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), resourceModel)
|
||||
{}
|
||||
|
||||
public slots:
|
||||
@@ -19,7 +19,7 @@ class FlameCheckUpdate : public CheckUpdateTask {
|
||||
protected slots:
|
||||
void executeTask() override;
|
||||
private slots:
|
||||
void getLatestVersionCallback(Resource* resource, std::shared_ptr<QByteArray> response);
|
||||
void getLatestVersionCallback(Resource* resource, QByteArray* response);
|
||||
void collectBlockedMods();
|
||||
|
||||
private:
|
||||
|
||||
@@ -91,7 +91,7 @@ bool FlameCreationTask::updateInstance()
|
||||
auto instance_list = APPLICATION->instances();
|
||||
|
||||
// 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()) {
|
||||
inst = instance_list->getInstanceById(original_id);
|
||||
Q_ASSERT(inst);
|
||||
@@ -185,7 +185,7 @@ bool FlameCreationTask::updateInstance()
|
||||
}
|
||||
|
||||
auto raw_response = std::make_shared<QByteArray>();
|
||||
auto job = api.getFiles(fileIds, raw_response);
|
||||
auto job = api.getFiles(fileIds, raw_response.get());
|
||||
|
||||
QEventLoop loop;
|
||||
|
||||
@@ -386,8 +386,8 @@ bool FlameCreationTask::createInstance()
|
||||
}
|
||||
|
||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||
auto mcVersion = m_pack.minecraft.version;
|
||||
|
||||
// Hack to correct some 'special sauce'...
|
||||
|
||||
@@ -52,7 +52,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
||||
|
||||
public:
|
||||
FlameCreationTask(const QString& staging_path,
|
||||
SettingsObjectPtr global_settings,
|
||||
SettingsObject* global_settings,
|
||||
QWidget* parent,
|
||||
QString id,
|
||||
QString version_id,
|
||||
@@ -91,7 +91,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
||||
|
||||
QList<std::pair<QString, QString>> m_otherResources;
|
||||
|
||||
std::optional<InstancePtr> m_instance;
|
||||
std::optional<BaseInstance*> m_instance;
|
||||
|
||||
QStringList m_selectedOptionalMods;
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ void FlamePackExportTask::collectFiles()
|
||||
resolvedFiles.clear();
|
||||
|
||||
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()
|
||||
@@ -174,7 +174,7 @@ void FlamePackExportTask::makeApiRequest()
|
||||
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] {
|
||||
QJsonParseError parseError{};
|
||||
@@ -252,9 +252,9 @@ void FlamePackExportTask::getProjectsInfo()
|
||||
buildZip();
|
||||
return;
|
||||
} else if (addonIds.size() == 1) {
|
||||
projTask = api.getProject(*addonIds.begin(), response);
|
||||
projTask = api.getProject(*addonIds.begin(), response.get());
|
||||
} else {
|
||||
projTask = api.getProjects(addonIds, response);
|
||||
projTask = api.getProjects(addonIds, response.get());
|
||||
}
|
||||
|
||||
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds] {
|
||||
|
||||
@@ -29,7 +29,7 @@ struct FlamePackExportOptions {
|
||||
QString version;
|
||||
QString author;
|
||||
bool optionalFiles;
|
||||
MinecraftInstancePtr instance;
|
||||
MinecraftInstance* instance;
|
||||
QString output;
|
||||
MMCZip::FilterFileFunction filter;
|
||||
int recommendedRAM;
|
||||
|
||||
@@ -51,9 +51,9 @@ void PackInstallTask::copySettings()
|
||||
setStatus(tr("Copying settings..."));
|
||||
progress(2, 2);
|
||||
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||
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("totalTimePlayed", m_pack.totalPlayTime / 1000);
|
||||
|
||||
@@ -108,7 +108,7 @@ void PackInstallTask::copySettings()
|
||||
if (m_instIcon == "default")
|
||||
m_instIcon = "ftb_logo";
|
||||
instance.setIconKey(m_instIcon);
|
||||
instanceSettings->resumeSave();
|
||||
instance.settings()->resumeSave();
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ void PackFetchTask::fetch()
|
||||
|
||||
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
|
||||
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");
|
||||
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::failed, this, &PackFetchTask::fileDownloadFailed);
|
||||
@@ -73,7 +73,7 @@ void PackFetchTask::fetchPrivate(const QStringList& toFetch)
|
||||
for (auto& packCode : toFetch) {
|
||||
auto data = std::make_shared<QByteArray>();
|
||||
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);
|
||||
|
||||
connect(job, &NetJob::succeeded, this, [this, job, data, packCode] {
|
||||
|
||||
@@ -13,18 +13,18 @@ class PackFetchTask : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network) {};
|
||||
PackFetchTask(QNetworkAccessManager* network) : QObject(nullptr), m_network(network) {};
|
||||
virtual ~PackFetchTask() = default;
|
||||
|
||||
void fetch();
|
||||
void fetchPrivate(const QStringList& toFetch);
|
||||
|
||||
private:
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
QNetworkAccessManager* m_network;
|
||||
NetJob::Ptr jobPtr;
|
||||
|
||||
std::shared_ptr<QByteArray> publicModpacksXmlFileData = std::make_shared<QByteArray>();
|
||||
std::shared_ptr<QByteArray> thirdPartyModpacksXmlFileData = std::make_shared<QByteArray>();
|
||||
std::unique_ptr<QByteArray> publicModpacksXmlFileData = std::make_unique<QByteArray>();
|
||||
std::unique_ptr<QByteArray> thirdPartyModpacksXmlFileData = std::make_unique<QByteArray>();
|
||||
|
||||
bool parseAndAddPacks(QByteArray& data, PackType packType, ModpackList& list);
|
||||
ModpackList publicPacks;
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
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_version = version;
|
||||
@@ -133,10 +133,10 @@ void PackInstallTask::install()
|
||||
}
|
||||
|
||||
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(instanceConfigPath);
|
||||
instanceSettings->suspendSave();
|
||||
|
||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
||||
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||
auto components = instance.getPackProfile();
|
||||
components->buildingFromScratch();
|
||||
components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
|
||||
@@ -204,7 +204,7 @@ void PackInstallTask::install()
|
||||
m_instIcon = "ftb_logo";
|
||||
}
|
||||
instance.setIconKey(m_instIcon);
|
||||
instanceSettings->resumeSave();
|
||||
instance.settings()->resumeSave();
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class PackInstallTask : public InstanceTask {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const Modpack& pack, QString version);
|
||||
explicit PackInstallTask(QNetworkAccessManager* network, const Modpack& pack, QString version);
|
||||
virtual ~PackInstallTask() {}
|
||||
|
||||
bool canAbort() const override { return true; }
|
||||
@@ -35,7 +35,7 @@ class PackInstallTask : public InstanceTask {
|
||||
void onUnzipCanceled();
|
||||
|
||||
private: /* data */
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
QNetworkAccessManager* m_network;
|
||||
bool abortable = false;
|
||||
QFuture<std::optional<QStringList>> m_extractFuture;
|
||||
QFutureWatcher<std::optional<QStringList>> m_extractFutureWatcher;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "net/NetJob.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());
|
||||
|
||||
@@ -21,7 +21,7 @@ Task::Ptr ModrinthAPI::currentVersion(QString hash, QString hash_format, std::sh
|
||||
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());
|
||||
|
||||
@@ -42,7 +42,7 @@ Task::Ptr ModrinthAPI::latestVersion(QString hash,
|
||||
QString hash_format,
|
||||
std::optional<std::list<Version>> mcVersions,
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||
std::shared_ptr<QByteArray> response)
|
||||
QByteArray* response)
|
||||
{
|
||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersion"), APPLICATION->network());
|
||||
|
||||
@@ -72,7 +72,7 @@ Task::Ptr ModrinthAPI::latestVersions(const QStringList& hashes,
|
||||
QString hash_format,
|
||||
std::optional<std::list<Version>> mcVersions,
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||
std::shared_ptr<QByteArray> response)
|
||||
QByteArray* response)
|
||||
{
|
||||
auto netJob = makeShared<NetJob>(QString("Modrinth::GetLatestVersions"), APPLICATION->network());
|
||||
|
||||
@@ -101,7 +101,7 @@ Task::Ptr ModrinthAPI::latestVersions(const QStringList& hashes,
|
||||
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 searchUrl = getMultipleModInfoURL(addonIds);
|
||||
@@ -121,7 +121,7 @@ QList<ResourceAPI::SortingMethod> ModrinthAPI::getSortingMethods() const
|
||||
{ 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());
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
QJsonParseError parse_error{};
|
||||
@@ -159,7 +159,7 @@ QList<ModPlatform::Category> ModrinthAPI::loadCategories(std::shared_ptr<QByteAr
|
||||
return categories;
|
||||
}
|
||||
|
||||
QList<ModPlatform::Category> ModrinthAPI::loadModCategories(std::shared_ptr<QByteArray> response)
|
||||
QList<ModPlatform::Category> ModrinthAPI::loadModCategories(QByteArray* response)
|
||||
{
|
||||
return loadCategories(response, "mod");
|
||||
};
|
||||
|
||||
@@ -14,27 +14,27 @@
|
||||
|
||||
class ModrinthAPI : public ResourceAPI {
|
||||
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,
|
||||
QString hash_format,
|
||||
std::optional<std::list<Version>> mcVersions,
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||
std::shared_ptr<QByteArray> response);
|
||||
QByteArray* response);
|
||||
|
||||
Task::Ptr latestVersions(const QStringList& hashes,
|
||||
QString hash_format,
|
||||
std::optional<std::list<Version>> mcVersions,
|
||||
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 QList<ModPlatform::Category> loadCategories(std::shared_ptr<QByteArray> response, QString projectType);
|
||||
static QList<ModPlatform::Category> loadModCategories(std::shared_ptr<QByteArray> response);
|
||||
static Task::Ptr getModCategories(QByteArray* response);
|
||||
static QList<ModPlatform::Category> loadCategories(QByteArray* response, QString projectType);
|
||||
static QList<ModPlatform::Category> loadModCategories(QByteArray* response);
|
||||
|
||||
public:
|
||||
auto getSortingMethods() const -> QList<ResourceAPI::SortingMethod> override;
|
||||
|
||||
@@ -18,8 +18,8 @@ static ModrinthAPI api;
|
||||
ModrinthCheckUpdate::ModrinthCheckUpdate(QList<Resource*>& resources,
|
||||
std::list<Version>& mcVersions,
|
||||
QList<ModPlatform::ModLoaderType> loadersList,
|
||||
std::shared_ptr<ResourceFolderModel> resourceModel)
|
||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), std::move(resourceModel))
|
||||
ResourceFolderModel* resourceModel)
|
||||
: CheckUpdateTask(resources, mcVersions, std::move(loadersList), resourceModel)
|
||||
, 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
|
||||
@@ -97,9 +97,9 @@ void ModrinthCheckUpdate::getUpdateModsForLoader(std::optional<ModPlatform::ModL
|
||||
} else {
|
||||
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);
|
||||
|
||||
@@ -108,7 +108,7 @@ void ModrinthCheckUpdate::getUpdateModsForLoader(std::optional<ModPlatform::ModL
|
||||
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..."));
|
||||
setProgress(m_progress + 1, m_progressTotal);
|
||||
@@ -223,4 +223,4 @@ void ModrinthCheckUpdate::checkNextLoader()
|
||||
}
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class ModrinthCheckUpdate : public CheckUpdateTask {
|
||||
ModrinthCheckUpdate(QList<Resource*>& resources,
|
||||
std::list<Version>& mcVersions,
|
||||
QList<ModPlatform::ModLoaderType> loadersList,
|
||||
std::shared_ptr<ResourceFolderModel> resourceModel);
|
||||
ResourceFolderModel* resourceModel);
|
||||
|
||||
public slots:
|
||||
bool abort() override;
|
||||
@@ -17,7 +17,7 @@ class ModrinthCheckUpdate : public CheckUpdateTask {
|
||||
protected slots:
|
||||
void executeTask() override;
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
@@ -43,7 +43,7 @@ bool ModrinthCreationTask::updateInstance()
|
||||
auto instance_list = APPLICATION->instances();
|
||||
|
||||
// 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()) {
|
||||
inst = instance_list->getInstanceById(original_id);
|
||||
Q_ASSERT(inst);
|
||||
@@ -212,8 +212,8 @@ bool ModrinthCreationTask::createInstance()
|
||||
}
|
||||
|
||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||
|
||||
auto components = instance.getPackProfile();
|
||||
components->buildingFromScratch();
|
||||
|
||||
@@ -25,7 +25,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
|
||||
|
||||
public:
|
||||
ModrinthCreationTask(QString staging_path,
|
||||
SettingsObjectPtr global_settings,
|
||||
SettingsObject* global_settings,
|
||||
QWidget* parent,
|
||||
QString id,
|
||||
QString version_id = {},
|
||||
@@ -55,7 +55,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
|
||||
std::vector<File> m_files;
|
||||
Task::Ptr m_task;
|
||||
|
||||
std::optional<InstancePtr> m_instance;
|
||||
std::optional<BaseInstance*> m_instance;
|
||||
|
||||
QString m_root_path = "minecraft";
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||
const QString& version,
|
||||
const QString& summary,
|
||||
bool optionalFiles,
|
||||
InstancePtr instance,
|
||||
BaseInstance* instance,
|
||||
const QString& output,
|
||||
MMCZip::FilterFileFunction filter)
|
||||
: name(name)
|
||||
@@ -48,7 +48,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||
, summary(summary)
|
||||
, optionalFiles(optionalFiles)
|
||||
, instance(instance)
|
||||
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
||||
, mcInstance(dynamic_cast<MinecraftInstance*>(instance))
|
||||
, gameRoot(instance->gameRoot())
|
||||
, output(output)
|
||||
, filter(filter)
|
||||
@@ -86,7 +86,7 @@ void ModrinthPackExportTask::collectFiles()
|
||||
|
||||
if (mcInstance) {
|
||||
mcInstance->loaderModList()->update();
|
||||
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
|
||||
connect(mcInstance->loaderModList(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
|
||||
} else
|
||||
collectHashes();
|
||||
}
|
||||
@@ -156,15 +156,15 @@ void ModrinthPackExportTask::makeApiRequest()
|
||||
else {
|
||||
setStatus(tr("Finding versions for hashes..."));
|
||||
auto response = std::make_shared<QByteArray>();
|
||||
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
||||
connect(task.get(), &Task::succeeded, [this, response]() { parseApiResponse(response); });
|
||||
task = api.currentVersions(pendingHashes.values(), "sha512", response.get());
|
||||
connect(task.get(), &Task::succeeded, [this, response]() { parseApiResponse(response.get()); });
|
||||
connect(task.get(), &Task::failed, this, &ModrinthPackExportTask::emitFailed);
|
||||
connect(task.get(), &Task::aborted, this, &ModrinthPackExportTask::emitAborted);
|
||||
task->start();
|
||||
}
|
||||
}
|
||||
|
||||
void ModrinthPackExportTask::parseApiResponse(const std::shared_ptr<QByteArray> response)
|
||||
void ModrinthPackExportTask::parseApiResponse(QByteArray* response)
|
||||
{
|
||||
task = nullptr;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class ModrinthPackExportTask : public Task {
|
||||
const QString& version,
|
||||
const QString& summary,
|
||||
bool optionalFiles,
|
||||
InstancePtr instance,
|
||||
BaseInstance* instance,
|
||||
const QString& output,
|
||||
MMCZip::FilterFileFunction filter);
|
||||
|
||||
@@ -55,7 +55,7 @@ class ModrinthPackExportTask : public Task {
|
||||
// inputs
|
||||
const QString name, version, summary;
|
||||
const bool optionalFiles;
|
||||
const InstancePtr instance;
|
||||
const BaseInstance* instance;
|
||||
MinecraftInstance* mcInstance;
|
||||
const QDir gameRoot;
|
||||
const QString output;
|
||||
@@ -70,7 +70,7 @@ class ModrinthPackExportTask : public Task {
|
||||
void collectFiles();
|
||||
void collectHashes();
|
||||
void makeApiRequest();
|
||||
void parseApiResponse(std::shared_ptr<QByteArray> response);
|
||||
void parseApiResponse(QByteArray* response);
|
||||
void buildZip();
|
||||
|
||||
QByteArray generateIndex();
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/ChecksumValidator.h"
|
||||
|
||||
Technic::SolderPackInstallTask::SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network,
|
||||
Technic::SolderPackInstallTask::SolderPackInstallTask(QNetworkAccessManager* network,
|
||||
const QUrl& solderUrl,
|
||||
const QString& pack,
|
||||
const QString& version,
|
||||
@@ -72,7 +72,7 @@ void Technic::SolderPackInstallTask::executeTask()
|
||||
|
||||
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);
|
||||
m_filesNetJob->addNetAction(Net::ApiDownload::makeByteArray(sourceUrl, m_response));
|
||||
m_filesNetJob->addNetAction(Net::ApiDownload::makeByteArray(sourceUrl, m_response.get()));
|
||||
|
||||
auto job = m_filesNetJob.get();
|
||||
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Technic {
|
||||
class SolderPackInstallTask : public InstanceTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network,
|
||||
explicit SolderPackInstallTask(QNetworkAccessManager* network,
|
||||
const QUrl& solderUrl,
|
||||
const QString& pack,
|
||||
const QString& version,
|
||||
@@ -71,14 +71,14 @@ class SolderPackInstallTask : public InstanceTask {
|
||||
private:
|
||||
bool m_abortable = false;
|
||||
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
QNetworkAccessManager* m_network;
|
||||
|
||||
NetJob::Ptr m_filesNetJob;
|
||||
QUrl m_solderUrl;
|
||||
QString m_pack;
|
||||
QString m_version;
|
||||
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;
|
||||
int m_modCount;
|
||||
QFuture<bool> m_extractFuture;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <memory>
|
||||
#include "archive/ArchiveReader.h"
|
||||
|
||||
void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings,
|
||||
void Technic::TechnicPackProcessor::run(SettingsObject* globalSettings,
|
||||
const QString& instName,
|
||||
const QString& instIcon,
|
||||
const QString& stagingPath,
|
||||
@@ -33,8 +33,8 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings,
|
||||
{
|
||||
QString minecraftPath = FS::PathCombine(stagingPath, "minecraft");
|
||||
QString configPath = FS::PathCombine(stagingPath, "instance.cfg");
|
||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(globalSettings, instanceSettings, stagingPath);
|
||||
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||
MinecraftInstance instance(globalSettings, std::move(instanceSettings), stagingPath);
|
||||
|
||||
instance.setName(instName);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class TechnicPackProcessor : public QObject {
|
||||
void failed(QString reason);
|
||||
|
||||
public:
|
||||
void run(SettingsObjectPtr globalSettings,
|
||||
void run(SettingsObject* globalSettings,
|
||||
const QString& instName,
|
||||
const QString& instIcon,
|
||||
const QString& stagingPath,
|
||||
|
||||
@@ -25,21 +25,21 @@ namespace Net {
|
||||
Download::Ptr ApiDownload::makeCached(QUrl url, MetaEntryPtr entry, Download::Options options)
|
||||
{
|
||||
auto dl = Download::makeCached(url, entry, options);
|
||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
||||
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||
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);
|
||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
||||
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||
return dl;
|
||||
}
|
||||
|
||||
Download::Ptr ApiDownload::makeFile(QUrl url, QString path, Download::Options options)
|
||||
{
|
||||
auto dl = Download::makeFile(url, path, options);
|
||||
dl->addHeaderProxy(new ApiHeaderProxy());
|
||||
dl->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||
return dl;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Net {
|
||||
|
||||
namespace ApiDownload {
|
||||
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);
|
||||
}; // namespace ApiDownload
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
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);
|
||||
up->addHeaderProxy(new ApiHeaderProxy());
|
||||
up->addHeaderProxy(std::make_unique<ApiHeaderProxy>());
|
||||
return up;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace Net {
|
||||
|
||||
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
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Net {
|
||||
*/
|
||||
class ByteArraySink : public Sink {
|
||||
public:
|
||||
ByteArraySink(std::shared_ptr<QByteArray> output) : m_output(output) {};
|
||||
ByteArraySink(QByteArray* output) : m_output(output) {}
|
||||
|
||||
virtual ~ByteArraySink() = default;
|
||||
|
||||
@@ -92,6 +92,6 @@ class ByteArraySink : public Sink {
|
||||
auto hasLocalData() -> bool override { return false; }
|
||||
|
||||
protected:
|
||||
std::shared_ptr<QByteArray> m_output;
|
||||
QByteArray* m_output;
|
||||
};
|
||||
} // namespace Net
|
||||
|
||||
@@ -63,7 +63,7 @@ auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Down
|
||||
}
|
||||
#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>();
|
||||
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;
|
||||
#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;
|
||||
|
||||
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"
|
||||
#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)
|
||||
{
|
||||
#if defined(LAUNCHER_APPLICATION)
|
||||
|
||||
@@ -50,9 +50,10 @@ class NetJob : public ConcurrentTask {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// TODO: delete
|
||||
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;
|
||||
|
||||
auto size() const -> int;
|
||||
@@ -77,7 +78,7 @@ class NetJob : public ConcurrentTask {
|
||||
bool isOnline();
|
||||
|
||||
private:
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
QNetworkAccessManager* m_network;
|
||||
|
||||
int m_try = 1;
|
||||
bool m_ask_retry = true;
|
||||
|
||||
@@ -68,8 +68,8 @@ class NetRequest : public Task {
|
||||
auto abort() -> bool override;
|
||||
auto canAbort() const -> bool override { return true; }
|
||||
|
||||
void setNetwork(shared_qobject_ptr<QNetworkAccessManager> network) { m_network = network; }
|
||||
void addHeaderProxy(Net::HeaderProxy* proxy) { m_headerProxies.push_back(std::shared_ptr<Net::HeaderProxy>(proxy)); }
|
||||
void setNetwork(QNetworkAccessManager* network) { m_network = network; }
|
||||
void addHeaderProxy(std::unique_ptr<Net::HeaderProxy> proxy) { m_headerProxies.push_back(std::move(proxy)); }
|
||||
|
||||
QUrl url() const;
|
||||
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;
|
||||
qint64 m_last_progress_bytes;
|
||||
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
QNetworkAccessManager* m_network;
|
||||
|
||||
/// the network reply
|
||||
unique_qobject_ptr<QNetworkReply> m_reply;
|
||||
std::unique_ptr<QNetworkReply> m_reply;
|
||||
QByteArray m_errorResponse;
|
||||
|
||||
/// source URL
|
||||
QUrl m_url;
|
||||
std::vector<std::shared_ptr<Net::HeaderProxy>> m_headerProxies;
|
||||
std::vector<std::unique_ptr<Net::HeaderProxy>> m_headerProxies;
|
||||
};
|
||||
} // namespace Net
|
||||
|
||||
|
||||
@@ -214,5 +214,5 @@ PasteUpload::PasteUpload(const QString& log, QString url, PasteType pasteType) :
|
||||
else
|
||||
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 {
|
||||
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;
|
||||
|
||||
public:
|
||||
@@ -93,4 +93,5 @@ class PasteUpload : public Net::NetRequest {
|
||||
QString m_pasteLink;
|
||||
QString m_baseUrl;
|
||||
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
Reference in New Issue
Block a user