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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#include "StdAfx.h"
#include "ModuleInfo.h"
#include "QuotesProviders.h"
#include "HTMLParserMS.h"
#include "LightMutex.h"
#include "WinCtrlHelper.h"
#include "EconomicRateInfo.h"
#include "XMLEngineMI.h"
namespace
{
HINSTANCE g_hInstance = NULL;
CModuleInfo::TXMLEnginePtr g_pXMLEngine;
CModuleInfo::THTMLEnginePtr g_pHTMLEngine;
CLightMutex g_lmParsers;
}
CModuleInfo::CModuleInfo()
: m_bExtendedStatusInfo(1 == DBGetContactSettingByte(NULL,QUOTES_MODULE_NAME,"ExtendedStatus",false))
{
}
CModuleInfo::~CModuleInfo()
{
}
CModuleInfo& CModuleInfo::GetInstance()
{
static CModuleInfo mi;
return mi;
}
HANDLE CModuleInfo::GetWindowList(const std::string& rsKey,bool bAllocateIfNonExist /*= true*/)
{
HANDLE hResult = NULL;
THandles::const_iterator i = m_ahWindowLists.find(rsKey);
if(i != m_ahWindowLists.end())
{
hResult = i->second;
}
else if(bAllocateIfNonExist)
{
hResult = reinterpret_cast<HANDLE>(CallService(MS_UTILS_ALLOCWINDOWLIST,0,0));
if(hResult)
{
m_ahWindowLists.insert(std::make_pair(rsKey,hResult));
}
}
return hResult;
}
void CModuleInfo::OnMirandaShutdown()
{
BOOST_FOREACH(THandles::value_type p,m_ahWindowLists)
{
WindowList_Broadcast(p.second,WM_CLOSE,0,0);
}
}
void CModuleInfo::SetModuleHandle(HINSTANCE hInstance)
{
assert(NULL == g_hInstance);
assert(NULL != hInstance);
g_hInstance = hInstance;
}
HINSTANCE CModuleInfo::GetModuleHandle()
{
assert(NULL != g_hInstance);
return g_hInstance;
}
CModuleInfo::TQuotesProvidersPtr CModuleInfo::GetQuoteProvidersPtr()
{
static TQuotesProvidersPtr pProviders(new CQuotesProviders);
return pProviders;
}
CModuleInfo::TXMLEnginePtr CModuleInfo::GetXMLEnginePtr()
{
if(!g_pXMLEngine)
{
CGuard<CLightMutex> cs(g_lmParsers);
if(!g_pXMLEngine)
{
mir_getXI(&xi);
g_pXMLEngine = TXMLEnginePtr(new CXMLEngineMI);
}
}
return g_pXMLEngine;
}
// void CModuleInfo::SetXMLEnginePtr(TXMLEnginePtr pEngine)
// {
// g_pXMLEngine = pEngine;
// }
CModuleInfo::THTMLEnginePtr CModuleInfo::GetHTMLEngine()
{
if(!g_pHTMLEngine)
{
CGuard<CLightMutex> cs(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(!GetXMLEnginePtr())
{
Quotes_MessageBox(NULL,TranslateT("Miranda could not load Quotes plugin. XML parser is missing."),MB_OK|MB_ICONERROR);
return false;
}
if(!g_pHTMLEngine && (false == CHTMLParserMS::IsInstalled()))
{
Quotes_MessageBox(NULL,
TranslateT("Miranda could not load Quotes plugin. Microsoft HTML parser is missing."),
MB_YESNO|MB_ICONQUESTION);
return false;
}
return true;
}
bool CModuleInfo::GetExtendedStatusFlag()const
{
return m_bExtendedStatusInfo;
}
|