summaryrefslogtreecommitdiffstats
path: root/api/logic/Env.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-04-10 15:53:05 +0200
committerPetr Mrázek <peterix@gmail.com>2016-05-01 00:00:14 +0200
commitb6d455a02bd338e9dc0faa09d4d8177ecd8d569a (patch)
tree41982bca1ede50049f2f8c7109dd18edeefde6d0 /api/logic/Env.h
parent47e37635f50c09b4f9a9ee7699e3120bab3e4088 (diff)
downloadMultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.gz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.lz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.xz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.zip
NOISSUE reorganize and document libraries
Diffstat (limited to 'api/logic/Env.h')
-rw-r--r--api/logic/Env.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/api/logic/Env.h b/api/logic/Env.h
new file mode 100644
index 00000000..4d8945d7
--- /dev/null
+++ b/api/logic/Env.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <memory>
+#include <QString>
+#include <QMap>
+
+#include "multimc_logic_export.h"
+
+class QNetworkAccessManager;
+class HttpMetaCache;
+class BaseVersionList;
+class BaseVersion;
+class WonkoIndex;
+
+#if defined(ENV)
+ #undef ENV
+#endif
+#define ENV (Env::getInstance())
+
+class MULTIMC_LOGIC_EXPORT Env
+{
+ friend class MultiMC;
+private:
+ Env();
+public:
+ static Env& getInstance();
+
+ // call when Qt stuff is being torn down
+ void destroy();
+
+ std::shared_ptr<QNetworkAccessManager> qnam();
+
+ std::shared_ptr<HttpMetaCache> metacache();
+
+ /// 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);
+
+ /// 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);
+
+ std::shared_ptr<WonkoIndex> wonkoIndex();
+
+ QString wonkoRootUrl() const { return m_wonkoRootUrl; }
+ void setWonkoRootUrl(const QString &url) { m_wonkoRootUrl = url; }
+
+protected:
+ std::shared_ptr<QNetworkAccessManager> m_qnam;
+ std::shared_ptr<HttpMetaCache> m_metacache;
+ QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
+ std::shared_ptr<WonkoIndex> m_wonkoIndex;
+ QString m_wonkoRootUrl;
+};