summaryrefslogtreecommitdiff
path: root/protocols/Quotes/ModuleInfo.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
commitb61ba851da0157ace3bdfc1ebbf87156b0b76413 (patch)
treed6c567db57af1eb09c254a8bee13c305282334f8 /protocols/Quotes/ModuleInfo.cpp
parenta4c70f6bedb25e5cffb08dfc5cbc2597d1642d6b (diff)
protocols plugins moved to protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Quotes/ModuleInfo.cpp')
-rw-r--r--protocols/Quotes/ModuleInfo.cpp150
1 files changed, 150 insertions, 0 deletions
diff --git a/protocols/Quotes/ModuleInfo.cpp b/protocols/Quotes/ModuleInfo.cpp
new file mode 100644
index 0000000000..69a835409e
--- /dev/null
+++ b/protocols/Quotes/ModuleInfo.cpp
@@ -0,0 +1,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;
+}