2015-01-31 15:59:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2016-05-02 23:27:28 +01:00
|
|
|
#include "icons/IIconList.h"
|
2015-01-31 15:59:03 +00:00
|
|
|
#include <QString>
|
2015-02-02 00:09:28 +00:00
|
|
|
#include <QMap>
|
2015-01-31 15:59:03 +00:00
|
|
|
|
2015-09-05 17:46:57 +01:00
|
|
|
#include "multimc_logic_export.h"
|
|
|
|
|
2015-01-31 15:59:03 +00:00
|
|
|
class QNetworkAccessManager;
|
|
|
|
class HttpMetaCache;
|
2015-02-02 00:09:28 +00:00
|
|
|
class BaseVersionList;
|
|
|
|
class BaseVersion;
|
2016-04-06 22:09:30 +01:00
|
|
|
class WonkoIndex;
|
2015-01-31 15:59:03 +00:00
|
|
|
|
|
|
|
#if defined(ENV)
|
|
|
|
#undef ENV
|
|
|
|
#endif
|
|
|
|
#define ENV (Env::getInstance())
|
|
|
|
|
2015-09-05 17:46:57 +01:00
|
|
|
class MULTIMC_LOGIC_EXPORT Env
|
2015-01-31 15:59:03 +00:00
|
|
|
{
|
|
|
|
friend class MultiMC;
|
|
|
|
private:
|
|
|
|
Env();
|
|
|
|
public:
|
|
|
|
static Env& getInstance();
|
|
|
|
|
|
|
|
// call when Qt stuff is being torn down
|
|
|
|
void destroy();
|
|
|
|
|
2015-01-31 18:21:47 +00:00
|
|
|
std::shared_ptr<QNetworkAccessManager> qnam();
|
|
|
|
|
|
|
|
std::shared_ptr<HttpMetaCache> metacache();
|
2015-01-31 15:59:03 +00:00
|
|
|
|
2016-05-02 23:27:28 +01:00
|
|
|
std::shared_ptr<IIconList> icons();
|
|
|
|
|
2015-01-31 15:59:03 +00:00
|
|
|
/// init the cache. FIXME: possible future hook point
|
2015-12-27 02:34:03 +00:00
|
|
|
void initHttpMetaCache();
|
2015-01-31 15:59:03 +00:00
|
|
|
|
|
|
|
/// Updates the application proxy settings from the settings object.
|
|
|
|
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
|
|
|
|
2015-02-02 00:09:28 +00:00
|
|
|
/// get a version list by name
|
|
|
|
std::shared_ptr<BaseVersionList> getVersionList(QString component);
|
|
|
|
|
|
|
|
/// get a version by list name and version name
|
|
|
|
std::shared_ptr<BaseVersion> getVersion(QString component, QString version);
|
|
|
|
|
|
|
|
void registerVersionList(QString name, std::shared_ptr<BaseVersionList> vlist);
|
2016-04-06 22:09:30 +01:00
|
|
|
|
2016-05-02 23:27:28 +01:00
|
|
|
void registerIconList(std::shared_ptr<IIconList> iconlist);
|
|
|
|
|
2016-04-06 22:09:30 +01:00
|
|
|
std::shared_ptr<WonkoIndex> wonkoIndex();
|
|
|
|
|
|
|
|
QString wonkoRootUrl() const { return m_wonkoRootUrl; }
|
|
|
|
void setWonkoRootUrl(const QString &url) { m_wonkoRootUrl = url; }
|
|
|
|
|
2015-01-31 15:59:03 +00:00
|
|
|
protected:
|
|
|
|
std::shared_ptr<QNetworkAccessManager> m_qnam;
|
|
|
|
std::shared_ptr<HttpMetaCache> m_metacache;
|
2016-05-02 23:27:28 +01:00
|
|
|
std::shared_ptr<IIconList> m_iconlist;
|
2015-02-02 00:09:28 +00:00
|
|
|
QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
|
2016-04-06 22:09:30 +01:00
|
|
|
std::shared_ptr<WonkoIndex> m_wonkoIndex;
|
|
|
|
QString m_wonkoRootUrl;
|
2015-01-31 15:59:03 +00:00
|
|
|
};
|