summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src/ModuleInfo.cpp
blob: 172f2ba8840dcf3710d8b17b2b92ec8cb7ed3026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
}