summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src/ModuleInfo.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-02 12:32:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-02 12:32:55 +0300
commit931a7dc1ac0dbc7e6c1083583ced915e572f5b47 (patch)
tree9fe9a6448d44030e26aa7107ce16044ed413e0d0 /protocols/CurrencyRates/src/ModuleInfo.cpp
parentdd7d9954042254e66e3bbbec7195c6be8b1a0663 (diff)
all protocols (even virtual ones) moved to the Protocols folder
Diffstat (limited to 'protocols/CurrencyRates/src/ModuleInfo.cpp')
-rw-r--r--protocols/CurrencyRates/src/ModuleInfo.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/protocols/CurrencyRates/src/ModuleInfo.cpp b/protocols/CurrencyRates/src/ModuleInfo.cpp
new file mode 100644
index 0000000000..172f2ba884
--- /dev/null
+++ b/protocols/CurrencyRates/src/ModuleInfo.cpp
@@ -0,0 +1,64 @@
+#include "StdAfx.h"
+
+static CModuleInfo mi;
+static CModuleInfo::THTMLEnginePtr g_pHTMLEngine;
+static mir_cs g_lmParsers;
+
+typedef std::map<std::string, MWindowList> THandles;
+static THandles g_ahWindowLists;
+
+MWindowList CModuleInfo::GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist /*= true*/)
+{
+ MWindowList hResult = nullptr;
+ THandles::const_iterator i = g_ahWindowLists.find(rsKey);
+ if (i != g_ahWindowLists.end()) {
+ hResult = i->second;
+ }
+ else if (bAllocateIfNonExist) {
+ hResult = WindowList_Create();
+ if (hResult)
+ g_ahWindowLists.insert(std::make_pair(rsKey, hResult));
+ }
+
+ return hResult;
+}
+
+void CModuleInfo::OnMirandaShutdown()
+{
+ for (auto &p : g_ahWindowLists)
+ WindowList_Broadcast(p.second, WM_CLOSE, 0, 0);
+}
+
+CModuleInfo::THTMLEnginePtr CModuleInfo::GetHTMLEngine()
+{
+ if (!g_pHTMLEngine) {
+ mir_cslock lck(g_lmParsers);
+ if (!g_pHTMLEngine)
+ g_pHTMLEngine = THTMLEnginePtr(new CHTMLEngineMS);
+ }
+
+ return g_pHTMLEngine;
+}
+
+void CModuleInfo::SetHTMLEngine(THTMLEnginePtr pEngine)
+{
+ g_pHTMLEngine = pEngine;
+}
+
+bool CModuleInfo::Verify()
+{
+ INITCOMMONCONTROLSEX icc = { 0 };
+ icc.dwSize = sizeof(icc);
+ icc.dwICC = ICC_WIN95_CLASSES | ICC_LINK_CLASS;
+ if (FALSE == ::InitCommonControlsEx(&icc))
+ return false;
+
+ if (!g_pHTMLEngine && (false == CHTMLParserMS::IsInstalled())) {
+ CurrencyRates_MessageBox(nullptr,
+ TranslateT("Miranda could not load CurrencyRates plugin. Microsoft HTML parser is missing."),
+ MB_YESNO | MB_ICONQUESTION);
+ return false;
+ }
+
+ return true;
+}