NOISSUE continue refactoring things to make tests pass
This commit is contained in:
parent
c2c56a2f6c
commit
69213b1206
@ -47,7 +47,6 @@
|
|||||||
#include <minecraft/auth/AccountList.h>
|
#include <minecraft/auth/AccountList.h>
|
||||||
#include "icons/IconList.h"
|
#include "icons/IconList.h"
|
||||||
#include "net/HttpMetaCache.h"
|
#include "net/HttpMetaCache.h"
|
||||||
#include "Env.h"
|
|
||||||
|
|
||||||
#include "java/JavaUtils.h"
|
#include "java/JavaUtils.h"
|
||||||
|
|
||||||
@ -62,6 +61,7 @@
|
|||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
#include "translations/TranslationsModel.h"
|
#include "translations/TranslationsModel.h"
|
||||||
|
#include "meta/Index.h"
|
||||||
|
|
||||||
#include <Commandline.h>
|
#include <Commandline.h>
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
@ -520,10 +520,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
FS::updateTimestamp(m_rootPath);
|
FS::updateTimestamp(m_rootPath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MULTIMC_JARS_LOCATION
|
|
||||||
ENV->setJarsPath( TOSTRING(MULTIMC_JARS_LOCATION) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT;
|
qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT;
|
||||||
qDebug() << "Version : " << BuildConfig.printableVersionString();
|
qDebug() << "Version : " << BuildConfig.printableVersionString();
|
||||||
qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT;
|
qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT;
|
||||||
@ -730,6 +726,18 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
QAccessible::installFactory(groupViewAccessibleFactory);
|
QAccessible::installFactory(groupViewAccessibleFactory);
|
||||||
#endif /* !QT_NO_ACCESSIBILITY */
|
#endif /* !QT_NO_ACCESSIBILITY */
|
||||||
|
|
||||||
|
// initialize network access and proxy setup
|
||||||
|
{
|
||||||
|
m_network = new QNetworkAccessManager();
|
||||||
|
QString proxyTypeStr = settings()->get("ProxyType").toString();
|
||||||
|
QString addr = settings()->get("ProxyAddr").toString();
|
||||||
|
int port = settings()->get("ProxyPort").value<qint16>();
|
||||||
|
QString user = settings()->get("ProxyUser").toString();
|
||||||
|
QString pass = settings()->get("ProxyPass").toString();
|
||||||
|
updateProxySettings(proxyTypeStr, addr, port, user, pass);
|
||||||
|
qDebug() << "<> Network done.";
|
||||||
|
}
|
||||||
|
|
||||||
// load translations
|
// load translations
|
||||||
{
|
{
|
||||||
m_translations.reset(new TranslationsModel("translations"));
|
m_translations.reset(new TranslationsModel("translations"));
|
||||||
@ -745,7 +753,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
||||||
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
||||||
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
||||||
m_updateChecker.reset(new UpdateChecker(channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||||
qDebug() << "<> Updater started.";
|
qDebug() << "<> Updater started.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +772,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
{
|
{
|
||||||
m_icons->directoryChanged(value.toString());
|
m_icons->directoryChanged(value.toString());
|
||||||
});
|
});
|
||||||
ENV->registerIconList(m_icons);
|
|
||||||
qDebug() << "<> Instance icons intialized.";
|
qDebug() << "<> Instance icons intialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,21 +828,28 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
|
|
||||||
// init the http meta cache
|
// init the http meta cache
|
||||||
{
|
{
|
||||||
ENV->initHttpMetaCache();
|
m_metacache.reset(new HttpMetaCache("metacache"));
|
||||||
|
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
||||||
|
m_metacache->addBase("asset_objects", QDir("assets/objects").absolutePath());
|
||||||
|
m_metacache->addBase("versions", QDir("versions").absolutePath());
|
||||||
|
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
||||||
|
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath());
|
||||||
|
m_metacache->addBase("fmllibs", QDir("mods/minecraftforge/libs").absolutePath());
|
||||||
|
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
|
||||||
|
m_metacache->addBase("general", QDir("cache").absolutePath());
|
||||||
|
m_metacache->addBase("ATLauncherPacks", QDir("cache/ATLauncherPacks").absolutePath());
|
||||||
|
m_metacache->addBase("FTBPacks", QDir("cache/FTBPacks").absolutePath());
|
||||||
|
m_metacache->addBase("ModpacksCHPacks", QDir("cache/ModpacksCHPacks").absolutePath());
|
||||||
|
m_metacache->addBase("TechnicPacks", QDir("cache/TechnicPacks").absolutePath());
|
||||||
|
m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath());
|
||||||
|
m_metacache->addBase("root", QDir::currentPath());
|
||||||
|
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
||||||
|
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
|
||||||
|
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
||||||
|
m_metacache->Load();
|
||||||
qDebug() << "<> Cache initialized.";
|
qDebug() << "<> Cache initialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// init proxy settings
|
|
||||||
{
|
|
||||||
QString proxyTypeStr = settings()->get("ProxyType").toString();
|
|
||||||
QString addr = settings()->get("ProxyAddr").toString();
|
|
||||||
int port = settings()->get("ProxyPort").value<qint16>();
|
|
||||||
QString user = settings()->get("ProxyUser").toString();
|
|
||||||
QString pass = settings()->get("ProxyPass").toString();
|
|
||||||
ENV->updateProxySettings(proxyTypeStr, addr, port, user, pass);
|
|
||||||
qDebug() << "<> Proxy settings done.";
|
|
||||||
}
|
|
||||||
|
|
||||||
// now we have network, download translation updates
|
// now we have network, download translation updates
|
||||||
m_translations->downloadIndex();
|
m_translations->downloadIndex();
|
||||||
|
|
||||||
@ -894,7 +908,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, analyticsVersion, this);
|
m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, analyticsVersion, this);
|
||||||
m_analytics->setLogLevel(GAnalytics::Debug);
|
m_analytics->setLogLevel(GAnalytics::Debug);
|
||||||
m_analytics->setAnonymizeIPs(true);
|
m_analytics->setAnonymizeIPs(true);
|
||||||
m_analytics->setNetworkAccessManager(&ENV->network());
|
// FIXME: the ganalytics library has no idea about our fancy shared pointers...
|
||||||
|
m_analytics->setNetworkAccessManager(network().get());
|
||||||
|
|
||||||
if(m_settings->get("AnalyticsSeen").toInt() < m_analytics->version())
|
if(m_settings->get("AnalyticsSeen").toInt() < m_analytics->version())
|
||||||
{
|
{
|
||||||
@ -1043,9 +1058,6 @@ void Application::showFatalErrorMessage(const QString& title, const QString& con
|
|||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
// kill the other globals.
|
|
||||||
Env::dispose();
|
|
||||||
|
|
||||||
// Shut down logger by setting the logger function to nothing
|
// Shut down logger by setting the logger function to nothing
|
||||||
qInstallMessageHandler(nullptr);
|
qInstallMessageHandler(nullptr);
|
||||||
|
|
||||||
@ -1535,3 +1547,92 @@ void Application::on_windowClose()
|
|||||||
QString Application::msaClientId() const {
|
QString Application::msaClientId() const {
|
||||||
return Secrets::getMSAClientID('-');
|
return Secrets::getMSAClientID('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password)
|
||||||
|
{
|
||||||
|
// Set the application proxy settings.
|
||||||
|
if (proxyTypeStr == "SOCKS5")
|
||||||
|
{
|
||||||
|
QNetworkProxy::setApplicationProxy(
|
||||||
|
QNetworkProxy(QNetworkProxy::Socks5Proxy, addr, port, user, password));
|
||||||
|
}
|
||||||
|
else if (proxyTypeStr == "HTTP")
|
||||||
|
{
|
||||||
|
QNetworkProxy::setApplicationProxy(
|
||||||
|
QNetworkProxy(QNetworkProxy::HttpProxy, addr, port, user, password));
|
||||||
|
}
|
||||||
|
else if (proxyTypeStr == "None")
|
||||||
|
{
|
||||||
|
// If we have no proxy set, set no proxy and return.
|
||||||
|
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If we have "Default" selected, set Qt to use the system proxy settings.
|
||||||
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Detecting proxy settings...";
|
||||||
|
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
|
||||||
|
m_network->setProxy(proxy);
|
||||||
|
|
||||||
|
QString proxyDesc;
|
||||||
|
if (proxy.type() == QNetworkProxy::NoProxy)
|
||||||
|
{
|
||||||
|
qDebug() << "Using no proxy is an option!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (proxy.type())
|
||||||
|
{
|
||||||
|
case QNetworkProxy::DefaultProxy:
|
||||||
|
proxyDesc = "Default proxy: ";
|
||||||
|
break;
|
||||||
|
case QNetworkProxy::Socks5Proxy:
|
||||||
|
proxyDesc = "Socks5 proxy: ";
|
||||||
|
break;
|
||||||
|
case QNetworkProxy::HttpProxy:
|
||||||
|
proxyDesc = "HTTP proxy: ";
|
||||||
|
break;
|
||||||
|
case QNetworkProxy::HttpCachingProxy:
|
||||||
|
proxyDesc = "HTTP caching: ";
|
||||||
|
break;
|
||||||
|
case QNetworkProxy::FtpCachingProxy:
|
||||||
|
proxyDesc = "FTP caching: ";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
proxyDesc = "DERP proxy: ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
proxyDesc += QString("%1:%2")
|
||||||
|
.arg(proxy.hostName())
|
||||||
|
.arg(proxy.port());
|
||||||
|
qDebug() << proxyDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_qobject_ptr< HttpMetaCache > Application::metacache()
|
||||||
|
{
|
||||||
|
return m_metacache;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> Application::network()
|
||||||
|
{
|
||||||
|
return m_network;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_qobject_ptr<Meta::Index> Application::metadataIndex()
|
||||||
|
{
|
||||||
|
if (!m_metadataIndex)
|
||||||
|
{
|
||||||
|
m_metadataIndex.reset(new Meta::Index());
|
||||||
|
}
|
||||||
|
return m_metadataIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Application::getJarsPath()
|
||||||
|
{
|
||||||
|
if(m_jarsPath.isEmpty())
|
||||||
|
{
|
||||||
|
return FS::PathCombine(QCoreApplication::applicationDirPath(), "jars");
|
||||||
|
}
|
||||||
|
return m_jarsPath;
|
||||||
|
}
|
||||||
|
@ -18,7 +18,6 @@ class LocalPeer;
|
|||||||
class InstanceWindow;
|
class InstanceWindow;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class SetupWizard;
|
class SetupWizard;
|
||||||
class FolderInstanceProvider;
|
|
||||||
class GenericPageProvider;
|
class GenericPageProvider;
|
||||||
class QFile;
|
class QFile;
|
||||||
class HttpMetaCache;
|
class HttpMetaCache;
|
||||||
@ -36,6 +35,10 @@ class ITheme;
|
|||||||
class MCEditTool;
|
class MCEditTool;
|
||||||
class GAnalytics;
|
class GAnalytics;
|
||||||
|
|
||||||
|
namespace Meta {
|
||||||
|
class Index;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(APPLICATION)
|
#if defined(APPLICATION)
|
||||||
#undef APPLICATION
|
#undef APPLICATION
|
||||||
#endif
|
#endif
|
||||||
@ -46,8 +49,7 @@ class Application : public QApplication
|
|||||||
// friends for the purpose of limiting access to deprecated stuff
|
// friends for the purpose of limiting access to deprecated stuff
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Status
|
enum Status {
|
||||||
{
|
|
||||||
StartingUp,
|
StartingUp,
|
||||||
Failed,
|
Failed,
|
||||||
Succeeded,
|
Succeeded,
|
||||||
@ -58,18 +60,15 @@ public:
|
|||||||
Application(int &argc, char **argv);
|
Application(int &argc, char **argv);
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
GAnalytics *analytics() const
|
GAnalytics *analytics() const {
|
||||||
{
|
|
||||||
return m_analytics;
|
return m_analytics;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SettingsObject> settings() const
|
std::shared_ptr<SettingsObject> settings() const {
|
||||||
{
|
|
||||||
return m_settings;
|
return m_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 timeSinceStart() const
|
qint64 timeSinceStart() const {
|
||||||
{
|
|
||||||
return startTime.msecsTo(QDateTime::currentDateTime());
|
return startTime.msecsTo(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +80,7 @@ public:
|
|||||||
|
|
||||||
void setApplicationTheme(const QString& name, bool initial);
|
void setApplicationTheme(const QString& name, bool initial);
|
||||||
|
|
||||||
// DownloadUpdateTask
|
shared_qobject_ptr<UpdateChecker> updateChecker() {
|
||||||
std::shared_ptr<UpdateChecker> updateChecker()
|
|
||||||
{
|
|
||||||
return m_updateChecker;
|
return m_updateChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,46 +88,44 @@ public:
|
|||||||
|
|
||||||
std::shared_ptr<JavaInstallList> javalist();
|
std::shared_ptr<JavaInstallList> javalist();
|
||||||
|
|
||||||
std::shared_ptr<InstanceList> instances() const
|
std::shared_ptr<InstanceList> instances() const {
|
||||||
{
|
|
||||||
return m_instances;
|
return m_instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderInstanceProvider * folderProvider() const
|
std::shared_ptr<IconList> icons() const {
|
||||||
{
|
|
||||||
return m_instanceFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<IconList> icons() const
|
|
||||||
{
|
|
||||||
return m_icons;
|
return m_icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCEditTool *mcedit() const
|
MCEditTool *mcedit() const {
|
||||||
{
|
|
||||||
return m_mcedit.get();
|
return m_mcedit.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<AccountList> accounts() const
|
shared_qobject_ptr<AccountList> accounts() const {
|
||||||
{
|
|
||||||
return m_accounts;
|
return m_accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString msaClientId() const;
|
QString msaClientId() const;
|
||||||
|
|
||||||
Status status() const
|
Status status() const {
|
||||||
{
|
|
||||||
return m_status;
|
return m_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, std::shared_ptr<BaseProfilerFactory>> &profilers() const
|
const QMap<QString, std::shared_ptr<BaseProfilerFactory>> &profilers() const {
|
||||||
{
|
|
||||||
return m_profilers;
|
return m_profilers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
||||||
|
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> network();
|
||||||
|
|
||||||
|
shared_qobject_ptr<HttpMetaCache> metacache();
|
||||||
|
|
||||||
|
shared_qobject_ptr<Meta::Index> metadataIndex();
|
||||||
|
|
||||||
|
QString getJarsPath();
|
||||||
|
|
||||||
/// this is the root of the 'installation'. Used for automatic updates
|
/// this is the root of the 'installation'. Used for automatic updates
|
||||||
const QString &root()
|
const QString &root() {
|
||||||
{
|
|
||||||
return m_rootPath;
|
return m_rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,17 +181,24 @@ private:
|
|||||||
private:
|
private:
|
||||||
QDateTime startTime;
|
QDateTime startTime;
|
||||||
|
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
|
shared_qobject_ptr<UpdateChecker> m_updateChecker;
|
||||||
|
shared_qobject_ptr<AccountList> m_accounts;
|
||||||
|
|
||||||
|
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
||||||
|
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
||||||
|
|
||||||
std::shared_ptr<SettingsObject> m_settings;
|
std::shared_ptr<SettingsObject> m_settings;
|
||||||
std::shared_ptr<InstanceList> m_instances;
|
std::shared_ptr<InstanceList> m_instances;
|
||||||
FolderInstanceProvider * m_instanceFolder = nullptr;
|
|
||||||
std::shared_ptr<IconList> m_icons;
|
std::shared_ptr<IconList> m_icons;
|
||||||
std::shared_ptr<UpdateChecker> m_updateChecker;
|
|
||||||
shared_qobject_ptr<AccountList> m_accounts;
|
|
||||||
std::shared_ptr<JavaInstallList> m_javalist;
|
std::shared_ptr<JavaInstallList> m_javalist;
|
||||||
std::shared_ptr<TranslationsModel> m_translations;
|
std::shared_ptr<TranslationsModel> m_translations;
|
||||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||||
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
||||||
std::unique_ptr<MCEditTool> m_mcedit;
|
std::unique_ptr<MCEditTool> m_mcedit;
|
||||||
|
QString m_jarsPath;
|
||||||
|
QSet<QString> m_features;
|
||||||
|
|
||||||
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
|
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
|
||||||
|
|
||||||
@ -209,8 +211,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: attach to instances instead.
|
// FIXME: attach to instances instead.
|
||||||
struct InstanceXtras
|
struct InstanceXtras {
|
||||||
{
|
|
||||||
InstanceWindow * window = nullptr;
|
InstanceWindow * window = nullptr;
|
||||||
shared_qobject_ptr<LaunchController> controller;
|
shared_qobject_ptr<LaunchController> controller;
|
||||||
};
|
};
|
||||||
|
@ -43,10 +43,6 @@ set(CORE_SOURCES
|
|||||||
# Prefix tree where node names are strings between separators
|
# Prefix tree where node names are strings between separators
|
||||||
SeparatorPrefixTree.h
|
SeparatorPrefixTree.h
|
||||||
|
|
||||||
# WARNING: globals live here
|
|
||||||
Env.h
|
|
||||||
Env.cpp
|
|
||||||
|
|
||||||
# String filters
|
# String filters
|
||||||
Filter.h
|
Filter.h
|
||||||
Filter.cpp
|
Filter.cpp
|
||||||
@ -191,8 +187,6 @@ set(NEWS_SOURCES
|
|||||||
# Icon interface
|
# Icon interface
|
||||||
set(ICONS_SOURCES
|
set(ICONS_SOURCES
|
||||||
# Icons System and related code
|
# Icons System and related code
|
||||||
icons/IIconList.h
|
|
||||||
icons/IIconList.cpp
|
|
||||||
icons/IconUtils.h
|
icons/IconUtils.h
|
||||||
icons/IconUtils.cpp
|
icons/IconUtils.cpp
|
||||||
)
|
)
|
||||||
|
210
launcher/Env.cpp
210
launcher/Env.cpp
@ -1,210 +0,0 @@
|
|||||||
#include "Env.h"
|
|
||||||
#include "net/HttpMetaCache.h"
|
|
||||||
#include "BaseVersion.h"
|
|
||||||
#include "BaseVersionList.h"
|
|
||||||
#include <QDir>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QNetworkProxy>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QDebug>
|
|
||||||
#include "tasks/Task.h"
|
|
||||||
#include "meta/Index.h"
|
|
||||||
#include "FileSystem.h"
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
|
|
||||||
struct Env::Private
|
|
||||||
{
|
|
||||||
QNetworkAccessManager m_qnam;
|
|
||||||
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
|
||||||
std::shared_ptr<IIconList> m_iconlist;
|
|
||||||
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
|
||||||
QString m_jarsPath;
|
|
||||||
QSet<QString> m_features;
|
|
||||||
};
|
|
||||||
|
|
||||||
static Env * instance;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The *NEW* global rat nest of an object. Handle with care.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Env::Env()
|
|
||||||
{
|
|
||||||
d = new Private();
|
|
||||||
}
|
|
||||||
|
|
||||||
Env::~Env()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
Env* Env::Env::getInstance()
|
|
||||||
{
|
|
||||||
if(!instance)
|
|
||||||
{
|
|
||||||
instance = new Env();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::dispose()
|
|
||||||
{
|
|
||||||
delete instance;
|
|
||||||
instance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
shared_qobject_ptr< HttpMetaCache > Env::metacache()
|
|
||||||
{
|
|
||||||
return d->m_metacache;
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkAccessManager& Env::network() const
|
|
||||||
{
|
|
||||||
return d->m_qnam;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<IIconList> Env::icons()
|
|
||||||
{
|
|
||||||
return d->m_iconlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::registerIconList(std::shared_ptr<IIconList> iconlist)
|
|
||||||
{
|
|
||||||
d->m_iconlist = iconlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> Env::metadataIndex()
|
|
||||||
{
|
|
||||||
if (!d->m_metadataIndex)
|
|
||||||
{
|
|
||||||
d->m_metadataIndex.reset(new Meta::Index());
|
|
||||||
}
|
|
||||||
return d->m_metadataIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Env::initHttpMetaCache()
|
|
||||||
{
|
|
||||||
auto &m_metacache = d->m_metacache;
|
|
||||||
m_metacache.reset(new HttpMetaCache("metacache"));
|
|
||||||
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
|
||||||
m_metacache->addBase("asset_objects", QDir("assets/objects").absolutePath());
|
|
||||||
m_metacache->addBase("versions", QDir("versions").absolutePath());
|
|
||||||
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
|
||||||
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath());
|
|
||||||
m_metacache->addBase("fmllibs", QDir("mods/minecraftforge/libs").absolutePath());
|
|
||||||
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
|
|
||||||
m_metacache->addBase("general", QDir("cache").absolutePath());
|
|
||||||
m_metacache->addBase("ATLauncherPacks", QDir("cache/ATLauncherPacks").absolutePath());
|
|
||||||
m_metacache->addBase("FTBPacks", QDir("cache/FTBPacks").absolutePath());
|
|
||||||
m_metacache->addBase("ModpacksCHPacks", QDir("cache/ModpacksCHPacks").absolutePath());
|
|
||||||
m_metacache->addBase("TechnicPacks", QDir("cache/TechnicPacks").absolutePath());
|
|
||||||
m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath());
|
|
||||||
m_metacache->addBase("root", QDir::currentPath());
|
|
||||||
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
|
||||||
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
|
|
||||||
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
|
||||||
m_metacache->Load();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password)
|
|
||||||
{
|
|
||||||
// Set the application proxy settings.
|
|
||||||
if (proxyTypeStr == "SOCKS5")
|
|
||||||
{
|
|
||||||
QNetworkProxy::setApplicationProxy(
|
|
||||||
QNetworkProxy(QNetworkProxy::Socks5Proxy, addr, port, user, password));
|
|
||||||
}
|
|
||||||
else if (proxyTypeStr == "HTTP")
|
|
||||||
{
|
|
||||||
QNetworkProxy::setApplicationProxy(
|
|
||||||
QNetworkProxy(QNetworkProxy::HttpProxy, addr, port, user, password));
|
|
||||||
}
|
|
||||||
else if (proxyTypeStr == "None")
|
|
||||||
{
|
|
||||||
// If we have no proxy set, set no proxy and return.
|
|
||||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If we have "Default" selected, set Qt to use the system proxy settings.
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Detecting proxy settings...";
|
|
||||||
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
|
|
||||||
d->m_qnam.setProxy(proxy);
|
|
||||||
QString proxyDesc;
|
|
||||||
if (proxy.type() == QNetworkProxy::NoProxy)
|
|
||||||
{
|
|
||||||
qDebug() << "Using no proxy is an option!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (proxy.type())
|
|
||||||
{
|
|
||||||
case QNetworkProxy::DefaultProxy:
|
|
||||||
proxyDesc = "Default proxy: ";
|
|
||||||
break;
|
|
||||||
case QNetworkProxy::Socks5Proxy:
|
|
||||||
proxyDesc = "Socks5 proxy: ";
|
|
||||||
break;
|
|
||||||
case QNetworkProxy::HttpProxy:
|
|
||||||
proxyDesc = "HTTP proxy: ";
|
|
||||||
break;
|
|
||||||
case QNetworkProxy::HttpCachingProxy:
|
|
||||||
proxyDesc = "HTTP caching: ";
|
|
||||||
break;
|
|
||||||
case QNetworkProxy::FtpCachingProxy:
|
|
||||||
proxyDesc = "FTP caching: ";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
proxyDesc = "DERP proxy: ";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
proxyDesc += QString("%1:%2")
|
|
||||||
.arg(proxy.hostName())
|
|
||||||
.arg(proxy.port());
|
|
||||||
qDebug() << proxyDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Env::getJarsPath()
|
|
||||||
{
|
|
||||||
if(d->m_jarsPath.isEmpty())
|
|
||||||
{
|
|
||||||
return FS::PathCombine(QCoreApplication::applicationDirPath(), "jars");
|
|
||||||
}
|
|
||||||
return d->m_jarsPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::setJarsPath(const QString& path)
|
|
||||||
{
|
|
||||||
d->m_jarsPath = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::enableFeature(const QString& featureName, bool state)
|
|
||||||
{
|
|
||||||
if(state)
|
|
||||||
{
|
|
||||||
d->m_features.insert(featureName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d->m_features.remove(featureName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Env::isFeatureEnabled(const QString& featureName) const
|
|
||||||
{
|
|
||||||
return d->m_features.contains(featureName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::getEnabledFeatures(QSet<QString>& features) const
|
|
||||||
{
|
|
||||||
features = d->m_features;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Env::setEnabledFeatures(const QSet<QString>& features) const
|
|
||||||
{
|
|
||||||
d->m_features = features;
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "icons/IIconList.h"
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
#include "QObjectPtr.h"
|
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
|
||||||
class HttpMetaCache;
|
|
||||||
class BaseVersionList;
|
|
||||||
class BaseVersion;
|
|
||||||
|
|
||||||
namespace Meta
|
|
||||||
{
|
|
||||||
class Index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENV)
|
|
||||||
#undef ENV
|
|
||||||
#endif
|
|
||||||
#define ENV (Env::getInstance())
|
|
||||||
|
|
||||||
|
|
||||||
class Env
|
|
||||||
{
|
|
||||||
friend class Application;
|
|
||||||
private:
|
|
||||||
struct Private;
|
|
||||||
Env();
|
|
||||||
~Env();
|
|
||||||
static void dispose();
|
|
||||||
public:
|
|
||||||
static Env* getInstance();
|
|
||||||
|
|
||||||
QNetworkAccessManager &network() const;
|
|
||||||
|
|
||||||
shared_qobject_ptr<HttpMetaCache> metacache();
|
|
||||||
|
|
||||||
std::shared_ptr<IIconList> icons();
|
|
||||||
|
|
||||||
/// init the cache. FIXME: possible future hook point
|
|
||||||
void initHttpMetaCache();
|
|
||||||
|
|
||||||
/// Updates the application proxy settings from the settings object.
|
|
||||||
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
|
||||||
|
|
||||||
void registerIconList(std::shared_ptr<IIconList> iconlist);
|
|
||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> metadataIndex();
|
|
||||||
|
|
||||||
QString getJarsPath();
|
|
||||||
void setJarsPath(const QString & path);
|
|
||||||
|
|
||||||
bool isFeatureEnabled(const QString & featureName) const;
|
|
||||||
void enableFeature(const QString & featureName, bool state = true);
|
|
||||||
void getEnabledFeatures(QSet<QString> & features) const;
|
|
||||||
void setEnabledFeatures(const QSet<QString> & features) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Private * d;
|
|
||||||
};
|
|
@ -16,11 +16,10 @@
|
|||||||
#include "InstanceImportTask.h"
|
#include "InstanceImportTask.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Env.h"
|
#include "Application.h"
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "NullInstance.h"
|
#include "NullInstance.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "icons/IIconList.h"
|
|
||||||
#include "icons/IconUtils.h"
|
#include "icons/IconUtils.h"
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
@ -33,6 +32,9 @@
|
|||||||
#include <quazipdir.h>
|
#include <quazipdir.h>
|
||||||
#include "modplatform/technic/TechnicPackProcessor.h"
|
#include "modplatform/technic/TechnicPackProcessor.h"
|
||||||
|
|
||||||
|
#include "icons/IconList.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
|
InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
|
||||||
{
|
{
|
||||||
m_sourceUrl = sourceUrl;
|
m_sourceUrl = sourceUrl;
|
||||||
@ -51,7 +53,7 @@ void InstanceImportTask::executeTask()
|
|||||||
m_downloadRequired = true;
|
m_downloadRequired = true;
|
||||||
|
|
||||||
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
||||||
auto entry = ENV->metacache()->resolveEntry("general", path);
|
auto entry = APPLICATION->metacache()->resolveEntry("general", path);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
m_filesNetJob.reset(new NetJob(tr("Modpack download")));
|
m_filesNetJob.reset(new NetJob(tr("Modpack download")));
|
||||||
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
||||||
@ -60,7 +62,7 @@ void InstanceImportTask::executeTask()
|
|||||||
connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
||||||
connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
||||||
connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +333,7 @@ void InstanceImportTask::processFlame()
|
|||||||
FS::deletePath(jarmodsPath);
|
FS::deletePath(jarmodsPath);
|
||||||
}
|
}
|
||||||
instance.setName(m_instName);
|
instance.setName(m_instName);
|
||||||
m_modIdResolver.reset(new Flame::FileResolvingTask(pack));
|
m_modIdResolver = new Flame::FileResolvingTask(APPLICATION->network(), pack);
|
||||||
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]()
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]()
|
||||||
{
|
{
|
||||||
auto results = m_modIdResolver->getResults();
|
auto results = m_modIdResolver->getResults();
|
||||||
@ -389,7 +391,7 @@ void InstanceImportTask::processFlame()
|
|||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason)
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason)
|
||||||
@ -418,7 +420,6 @@ void InstanceImportTask::processTechnic()
|
|||||||
|
|
||||||
void InstanceImportTask::processMultiMC()
|
void InstanceImportTask::processMultiMC()
|
||||||
{
|
{
|
||||||
// FIXME: copy from FolderInstanceProvider!!! FIX IT!!!
|
|
||||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
||||||
instanceSettings->registerSetting("InstanceType", "Legacy");
|
instanceSettings->registerSetting("InstanceType", "Legacy");
|
||||||
@ -444,7 +445,7 @@ void InstanceImportTask::processMultiMC()
|
|||||||
if (!importIconPath.isNull() && QFile::exists(importIconPath))
|
if (!importIconPath.isNull() && QFile::exists(importIconPath))
|
||||||
{
|
{
|
||||||
// import icon
|
// import icon
|
||||||
auto iconList = ENV->icons();
|
auto iconList = APPLICATION->icons();
|
||||||
if (iconList->iconFileExists(m_instIcon))
|
if (iconList->iconFileExists(m_instIcon))
|
||||||
{
|
{
|
||||||
iconList->deleteIcon(m_instIcon);
|
iconList->deleteIcon(m_instIcon);
|
||||||
|
@ -55,7 +55,7 @@ private slots:
|
|||||||
void extractAborted();
|
void extractAborted();
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
NetJobPtr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
shared_qobject_ptr<Flame::FileResolvingTask> m_modIdResolver;
|
shared_qobject_ptr<Flame::FileResolvingTask> m_modIdResolver;
|
||||||
QUrl m_sourceUrl;
|
QUrl m_sourceUrl;
|
||||||
QString m_archivePath;
|
QString m_archivePath;
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include "pages/instance/ServersPage.h"
|
#include "pages/instance/ServersPage.h"
|
||||||
#include "pages/instance/GameOptionsPage.h"
|
#include "pages/instance/GameOptionsPage.h"
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
|
|
||||||
class InstancePageProvider : public QObject, public BasePageProvider
|
class InstancePageProvider : public QObject, public BasePageProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include <QtWidgets/QShortcut>
|
#include <QtWidgets/QShortcut>
|
||||||
|
|
||||||
#include <BaseInstance.h>
|
#include <BaseInstance.h>
|
||||||
#include <Env.h>
|
|
||||||
#include <InstanceList.h>
|
#include <InstanceList.h>
|
||||||
#include <MMCZip.h>
|
#include <MMCZip.h>
|
||||||
#include <icons/IconList.h>
|
#include <icons/IconList.h>
|
||||||
@ -681,7 +680,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
|
|
||||||
// Add the news label to the news toolbar.
|
// Add the news label to the news toolbar.
|
||||||
{
|
{
|
||||||
m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL));
|
m_newsChecker.reset(new NewsChecker(APPLICATION->network(), BuildConfig.NEWS_RSS_URL));
|
||||||
newsLabel = new QToolButton();
|
newsLabel = new QToolButton();
|
||||||
newsLabel->setIcon(APPLICATION->getThemedIcon("news"));
|
newsLabel->setIcon(APPLICATION->getThemedIcon("news"));
|
||||||
newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
@ -876,7 +875,6 @@ QMenu * MainWindow::createPopupMenu()
|
|||||||
|
|
||||||
void MainWindow::konamiTriggered()
|
void MainWindow::konamiTriggered()
|
||||||
{
|
{
|
||||||
// ENV->enableFeature("NewModsPage");
|
|
||||||
qDebug() << "Super Secret Mode ACTIVATED!";
|
qDebug() << "Super Secret Mode ACTIVATED!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1280,7 +1278,7 @@ void MainWindow::downloadUpdates(GoUpdate::Status status)
|
|||||||
{
|
{
|
||||||
CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
GoUpdate::DownloadTask updateTask(status, dlPath, &updateDlg);
|
GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg);
|
||||||
// If the task succeeds, install the updates.
|
// If the task succeeds, install the updates.
|
||||||
if (updateDlg.execWithTask(&updateTask))
|
if (updateDlg.execWithTask(&updateTask))
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "SkinUtils.h"
|
#include "SkinUtils.h"
|
||||||
#include "net/HttpMetaCache.h"
|
#include "net/HttpMetaCache.h"
|
||||||
#include "Env.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -30,7 +30,7 @@ namespace SkinUtils
|
|||||||
*/
|
*/
|
||||||
QPixmap getFaceFromCache(QString username, int height, int width)
|
QPixmap getFaceFromCache(QString username, int height, int width)
|
||||||
{
|
{
|
||||||
QFile fskin(ENV->metacache()->resolveEntry("skins", username + ".png")->getFullPath());
|
QFile fskin(APPLICATION->metacache()->resolveEntry("skins", username + ".png")->getFullPath());
|
||||||
|
|
||||||
if (fskin.exists())
|
if (fskin.exists())
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ void AboutDialog::loadPatronList()
|
|||||||
netJob.reset(new NetJob("Patreon Patron List"));
|
netJob.reset(new NetJob("Patreon Patron List"));
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink));
|
||||||
connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded);
|
connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded);
|
||||||
netJob->start();
|
netJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::patronListLoaded()
|
void AboutDialog::patronListLoaded()
|
||||||
|
@ -42,6 +42,6 @@ slots:
|
|||||||
private:
|
private:
|
||||||
Ui::AboutDialog *ui;
|
Ui::AboutDialog *ui;
|
||||||
|
|
||||||
NetJobPtr netJob;
|
NetJob::Ptr netJob;
|
||||||
QByteArray dataSink;
|
QByteArray dataSink;
|
||||||
};
|
};
|
||||||
|
@ -49,7 +49,7 @@ void UpdateDialog::loadChangelog()
|
|||||||
dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData));
|
dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData));
|
||||||
connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded);
|
connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded);
|
||||||
connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed);
|
connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed);
|
||||||
dljob->start();
|
dljob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString reprocessMarkdown(QByteArray markdown)
|
QString reprocessMarkdown(QByteArray markdown)
|
||||||
|
@ -62,6 +62,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Ui::UpdateDialog *ui;
|
Ui::UpdateDialog *ui;
|
||||||
QByteArray changelogData;
|
QByteArray changelogData;
|
||||||
NetJobPtr dljob;
|
NetJob::Ptr dljob;
|
||||||
ChangelogType m_changelogType = CHANGELOG_MARKDOWN;
|
ChangelogType m_changelogType = CHANGELOG_MARKDOWN;
|
||||||
};
|
};
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
#include "IIconList.h"
|
|
||||||
|
|
||||||
// blargh
|
|
||||||
IIconList::~IIconList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
enum IconType : unsigned
|
|
||||||
{
|
|
||||||
Builtin,
|
|
||||||
Transient,
|
|
||||||
FileBased,
|
|
||||||
ICONS_TOTAL,
|
|
||||||
ToBeDeleted
|
|
||||||
};
|
|
||||||
|
|
||||||
class IIconList
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IIconList();
|
|
||||||
virtual bool addIcon(const QString &key, const QString &name, const QString &path, const IconType type) = 0;
|
|
||||||
virtual bool deleteIcon(const QString &key) = 0;
|
|
||||||
virtual void saveIcon(const QString &key, const QString &path, const char * format) const = 0;
|
|
||||||
virtual bool iconFileExists(const QString &key) const = 0;
|
|
||||||
virtual void installIcons(const QStringList &iconFiles) = 0;
|
|
||||||
virtual void installIcon(const QString &file, const QString &name) = 0;
|
|
||||||
};
|
|
@ -21,14 +21,15 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "MMCIcon.h"
|
#include "MMCIcon.h"
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
#include "Env.h" // there is a global icon list inside Env.
|
|
||||||
#include <icons/IIconList.h>
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
class IconList : public QAbstractListModel, public IIconList
|
class IconList : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -42,19 +43,19 @@ public:
|
|||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
|
||||||
bool addThemeIcon(const QString &key);
|
|
||||||
bool addIcon(const QString &key, const QString &name, const QString &path, const IconType type) override;
|
|
||||||
void saveIcon(const QString &key, const QString &path, const char * format) const override;
|
|
||||||
bool deleteIcon(const QString &key) override;
|
|
||||||
bool iconFileExists(const QString &key) const override;
|
|
||||||
|
|
||||||
virtual QStringList mimeTypes() const override;
|
virtual QStringList mimeTypes() const override;
|
||||||
virtual Qt::DropActions supportedDropActions() const override;
|
virtual Qt::DropActions supportedDropActions() const override;
|
||||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
|
||||||
void installIcons(const QStringList &iconFiles) override;
|
bool addThemeIcon(const QString &key);
|
||||||
void installIcon(const QString &file, const QString &name) override;
|
bool addIcon(const QString &key, const QString &name, const QString &path, const IconType type);
|
||||||
|
void saveIcon(const QString &key, const QString &path, const char * format) const;
|
||||||
|
bool deleteIcon(const QString &key);
|
||||||
|
bool iconFileExists(const QString &key) const;
|
||||||
|
|
||||||
|
void installIcons(const QStringList &iconFiles);
|
||||||
|
void installIcon(const QString &file, const QString &name);
|
||||||
|
|
||||||
const MMCIcon * icon(const QString &key) const;
|
const MMCIcon * icon(const QString &key) const;
|
||||||
|
|
||||||
|
@ -17,7 +17,15 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <icons/IIconList.h>
|
|
||||||
|
enum IconType : unsigned
|
||||||
|
{
|
||||||
|
Builtin,
|
||||||
|
Transient,
|
||||||
|
FileBased,
|
||||||
|
ICONS_TOTAL,
|
||||||
|
ToBeDeleted
|
||||||
|
};
|
||||||
|
|
||||||
struct MMCImage
|
struct MMCImage
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#include "JavaChecker.h"
|
#include "JavaChecker.h"
|
||||||
#include "JavaUtils.h"
|
|
||||||
#include <FileSystem.h>
|
|
||||||
#include <Commandline.h>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "Env.h"
|
#include "JavaUtils.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
#include "Commandline.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
void JavaChecker::performCheck()
|
void JavaChecker::performCheck()
|
||||||
{
|
{
|
||||||
QString checkerJar = FS::PathCombine(ENV->getJarsPath(), "JavaCheck.jar");
|
QString checkerJar = FS::PathCombine(APPLICATION->getJarsPath(), "JavaCheck.jar");
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
|
@ -15,16 +15,13 @@
|
|||||||
|
|
||||||
#include "BaseEntity.h"
|
#include "BaseEntity.h"
|
||||||
|
|
||||||
#include "Json.h"
|
|
||||||
|
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
#include "net/HttpMetaCache.h"
|
#include "net/HttpMetaCache.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
class ParsingValidator : public Net::Validator
|
class ParsingValidator : public Net::Validator
|
||||||
{
|
{
|
||||||
@ -120,9 +117,9 @@ void Meta::BaseEntity::load(Net::Mode loadType)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
|
m_updateTask = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
|
||||||
auto url = this->url();
|
auto url = this->url();
|
||||||
auto entry = ENV->metacache()->resolveEntry("meta", localFilename());
|
auto entry = APPLICATION->metacache()->resolveEntry("meta", localFilename());
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
auto dl = Net::Download::makeCached(url, entry);
|
auto dl = Net::Download::makeCached(url, entry);
|
||||||
/*
|
/*
|
||||||
@ -130,21 +127,20 @@ void Meta::BaseEntity::load(Net::Mode loadType)
|
|||||||
* If that fails, the file is not written to storage.
|
* If that fails, the file is not written to storage.
|
||||||
*/
|
*/
|
||||||
dl->addValidator(new ParsingValidator(this));
|
dl->addValidator(new ParsingValidator(this));
|
||||||
job->addNetAction(dl);
|
m_updateTask->addNetAction(dl);
|
||||||
m_updateStatus = UpdateStatus::InProgress;
|
m_updateStatus = UpdateStatus::InProgress;
|
||||||
m_updateTask.reset(job);
|
QObject::connect(m_updateTask.get(), &NetJob::succeeded, [&]()
|
||||||
QObject::connect(job, &NetJob::succeeded, [&]()
|
|
||||||
{
|
{
|
||||||
m_loadStatus = LoadStatus::Remote;
|
m_loadStatus = LoadStatus::Remote;
|
||||||
m_updateStatus = UpdateStatus::Succeeded;
|
m_updateStatus = UpdateStatus::Succeeded;
|
||||||
m_updateTask.reset();
|
m_updateTask.reset();
|
||||||
});
|
});
|
||||||
QObject::connect(job, &NetJob::failed, [&]()
|
QObject::connect(m_updateTask.get(), &NetJob::failed, [&]()
|
||||||
{
|
{
|
||||||
m_updateStatus = UpdateStatus::Failed;
|
m_updateStatus = UpdateStatus::Failed;
|
||||||
m_updateTask.reset();
|
m_updateTask.reset();
|
||||||
});
|
});
|
||||||
m_updateTask->start();
|
m_updateTask->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::BaseEntity::isLoaded() const
|
bool Meta::BaseEntity::isLoaded() const
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#include "QObjectPtr.h"
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
#include "net/Mode.h"
|
#include "net/Mode.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class Task;
|
|
||||||
namespace Meta
|
namespace Meta
|
||||||
{
|
{
|
||||||
class BaseEntity
|
class BaseEntity
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
bool shouldStartRemoteUpdate() const;
|
bool shouldStartRemoteUpdate() const;
|
||||||
|
|
||||||
void load(Net::Mode loadType);
|
void load(Net::Mode loadType);
|
||||||
shared_qobject_ptr<Task> getCurrentTask();
|
Task::Ptr getCurrentTask();
|
||||||
|
|
||||||
protected: /* methods */
|
protected: /* methods */
|
||||||
bool loadLocalFile();
|
bool loadLocalFile();
|
||||||
@ -62,6 +62,6 @@ protected: /* methods */
|
|||||||
private:
|
private:
|
||||||
LoadStatus m_loadStatus = LoadStatus::NotLoaded;
|
LoadStatus m_loadStatus = LoadStatus::NotLoaded;
|
||||||
UpdateStatus m_updateStatus = UpdateStatus::NotDone;
|
UpdateStatus m_updateStatus = UpdateStatus::NotDone;
|
||||||
shared_qobject_ptr<Task> m_updateTask;
|
NetJob::Ptr m_updateTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,12 @@
|
|||||||
|
|
||||||
#include "meta/Index.h"
|
#include "meta/Index.h"
|
||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
#include "Env.h"
|
|
||||||
|
|
||||||
class IndexTest : public QObject
|
class IndexTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void test_isProvidedByEnv()
|
|
||||||
{
|
|
||||||
QVERIFY(ENV->metadataIndex());
|
|
||||||
QCOMPARE(ENV->metadataIndex(), ENV->metadataIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_hasUid_and_getList()
|
void test_hasUid_and_getList()
|
||||||
{
|
{
|
||||||
Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")});
|
Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")});
|
||||||
|
@ -284,7 +284,7 @@ bool reconstructAssets(QString assetsId, QString resourcesFolder)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetActionPtr AssetObject::getDownloadAction()
|
NetAction::Ptr AssetObject::getDownloadAction()
|
||||||
{
|
{
|
||||||
QFileInfo objectFile(getLocalPath());
|
QFileInfo objectFile(getLocalPath());
|
||||||
if ((!objectFile.isFile()) || (objectFile.size() != size))
|
if ((!objectFile.isFile()) || (objectFile.size() != size))
|
||||||
@ -316,7 +316,7 @@ QString AssetObject::getRelPath()
|
|||||||
return hash.left(2) + "/" + hash;
|
return hash.left(2) + "/" + hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetJobPtr AssetsIndex::getDownloadJob()
|
NetJob::Ptr AssetsIndex::getDownloadJob()
|
||||||
{
|
{
|
||||||
auto job = new NetJob(QObject::tr("Assets for %1").arg(id));
|
auto job = new NetJob(QObject::tr("Assets for %1").arg(id));
|
||||||
for (auto &object : objects.values())
|
for (auto &object : objects.values())
|
||||||
|
@ -25,7 +25,7 @@ struct AssetObject
|
|||||||
QString getRelPath();
|
QString getRelPath();
|
||||||
QUrl getUrl();
|
QUrl getUrl();
|
||||||
QString getLocalPath();
|
QString getLocalPath();
|
||||||
NetActionPtr getDownloadAction();
|
NetAction::Ptr getDownloadAction();
|
||||||
|
|
||||||
QString hash;
|
QString hash;
|
||||||
qint64 size;
|
qint64 size;
|
||||||
@ -33,7 +33,7 @@ struct AssetObject
|
|||||||
|
|
||||||
struct AssetsIndex
|
struct AssetsIndex
|
||||||
{
|
{
|
||||||
NetJobPtr getDownloadJob();
|
NetJob::Ptr getDownloadJob();
|
||||||
|
|
||||||
QString id;
|
QString id;
|
||||||
QMap<QString, AssetObject> objects;
|
QMap<QString, AssetObject> objects;
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
#include <meta/VersionList.h>
|
#include <meta/VersionList.h>
|
||||||
#include <meta/Index.h>
|
#include <meta/Index.h>
|
||||||
#include <Env.h>
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
|
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
#include "meta/Version.h"
|
#include "meta/Version.h"
|
||||||
#include "VersionFile.h"
|
#include "VersionFile.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include <FileSystem.h>
|
#include "FileSystem.h"
|
||||||
#include <QSaveFile>
|
|
||||||
#include "OneSixVersionFormat.h"
|
#include "OneSixVersionFormat.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
Component::Component(PackProfile * parent, const QString& uid)
|
Component::Component(PackProfile * parent, const QString& uid)
|
||||||
@ -85,9 +87,9 @@ std::shared_ptr<class VersionFile> Component::getVersionFile() const
|
|||||||
std::shared_ptr<class Meta::VersionList> Component::getVersionList() const
|
std::shared_ptr<class Meta::VersionList> Component::getVersionList() const
|
||||||
{
|
{
|
||||||
// FIXME: what if the metadata index isn't loaded yet?
|
// FIXME: what if the metadata index isn't loaded yet?
|
||||||
if(ENV->metadataIndex()->hasUid(m_uid))
|
if(APPLICATION->metadataIndex()->hasUid(m_uid))
|
||||||
{
|
{
|
||||||
return ENV->metadataIndex()->get(m_uid);
|
return APPLICATION->metadataIndex()->get(m_uid);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -192,7 +194,7 @@ bool Component::isRevertible()
|
|||||||
{
|
{
|
||||||
if (isCustom())
|
if (isCustom())
|
||||||
{
|
{
|
||||||
if(ENV->metadataIndex()->hasUid(m_uid))
|
if(APPLICATION->metadataIndex()->hasUid(m_uid))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -266,7 +268,7 @@ void Component::setVersion(const QString& version)
|
|||||||
// we don't have a file, therefore we are loaded with metadata
|
// we don't have a file, therefore we are loaded with metadata
|
||||||
m_cachedVersion = version;
|
m_cachedVersion = version;
|
||||||
// see if the meta version is loaded
|
// see if the meta version is loaded
|
||||||
auto metaVersion = ENV->metadataIndex()->get(m_uid, version);
|
auto metaVersion = APPLICATION->metadataIndex()->get(m_uid, version);
|
||||||
if(metaVersion->isLoaded())
|
if(metaVersion->isLoaded())
|
||||||
{
|
{
|
||||||
// if yes, we can continue with that.
|
// if yes, we can continue with that.
|
||||||
@ -350,7 +352,7 @@ bool Component::revert()
|
|||||||
m_file.reset();
|
m_file.reset();
|
||||||
|
|
||||||
// check local cache for metadata...
|
// check local cache for metadata...
|
||||||
auto version = ENV->metadataIndex()->get(m_uid, m_version);
|
auto version = APPLICATION->metadataIndex()->get(m_uid, m_version);
|
||||||
if(version->isLoaded())
|
if(version->isLoaded())
|
||||||
{
|
{
|
||||||
m_metaVersion = version;
|
m_metaVersion = version;
|
||||||
|
@ -3,16 +3,17 @@
|
|||||||
#include "PackProfile_p.h"
|
#include "PackProfile_p.h"
|
||||||
#include "PackProfile.h"
|
#include "PackProfile.h"
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include <Env.h>
|
#include "meta/Index.h"
|
||||||
#include <meta/Index.h>
|
#include "meta/VersionList.h"
|
||||||
#include <meta/VersionList.h>
|
#include "meta/Version.h"
|
||||||
#include <meta/Version.h>
|
|
||||||
#include "ComponentUpdateTask_p.h"
|
#include "ComponentUpdateTask_p.h"
|
||||||
#include <cassert>
|
#include "cassert"
|
||||||
#include <Version.h>
|
#include "Version.h"
|
||||||
#include "net/Mode.h"
|
#include "net/Mode.h"
|
||||||
#include "OneSixVersionFormat.h"
|
#include "OneSixVersionFormat.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is responsible for loading the components of a component list AND resolving dependency issues between them
|
* This is responsible for loading the components of a component list AND resolving dependency issues between them
|
||||||
*/
|
*/
|
||||||
@ -102,7 +103,7 @@ static LoadResult loadComponent(ComponentPtr component, shared_qobject_ptr<Task>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto metaVersion = ENV->metadataIndex()->get(component->m_uid, component->m_version);
|
auto metaVersion = APPLICATION->metadataIndex()->get(component->m_uid, component->m_version);
|
||||||
component->m_metaVersion = metaVersion;
|
component->m_metaVersion = metaVersion;
|
||||||
if(metaVersion->isLoaded())
|
if(metaVersion->isLoaded())
|
||||||
{
|
{
|
||||||
@ -135,7 +136,7 @@ static LoadResult loadPackProfile(ComponentPtr component, shared_qobject_ptr<Tas
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoadResult result = LoadResult::Failed;
|
LoadResult result = LoadResult::Failed;
|
||||||
auto metaList = ENV->metadataIndex()->get(component->m_uid);
|
auto metaList = APPLICATION->metadataIndex()->get(component->m_uid);
|
||||||
if(metaList->isLoaded())
|
if(metaList->isLoaded())
|
||||||
{
|
{
|
||||||
component->m_loaded = true;
|
component->m_loaded = true;
|
||||||
@ -154,13 +155,13 @@ static LoadResult loadPackProfile(ComponentPtr component, shared_qobject_ptr<Tas
|
|||||||
static LoadResult loadIndex(shared_qobject_ptr<Task>& loadTask, Net::Mode netmode)
|
static LoadResult loadIndex(shared_qobject_ptr<Task>& loadTask, Net::Mode netmode)
|
||||||
{
|
{
|
||||||
// FIXME: DECIDE. do we want to run the update task anyway?
|
// FIXME: DECIDE. do we want to run the update task anyway?
|
||||||
if(ENV->metadataIndex()->isLoaded())
|
if(APPLICATION->metadataIndex()->isLoaded())
|
||||||
{
|
{
|
||||||
qDebug() << "Index is already loaded";
|
qDebug() << "Index is already loaded";
|
||||||
return LoadResult::LoadedLocal;
|
return LoadResult::LoadedLocal;
|
||||||
}
|
}
|
||||||
ENV->metadataIndex()->load(netmode);
|
APPLICATION->metadataIndex()->load(netmode);
|
||||||
loadTask = ENV->metadataIndex()->getCurrentTask();
|
loadTask = APPLICATION->metadataIndex()->getCurrentTask();
|
||||||
if(loadTask)
|
if(loadTask)
|
||||||
{
|
{
|
||||||
return LoadResult::RequiresRemote;
|
return LoadResult::RequiresRemote;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <net/Download.h>
|
#include <net/Download.h>
|
||||||
#include <net/ChecksumValidator.h>
|
#include <net/ChecksumValidator.h>
|
||||||
#include <Env.h>
|
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
|
|
||||||
@ -45,14 +44,14 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< std::shared_ptr< NetAction > > Library::getDownloads(
|
QList<NetAction::Ptr> Library::getDownloads(
|
||||||
OpSys system,
|
OpSys system,
|
||||||
class HttpMetaCache* cache,
|
class HttpMetaCache* cache,
|
||||||
QStringList& failedLocalFiles,
|
QStringList& failedLocalFiles,
|
||||||
const QString & overridePath
|
const QString & overridePath
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
QList<NetActionPtr> out;
|
QList<NetAction::Ptr> out;
|
||||||
bool stale = isAlwaysStale();
|
bool stale = isAlwaysStale();
|
||||||
bool local = isLocal();
|
bool local = isLocal();
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public: /* methods */
|
|||||||
bool isForge() const;
|
bool isForge() const;
|
||||||
|
|
||||||
// Get a list of downloads for this library
|
// Get a list of downloads for this library
|
||||||
QList<NetActionPtr> getDownloads(OpSys system, class HttpMetaCache * cache,
|
QList<NetAction::Ptr> getDownloads(OpSys system, class HttpMetaCache * cache,
|
||||||
QStringList & failedLocalFiles, const QString & overridePath) const;
|
QStringList & failedLocalFiles, const QString & overridePath) const;
|
||||||
|
|
||||||
private: /* methods */
|
private: /* methods */
|
||||||
|
@ -55,7 +55,7 @@ slots:
|
|||||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(downloads.size(), 1);
|
QCOMPARE(downloads.size(), 1);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
NetActionPtr dl = downloads[0];
|
NetAction::Ptr dl = downloads[0];
|
||||||
QCOMPARE(dl->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion.jar"));
|
QCOMPARE(dl->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion.jar"));
|
||||||
}
|
}
|
||||||
void test_legacy_url_local_broken()
|
void test_legacy_url_local_broken()
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
#include "MinecraftInstance.h"
|
#include "MinecraftInstance.h"
|
||||||
#include <minecraft/launch/CreateGameFolders.h>
|
#include "minecraft/launch/CreateGameFolders.h"
|
||||||
#include <minecraft/launch/ExtractNatives.h>
|
#include "minecraft/launch/ExtractNatives.h"
|
||||||
#include <minecraft/launch/PrintInstanceInfo.h>
|
#include "minecraft/launch/PrintInstanceInfo.h"
|
||||||
#include <settings/Setting.h>
|
#include "settings/Setting.h"
|
||||||
#include "settings/SettingsObject.h"
|
#include "settings/SettingsObject.h"
|
||||||
#include "Env.h"
|
#include "Application.h"
|
||||||
#include <MMCStrings.h>
|
|
||||||
#include <pathmatcher/RegexpMatcher.h>
|
#include "MMCStrings.h"
|
||||||
#include <pathmatcher/MultiMatcher.h>
|
#include "pathmatcher/RegexpMatcher.h"
|
||||||
#include <FileSystem.h>
|
#include "pathmatcher/MultiMatcher.h"
|
||||||
#include <java/JavaVersion.h>
|
#include "FileSystem.h"
|
||||||
|
#include "java/JavaVersion.h"
|
||||||
#include "MMCTime.h"
|
#include "MMCTime.h"
|
||||||
|
|
||||||
#include "launch/LaunchTask.h"
|
#include "launch/LaunchTask.h"
|
||||||
@ -18,6 +19,7 @@
|
|||||||
#include "launch/steps/Update.h"
|
#include "launch/steps/Update.h"
|
||||||
#include "launch/steps/PreLaunchCommand.h"
|
#include "launch/steps/PreLaunchCommand.h"
|
||||||
#include "launch/steps/TextPrint.h"
|
#include "launch/steps/TextPrint.h"
|
||||||
|
|
||||||
#include "minecraft/launch/LauncherPartLaunch.h"
|
#include "minecraft/launch/LauncherPartLaunch.h"
|
||||||
#include "minecraft/launch/DirectJavaLaunch.h"
|
#include "minecraft/launch/DirectJavaLaunch.h"
|
||||||
#include "minecraft/launch/ModMinecraftJar.h"
|
#include "minecraft/launch/ModMinecraftJar.h"
|
||||||
@ -25,25 +27,27 @@
|
|||||||
#include "minecraft/launch/ReconstructAssets.h"
|
#include "minecraft/launch/ReconstructAssets.h"
|
||||||
#include "minecraft/launch/ScanModFolders.h"
|
#include "minecraft/launch/ScanModFolders.h"
|
||||||
#include "minecraft/launch/VerifyJavaInstall.h"
|
#include "minecraft/launch/VerifyJavaInstall.h"
|
||||||
|
|
||||||
#include "java/launch/CheckJava.h"
|
#include "java/launch/CheckJava.h"
|
||||||
#include "java/JavaUtils.h"
|
#include "java/JavaUtils.h"
|
||||||
|
|
||||||
#include "meta/Index.h"
|
#include "meta/Index.h"
|
||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
|
|
||||||
|
#include "icons/IconList.h"
|
||||||
|
|
||||||
#include "mod/ModFolderModel.h"
|
#include "mod/ModFolderModel.h"
|
||||||
#include "mod/ResourcePackFolderModel.h"
|
#include "mod/ResourcePackFolderModel.h"
|
||||||
#include "mod/TexturePackFolderModel.h"
|
#include "mod/TexturePackFolderModel.h"
|
||||||
|
|
||||||
#include "WorldList.h"
|
#include "WorldList.h"
|
||||||
|
|
||||||
#include "icons/IIconList.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include "PackProfile.h"
|
#include "PackProfile.h"
|
||||||
#include "AssetsUtils.h"
|
#include "AssetsUtils.h"
|
||||||
#include "MinecraftUpdate.h"
|
#include "MinecraftUpdate.h"
|
||||||
#include "MinecraftLoadAndCheck.h"
|
#include "MinecraftLoadAndCheck.h"
|
||||||
#include <minecraft/gameoptions/GameOptions.h>
|
#include "minecraft/gameoptions/GameOptions.h"
|
||||||
#include <minecraft/update/FoldersTask.h>
|
#include "minecraft/update/FoldersTask.h"
|
||||||
|
|
||||||
#define IBUS "@im=ibus"
|
#define IBUS "@im=ibus"
|
||||||
|
|
||||||
@ -816,7 +820,7 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
|||||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
||||||
auto pptr = process.get();
|
auto pptr = process.get();
|
||||||
|
|
||||||
ENV->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
|
APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
|
||||||
|
|
||||||
// print a header
|
// print a header
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
#include "MinecraftUpdate.h"
|
#include "MinecraftUpdate.h"
|
||||||
#include "MinecraftInstance.h"
|
#include "MinecraftInstance.h"
|
||||||
|
|
||||||
|
@ -20,22 +20,23 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "Exception.h"
|
|
||||||
#include <minecraft/OneSixVersionFormat.h>
|
|
||||||
#include <FileSystem.h>
|
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <Env.h>
|
|
||||||
#include <meta/Index.h>
|
|
||||||
#include <minecraft/MinecraftInstance.h>
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <Json.h>
|
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "minecraft/OneSixVersionFormat.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
#include "meta/Index.h"
|
||||||
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "Json.h"
|
||||||
|
|
||||||
#include "PackProfile.h"
|
#include "PackProfile.h"
|
||||||
#include "PackProfile_p.h"
|
#include "PackProfile_p.h"
|
||||||
#include "ComponentUpdateTask.h"
|
#include "ComponentUpdateTask.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
PackProfile::PackProfile(MinecraftInstance * instance)
|
PackProfile::PackProfile(MinecraftInstance * instance)
|
||||||
: QAbstractListModel()
|
: QAbstractListModel()
|
||||||
{
|
{
|
||||||
@ -481,7 +482,7 @@ bool PackProfile::migratePreComponentConfig()
|
|||||||
}
|
}
|
||||||
else if(!intendedVersion.isEmpty())
|
else if(!intendedVersion.isEmpty())
|
||||||
{
|
{
|
||||||
auto metaVersion = ENV->metadataIndex()->get(uid, intendedVersion);
|
auto metaVersion = APPLICATION->metadataIndex()->get(uid, intendedVersion);
|
||||||
component = new Component(this, metaVersion);
|
component = new Component(this, metaVersion);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -546,7 +547,7 @@ bool PackProfile::migratePreComponentConfig()
|
|||||||
auto patchVersion = d->getOldConfigVersion(uid);
|
auto patchVersion = d->getOldConfigVersion(uid);
|
||||||
if(!patchVersion.isEmpty() && !loadedComponents.contains(uid))
|
if(!patchVersion.isEmpty() && !loadedComponents.contains(uid))
|
||||||
{
|
{
|
||||||
auto patch = new Component(this, ENV->metadataIndex()->get(uid, patchVersion));
|
auto patch = new Component(this, APPLICATION->metadataIndex()->get(uid, patchVersion));
|
||||||
patch->setOrder(order);
|
patch->setOrder(order);
|
||||||
loadedComponents[uid] = patch;
|
loadedComponents[uid] = patch;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "Parsers.h"
|
#include "Parsers.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Env.h>
|
|
||||||
|
|
||||||
using OAuth2 = Katabasis::OAuth2;
|
using OAuth2 = Katabasis::OAuth2;
|
||||||
using Activity = Katabasis::Activity;
|
using Activity = Katabasis::Activity;
|
||||||
@ -58,7 +57,8 @@ void AuthContext::initMSA() {
|
|||||||
opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
|
opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
|
||||||
opts.listenerPorts = {28562, 28563, 28564, 28565, 28566};
|
opts.listenerPorts = {28562, 28563, 28564, 28565, 28566};
|
||||||
|
|
||||||
m_oauth2 = new OAuth2(opts, m_data->msaToken, this, &ENV->network());
|
// FIXME: OAuth2 is not aware of our fancy shared pointers
|
||||||
|
m_oauth2 = new OAuth2(opts, m_data->msaToken, this, APPLICATION->network().get());
|
||||||
m_oauth2->setGrantFlow(Katabasis::OAuth2::GrantFlowDevice);
|
m_oauth2->setGrantFlow(Katabasis::OAuth2::GrantFlowDevice);
|
||||||
|
|
||||||
connect(m_oauth2, &OAuth2::linkingFailed, this, &AuthContext::onOAuthLinkingFailed);
|
connect(m_oauth2, &OAuth2::linkingFailed, this, &AuthContext::onOAuthLinkingFailed);
|
||||||
|
@ -5,11 +5,10 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "AuthRequest.h"
|
#include "AuthRequest.h"
|
||||||
#include "katabasis/Globals.h"
|
#include "katabasis/Globals.h"
|
||||||
|
|
||||||
#include <Env.h>
|
|
||||||
|
|
||||||
AuthRequest::AuthRequest(QObject *parent): QObject(parent) {
|
AuthRequest::AuthRequest(QObject *parent): QObject(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ AuthRequest::~AuthRequest() {
|
|||||||
|
|
||||||
void AuthRequest::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) {
|
void AuthRequest::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) {
|
||||||
setup(req, QNetworkAccessManager::GetOperation);
|
setup(req, QNetworkAccessManager::GetOperation);
|
||||||
reply_ = ENV->network().get(request_);
|
reply_ = APPLICATION->network()->get(request_);
|
||||||
status_ = Requesting;
|
status_ = Requesting;
|
||||||
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
||||||
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
@ -30,7 +29,7 @@ void AuthRequest::post(const QNetworkRequest &req, const QByteArray &data, int t
|
|||||||
setup(req, QNetworkAccessManager::PostOperation);
|
setup(req, QNetworkAccessManager::PostOperation);
|
||||||
data_ = data;
|
data_ = data;
|
||||||
status_ = Requesting;
|
status_ = Requesting;
|
||||||
reply_ = ENV->network().post(request_, data_);
|
reply_ = APPLICATION->network()->post(request_, data_);
|
||||||
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
||||||
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
||||||
|
@ -22,10 +22,9 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <Env.h>
|
#include "Application.h"
|
||||||
|
|
||||||
Yggdrasil::Yggdrasil(AccountData *data, QObject *parent)
|
Yggdrasil::Yggdrasil(AccountData *data, QObject *parent)
|
||||||
: AccountTask(data, parent)
|
: AccountTask(data, parent)
|
||||||
@ -38,7 +37,7 @@ void Yggdrasil::sendRequest(QUrl endpoint, QByteArray content) {
|
|||||||
|
|
||||||
QNetworkRequest netRequest(endpoint);
|
QNetworkRequest netRequest(endpoint);
|
||||||
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
m_netReply = ENV->network().post(netRequest, content);
|
m_netReply = APPLICATION->network()->post(netRequest, content);
|
||||||
connect(m_netReply, &QNetworkReply::finished, this, &Yggdrasil::processReply);
|
connect(m_netReply, &QNetworkReply::finished, this, &Yggdrasil::processReply);
|
||||||
connect(m_netReply, &QNetworkReply::uploadProgress, this, &Yggdrasil::refreshTimers);
|
connect(m_netReply, &QNetworkReply::uploadProgress, this, &Yggdrasil::refreshTimers);
|
||||||
connect(m_netReply, &QNetworkReply::downloadProgress, this, &Yggdrasil::refreshTimers);
|
connect(m_netReply, &QNetworkReply::downloadProgress, this, &Yggdrasil::refreshTimers);
|
||||||
|
@ -14,13 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LauncherPartLaunch.h"
|
#include "LauncherPartLaunch.h"
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <launch/LaunchTask.h>
|
|
||||||
#include <minecraft/MinecraftInstance.h>
|
|
||||||
#include <FileSystem.h>
|
|
||||||
#include <Commandline.h>
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include "Env.h"
|
|
||||||
|
#include "launch/LaunchTask.h"
|
||||||
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
#include "Commandline.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
|
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
|
||||||
{
|
{
|
||||||
@ -72,7 +73,7 @@ void LauncherPartLaunch::executeTask()
|
|||||||
m_process.setDetachable(true);
|
m_process.setDetachable(true);
|
||||||
|
|
||||||
auto classPath = minecraftInstance->getClassPath();
|
auto classPath = minecraftInstance->getClassPath();
|
||||||
classPath.prepend(FS::PathCombine(ENV->getJarsPath(), "NewLaunch.jar"));
|
classPath.prepend(FS::PathCombine(APPLICATION->getJarsPath(), "NewLaunch.jar"));
|
||||||
|
|
||||||
auto natPath = minecraftInstance->getNativePath();
|
auto natPath = minecraftInstance->getNativePath();
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "CapeChange.h"
|
#include "CapeChange.h"
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
#include <Env.h>
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
CapeChange::CapeChange(QObject *parent, AuthSessionPtr session, QString cape)
|
CapeChange::CapeChange(QObject *parent, AuthSessionPtr session, QString cape)
|
||||||
: Task(parent), m_capeId(cape), m_session(session)
|
: Task(parent), m_capeId(cape), m_session(session)
|
||||||
@ -12,7 +14,7 @@ void CapeChange::setCape(QString& cape) {
|
|||||||
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active"));
|
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active"));
|
||||||
auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId);
|
auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId);
|
||||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
||||||
QNetworkReply *rep = ENV->network().put(request, requestString.toUtf8());
|
QNetworkReply *rep = APPLICATION->network()->put(request, requestString.toUtf8());
|
||||||
|
|
||||||
setStatus(tr("Equipping cape"));
|
setStatus(tr("Equipping cape"));
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ void CapeChange::clearCape() {
|
|||||||
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active"));
|
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active"));
|
||||||
auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId);
|
auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId);
|
||||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
||||||
QNetworkReply *rep = ENV->network().deleteResource(request);
|
QNetworkReply *rep = APPLICATION->network()->deleteResource(request);
|
||||||
|
|
||||||
setStatus(tr("Removing cape"));
|
setStatus(tr("Removing cape"));
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "SkinDelete.h"
|
#include "SkinDelete.h"
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
#include <Env.h>
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
SkinDelete::SkinDelete(QObject *parent, AuthSessionPtr session)
|
SkinDelete::SkinDelete(QObject *parent, AuthSessionPtr session)
|
||||||
: Task(parent), m_session(session)
|
: Task(parent), m_session(session)
|
||||||
@ -12,7 +14,7 @@ void SkinDelete::executeTask()
|
|||||||
{
|
{
|
||||||
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/skins/active"));
|
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/skins/active"));
|
||||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit());
|
||||||
QNetworkReply *rep = ENV->network().deleteResource(request);
|
QNetworkReply *rep = APPLICATION->network()->deleteResource(request);
|
||||||
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
|
|
||||||
setStatus(tr("Deleting skin"));
|
setStatus(tr("Deleting skin"));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "SkinUpload.h"
|
#include "SkinUpload.h"
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
#include <Env.h>
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
QByteArray getVariant(SkinUpload::Model model) {
|
QByteArray getVariant(SkinUpload::Model model) {
|
||||||
switch (model) {
|
switch (model) {
|
||||||
@ -37,7 +39,7 @@ void SkinUpload::executeTask()
|
|||||||
multiPart->append(skin);
|
multiPart->append(skin);
|
||||||
multiPart->append(model);
|
multiPart->append(model);
|
||||||
|
|
||||||
QNetworkReply *rep = ENV->network().post(request, multiPart);
|
QNetworkReply *rep = APPLICATION->network()->post(request, multiPart);
|
||||||
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
|
|
||||||
setStatus(tr("Uploading skin"));
|
setStatus(tr("Uploading skin"));
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "Env.h"
|
|
||||||
#include "AssetUpdateTask.h"
|
#include "AssetUpdateTask.h"
|
||||||
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "net/ChecksumValidator.h"
|
#include "net/ChecksumValidator.h"
|
||||||
#include "minecraft/AssetsUtils.h"
|
#include "minecraft/AssetsUtils.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
|
AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
|
||||||
{
|
{
|
||||||
m_inst = inst;
|
m_inst = inst;
|
||||||
@ -24,7 +26,7 @@ void AssetUpdateTask::executeTask()
|
|||||||
QString localPath = assets->id + ".json";
|
QString localPath = assets->id + ".json";
|
||||||
auto job = new NetJob(tr("Asset index for %1").arg(m_inst->name()));
|
auto job = new NetJob(tr("Asset index for %1").arg(m_inst->name()));
|
||||||
|
|
||||||
auto metacache = ENV->metacache();
|
auto metacache = APPLICATION->metacache();
|
||||||
auto entry = metacache->resolveEntry("asset_indexes", localPath);
|
auto entry = metacache->resolveEntry("asset_indexes", localPath);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
auto hexSha1 = assets->sha1.toLatin1();
|
auto hexSha1 = assets->sha1.toLatin1();
|
||||||
@ -41,7 +43,7 @@ void AssetUpdateTask::executeTask()
|
|||||||
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
||||||
|
|
||||||
qDebug() << m_inst->name() << ": Starting asset index download";
|
qDebug() << m_inst->name() << ": Starting asset index download";
|
||||||
downloadJob->start();
|
downloadJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetUpdateTask::canAbort() const
|
bool AssetUpdateTask::canAbort() const
|
||||||
@ -62,7 +64,7 @@ void AssetUpdateTask::assetIndexFinished()
|
|||||||
// FIXME: this looks like a job for a generic validator based on json schema?
|
// FIXME: this looks like a job for a generic validator based on json schema?
|
||||||
if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index))
|
if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index))
|
||||||
{
|
{
|
||||||
auto metacache = ENV->metacache();
|
auto metacache = APPLICATION->metacache();
|
||||||
auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json");
|
auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json");
|
||||||
metacache->evictEntry(entry);
|
metacache->evictEntry(entry);
|
||||||
emitFailed(tr("Failed to read the assets index!"));
|
emitFailed(tr("Failed to read the assets index!"));
|
||||||
@ -76,7 +78,7 @@ void AssetUpdateTask::assetIndexFinished()
|
|||||||
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
|
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
|
||||||
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
|
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
|
||||||
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
||||||
downloadJob->start();
|
downloadJob->start(APPLICATION->network());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
|
@ -24,5 +24,5 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftInstance *m_inst;
|
MinecraftInstance *m_inst;
|
||||||
NetJobPtr downloadJob;
|
NetJob::Ptr downloadJob;
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "Env.h"
|
|
||||||
#include <FileSystem.h>
|
|
||||||
#include <minecraft/VersionFilterData.h>
|
|
||||||
#include "FMLLibrariesTask.h"
|
#include "FMLLibrariesTask.h"
|
||||||
|
|
||||||
|
#include "FileSystem.h"
|
||||||
|
#include "minecraft/VersionFilterData.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance * inst)
|
FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance * inst)
|
||||||
{
|
{
|
||||||
@ -60,7 +62,7 @@ void FMLLibrariesTask::executeTask()
|
|||||||
// download missing libs to our place
|
// download missing libs to our place
|
||||||
setStatus(tr("Downloading FML libraries..."));
|
setStatus(tr("Downloading FML libraries..."));
|
||||||
auto dljob = new NetJob("FML libraries");
|
auto dljob = new NetJob("FML libraries");
|
||||||
auto metacache = ENV->metacache();
|
auto metacache = APPLICATION->metacache();
|
||||||
for (auto &lib : fmlLibsToProcess)
|
for (auto &lib : fmlLibsToProcess)
|
||||||
{
|
{
|
||||||
auto entry = metacache->resolveEntry("fmllibs", lib.filename);
|
auto entry = metacache->resolveEntry("fmllibs", lib.filename);
|
||||||
@ -72,7 +74,7 @@ void FMLLibrariesTask::executeTask()
|
|||||||
connect(dljob, &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed);
|
connect(dljob, &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed);
|
||||||
connect(dljob, &NetJob::progress, this, &FMLLibrariesTask::progress);
|
connect(dljob, &NetJob::progress, this, &FMLLibrariesTask::progress);
|
||||||
downloadJob.reset(dljob);
|
downloadJob.reset(dljob);
|
||||||
downloadJob->start();
|
downloadJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FMLLibrariesTask::canAbort() const
|
bool FMLLibrariesTask::canAbort() const
|
||||||
@ -87,7 +89,7 @@ void FMLLibrariesTask::fmllibsFinished()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Copying FML libraries into the instance..."));
|
setStatus(tr("Copying FML libraries into the instance..."));
|
||||||
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
||||||
auto metacache = ENV->metacache();
|
auto metacache = APPLICATION->metacache();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto &lib : fmlLibsToProcess)
|
for (auto &lib : fmlLibsToProcess)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftInstance *m_inst;
|
MinecraftInstance *m_inst;
|
||||||
NetJobPtr downloadJob;
|
NetJob::Ptr downloadJob;
|
||||||
QList<FMLlib> fmlLibsToProcess;
|
QList<FMLlib> fmlLibsToProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "Env.h"
|
|
||||||
#include "LibrariesTask.h"
|
#include "LibrariesTask.h"
|
||||||
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
LibrariesTask::LibrariesTask(MinecraftInstance * inst)
|
LibrariesTask::LibrariesTask(MinecraftInstance * inst)
|
||||||
{
|
{
|
||||||
m_inst = inst;
|
m_inst = inst;
|
||||||
@ -21,7 +23,7 @@ void LibrariesTask::executeTask()
|
|||||||
auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()));
|
auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()));
|
||||||
downloadJob.reset(job);
|
downloadJob.reset(job);
|
||||||
|
|
||||||
auto metacache = ENV->metacache();
|
auto metacache = APPLICATION->metacache();
|
||||||
|
|
||||||
auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
|
auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
|
||||||
{
|
{
|
||||||
@ -63,7 +65,7 @@ void LibrariesTask::executeTask()
|
|||||||
connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
|
connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
|
||||||
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
|
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
|
||||||
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
|
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
|
||||||
downloadJob->start();
|
downloadJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LibrariesTask::canAbort() const
|
bool LibrariesTask::canAbort() const
|
||||||
|
@ -22,5 +22,5 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftInstance *m_inst;
|
MinecraftInstance *m_inst;
|
||||||
NetJobPtr downloadJob;
|
NetJob::Ptr downloadJob;
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include <Env.h>
|
|
||||||
#include <quazip.h>
|
|
||||||
#include <QtConcurrent/QtConcurrent>
|
|
||||||
#include <MMCZip.h>
|
|
||||||
#include <minecraft/OneSixVersionFormat.h>
|
|
||||||
#include <Version.h>
|
|
||||||
#include <net/ChecksumValidator.h>
|
|
||||||
#include "ATLPackInstallTask.h"
|
#include "ATLPackInstallTask.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
|
#include <quazip.h>
|
||||||
|
|
||||||
|
#include "MMCZip.h"
|
||||||
|
#include "minecraft/OneSixVersionFormat.h"
|
||||||
|
#include "Version.h"
|
||||||
|
#include "net/ChecksumValidator.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
@ -17,6 +17,9 @@
|
|||||||
#include "meta/Version.h"
|
#include "meta/Version.h"
|
||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
|
|
||||||
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace ATLauncher {
|
namespace ATLauncher {
|
||||||
|
|
||||||
PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString pack, QString version)
|
PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString pack, QString version)
|
||||||
@ -43,7 +46,7 @@ void PackInstallTask::executeTask()
|
|||||||
.arg(m_pack).arg(m_version_name);
|
.arg(m_pack).arg(m_version_name);
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
@ -76,7 +79,7 @@ void PackInstallTask::onDownloadSucceeded()
|
|||||||
}
|
}
|
||||||
m_version = version;
|
m_version = version;
|
||||||
|
|
||||||
auto vlist = ENV->metadataIndex()->get("net.minecraft");
|
auto vlist = APPLICATION->metadataIndex()->get("net.minecraft");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
emitFailed(tr("Failed to get local metadata index for %1").arg("net.minecraft"));
|
emitFailed(tr("Failed to get local metadata index for %1").arg("net.minecraft"));
|
||||||
@ -157,7 +160,7 @@ QString PackInstallTask::getDirForModType(ModType type, QString raw)
|
|||||||
QString PackInstallTask::getVersionForLoader(QString uid)
|
QString PackInstallTask::getVersionForLoader(QString uid)
|
||||||
{
|
{
|
||||||
if(m_version.loader.recommended || m_version.loader.latest || m_version.loader.choose) {
|
if(m_version.loader.recommended || m_version.loader.latest || m_version.loader.choose) {
|
||||||
auto vlist = ENV->metadataIndex()->get(uid);
|
auto vlist = APPLICATION->metadataIndex()->get(uid);
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
emitFailed(tr("Failed to get local metadata index for %1").arg(uid));
|
emitFailed(tr("Failed to get local metadata index for %1").arg(uid));
|
||||||
@ -409,7 +412,7 @@ void PackInstallTask::installConfigs()
|
|||||||
auto path = QString("Configs/%1/%2.zip").arg(m_pack).arg(m_version_name);
|
auto path = QString("Configs/%1/%2.zip").arg(m_pack).arg(m_version_name);
|
||||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.zip")
|
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.zip")
|
||||||
.arg(m_pack).arg(m_version_name);
|
.arg(m_pack).arg(m_version_name);
|
||||||
auto entry = ENV->metacache()->resolveEntry("ATLauncherPacks", path);
|
auto entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", path);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
|
|
||||||
auto dl = Net::Download::makeCached(url, entry);
|
auto dl = Net::Download::makeCached(url, entry);
|
||||||
@ -438,7 +441,7 @@ void PackInstallTask::installConfigs()
|
|||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::extractConfigs()
|
void PackInstallTask::extractConfigs()
|
||||||
@ -516,7 +519,7 @@ void PackInstallTask::downloadMods()
|
|||||||
auto cacheName = fileName.completeBaseName() + "-" + mod.md5 + "." + fileName.suffix();
|
auto cacheName = fileName.completeBaseName() + "-" + mod.md5 + "." + fileName.suffix();
|
||||||
|
|
||||||
if (mod.type == ModType::Extract || mod.type == ModType::TexturePackExtract || mod.type == ModType::ResourcePackExtract) {
|
if (mod.type == ModType::Extract || mod.type == ModType::TexturePackExtract || mod.type == ModType::ResourcePackExtract) {
|
||||||
auto entry = ENV->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
auto entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
modsToExtract.insert(entry->getFullPath(), mod);
|
modsToExtract.insert(entry->getFullPath(), mod);
|
||||||
|
|
||||||
@ -528,7 +531,7 @@ void PackInstallTask::downloadMods()
|
|||||||
jobPtr->addNetAction(dl);
|
jobPtr->addNetAction(dl);
|
||||||
}
|
}
|
||||||
else if(mod.type == ModType::Decomp) {
|
else if(mod.type == ModType::Decomp) {
|
||||||
auto entry = ENV->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
auto entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
modsToDecomp.insert(entry->getFullPath(), mod);
|
modsToDecomp.insert(entry->getFullPath(), mod);
|
||||||
|
|
||||||
@ -543,7 +546,7 @@ void PackInstallTask::downloadMods()
|
|||||||
auto relpath = getDirForModType(mod.type, mod.type_raw);
|
auto relpath = getDirForModType(mod.type, mod.type_raw);
|
||||||
if(relpath == Q_NULLPTR) continue;
|
if(relpath == Q_NULLPTR) continue;
|
||||||
|
|
||||||
auto entry = ENV->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
auto entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", cacheName);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
|
|
||||||
auto dl = Net::Download::makeCached(url, entry);
|
auto dl = Net::Download::makeCached(url, entry);
|
||||||
@ -558,7 +561,7 @@ void PackInstallTask::downloadMods()
|
|||||||
modsToCopy[entry->getFullPath()] = path;
|
modsToCopy[entry->getFullPath()] = path;
|
||||||
|
|
||||||
if(mod.type == ModType::Forge) {
|
if(mod.type == ModType::Forge) {
|
||||||
auto vlist = ENV->metadataIndex()->get("net.minecraftforge");
|
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
|
||||||
if(vlist)
|
if(vlist)
|
||||||
{
|
{
|
||||||
auto ver = vlist->getVersion(mod.version);
|
auto ver = vlist->getVersion(mod.version);
|
||||||
@ -593,7 +596,7 @@ void PackInstallTask::downloadMods()
|
|||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onModsDownloaded() {
|
void PackInstallTask::onModsDownloaded() {
|
||||||
|
@ -74,7 +74,7 @@ private:
|
|||||||
|
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
|
|
||||||
QString m_pack;
|
QString m_pack;
|
||||||
|
@ -5,8 +5,8 @@ namespace {
|
|||||||
const char * metabase = "https://cursemeta.dries007.net";
|
const char * metabase = "https://cursemeta.dries007.net";
|
||||||
}
|
}
|
||||||
|
|
||||||
Flame::FileResolvingTask::FileResolvingTask(Flame::Manifest& toProcess)
|
Flame::FileResolvingTask::FileResolvingTask(shared_qobject_ptr<QNetworkAccessManager> network, Flame::Manifest& toProcess)
|
||||||
: m_toProcess(toProcess)
|
: m_network(network), m_toProcess(toProcess)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ void Flame::FileResolvingTask::executeTask()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Resolving mod IDs..."));
|
setStatus(tr("Resolving mod IDs..."));
|
||||||
setProgress(0, m_toProcess.files.size());
|
setProgress(0, m_toProcess.files.size());
|
||||||
m_dljob.reset(new NetJob("Mod id resolver"));
|
m_dljob = new NetJob("Mod id resolver");
|
||||||
results.resize(m_toProcess.files.size());
|
results.resize(m_toProcess.files.size());
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(auto & file: m_toProcess.files)
|
for(auto & file: m_toProcess.files)
|
||||||
@ -27,7 +27,7 @@ void Flame::FileResolvingTask::executeTask()
|
|||||||
index ++;
|
index ++;
|
||||||
}
|
}
|
||||||
connect(m_dljob.get(), &NetJob::finished, this, &Flame::FileResolvingTask::netJobFinished);
|
connect(m_dljob.get(), &NetJob::finished, this, &Flame::FileResolvingTask::netJobFinished);
|
||||||
m_dljob->start();
|
m_dljob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flame::FileResolvingTask::netJobFinished()
|
void Flame::FileResolvingTask::netJobFinished()
|
||||||
|
@ -10,7 +10,7 @@ class FileResolvingTask : public Task
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FileResolvingTask(Flame::Manifest &toProcess);
|
explicit FileResolvingTask(shared_qobject_ptr<QNetworkAccessManager> network, Flame::Manifest &toProcess);
|
||||||
virtual ~FileResolvingTask() {};
|
virtual ~FileResolvingTask() {};
|
||||||
|
|
||||||
const Flame::Manifest &getResults() const
|
const Flame::Manifest &getResults() const
|
||||||
@ -25,8 +25,9 @@ protected slots:
|
|||||||
void netJobFinished();
|
void netJobFinished();
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
Flame::Manifest m_toProcess;
|
Flame::Manifest m_toProcess;
|
||||||
QVector<QByteArray> results;
|
QVector<QByteArray> results;
|
||||||
NetJobPtr m_dljob;
|
NetJob::Ptr m_dljob;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
#include "PrivatePackManager.h"
|
#include "PrivatePackManager.h"
|
||||||
|
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <BuildConfig.h>
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
@ -11,21 +12,20 @@ void PackFetchTask::fetch()
|
|||||||
publicPacks.clear();
|
publicPacks.clear();
|
||||||
thirdPartyPacks.clear();
|
thirdPartyPacks.clear();
|
||||||
|
|
||||||
NetJob *netJob = new NetJob("LegacyFTB::ModpackFetch");
|
jobPtr = new NetJob("LegacyFTB::ModpackFetch");
|
||||||
|
|
||||||
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
|
QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
|
||||||
qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
|
qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(publicPacksUrl, &publicModpacksXmlFileData));
|
jobPtr->addNetAction(Net::Download::makeByteArray(publicPacksUrl, &publicModpacksXmlFileData));
|
||||||
|
|
||||||
QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml");
|
QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml");
|
||||||
qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString();
|
qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString();
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, &thirdPartyModpacksXmlFileData));
|
jobPtr->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, &thirdPartyModpacksXmlFileData));
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
QObject::connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
QObject::connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
||||||
|
|
||||||
jobPtr.reset(netJob);
|
jobPtr->start(m_network);
|
||||||
netJob->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackFetchTask::fetchPrivate(const QStringList & toFetch)
|
void PackFetchTask::fetchPrivate(const QStringList & toFetch)
|
||||||
@ -63,7 +63,7 @@ void PackFetchTask::fetchPrivate(const QStringList & toFetch)
|
|||||||
delete data;
|
delete data;
|
||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start(m_network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,14 +13,15 @@ class PackFetchTask : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackFetchTask() = default;
|
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network) {};
|
||||||
virtual ~PackFetchTask() = default;
|
virtual ~PackFetchTask() = default;
|
||||||
|
|
||||||
void fetch();
|
void fetch();
|
||||||
void fetchPrivate(const QStringList &toFetch);
|
void fetchPrivate(const QStringList &toFetch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetJobPtr jobPtr;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
NetJob::Ptr jobPtr;
|
||||||
|
|
||||||
QByteArray publicModpacksXmlFileData;
|
QByteArray publicModpacksXmlFileData;
|
||||||
QByteArray thirdPartyModpacksXmlFileData;
|
QByteArray thirdPartyModpacksXmlFileData;
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
#include "PackInstallTask.h"
|
#include "PackInstallTask.h"
|
||||||
|
|
||||||
#include "Env.h"
|
#include <QtConcurrent>
|
||||||
#include "MMCZip.h"
|
|
||||||
|
|
||||||
|
#include "MMCZip.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "minecraft/GradleSpecifier.h"
|
#include "minecraft/GradleSpecifier.h"
|
||||||
#include "BuildConfig.h"
|
|
||||||
|
|
||||||
#include <QtConcurrent>
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
PackInstallTask::PackInstallTask(Modpack pack, QString version)
|
PackInstallTask::PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version)
|
||||||
{
|
{
|
||||||
m_pack = pack;
|
m_pack = pack;
|
||||||
m_version = version;
|
m_version = version;
|
||||||
|
m_network = network;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::executeTask()
|
void PackInstallTask::executeTask()
|
||||||
@ -31,8 +32,8 @@ void PackInstallTask::downloadPack()
|
|||||||
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
|
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
|
||||||
|
|
||||||
auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
|
auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
|
||||||
auto entry = ENV->metacache()->resolveEntry("FTBPacks", packoffset);
|
auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", packoffset);
|
||||||
NetJob *job = new NetJob("Download FTB Pack");
|
netJobContainer = new NetJob("Download FTB Pack");
|
||||||
|
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
QString url;
|
QString url;
|
||||||
@ -44,14 +45,13 @@ void PackInstallTask::downloadPack()
|
|||||||
{
|
{
|
||||||
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
|
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
|
||||||
}
|
}
|
||||||
job->addNetAction(Net::Download::makeCached(url, entry));
|
netJobContainer->addNetAction(Net::Download::makeCached(url, entry));
|
||||||
archivePath = entry->getFullPath();
|
archivePath = entry->getFullPath();
|
||||||
|
|
||||||
netJobContainer.reset(job);
|
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
connect(job, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
connect(job, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
||||||
connect(job, &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
netJobContainer->start(m_network);
|
||||||
job->start();
|
|
||||||
|
|
||||||
progress(1, 4);
|
progress(1, 4);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
#include "PackHelpers.h"
|
#include "PackHelpers.h"
|
||||||
|
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
#include <nonstd/optional>
|
#include <nonstd/optional>
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
@ -17,7 +19,7 @@ class PackInstallTask : public InstanceTask
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PackInstallTask(Modpack pack, QString version);
|
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
|
||||||
virtual ~PackInstallTask(){}
|
virtual ~PackInstallTask(){}
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
@ -41,11 +43,12 @@ private slots:
|
|||||||
void onUnzipCanceled();
|
void onUnzipCanceled();
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
std::unique_ptr<QuaZip> m_packZip;
|
std::unique_ptr<QuaZip> m_packZip;
|
||||||
QFuture<nonstd::optional<QStringList>> m_extractFuture;
|
QFuture<nonstd::optional<QStringList>> m_extractFuture;
|
||||||
QFutureWatcher<nonstd::optional<QStringList>> m_extractFutureWatcher;
|
QFutureWatcher<nonstd::optional<QStringList>> m_extractFutureWatcher;
|
||||||
NetJobPtr netJobContainer;
|
NetJob::Ptr netJobContainer;
|
||||||
QString archivePath;
|
QString archivePath;
|
||||||
|
|
||||||
Modpack m_pack;
|
Modpack m_pack;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "FTBPackInstallTask.h"
|
#include "FTBPackInstallTask.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
#include "Env.h"
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
@ -9,6 +7,9 @@
|
|||||||
#include "net/ChecksumValidator.h"
|
#include "net/ChecksumValidator.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
|
|
||||||
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace ModpacksCH {
|
namespace ModpacksCH {
|
||||||
|
|
||||||
PackInstallTask::PackInstallTask(Modpack pack, QString version)
|
PackInstallTask::PackInstallTask(Modpack pack, QString version)
|
||||||
@ -50,7 +51,7 @@ void PackInstallTask::executeTask()
|
|||||||
.arg(m_pack.id).arg(version.id);
|
.arg(m_pack.id).arg(version.id);
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
@ -95,14 +96,14 @@ void PackInstallTask::downloadPack()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
|
|
||||||
jobPtr.reset(new NetJob(tr("Mod download")));
|
jobPtr = new NetJob(tr("Mod download"));
|
||||||
for(auto file : m_version.files) {
|
for(auto file : m_version.files) {
|
||||||
if(file.serverOnly) continue;
|
if(file.serverOnly) continue;
|
||||||
|
|
||||||
QFileInfo fileName(file.name);
|
QFileInfo fileName(file.name);
|
||||||
auto cacheName = fileName.completeBaseName() + "-" + file.sha1 + "." + fileName.suffix();
|
auto cacheName = fileName.completeBaseName() + "-" + file.sha1 + "." + fileName.suffix();
|
||||||
|
|
||||||
auto entry = ENV->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
|
auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
|
|
||||||
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
||||||
@ -141,7 +142,7 @@ void PackInstallTask::downloadPack()
|
|||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::install()
|
void PackInstallTask::install()
|
||||||
|
@ -32,7 +32,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
|
|
||||||
Modpack m_pack;
|
Modpack m_pack;
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
|
|
||||||
#include "SingleZipPackInstallTask.h"
|
#include "SingleZipPackInstallTask.h"
|
||||||
|
|
||||||
#include "Env.h"
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "TechnicPackProcessor.h"
|
#include "TechnicPackProcessor.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
|
||||||
#include <QtConcurrent>
|
#include "Application.h"
|
||||||
#include <FileSystem.h>
|
|
||||||
|
|
||||||
Technic::SingleZipPackInstallTask::SingleZipPackInstallTask(const QUrl &sourceUrl, const QString &minecraftVersion)
|
Technic::SingleZipPackInstallTask::SingleZipPackInstallTask(const QUrl &sourceUrl, const QString &minecraftVersion)
|
||||||
{
|
{
|
||||||
@ -41,7 +42,7 @@ void Technic::SingleZipPackInstallTask::executeTask()
|
|||||||
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
|
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
|
||||||
|
|
||||||
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
||||||
auto entry = ENV->metacache()->resolveEntry("general", path);
|
auto entry = APPLICATION->metacache()->resolveEntry("general", path);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
m_filesNetJob.reset(new NetJob(tr("Modpack download")));
|
m_filesNetJob.reset(new NetJob(tr("Modpack download")));
|
||||||
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
||||||
@ -50,7 +51,7 @@ void Technic::SingleZipPackInstallTask::executeTask()
|
|||||||
connect(job, &NetJob::succeeded, this, &Technic::SingleZipPackInstallTask::downloadSucceeded);
|
connect(job, &NetJob::succeeded, this, &Technic::SingleZipPackInstallTask::downloadSucceeded);
|
||||||
connect(job, &NetJob::progress, this, &Technic::SingleZipPackInstallTask::downloadProgressChanged);
|
connect(job, &NetJob::progress, this, &Technic::SingleZipPackInstallTask::downloadProgressChanged);
|
||||||
connect(job, &NetJob::failed, this, &Technic::SingleZipPackInstallTask::downloadFailed);
|
connect(job, &NetJob::failed, this, &Technic::SingleZipPackInstallTask::downloadFailed);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Technic::SingleZipPackInstallTask::downloadSucceeded()
|
void Technic::SingleZipPackInstallTask::downloadSucceeded()
|
||||||
|
@ -55,7 +55,7 @@ private:
|
|||||||
QUrl m_sourceUrl;
|
QUrl m_sourceUrl;
|
||||||
QString m_minecraftVersion;
|
QString m_minecraftVersion;
|
||||||
QString m_archivePath;
|
QString m_archivePath;
|
||||||
NetJobPtr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
std::unique_ptr<QuaZip> m_packZip;
|
std::unique_ptr<QuaZip> m_packZip;
|
||||||
QFuture<nonstd::optional<QStringList>> m_extractFuture;
|
QFuture<nonstd::optional<QStringList>> m_extractFuture;
|
||||||
QFutureWatcher<nonstd::optional<QStringList>> m_extractFutureWatcher;
|
QFutureWatcher<nonstd::optional<QStringList>> m_extractFutureWatcher;
|
||||||
|
@ -21,10 +21,14 @@
|
|||||||
#include <MMCZip.h>
|
#include <MMCZip.h>
|
||||||
#include "TechnicPackProcessor.h"
|
#include "TechnicPackProcessor.h"
|
||||||
|
|
||||||
Technic::SolderPackInstallTask::SolderPackInstallTask(const QUrl &sourceUrl, const QString &minecraftVersion)
|
Technic::SolderPackInstallTask::SolderPackInstallTask(
|
||||||
{
|
shared_qobject_ptr<QNetworkAccessManager> network,
|
||||||
|
const QUrl &sourceUrl,
|
||||||
|
const QString &minecraftVersion
|
||||||
|
) {
|
||||||
m_sourceUrl = sourceUrl;
|
m_sourceUrl = sourceUrl;
|
||||||
m_minecraftVersion = minecraftVersion;
|
m_minecraftVersion = minecraftVersion;
|
||||||
|
m_network = network;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Technic::SolderPackInstallTask::abort() {
|
bool Technic::SolderPackInstallTask::abort() {
|
||||||
@ -43,7 +47,7 @@ void Technic::SolderPackInstallTask::executeTask()
|
|||||||
auto job = m_filesNetJob.get();
|
auto job = m_filesNetJob.get();
|
||||||
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::versionSucceeded);
|
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::versionSucceeded);
|
||||||
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Technic::SolderPackInstallTask::versionSucceeded()
|
void Technic::SolderPackInstallTask::versionSucceeded()
|
||||||
@ -68,7 +72,7 @@ void Technic::SolderPackInstallTask::versionSucceeded()
|
|||||||
auto job = m_filesNetJob.get();
|
auto job = m_filesNetJob.get();
|
||||||
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
||||||
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Technic::SolderPackInstallTask::fileListSucceeded()
|
void Technic::SolderPackInstallTask::fileListSucceeded()
|
||||||
@ -109,7 +113,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
|
|||||||
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
|
||||||
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
|
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
|
||||||
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Technic::SolderPackInstallTask::downloadSucceeded()
|
void Technic::SolderPackInstallTask::downloadSucceeded()
|
||||||
|
@ -27,7 +27,7 @@ namespace Technic
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SolderPackInstallTask(const QUrl &sourceUrl, const QString &minecraftVersion);
|
explicit SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const QUrl &sourceUrl, const QString &minecraftVersion);
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
@ -48,7 +48,9 @@ namespace Technic
|
|||||||
private:
|
private:
|
||||||
bool m_abortable = false;
|
bool m_abortable = false;
|
||||||
|
|
||||||
NetJobPtr m_filesNetJob;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
|
NetJob::Ptr m_filesNetJob;
|
||||||
QUrl m_sourceUrl;
|
QUrl m_sourceUrl;
|
||||||
QString m_minecraftVersion;
|
QString m_minecraftVersion;
|
||||||
QByteArray m_response;
|
QByteArray m_response;
|
||||||
|
@ -15,16 +15,17 @@
|
|||||||
|
|
||||||
#include "Download.h"
|
#include "Download.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "Env.h"
|
|
||||||
#include <FileSystem.h>
|
#include "FileSystem.h"
|
||||||
#include "ChecksumValidator.h"
|
#include "ChecksumValidator.h"
|
||||||
#include "MetaCacheSink.h"
|
#include "MetaCacheSink.h"
|
||||||
#include "ByteArraySink.h"
|
#include "ByteArraySink.h"
|
||||||
|
|
||||||
|
#include "BuildConfig.h"
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
Download::Download():NetAction()
|
Download::Download():NetAction()
|
||||||
@ -41,7 +42,7 @@ Download::Ptr Download::makeCached(QUrl url, MetaEntryPtr entry, Options options
|
|||||||
auto cachedNode = new MetaCacheSink(entry, md5Node);
|
auto cachedNode = new MetaCacheSink(entry, md5Node);
|
||||||
dl->m_sink.reset(cachedNode);
|
dl->m_sink.reset(cachedNode);
|
||||||
dl->m_target_path = entry->getFullPath();
|
dl->m_target_path = entry->getFullPath();
|
||||||
return std::shared_ptr<Download>(dl);
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Download::Ptr Download::makeByteArray(QUrl url, QByteArray *output, Options options)
|
Download::Ptr Download::makeByteArray(QUrl url, QByteArray *output, Options options)
|
||||||
@ -50,7 +51,7 @@ Download::Ptr Download::makeByteArray(QUrl url, QByteArray *output, Options opti
|
|||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
dl->m_sink.reset(new ByteArraySink(output));
|
dl->m_sink.reset(new ByteArraySink(output));
|
||||||
return std::shared_ptr<Download>(dl);
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Download::Ptr Download::makeFile(QUrl url, QString path, Options options)
|
Download::Ptr Download::makeFile(QUrl url, QString path, Options options)
|
||||||
@ -59,7 +60,7 @@ Download::Ptr Download::makeFile(QUrl url, QString path, Options options)
|
|||||||
dl->m_url = url;
|
dl->m_url = url;
|
||||||
dl->m_options = options;
|
dl->m_options = options;
|
||||||
dl->m_sink.reset(new FileSink(path));
|
dl->m_sink.reset(new FileSink(path));
|
||||||
return std::shared_ptr<Download>(dl);
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Download::addValidator(Validator * v)
|
void Download::addValidator(Validator * v)
|
||||||
@ -67,7 +68,7 @@ void Download::addValidator(Validator * v)
|
|||||||
m_sink->addValidator(v);
|
m_sink->addValidator(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Download::start()
|
void Download::startImpl()
|
||||||
{
|
{
|
||||||
if(m_status == Job_Aborted)
|
if(m_status == Job_Aborted)
|
||||||
{
|
{
|
||||||
@ -97,7 +98,7 @@ void Download::start()
|
|||||||
|
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, BuildConfig.USER_AGENT);
|
request.setHeader(QNetworkRequest::UserAgentHeader, BuildConfig.USER_AGENT);
|
||||||
|
|
||||||
QNetworkReply *rep = ENV->network().get(request);
|
QNetworkReply *rep = m_network->get(request);
|
||||||
|
|
||||||
m_reply.reset(rep);
|
m_reply.reset(rep);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64)));
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64)));
|
||||||
@ -207,7 +208,7 @@ bool Download::handleRedirect()
|
|||||||
|
|
||||||
m_url = QUrl(redirect.toString());
|
m_url = QUrl(redirect.toString());
|
||||||
qDebug() << "Following redirect to " << m_url.toString();
|
qDebug() << "Following redirect to " << m_url.toString();
|
||||||
start();
|
start(m_network);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,15 @@
|
|||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
#include "Sink.h"
|
#include "Sink.h"
|
||||||
|
|
||||||
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
class Download : public NetAction
|
class Download : public NetAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public: /* types */
|
public: /* types */
|
||||||
typedef std::shared_ptr<class Download> Ptr;
|
typedef shared_qobject_ptr<class Download> Ptr;
|
||||||
enum class Option
|
enum class Option
|
||||||
{
|
{
|
||||||
NoOptions = 0,
|
NoOptions = 0,
|
||||||
@ -62,7 +64,7 @@ protected slots:
|
|||||||
void downloadReadyRead() override;
|
void downloadReadyRead() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start() override;
|
void startImpl() override;
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
// FIXME: remove this, it has no business being here.
|
// FIXME: remove this, it has no business being here.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "FileSink.h"
|
#include "FileSink.h"
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "Env.h"
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
#include "HttpMetaCache.h"
|
#include "HttpMetaCache.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "MetaCacheSink.h"
|
#include "MetaCacheSink.h"
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "Env.h"
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ JobStatus MetaCacheSink::finalizeCache(QNetworkReply & reply)
|
|||||||
}
|
}
|
||||||
m_entry->setLocalChangedTimestamp(output_file_info.lastModified().toUTC().toMSecsSinceEpoch());
|
m_entry->setLocalChangedTimestamp(output_file_info.lastModified().toUTC().toMSecsSinceEpoch());
|
||||||
m_entry->setStale(false);
|
m_entry->setStale(false);
|
||||||
ENV->metacache()->updateEntry(m_entry);
|
APPLICATION->metacache()->updateEntry(m_entry);
|
||||||
return Job_Finished;
|
return Job_Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,14 +35,15 @@ enum JobStatus
|
|||||||
Job_Failed_Proceed
|
Job_Failed_Proceed
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<class NetAction> NetActionPtr;
|
|
||||||
class NetAction : public QObject
|
class NetAction : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
explicit NetAction() : QObject(0) {};
|
explicit NetAction() : QObject(nullptr) {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using Ptr = shared_qobject_ptr<NetAction>;
|
||||||
|
|
||||||
virtual ~NetAction() {};
|
virtual ~NetAction() {};
|
||||||
|
|
||||||
bool isRunning() const
|
bool isRunning() const
|
||||||
@ -93,9 +94,17 @@ protected slots:
|
|||||||
virtual void downloadReadyRead() = 0;
|
virtual void downloadReadyRead() = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void start() = 0;
|
void start(shared_qobject_ptr<QNetworkAccessManager> network) {
|
||||||
|
m_network = network;
|
||||||
|
startImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void startImpl() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
/// index within the parent job, FIXME: nuke
|
/// index within the parent job, FIXME: nuke
|
||||||
int m_index_within_job = 0;
|
int m_index_within_job = 0;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void NetJob::startMoreParts()
|
|||||||
connect(part.get(), SIGNAL(aborted(int)), SLOT(partAborted(int)));
|
connect(part.get(), SIGNAL(aborted(int)), SLOT(partAborted(int)));
|
||||||
connect(part.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
|
connect(part.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
|
||||||
SLOT(partProgress(int, qint64, qint64)));
|
SLOT(partProgress(int, qint64, qint64)));
|
||||||
part->start();
|
part->start(m_network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ bool NetJob::abort()
|
|||||||
return fullyAborted;
|
return fullyAborted;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetJob::addNetAction(NetActionPtr action)
|
bool NetJob::addNetAction(NetAction::Ptr action)
|
||||||
{
|
{
|
||||||
action->m_index_within_job = downloads.size();
|
action->m_index_within_job = downloads.size();
|
||||||
downloads.append(action);
|
downloads.append(action);
|
||||||
|
@ -22,33 +22,34 @@
|
|||||||
#include "QObjectPtr.h"
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
class NetJob;
|
class NetJob;
|
||||||
typedef shared_qobject_ptr<NetJob> NetJobPtr;
|
|
||||||
|
|
||||||
class NetJob : public Task
|
class NetJob : public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
using Ptr = shared_qobject_ptr<NetJob>;
|
||||||
|
|
||||||
explicit NetJob(QString job_name) : Task()
|
explicit NetJob(QString job_name) : Task()
|
||||||
{
|
{
|
||||||
setObjectName(job_name);
|
setObjectName(job_name);
|
||||||
}
|
}
|
||||||
virtual ~NetJob();
|
virtual ~NetJob();
|
||||||
|
|
||||||
bool addNetAction(NetActionPtr action);
|
bool addNetAction(NetAction::Ptr action);
|
||||||
|
|
||||||
NetActionPtr operator[](int index)
|
NetAction::Ptr operator[](int index)
|
||||||
{
|
{
|
||||||
return downloads[index];
|
return downloads[index];
|
||||||
}
|
}
|
||||||
const NetActionPtr at(const int index)
|
const NetAction::Ptr at(const int index)
|
||||||
{
|
{
|
||||||
return downloads.at(index);
|
return downloads.at(index);
|
||||||
}
|
}
|
||||||
NetActionPtr first()
|
NetAction::Ptr first()
|
||||||
{
|
{
|
||||||
if (downloads.size())
|
if (downloads.size())
|
||||||
return downloads[0];
|
return downloads[0];
|
||||||
return NetActionPtr();
|
return NetAction::Ptr();
|
||||||
}
|
}
|
||||||
int size() const
|
int size() const
|
||||||
{
|
{
|
||||||
@ -64,6 +65,19 @@ private slots:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void executeTask() override;
|
virtual void executeTask() override;
|
||||||
virtual bool abort() override;
|
virtual bool abort() override;
|
||||||
|
virtual void start(shared_qobject_ptr<QNetworkAccessManager> network) {
|
||||||
|
m_network = network;
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void start() override {
|
||||||
|
if(!m_network) {
|
||||||
|
throw "Missing network while trying to start " + objectName();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Task::start();
|
||||||
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);
|
void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);
|
||||||
@ -72,13 +86,15 @@ private slots:
|
|||||||
void partAborted(int index);
|
void partAborted(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
struct part_info
|
struct part_info
|
||||||
{
|
{
|
||||||
qint64 current_progress = 0;
|
qint64 current_progress = 0;
|
||||||
qint64 total_progress = 1;
|
qint64 total_progress = 1;
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
};
|
};
|
||||||
QList<NetActionPtr> downloads;
|
QList<NetAction::Ptr> downloads;
|
||||||
QList<part_info> parts_progress;
|
QList<part_info> parts_progress;
|
||||||
QQueue<int> m_todo;
|
QQueue<int> m_todo;
|
||||||
QSet<int> m_doing;
|
QSet<int> m_doing;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#include "PasteUpload.h"
|
#include "PasteUpload.h"
|
||||||
#include "Env.h"
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <BuildConfig.h>
|
|
||||||
|
|
||||||
PasteUpload::PasteUpload(QWidget *window, QString text, QString key) : m_window(window)
|
PasteUpload::PasteUpload(QWidget *window, QString text, QString key) : m_window(window)
|
||||||
{
|
{
|
||||||
@ -41,7 +42,7 @@ void PasteUpload::executeTask()
|
|||||||
request.setRawHeader("Content-Length", QByteArray::number(m_jsonContent.size()));
|
request.setRawHeader("Content-Length", QByteArray::number(m_jsonContent.size()));
|
||||||
request.setRawHeader("X-Auth-Token", m_key.toStdString().c_str());
|
request.setRawHeader("X-Auth-Token", m_key.toStdString().c_str());
|
||||||
|
|
||||||
QNetworkReply *rep = ENV->network().post(request, m_jsonContent);
|
QNetworkReply *rep = APPLICATION->network()->post(request, m_jsonContent);
|
||||||
|
|
||||||
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
setStatus(tr("Uploading to paste.ee"));
|
setStatus(tr("Uploading to paste.ee"));
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
NewsChecker::NewsChecker(const QString& feedUrl)
|
NewsChecker::NewsChecker(shared_qobject_ptr<QNetworkAccessManager> network, const QString& feedUrl)
|
||||||
{
|
{
|
||||||
|
m_network = network;
|
||||||
m_feedUrl = feedUrl;
|
m_feedUrl = feedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ void NewsChecker::reloadNews()
|
|||||||
QObject::connect(job, &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished);
|
QObject::connect(job, &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished);
|
||||||
QObject::connect(job, &NetJob::failed, this, &NewsChecker::rssDownloadFailed);
|
QObject::connect(job, &NetJob::failed, this, &NewsChecker::rssDownloadFailed);
|
||||||
m_newsNetJob.reset(job);
|
m_newsNetJob.reset(job);
|
||||||
job->start();
|
job->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewsChecker::rssDownloadFinished()
|
void NewsChecker::rssDownloadFinished()
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* Constructs a news reader to read from the given RSS feed URL.
|
* Constructs a news reader to read from the given RSS feed URL.
|
||||||
*/
|
*/
|
||||||
NewsChecker(const QString& feedUrl);
|
NewsChecker(shared_qobject_ptr<QNetworkAccessManager> network, const QString& feedUrl);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the error message for the last time the news was loaded.
|
* Returns the error message for the last time the news was loaded.
|
||||||
@ -80,7 +80,7 @@ protected: /* data */
|
|||||||
QList<NewsEntryPtr> m_newsEntries;
|
QList<NewsEntryPtr> m_newsEntries;
|
||||||
|
|
||||||
//! The network job to use to load the news.
|
//! The network job to use to load the news.
|
||||||
NetJobPtr m_newsNetJob;
|
NetJob::Ptr m_newsNetJob;
|
||||||
|
|
||||||
//! True if news has been loaded.
|
//! True if news has been loaded.
|
||||||
bool m_loadedNews;
|
bool m_loadedNews;
|
||||||
@ -93,6 +93,8 @@ protected: /* data */
|
|||||||
*/
|
*/
|
||||||
QString m_lastLoadError;
|
QString m_lastLoadError;
|
||||||
|
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
/// Emits newsLoaded() and sets m_lastLoadError to empty string.
|
/// Emits newsLoaded() and sets m_lastLoadError to empty string.
|
||||||
void succeed();
|
void succeed();
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
NotificationChecker::NotificationChecker(QObject *parent)
|
NotificationChecker::NotificationChecker(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -53,11 +53,11 @@ void NotificationChecker::checkForNotifications()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_checkJob.reset(new NetJob("Checking for notifications"));
|
m_checkJob.reset(new NetJob("Checking for notifications"));
|
||||||
auto entry = ENV->metacache()->resolveEntry("root", "notifications.json");
|
auto entry = APPLICATION->metacache()->resolveEntry("root", "notifications.json");
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
m_checkJob->addNetAction(m_download = Net::Download::makeCached(m_notificationsUrl, entry));
|
m_checkJob->addNetAction(m_download = Net::Download::makeCached(m_notificationsUrl, entry));
|
||||||
connect(m_download.get(), &Net::Download::succeeded, this, &NotificationChecker::downloadSucceeded);
|
connect(m_download.get(), &Net::Download::succeeded, this, &NotificationChecker::downloadSucceeded);
|
||||||
m_checkJob->start();
|
m_checkJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationChecker::downloadSucceeded(int)
|
void NotificationChecker::downloadSucceeded(int)
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QList<NotificationEntry> m_entries;
|
QList<NotificationEntry> m_entries;
|
||||||
QUrl m_notificationsUrl;
|
QUrl m_notificationsUrl;
|
||||||
NetJobPtr m_checkJob;
|
NetJob::Ptr m_checkJob;
|
||||||
Net::Download::Ptr m_download;
|
Net::Download::Ptr m_download;
|
||||||
|
|
||||||
QString m_appVersionChannel;
|
QString m_appVersionChannel;
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include "Env.h"
|
|
||||||
|
|
||||||
#include "dialogs/ProgressDialog.h"
|
#include "dialogs/ProgressDialog.h"
|
||||||
#include "dialogs/LoginDialog.h"
|
#include "dialogs/LoginDialog.h"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "settings/SettingsObject.h"
|
#include "settings/SettingsObject.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Env.h"
|
#include "Application.h"
|
||||||
|
|
||||||
ProxyPage::ProxyPage(QWidget *parent) : QWidget(parent), ui(new Ui::ProxyPage)
|
ProxyPage::ProxyPage(QWidget *parent) : QWidget(parent), ui(new Ui::ProxyPage)
|
||||||
{
|
{
|
||||||
@ -77,8 +77,13 @@ void ProxyPage::applySettings()
|
|||||||
s->set("ProxyUser", ui->proxyUserEdit->text());
|
s->set("ProxyUser", ui->proxyUserEdit->text());
|
||||||
s->set("ProxyPass", ui->proxyPassEdit->text());
|
s->set("ProxyPass", ui->proxyPassEdit->text());
|
||||||
|
|
||||||
ENV->updateProxySettings(proxyType, ui->proxyAddrEdit->text(), ui->proxyPortEdit->value(),
|
APPLICATION->updateProxySettings(
|
||||||
ui->proxyUserEdit->text(), ui->proxyPassEdit->text());
|
proxyType,
|
||||||
|
ui->proxyAddrEdit->text(),
|
||||||
|
ui->proxyPortEdit->value(),
|
||||||
|
ui->proxyUserEdit->text(),
|
||||||
|
ui->proxyPassEdit->text()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
void ProxyPage::loadSettings()
|
void ProxyPage::loadSettings()
|
||||||
{
|
{
|
||||||
|
@ -302,8 +302,8 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
|||||||
if (selection.isEmpty())
|
if (selection.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<ScreenshotPtr> uploaded;
|
QList<ScreenShot::Ptr> uploaded;
|
||||||
auto job = NetJobPtr(new NetJob("Screenshot Upload"));
|
auto job = NetJob::Ptr(new NetJob("Screenshot Upload"));
|
||||||
if(selection.size() < 2)
|
if(selection.size() < 2)
|
||||||
{
|
{
|
||||||
auto item = selection.at(0);
|
auto item = selection.at(0);
|
||||||
@ -344,7 +344,7 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
|||||||
job->addNetAction(ImgurUpload::make(screenshot));
|
job->addNetAction(ImgurUpload::make(screenshot));
|
||||||
}
|
}
|
||||||
SequentialTask task;
|
SequentialTask task;
|
||||||
auto albumTask = NetJobPtr(new NetJob("Imgur Album Creation"));
|
auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation"));
|
||||||
auto imgurAlbum = ImgurAlbumCreation::make(uploaded);
|
auto imgurAlbum = ImgurAlbumCreation::make(uploaded);
|
||||||
albumTask->addNetAction(imgurAlbum);
|
albumTask->addNetAction(imgurAlbum);
|
||||||
task.addTask(job);
|
task.addTask(job);
|
||||||
|
@ -420,7 +420,7 @@ void VersionPage::on_actionDownload_All_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionInstall_Forge_triggered()
|
void VersionPage::on_actionInstall_Forge_triggered()
|
||||||
{
|
{
|
||||||
auto vlist = ENV->metadataIndex()->get("net.minecraftforge");
|
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -449,7 +449,7 @@ void VersionPage::on_actionInstall_Forge_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionInstall_Fabric_triggered()
|
void VersionPage::on_actionInstall_Fabric_triggered()
|
||||||
{
|
{
|
||||||
auto vlist = ENV->metadataIndex()->get("net.fabricmc.fabric-loader");
|
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -494,7 +494,7 @@ void VersionPage::on_actionAdd_Empty_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionInstall_LiteLoader_triggered()
|
void VersionPage::on_actionInstall_LiteLoader_triggered()
|
||||||
{
|
{
|
||||||
auto vlist = ENV->metadataIndex()->get("com.mumfrey.liteloader");
|
auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
#include "VanillaPage.h"
|
#include "VanillaPage.h"
|
||||||
#include "ui_VanillaPage.h"
|
#include "ui_VanillaPage.h"
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
|
|
||||||
#include <meta/Index.h>
|
|
||||||
#include <meta/VersionList.h>
|
|
||||||
#include <dialogs/NewInstanceDialog.h>
|
|
||||||
#include <Filter.h>
|
|
||||||
#include <Env.h>
|
|
||||||
#include <InstanceCreationTask.h>
|
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
#include "meta/Index.h"
|
||||||
|
#include "meta/VersionList.h"
|
||||||
|
#include "dialogs/NewInstanceDialog.h"
|
||||||
|
#include "Filter.h"
|
||||||
|
#include "InstanceCreationTask.h"
|
||||||
|
|
||||||
VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
|
VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
|
||||||
: QWidget(parent), dialog(dialog), ui(new Ui::VanillaPage)
|
: QWidget(parent), dialog(dialog), ui(new Ui::VanillaPage)
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ void VanillaPage::openedImpl()
|
|||||||
{
|
{
|
||||||
if(!initialized)
|
if(!initialized)
|
||||||
{
|
{
|
||||||
auto vlist = ENV->metadataIndex()->get("net.minecraft");
|
auto vlist = APPLICATION->metadataIndex()->get("net.minecraft");
|
||||||
ui->versionList->initialize(vlist.get());
|
ui->versionList->initialize(vlist.get());
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Env.h>
|
|
||||||
#include <Json.h>
|
#include <Json.h>
|
||||||
|
|
||||||
namespace Atl {
|
namespace Atl {
|
||||||
@ -75,7 +74,7 @@ void ListModel::request()
|
|||||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/json/packsnew.json");
|
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/json/packsnew.json");
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
|
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
|
||||||
@ -134,7 +133,7 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac
|
|||||||
{
|
{
|
||||||
if(m_logoMap.contains(logo))
|
if(m_logoMap.contains(logo))
|
||||||
{
|
{
|
||||||
callback(ENV->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
callback(APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -167,7 +166,7 @@ void ListModel::requestLogo(QString file, QString url)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
||||||
NetJob *job = new NetJob(QString("ATLauncher Icon Download %1").arg(file));
|
NetJob *job = new NetJob(QString("ATLauncher Icon Download %1").arg(file));
|
||||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
@ -186,7 +185,7 @@ void ListModel::requestLogo(QString file, QString url)
|
|||||||
emit logoFailed(file);
|
emit logoFailed(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start(APPLICATION->network());
|
||||||
|
|
||||||
m_loadingLogos.append(file);
|
m_loadingLogos.append(file);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
LogoMap m_logoMap;
|
LogoMap m_logoMap;
|
||||||
QMap<QString, LogoCallback> waitingCallbacks;
|
QMap<QString, LogoCallback> waitingCallbacks;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <RWStorage.h>
|
#include <RWStorage.h>
|
||||||
#include <Env.h>
|
|
||||||
|
|
||||||
namespace Flame {
|
namespace Flame {
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
||||||
NetJob *job = new NetJob(QString("Flame Icon Download %1").arg(logo));
|
NetJob *job = new NetJob(QString("Flame Icon Download %1").arg(logo));
|
||||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
@ -119,7 +118,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
emit logoFailed(logo);
|
emit logoFailed(logo);
|
||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start(APPLICATION->network());
|
||||||
|
|
||||||
m_loadingLogos.append(logo);
|
m_loadingLogos.append(logo);
|
||||||
}
|
}
|
||||||
@ -128,7 +127,7 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac
|
|||||||
{
|
{
|
||||||
if(m_logoMap.contains(logo))
|
if(m_logoMap.contains(logo))
|
||||||
{
|
{
|
||||||
callback(ENV->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
callback(APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -172,7 +171,7 @@ void ListModel::performPaginatedSearch()
|
|||||||
).arg(nextSearchOffset).arg(currentSearchTerm).arg(currentSort);
|
).arg(nextSearchOffset).arg(currentSearchTerm).arg(currentSort);
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
ResetRequested,
|
ResetRequested,
|
||||||
Finished
|
Finished
|
||||||
} searchState = None;
|
} searchState = None;
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
|||||||
|
|
||||||
suggestCurrent();
|
suggestCurrent();
|
||||||
});
|
});
|
||||||
netJob->start();
|
netJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "FtbListModel.h"
|
#include "FtbListModel.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "Env.h"
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac
|
|||||||
{
|
{
|
||||||
if(m_logoMap.contains(logo))
|
if(m_logoMap.contains(logo))
|
||||||
{
|
{
|
||||||
callback(ENV->metacache()->resolveEntry("ModpacksCHPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
callback(APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -96,7 +95,7 @@ void ListModel::request()
|
|||||||
auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all");
|
auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all");
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
|
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
|
||||||
@ -140,7 +139,7 @@ void ListModel::requestPack()
|
|||||||
.arg(currentPack);
|
.arg(currentPack);
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::packRequestFinished);
|
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::packRequestFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::packRequestFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &ListModel::packRequestFailed);
|
||||||
@ -252,7 +251,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("ModpacksCHPacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
||||||
|
|
||||||
bool stale = entry->isStale();
|
bool stale = entry->isStale();
|
||||||
|
|
||||||
@ -273,7 +272,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
auto &newLogoEntry = m_logoMap[logo];
|
auto &newLogoEntry = m_logoMap[logo];
|
||||||
newLogoEntry.downloadJob = job;
|
newLogoEntry.downloadJob = job;
|
||||||
newLogoEntry.fullpath = fullPath;
|
newLogoEntry.fullpath = fullPath;
|
||||||
job->start();
|
job->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace Ftb {
|
|||||||
|
|
||||||
struct Logo {
|
struct Logo {
|
||||||
QString fullpath;
|
QString fullpath;
|
||||||
NetJobPtr downloadJob;
|
NetJob::Ptr downloadJob;
|
||||||
QIcon result;
|
QIcon result;
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ private:
|
|||||||
QList<ModpacksCH::Modpack> modpacks;
|
QList<ModpacksCH::Modpack> modpacks;
|
||||||
LogoMap m_logoMap;
|
LogoMap m_logoMap;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
int currentPack;
|
int currentPack;
|
||||||
QList<int> remainingPacks;
|
QList<int> remainingPacks;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <RWStorage.h>
|
#include <RWStorage.h>
|
||||||
#include <Env.h>
|
|
||||||
|
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
|
|
||||||
@ -216,7 +215,7 @@ void ListModel::requestLogo(QString file)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
||||||
NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file));
|
NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file));
|
||||||
job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
||||||
|
|
||||||
@ -235,7 +234,7 @@ void ListModel::requestLogo(QString file)
|
|||||||
emit logoFailed(file);
|
emit logoFailed(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start(APPLICATION->network());
|
||||||
|
|
||||||
m_loadingLogos.append(file);
|
m_loadingLogos.append(file);
|
||||||
}
|
}
|
||||||
@ -244,7 +243,7 @@ void ListModel::getLogo(const QString &logo, LogoCallback callback)
|
|||||||
{
|
{
|
||||||
if(m_logoMap.contains(logo))
|
if(m_logoMap.contains(logo))
|
||||||
{
|
{
|
||||||
callback(ENV->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
callback(APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace LegacyFTB {
|
|||||||
Page::Page(NewInstanceDialog* dialog, QWidget *parent)
|
Page::Page(NewInstanceDialog* dialog, QWidget *parent)
|
||||||
: QWidget(parent), dialog(dialog), ui(new Ui::Page)
|
: QWidget(parent), dialog(dialog), ui(new Ui::Page)
|
||||||
{
|
{
|
||||||
ftbFetchTask.reset(new PackFetchTask());
|
ftbFetchTask.reset(new PackFetchTask(APPLICATION->network()));
|
||||||
ftbPrivatePacks.reset(new PrivatePackManager());
|
ftbPrivatePacks.reset(new PrivatePackManager());
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -133,7 +133,7 @@ void Page::suggestCurrent()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog->setSuggestedPack(selected.name, new PackInstallTask(selected, selectedVersion));
|
dialog->setSuggestedPack(selected.name, new PackInstallTask(APPLICATION->network(), selected, selectedVersion));
|
||||||
QString editedLogoName;
|
QString editedLogoName;
|
||||||
if(selected.logo.toLower().startsWith("ftb"))
|
if(selected.logo.toLower().startsWith("ftb"))
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TechnicModel.h"
|
#include "TechnicModel.h"
|
||||||
#include "Env.h"
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
@ -105,7 +104,7 @@ void Technic::ListModel::performSearch()
|
|||||||
}
|
}
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
jobPtr->start();
|
jobPtr->start(APPLICATION->network());
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
|
||||||
}
|
}
|
||||||
@ -163,7 +162,7 @@ void Technic::ListModel::getLogo(const QString& logo, const QString& logoUrl, Te
|
|||||||
{
|
{
|
||||||
if(m_logoMap.contains(logo))
|
if(m_logoMap.contains(logo))
|
||||||
{
|
{
|
||||||
callback(ENV->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo))->getFullPath());
|
callback(APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo))->getFullPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -216,7 +215,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
|
||||||
NetJob *job = new NetJob(QString("Technic Icon Download %1").arg(logo));
|
NetJob *job = new NetJob(QString("Technic Icon Download %1").arg(logo));
|
||||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
@ -232,7 +231,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
|
|||||||
logoFailed(logo);
|
logoFailed(logo);
|
||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start(APPLICATION->network());
|
||||||
|
|
||||||
m_loadingLogos.append(logo);
|
m_loadingLogos.append(logo);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ private:
|
|||||||
ResetRequested,
|
ResetRequested,
|
||||||
Finished
|
Finished
|
||||||
} searchState = None;
|
} searchState = None;
|
||||||
NetJobPtr jobPtr;
|
NetJob::Ptr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ void TechnicPage::suggestCurrent()
|
|||||||
current.metadataLoaded = true;
|
current.metadataLoaded = true;
|
||||||
metadataLoaded();
|
metadataLoaded();
|
||||||
});
|
});
|
||||||
netJob->start();
|
netJob->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
// expects current.metadataLoaded to be true
|
// expects current.metadataLoaded to be true
|
||||||
@ -193,6 +193,6 @@ void TechnicPage::metadataLoaded()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (current.url.endsWith('/')) current.url.chop(1);
|
while (current.url.endsWith('/')) current.url.chop(1);
|
||||||
dialog->setSuggestedPack(current.name, new Technic::SolderPackInstallTask(current.url + "/modpack/" + current.slug, current.minecraftVersion));
|
dialog->setSuggestedPack(current.name, new Technic::SolderPackInstallTask(APPLICATION->network(), current.url + "/modpack/" + current.slug, current.minecraftVersion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,18 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
#include "Env.h"
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> screenshots) : NetAction(), m_screenshots(screenshots)
|
#include "BuildConfig.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenShot::Ptr> screenshots) : NetAction(), m_screenshots(screenshots)
|
||||||
{
|
{
|
||||||
m_url = BuildConfig.IMGUR_BASE_URL + "album.json";
|
m_url = BuildConfig.IMGUR_BASE_URL + "album.json";
|
||||||
m_status = Job_NotStarted;
|
m_status = Job_NotStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImgurAlbumCreation::start()
|
void ImgurAlbumCreation::startImpl()
|
||||||
{
|
{
|
||||||
m_status = Job_InProgress;
|
m_status = Job_InProgress;
|
||||||
QNetworkRequest request(m_url);
|
QNetworkRequest request(m_url);
|
||||||
@ -33,7 +33,7 @@ void ImgurAlbumCreation::start()
|
|||||||
|
|
||||||
const QByteArray data = "deletehashes=" + hashes.join(',').toUtf8() + "&title=Minecraft%20Screenshots&privacy=hidden";
|
const QByteArray data = "deletehashes=" + hashes.join(',').toUtf8() + "&title=Minecraft%20Screenshots&privacy=hidden";
|
||||||
|
|
||||||
QNetworkReply *rep = ENV->network().post(request, data);
|
QNetworkReply *rep = APPLICATION->network()->post(request, data);
|
||||||
|
|
||||||
m_reply.reset(rep);
|
m_reply.reset(rep);
|
||||||
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurAlbumCreation::downloadProgress);
|
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurAlbumCreation::downloadProgress);
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "net/NetAction.h"
|
#include "net/NetAction.h"
|
||||||
#include "Screenshot.h"
|
#include "Screenshot.h"
|
||||||
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
typedef std::shared_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
|
typedef shared_qobject_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
|
||||||
class ImgurAlbumCreation : public NetAction
|
class ImgurAlbumCreation : public NetAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ImgurAlbumCreation(QList<ScreenshotPtr> screenshots);
|
explicit ImgurAlbumCreation(QList<ScreenShot::Ptr> screenshots);
|
||||||
static ImgurAlbumCreationPtr make(QList<ScreenshotPtr> screenshots)
|
static ImgurAlbumCreationPtr make(QList<ScreenShot::Ptr> screenshots)
|
||||||
{
|
{
|
||||||
return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots));
|
return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots));
|
||||||
}
|
}
|
||||||
@ -32,10 +33,10 @@ slots:
|
|||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
virtual void start();
|
virtual void startImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ScreenshotPtr> m_screenshots;
|
QList<ScreenShot::Ptr> m_screenshots;
|
||||||
|
|
||||||
QString m_deleteHash;
|
QString m_deleteHash;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "ImgurUpload.h"
|
#include "ImgurUpload.h"
|
||||||
|
#include "BuildConfig.h"
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
@ -7,18 +8,15 @@
|
|||||||
#include <QHttpPart>
|
#include <QHttpPart>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
#include "Env.h"
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot)
|
ImgurUpload::ImgurUpload(ScreenShot::Ptr shot) : NetAction(), m_shot(shot)
|
||||||
{
|
{
|
||||||
m_url = BuildConfig.IMGUR_BASE_URL + "upload.json";
|
m_url = BuildConfig.IMGUR_BASE_URL + "upload.json";
|
||||||
m_status = Job_NotStarted;
|
m_status = Job_NotStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImgurUpload::start()
|
void ImgurUpload::startImpl()
|
||||||
{
|
{
|
||||||
finished = false;
|
finished = false;
|
||||||
m_status = Job_InProgress;
|
m_status = Job_InProgress;
|
||||||
@ -49,7 +47,7 @@ void ImgurUpload::start()
|
|||||||
namePart.setBody(m_shot->m_file.baseName().toUtf8());
|
namePart.setBody(m_shot->m_file.baseName().toUtf8());
|
||||||
multipart->append(namePart);
|
multipart->append(namePart);
|
||||||
|
|
||||||
QNetworkReply *rep = ENV->network().post(request, multipart);
|
QNetworkReply *rep = m_network->post(request, multipart);
|
||||||
|
|
||||||
m_reply.reset(rep);
|
m_reply.reset(rep);
|
||||||
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurUpload::downloadProgress);
|
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurUpload::downloadProgress);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "QObjectPtr.h"
|
||||||
#include "net/NetAction.h"
|
#include "net/NetAction.h"
|
||||||
#include "Screenshot.h"
|
#include "Screenshot.h"
|
||||||
|
|
||||||
typedef std::shared_ptr<class ImgurUpload> ImgurUploadPtr;
|
class ImgurUpload : public NetAction {
|
||||||
class ImgurUpload : public NetAction
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
explicit ImgurUpload(ScreenshotPtr shot);
|
using Ptr = shared_qobject_ptr<ImgurUpload>;
|
||||||
static ImgurUploadPtr make(ScreenshotPtr shot)
|
|
||||||
{
|
explicit ImgurUpload(ScreenShot::Ptr shot);
|
||||||
return ImgurUploadPtr(new ImgurUpload(shot));
|
static Ptr make(ScreenShot::Ptr shot) {
|
||||||
|
return Ptr(new ImgurUpload(shot));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -17,15 +17,13 @@ slots:
|
|||||||
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||||
virtual void downloadError(QNetworkReply::NetworkError error);
|
virtual void downloadError(QNetworkReply::NetworkError error);
|
||||||
virtual void downloadFinished();
|
virtual void downloadFinished();
|
||||||
virtual void downloadReadyRead()
|
virtual void downloadReadyRead() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
virtual void start();
|
void startImpl() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScreenshotPtr m_shot;
|
ScreenShot::Ptr m_shot;
|
||||||
bool finished = true;
|
bool finished = true;
|
||||||
};
|
};
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
struct ScreenShot
|
struct ScreenShot {
|
||||||
{
|
using Ptr = std::shared_ptr<ScreenShot>;
|
||||||
ScreenShot(QFileInfo file)
|
|
||||||
{
|
ScreenShot(QFileInfo file) {
|
||||||
m_file = file;
|
m_file = file;
|
||||||
}
|
}
|
||||||
QFileInfo m_file;
|
QFileInfo m_file;
|
||||||
@ -16,5 +16,3 @@ struct ScreenShot
|
|||||||
QString m_imgurId;
|
QString m_imgurId;
|
||||||
QString m_imgurDeleteHash;
|
QString m_imgurDeleteHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ScreenShot> ScreenshotPtr;
|
|
||||||
|
@ -19,10 +19,14 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "QObjectPtr.h"
|
||||||
|
|
||||||
class Task : public QObject
|
class Task : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
using Ptr = shared_qobject_ptr<Task>;
|
||||||
|
|
||||||
enum class State
|
enum class State
|
||||||
{
|
{
|
||||||
Inactive,
|
Inactive,
|
||||||
|
@ -6,15 +6,17 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <FileSystem.h>
|
|
||||||
#include <net/NetJob.h>
|
#include "FileSystem.h"
|
||||||
#include <net/ChecksumValidator.h>
|
#include "net/NetJob.h"
|
||||||
#include <Env.h>
|
#include "net/ChecksumValidator.h"
|
||||||
#include <BuildConfig.h>
|
#include "BuildConfig.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
#include "POTranslator.h"
|
#include "POTranslator.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
const static QLatin1Literal defaultLangCode("en_US");
|
const static QLatin1Literal defaultLangCode("en_US");
|
||||||
|
|
||||||
enum class FileType
|
enum class FileType
|
||||||
@ -119,10 +121,10 @@ struct TranslationsModel::Private
|
|||||||
std::unique_ptr<QTranslator> m_qt_translator;
|
std::unique_ptr<QTranslator> m_qt_translator;
|
||||||
std::unique_ptr<QTranslator> m_app_translator;
|
std::unique_ptr<QTranslator> m_app_translator;
|
||||||
|
|
||||||
std::shared_ptr<Net::Download> m_index_task;
|
Net::Download::Ptr m_index_task;
|
||||||
QString m_downloadingTranslation;
|
QString m_downloadingTranslation;
|
||||||
NetJobPtr m_dl_job;
|
NetJob::Ptr m_dl_job;
|
||||||
NetJobPtr m_index_job;
|
NetJob::Ptr m_index_job;
|
||||||
QString m_nextDownload;
|
QString m_nextDownload;
|
||||||
|
|
||||||
std::unique_ptr<POTranslator> m_po_translator;
|
std::unique_ptr<POTranslator> m_po_translator;
|
||||||
@ -558,13 +560,13 @@ void TranslationsModel::downloadIndex()
|
|||||||
}
|
}
|
||||||
qDebug() << "Downloading Translations Index...";
|
qDebug() << "Downloading Translations Index...";
|
||||||
d->m_index_job.reset(new NetJob("Translations Index"));
|
d->m_index_job.reset(new NetJob("Translations Index"));
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("translations", "index_v2.json");
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("translations", "index_v2.json");
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
d->m_index_task = Net::Download::makeCached(QUrl("https://files.multimc.org/translations/index_v2.json"), entry);
|
d->m_index_task = Net::Download::makeCached(QUrl("https://files.multimc.org/translations/index_v2.json"), entry);
|
||||||
d->m_index_job->addNetAction(d->m_index_task);
|
d->m_index_job->addNetAction(d->m_index_task);
|
||||||
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
|
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
|
||||||
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived);
|
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived);
|
||||||
d->m_index_job->start();
|
d->m_index_job->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslationsModel::updateLanguage(QString key)
|
void TranslationsModel::updateLanguage(QString key)
|
||||||
@ -601,7 +603,7 @@ void TranslationsModel::downloadTranslation(QString key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->m_downloadingTranslation = key;
|
d->m_downloadingTranslation = key;
|
||||||
MetaEntryPtr entry = ENV->metacache()->resolveEntry("translations", "mmc_" + key + ".qm");
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("translations", "mmc_" + key + ".qm");
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
|
|
||||||
auto dl = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + lang->file_name), entry);
|
auto dl = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + lang->file_name), entry);
|
||||||
@ -615,7 +617,7 @@ void TranslationsModel::downloadTranslation(QString key)
|
|||||||
connect(d->m_dl_job.get(), &NetJob::succeeded, this, &TranslationsModel::dlGood);
|
connect(d->m_dl_job.get(), &NetJob::succeeded, this, &TranslationsModel::dlGood);
|
||||||
connect(d->m_dl_job.get(), &NetJob::failed, this, &TranslationsModel::dlFailed);
|
connect(d->m_dl_job.get(), &NetJob::failed, this, &TranslationsModel::dlFailed);
|
||||||
|
|
||||||
d->m_dl_job->start();
|
d->m_dl_job->start(APPLICATION->network());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslationsModel::downloadNext()
|
void TranslationsModel::downloadNext()
|
||||||
|
@ -26,8 +26,12 @@
|
|||||||
namespace GoUpdate
|
namespace GoUpdate
|
||||||
{
|
{
|
||||||
|
|
||||||
DownloadTask::DownloadTask(Status status, QString target, QObject *parent)
|
DownloadTask::DownloadTask(
|
||||||
: Task(parent), m_updateFilesDir(target)
|
shared_qobject_ptr<QNetworkAccessManager> network,
|
||||||
|
Status status,
|
||||||
|
QString target,
|
||||||
|
QObject *parent
|
||||||
|
) : Task(parent), m_updateFilesDir(target), m_network(network)
|
||||||
{
|
{
|
||||||
m_status = status;
|
m_status = status;
|
||||||
|
|
||||||
@ -63,7 +67,7 @@ void DownloadTask::loadVersionInfo()
|
|||||||
connect(netJob, &NetJob::succeeded, this, &DownloadTask::processDownloadedVersionInfo);
|
connect(netJob, &NetJob::succeeded, this, &DownloadTask::processDownloadedVersionInfo);
|
||||||
connect(netJob, &NetJob::failed, this, &DownloadTask::vinfoDownloadFailed);
|
connect(netJob, &NetJob::failed, this, &DownloadTask::vinfoDownloadFailed);
|
||||||
m_vinfoNetJob.reset(netJob);
|
m_vinfoNetJob.reset(netJob);
|
||||||
netJob->start();
|
netJob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadTask::vinfoDownloadFailed()
|
void DownloadTask::vinfoDownloadFailed()
|
||||||
@ -117,7 +121,7 @@ void DownloadTask::processDownloadedVersionInfo()
|
|||||||
setStatus(tr("Processing file lists - figuring out how to install the update..."));
|
setStatus(tr("Processing file lists - figuring out how to install the update..."));
|
||||||
|
|
||||||
// make a new netjob for the actual update files
|
// make a new netjob for the actual update files
|
||||||
NetJobPtr netJob (new NetJob("Update Files"));
|
NetJob::Ptr netJob (new NetJob("Update Files"));
|
||||||
|
|
||||||
// fill netJob and operationList
|
// fill netJob and operationList
|
||||||
if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, m_operations))
|
if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, m_operations))
|
||||||
@ -141,7 +145,7 @@ void DownloadTask::processDownloadedVersionInfo()
|
|||||||
}
|
}
|
||||||
qDebug() << "Begin downloading update files to" << m_updateFilesDir.path();
|
qDebug() << "Begin downloading update files to" << m_updateFilesDir.path();
|
||||||
m_filesNetJob = netJob;
|
m_filesNetJob = netJob;
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start(m_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadTask::fileDownloadFinished()
|
void DownloadTask::fileDownloadFinished()
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
*
|
*
|
||||||
* target is a template - XXXXXX at the end will be replaced with a random generated string, ensuring uniqueness
|
* target is a template - XXXXXX at the end will be replaced with a random generated string, ensuring uniqueness
|
||||||
*/
|
*/
|
||||||
explicit DownloadTask(Status status, QString target, QObject* parent = 0);
|
explicit DownloadTask(shared_qobject_ptr<QNetworkAccessManager> network, Status status, QString target, QObject* parent = 0);
|
||||||
virtual ~DownloadTask() {};
|
virtual ~DownloadTask() {};
|
||||||
|
|
||||||
/// Get the directory that will contain the update files.
|
/// Get the directory that will contain the update files.
|
||||||
@ -62,13 +62,13 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void loadVersionInfo();
|
void loadVersionInfo();
|
||||||
|
|
||||||
NetJobPtr m_vinfoNetJob;
|
NetJob::Ptr m_vinfoNetJob;
|
||||||
QByteArray currentVersionFileListData;
|
QByteArray currentVersionFileListData;
|
||||||
QByteArray newVersionFileListData;
|
QByteArray newVersionFileListData;
|
||||||
Net::Download::Ptr m_currentVersionFileListDownload;
|
Net::Download::Ptr m_currentVersionFileListDownload;
|
||||||
Net::Download::Ptr m_newVersionFileListDownload;
|
Net::Download::Ptr m_newVersionFileListDownload;
|
||||||
|
|
||||||
NetJobPtr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
|
|
||||||
Status m_status;
|
Status m_status;
|
||||||
|
|
||||||
@ -91,6 +91,9 @@ protected slots:
|
|||||||
void fileDownloadFinished();
|
void fileDownloadFinished();
|
||||||
void fileDownloadFailed(QString reason);
|
void fileDownloadFailed(QString reason);
|
||||||
void fileDownloadProgressChanged(qint64 current, qint64 total);
|
void fileDownloadProgressChanged(qint64 current, qint64 total);
|
||||||
|
|
||||||
|
private:
|
||||||
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ bool processFileLists
|
|||||||
const VersionFileList &newVersion,
|
const VersionFileList &newVersion,
|
||||||
const QString &rootPath,
|
const QString &rootPath,
|
||||||
const QString &tempPath,
|
const QString &tempPath,
|
||||||
NetJobPtr job,
|
NetJob::Ptr job,
|
||||||
OperationList &ops
|
OperationList &ops
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ bool processFileLists
|
|||||||
const VersionFileList &newVersion,
|
const VersionFileList &newVersion,
|
||||||
const QString &rootPath,
|
const QString &rootPath,
|
||||||
const QString &tempPath,
|
const QString &tempPath,
|
||||||
NetJobPtr job,
|
NetJob::Ptr job,
|
||||||
OperationList &ops
|
OperationList &ops
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user