diff options
Diffstat (limited to 'protocols')
36 files changed, 195 insertions, 655 deletions
diff --git a/protocols/CurrencyRates/Forex.vcxproj b/protocols/CurrencyRates/Forex.vcxproj index 5ddce213a2..4fd5b7ee2b 100644 --- a/protocols/CurrencyRates/Forex.vcxproj +++ b/protocols/CurrencyRates/Forex.vcxproj @@ -26,7 +26,6 @@ <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" /> </ImportGroup> <ItemGroup> - <ClCompile Include="src\ComHelper.cpp" /> <ClCompile Include="src\CommonOptionDlg.cpp" /> <ClCompile Include="src\CreateFilePath.cpp" /> <ClCompile Include="src\CurrencyConverter.cpp" /> @@ -38,7 +37,6 @@ <ClCompile Include="src\DBUtils.cpp" /> <ClCompile Include="src\ExtraImages.cpp" /> <ClCompile Include="src\Forex.cpp" /> - <ClCompile Include="src\HTMLParserMS.cpp" /> <ClCompile Include="src\HTTPSession.cpp" /> <ClCompile Include="src\IconLib.cpp" /> <ClCompile Include="src\ImportExport.cpp" /> @@ -51,7 +49,6 @@ </ClCompile> <ClCompile Include="src\WinCtrlHelper.cpp" /> <ClInclude Include="src\Chart.h" /> - <ClInclude Include="src\ComHelper.h" /> <ClInclude Include="src\CommonOptionDlg.h" /> <ClInclude Include="src\CreateFilePath.h" /> <ClInclude Include="src\CurrencyConverter.h" /> @@ -62,11 +59,8 @@ <ClInclude Include="src\DBUtils.h" /> <ClInclude Include="src\EconomicRateInfo.h" /> <ClInclude Include="src\ExtraImages.h" /> - <ClInclude Include="src\HTMLParserMS.h" /> <ClInclude Include="src\HTTPSession.h" /> <ClInclude Include="src\ICurrencyRatesProvider.h" /> - <ClInclude Include="src\IHTMLEngine.h" /> - <ClInclude Include="src\IHTMLParser.h" /> <ClInclude Include="src\ImportExport.h" /> <ClInclude Include="src\IsWithinAccuracy.h" /> <ClInclude Include="src\Locale.h" /> diff --git a/protocols/CurrencyRates/Forex.vcxproj.filters b/protocols/CurrencyRates/Forex.vcxproj.filters index c68f847fee..9e5d0d3b9e 100644 --- a/protocols/CurrencyRates/Forex.vcxproj.filters +++ b/protocols/CurrencyRates/Forex.vcxproj.filters @@ -2,9 +2,6 @@ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" /> <ItemGroup> - <ClCompile Include="src\ComHelper.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="src\CommonOptionDlg.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -38,9 +35,6 @@ <ClCompile Include="src\Forex.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="src\HTMLParserMS.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="src\HTTPSession.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -73,9 +67,6 @@ <ClInclude Include="src\Chart.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="src\ComHelper.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="src\CommonOptionDlg.h"> <Filter>Header Files</Filter> </ClInclude> @@ -106,21 +97,12 @@ <ClInclude Include="src\ExtraImages.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="src\HTMLParserMS.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="src\HTTPSession.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="src\ICurrencyRatesProvider.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="src\IHTMLEngine.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\IHTMLParser.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="src\ImportExport.h"> <Filter>Header Files</Filter> </ClInclude> diff --git a/protocols/CurrencyRates/src/Chart.h b/protocols/CurrencyRates/src/Chart.h index 430d067781..0a295ad4c3 100644 --- a/protocols/CurrencyRates/src/Chart.h +++ b/protocols/CurrencyRates/src/Chart.h @@ -7,14 +7,14 @@ namespace detail { template<class T> struct CConverter { - static double Convert(const T& v) + static double Convert(const T &v) { return boost::numeric_cast<double>(v); } - static tstring ToString(const T& v) + static std::wstring ToString(const T &v) { - return boost::lexical_cast<tstring>(v); + return boost::lexical_cast<std::wstring>(v); } }; @@ -25,7 +25,7 @@ namespace detail return v; } - static tstring ToString(double v) + static std::wstring ToString(double v) { wchar_t str[40]; swprintf_s(str, L"%.6lf", v); @@ -121,7 +121,7 @@ private: int nXIndent = 0; for (int y = rc.bottom - step; y > rc.top; y -= step, y_val += ((m_MaxY - m_MinY) / number_of_lines)) { - tstring sY = TYConverter::ToString(y_val); + std::wstring sY = TYConverter::ToString(y_val); SIZE sizeText = { 0, 0 }; BOOL bResult = ::GetTextExtentPoint32(hdc, sY.c_str(), (int)sY.size(), &sizeText); assert(TRUE == bResult); @@ -133,7 +133,7 @@ private: rc.left += nXIndent; for (int y = rc.bottom - step; y > rc.top; y -= step, y_val += ((m_MaxY - m_MinY) / number_of_lines)) { - tstring sY = TYConverter::ToString(y_val); + std::wstring sY = TYConverter::ToString(y_val); SIZE sizeText = { 0, 0 }; BOOL bResult = ::GetTextExtentPoint32(hdc, sY.c_str(), (int)sY.size(), &sizeText); assert(TRUE == bResult); @@ -157,7 +157,7 @@ private: TXValue x_val = m_aValues[0].first + ((m_aValues[m_aValues.size() - 1].first - m_aValues[0].first) / number_of_lines); for (int x = rc.left + step; x < rc.right; x += step, x_val += ((m_aValues[m_aValues.size() - 1].first - m_aValues[0].first) / number_of_lines)) { - tstring sX = TXConverter::ToString(x_val); + std::wstring sX = TXConverter::ToString(x_val); SIZE sizeText = { 0, 0 }; BOOL bResult = ::GetTextExtentPoint32(hdc, sX.c_str(), (int)sX.size(), &sizeText); assert(TRUE == bResult); diff --git a/protocols/CurrencyRates/src/ComHelper.cpp b/protocols/CurrencyRates/src/ComHelper.cpp deleted file mode 100644 index c4715892b5..0000000000 --- a/protocols/CurrencyRates/src/ComHelper.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "StdAfx.h" - -tstring ComException2Msg(_com_error& e, const tstring& rsAdditionalInfo) -{ - HRESULT hError = e.Error(); - tostringstream o; - if (false == rsAdditionalInfo.empty()) - o << rsAdditionalInfo << "\n"; - - o << e.ErrorMessage() << L" (" << std::hex << hError << L")"; - - IErrorInfo* p = e.ErrorInfo(); - CComPtr<IErrorInfo> pErrorInfo(p); - if (nullptr != p) - p->Release(); - - if (pErrorInfo) - o << L"\n" << e.Description(); - - return o.str(); -} - -void ShowComError(_com_error& e, const tstring& rsAdditionalInfo) -{ - tstring sErrorMsg = ComException2Msg(e, rsAdditionalInfo); - LogIt(sErrorMsg); - CurrencyRates_MessageBox(nullptr, sErrorMsg.c_str(), MB_OK | MB_ICONERROR); -} diff --git a/protocols/CurrencyRates/src/ComHelper.h b/protocols/CurrencyRates/src/ComHelper.h deleted file mode 100644 index 343d436785..0000000000 --- a/protocols/CurrencyRates/src/ComHelper.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ -#define __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ - -void ShowComError(_com_error& e, const tstring& rsAdditionalInfo); -tstring ComException2Msg(_com_error& e, const tstring& rsAdditionalInfo); - -#endif//__37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ diff --git a/protocols/CurrencyRates/src/CommonOptionDlg.cpp b/protocols/CurrencyRates/src/CommonOptionDlg.cpp index 27190b2545..56b857d331 100644 --- a/protocols/CurrencyRates/src/CommonOptionDlg.cpp +++ b/protocols/CurrencyRates/src/CommonOptionDlg.cpp @@ -166,7 +166,7 @@ void CommonOptionDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp, CCommonDlgPr HWND hEdit = ::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT); assert(IsWindow(hEdit)); - tstring s = get_window_text(hEdit); + std::wstring s = get_window_text(hEdit); if (true == s.empty()) { prepare_edit_ctrl_for_error(hEdit); CurrencyRates_MessageBox(hWnd, TranslateT("Enter text to display in contact list."), MB_OK | MB_ICONERROR); @@ -190,7 +190,7 @@ void CommonOptionDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp, CCommonDlgPr g_plugin.setWord(DB_KEY_RefreshRateType, nType); g_plugin.setWord(DB_KEY_RefreshRateValue, nRefreshRate); - tstring s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT)); + std::wstring s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT)); g_plugin.setWString(DB_KEY_DisplayNameFormat, s.c_str()); s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT)); diff --git a/protocols/CurrencyRates/src/CreateFilePath.cpp b/protocols/CurrencyRates/src/CreateFilePath.cpp index 71490432a9..04621eca64 100644 --- a/protocols/CurrencyRates/src/CreateFilePath.cpp +++ b/protocols/CurrencyRates/src/CreateFilePath.cpp @@ -1,6 +1,6 @@ #include "StdAfx.h" -tstring CreateFilePath(const tstring &rsName) +std::wstring CreateFilePath(const std::wstring &rsName) { wchar_t szPath[_MAX_PATH]; ::GetModuleFileName(g_plugin.getInst(), szPath, _MAX_PATH); @@ -9,9 +9,9 @@ tstring CreateFilePath(const tstring &rsName) if (p) *p = 0; - tstring s(rsName); + std::wstring s(rsName); FixInvalidChars(s); - tostringstream o; + std::wostringstream o; o << szPath << L"\\CurrencyRates\\" << s; return o.str(); }
\ No newline at end of file diff --git a/protocols/CurrencyRates/src/CreateFilePath.h b/protocols/CurrencyRates/src/CreateFilePath.h index e4a88494fb..6f11a24601 100644 --- a/protocols/CurrencyRates/src/CreateFilePath.h +++ b/protocols/CurrencyRates/src/CreateFilePath.h @@ -1,6 +1,6 @@ #ifndef _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ #define _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ -tstring CreateFilePath(const tstring& rsName); +std::wstring CreateFilePath(const std::wstring& rsName); #endif //_aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ diff --git a/protocols/CurrencyRates/src/CurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyConverter.cpp index e92efff053..e624f8233c 100644 --- a/protocols/CurrencyRates/src/CurrencyConverter.cpp +++ b/protocols/CurrencyRates/src/CurrencyConverter.cpp @@ -31,9 +31,9 @@ CCurrencyRateSection get_currencyrates(const CCurrencyRatesProviderCurrencyConve return CCurrencyRateSection(); } -inline tstring make_currencyrate_name(const CCurrencyRate &rCurrencyRate) +inline std::wstring make_currencyrate_name(const CCurrencyRate &rCurrencyRate) { - const tstring &rsDesc = rCurrencyRate.GetName(); + const std::wstring &rsDesc = rCurrencyRate.GetName(); return((false == rsDesc.empty()) ? rsDesc : rCurrencyRate.GetSymbol()); } @@ -58,16 +58,16 @@ inline void update_swap_button(HWND hDlg) EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_SWAP), bEnableButton); } -inline tstring double2str(double dValue) +inline std::wstring double2str(double dValue) { wchar_t str[40]; swprintf_s(str, L"%.2lf", dValue); return str; } -inline bool str2double(const tstring& s, double& d) +inline bool str2double(const std::wstring& s, double& d) { - tistringstream input(s); + std::wistringstream input(s); input.imbue(GetSystemLocale()); input >> d; return ((false == input.bad()) && (false == input.fail())); @@ -89,15 +89,15 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM HWND hcbxFrom = ::GetDlgItem(hDlg, IDC_COMBO_CONVERT_FROM); HWND hcbxTo = ::GetDlgItem(hDlg, IDC_COMBO_CONVERT_INTO); - tstring sFromCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_FROM_ID); - tstring sToCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_TO_ID); + std::wstring sFromCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_FROM_ID); + std::wstring sToCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_TO_ID); const auto pProvider = get_currency_converter_provider(); const auto& rSection = get_currencyrates(pProvider); auto cCurrencyRates = rSection.GetCurrencyRateCount(); for (auto i = 0u; i < cCurrencyRates; ++i) { const auto& rCurrencyRate = rSection.GetCurrencyRate(i); - tstring sName = make_currencyrate_name(rCurrencyRate); + std::wstring sName = make_currencyrate_name(rCurrencyRate); LPCTSTR pszName = sName.c_str(); LRESULT nFrom = ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszName)); LRESULT nTo = ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszName)); @@ -116,7 +116,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM ::SetDlgItemText(hDlg, IDC_EDIT_VALUE, double2str(dAmount).c_str()); const ICurrencyRatesProvider::CProviderInfo& pi = pProvider->GetInfo(); - tostringstream o; + std::wostringstream o; o << TranslateT("Info provided by") << L" <a href=\"" << pi.m_sURL << L"\">" << pi.m_sName << L"</a>"; ::SetDlgItemText(hDlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); @@ -179,7 +179,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM case IDC_BUTTON_CONVERT: { HWND hwndAmount = GetDlgItem(hDlg, IDC_EDIT_VALUE); - tstring sText = get_window_text(hwndAmount); + std::wstring sText = get_window_text(hwndAmount); double dAmount = 1.0; if ((true == str2double(sText, dAmount)) && (dAmount > 0.0)) { diff --git a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp index b9feaf046b..cc4b1b2de8 100644 --- a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp +++ b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp @@ -36,7 +36,7 @@ INT_PTR CALLBACK CurrencyRateInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT TranslateDialogDefault(hdlg); { - tstring sDescription = GetContactName(hContact); + std::wstring sDescription = GetContactName(hContact); ::SetDlgItemTextW(hdlg, IDC_STATIC_CURRENCYRATE_NAME, sDescription.c_str()); double dRate = 0.0; @@ -62,7 +62,7 @@ INT_PTR CALLBACK CurrencyRateInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT } const ICurrencyRatesProvider::CProviderInfo& pi = GetContactProviderPtr(hContact)->GetInfo(); - tostringstream o; + std::wostringstream o; o << TranslateT("Info provided by") << L" <a href=\"" << pi.m_sURL << L"\">" << pi.m_sName << L"</a>"; ::SetDlgItemTextW(hdlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); @@ -119,7 +119,7 @@ INT_PTR CurrencyRatesMenu_EditSettings(WPARAM wp, LPARAM) namespace { - bool get_log_file(MCONTACT hContact, tstring& rsLogfile) + bool get_log_file(MCONTACT hContact, std::wstring& rsLogfile) { rsLogfile = GetContactLogFileName(hContact); return ((rsLogfile.empty()) ? false : true); @@ -132,7 +132,7 @@ INT_PTR CurrencyRatesMenu_OpenLogFile(WPARAM wp, LPARAM) if (NULL == hContact) return 0; - tstring sLogFileName; + std::wstring sLogFileName; if ((true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty())) ::ShellExecute(nullptr, L"open", sLogFileName.c_str(), nullptr, nullptr, SW_SHOWNORMAL); @@ -239,7 +239,7 @@ int CurrencyRates_PrebuildContactMenu(WPARAM wp, LPARAM) Menu_EnableItem(g_hMenuRefresh, true); - tstring sLogFileName; + std::wstring sLogFileName; bool bThereIsLogFile = (true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty()) && (0 == _waccess(sLogFileName.c_str(), 04)); if (true == bThereIsLogFile) { diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp index 912536150f..0d973d39eb 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp @@ -8,17 +8,17 @@ struct CXMLFileInfo CXMLFileInfo() : m_qs(L"Unknown") {} ICurrencyRatesProvider::CProviderInfo m_pi; CCurrencyRateSection m_qs; - tstring m_sURL; + std::wstring m_sURL; }; -inline tstring get_ini_file_name(LPCTSTR pszFileName) +inline std::wstring get_ini_file_name(LPCTSTR pszFileName) { return CreateFilePath(pszFileName); } bool parse_currencyrate(const TiXmlNode *pTop, CCurrencyRate &q) { - tstring sSymbol, sDescription, sID; + std::wstring sSymbol, sDescription, sID; for (auto *pNode : TiXmlEnum(pTop)) { const char *sName = pNode->Value(); @@ -45,7 +45,7 @@ bool parse_section(const TiXmlNode *pTop, CCurrencyRateSection &qs) { CCurrencyRateSection::TSections aSections; CCurrencyRateSection::TCurrencyRates aCurrencyRates; - tstring sSectionName; + std::wstring sSectionName; for (auto *pNode : TiXmlEnum(pTop)) { const char *sName = pNode->Value(); @@ -84,7 +84,7 @@ const TiXmlNode* find_provider(const TiXmlNode *pRoot) return nullptr; } -CXMLFileInfo parse_ini_file(const tstring &rsXMLFile, bool &rbSucceded) +CXMLFileInfo parse_ini_file(const std::wstring &rsXMLFile, bool &rbSucceded) { CXMLFileInfo res; CCurrencyRateSection::TSections aSections; @@ -118,7 +118,7 @@ CXMLFileInfo parse_ini_file(const tstring &rsXMLFile, bool &rbSucceded) CXMLFileInfo init_xml_info(LPCTSTR pszFileName, bool& rbSucceded) { rbSucceded = false; - tstring sIniFile = get_ini_file_name(pszFileName); + std::wstring sIniFile = get_ini_file_name(pszFileName); return parse_ini_file(sIniFile, rbSucceded); } @@ -156,7 +156,7 @@ const CCurrencyRateSection& CCurrencyRatesProviderBase::GetCurrencyRates() const return m_pXMLInfo->m_qs; } -const tstring& CCurrencyRatesProviderBase::GetURL() const +const std::wstring& CCurrencyRatesProviderBase::GetURL() const { return m_pXMLInfo->m_sURL; } @@ -224,14 +224,14 @@ public: public: CTendency() : m_nComparison(NonValid) {} - bool Parse(CCurrencyRatesProviderBase *pProvider, const tstring& rsFrmt, MCONTACT hContact) + bool Parse(CCurrencyRatesProviderBase *pProvider, const std::wstring& rsFrmt, MCONTACT hContact) { m_abValueFlags[0] = false; m_abValueFlags[1] = false; m_nComparison = NonValid; bool bValid = true; int nCurValue = 0; - for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end() && bValid && nCurValue < NumValues;) { + for (std::wstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end() && bValid && nCurValue < NumValues;) { wchar_t chr = *i; switch (chr) { default: @@ -333,11 +333,11 @@ private: EComparison m_nComparison; }; -tstring format_rate(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, const tstring &rsFrmt) +std::wstring format_rate(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, const std::wstring &rsFrmt) { - tstring sResult; + std::wstring sResult; - for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end();) { + for (std::wstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end();) { wchar_t chr = *i; switch (chr) { default: @@ -390,15 +390,15 @@ tstring format_rate(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, void log_to_file(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, - const tstring& rsLogFileName, - const tstring& rsFormat) + const std::wstring& rsLogFileName, + const std::wstring& rsFormat) { CreatePathToFileW(rsLogFileName.c_str()); - tofstream file(rsLogFileName.c_str(), std::ios::app | std::ios::out); + std::wofstream file(rsLogFileName.c_str(), std::ios::app | std::ios::out); file.imbue(GetSystemLocale()); if (file.good()) { - tstring s = format_rate(pProvider, hContact, rsFormat); + std::wstring s = format_rate(pProvider, hContact, rsFormat); file << s; } } @@ -406,9 +406,9 @@ void log_to_file(const ICurrencyRatesProvider *pProvider, void log_to_history(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, time_t nTime, - const tstring& rsFormat) + const std::wstring& rsFormat) { - tstring s = format_rate(pProvider, hContact, rsFormat); + std::wstring s = format_rate(pProvider, hContact, rsFormat); T2Utf psz(s.c_str()); DBEVENTINFO dbei = {}; @@ -440,7 +440,7 @@ bool do_set_contact_extra_icon(MCONTACT hContact, const CTendency& tendency) bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, const CTendency& tendency, - const tstring& rsFormat, + const std::wstring& rsFormat, const CPopupSettings& ps) { POPUPDATAW ppd; @@ -460,7 +460,7 @@ bool show_popup(const ICurrencyRatesProvider *pProvider, mir_wstrncpy(ppd.lpwzContactName, pProvider->FormatSymbol(hContact, 's').c_str(), MAX_CONTACTNAME); { ptrW ss(variables_parsedup((wchar_t*)rsFormat.c_str(), nullptr, hContact)); - tstring sText = format_rate(pProvider, hContact, tstring(ss)); + std::wstring sText = format_rate(pProvider, hContact, std::wstring(ss)); mir_wstrncpy(ppd.lpwzText, sText.c_str(), MAX_SECONDLINE); } @@ -494,7 +494,7 @@ bool show_popup(const ICurrencyRatesProvider *pProvider, return (0 == PUAddPopupW(&ppd, lp)); } -void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol/* = ""*/) +void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, const std::wstring& rsSymbol/* = ""*/) { time_t nTime = ::time(0); @@ -509,12 +509,12 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat CurrencyRates_DBWriteDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate); g_plugin.setDword(hContact, DB_STR_CURRENCYRATE_FETCH_TIME, nTime); - tstring sSymbol = rsSymbol; + std::wstring sSymbol = rsSymbol; - tostringstream oNick; + std::wostringstream oNick; oNick.imbue(GetSystemLocale()); if (false == m_sContactListFormat.empty()) { - tstring s = format_rate(this, hContact, m_sContactListFormat); + std::wstring s = format_rate(this, hContact, m_sContactListFormat); oNick << s; } else { @@ -530,7 +530,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, oNick.str().c_str()); - tstring sStatusMsg = format_rate(this, hContact, m_sStatusMsgFormat); + std::wstring sStatusMsg = format_rate(this, hContact, m_sStatusMsgFormat); if (false == sStatusMsg.empty()) db_set_ws(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME, sStatusMsg.c_str()); else @@ -552,7 +552,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); } if (true == bAdd) { - tstring sLogFileName = (bUseContactSpecific) + std::wstring sLogFileName = (bUseContactSpecific) ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str()) : global_settings.GetLogFileName(); @@ -562,7 +562,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat sLogFileName = GenerateLogFileName(sLogFileName, sSymbol); - tstring sFormat = global_settings.GetLogFormat(); + std::wstring sFormat = global_settings.GetLogFormat(); if (bUseContactSpecific) sFormat = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, DB_DEF_LogFormat); @@ -579,7 +579,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); } if (true == bAdd) { - tstring sFormat = (bUseContactSpecific) + std::wstring sFormat = (bUseContactSpecific) ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) : global_settings.GetHistoryFormat(); @@ -593,7 +593,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat : global_settings.GetShowPopupIfValueChangedFlag(); if ((false == bOnlyIfChanged) || ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) { - tstring sFormat = (bUseContactSpecific) + std::wstring sFormat = (bUseContactSpecific) ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) : global_settings.GetPopupFormat(); @@ -606,12 +606,12 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat SetContactStatus(hContact, ID_STATUS_ONLINE); } -MCONTACT CCurrencyRatesProviderBase::CreateNewContact(const tstring& rsName) +MCONTACT CCurrencyRatesProviderBase::CreateNewContact(const std::wstring& rsName) { MCONTACT hContact = db_add_contact(); Proto_AddToContact(hContact, MODULENAME); - tstring sProvName = GetInfo().m_sName; + std::wstring sProvName = GetInfo().m_sName; g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_PROVIDER, sProvName.c_str()); g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_SYMBOL, rsName.c_str()); db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); @@ -846,21 +846,21 @@ static bool get_fetch_time(MCONTACT hContact, time_t &rTime) return true; } -static tstring format_fetch_time(MCONTACT hContact, const tstring &rsFormat) +static std::wstring format_fetch_time(MCONTACT hContact, const std::wstring &rsFormat) { time_t nTime; if (true == get_fetch_time(hContact, nTime)) { boost::posix_time::ptime time = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(boost::posix_time::from_time_t(nTime)); - tostringstream k; + std::wostringstream k; k.imbue(std::locale(GetSystemLocale(), new ttime_facet(rsFormat.c_str()))); k << time; return k.str(); } - return tstring(); + return std::wstring(); } -static tstring format_double(double dValue, int nWidth) +static std::wstring format_double(double dValue, int nWidth) { wchar_t str[100], format[] = L"%.6lf"; if (nWidth > 0 && nWidth <= 9) @@ -869,9 +869,9 @@ static tstring format_double(double dValue, int nWidth) return str; } -tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const +std::wstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const { - tstring ret; + std::wstring ret; double d = 0.0; switch (c) { @@ -894,7 +894,7 @@ tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, i break; case 't': { - tstring sFrmt = CurrencyRates_GetDateFormat(true); + std::wstring sFrmt = CurrencyRates_GetDateFormat(true); sFrmt += L" "; sFrmt += CurrencyRates_GetTimeFormat(true); ret = format_fetch_time(hContact, sFrmt); diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h index d407a9a709..f85887887f 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h @@ -7,17 +7,17 @@ class CCurrencyRate { public: - CCurrencyRate(const tstring& rsID = L"", const tstring& rsSymbol = L"", const tstring& rsName = L"") + CCurrencyRate(const std::wstring& rsID = L"", const std::wstring& rsSymbol = L"", const std::wstring& rsName = L"") : m_sSymbol(rsSymbol), m_sName(rsName), m_sID(rsID){} - const tstring& GetSymbol() const{ return m_sSymbol; } - const tstring& GetName() const{ return m_sName; } - const tstring& GetID() const{ return m_sID; } + const std::wstring& GetSymbol() const{ return m_sSymbol; } + const std::wstring& GetName() const{ return m_sName; } + const std::wstring& GetID() const{ return m_sID; } private: - tstring m_sSymbol; - tstring m_sName; - tstring m_sID; + std::wstring m_sSymbol; + std::wstring m_sName; + std::wstring m_sID; }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -30,10 +30,10 @@ public: typedef std::vector<CCurrencyRate> TCurrencyRates; public: - CCurrencyRateSection(const tstring& rsName = L"", const TSections& raSections = TSections(), const TCurrencyRates& raCurrencyRates = TCurrencyRates()) + CCurrencyRateSection(const std::wstring& rsName = L"", const TSections& raSections = TSections(), const TCurrencyRates& raCurrencyRates = TCurrencyRates()) : m_sName(rsName), m_aSections(raSections), m_aCurrencyRates(raCurrencyRates){} - const tstring& GetName() const + const std::wstring& GetName() const { return m_sName; } @@ -59,7 +59,7 @@ public: } private: - tstring m_sName; + std::wstring m_sName; TSections m_aSections; TCurrencyRates m_aCurrencyRates; }; @@ -77,9 +77,9 @@ class CCurrencyRatesProviderBase : public ICurrencyRatesProvider HANDLE m_hEventSettingsChanged; HANDLE m_hEventRefreshContact; - tstring m_sContactListFormat; - tstring m_sStatusMsgFormat; - tstring m_sTendencyFormat; + std::wstring m_sContactListFormat; + std::wstring m_sStatusMsgFormat; + std::wstring m_sTendencyFormat; TContacts m_aRefreshingContacts; bool m_bRefreshInProgress; @@ -103,14 +103,14 @@ public: void FillFormat(TFormatSpecificators&) const override; bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d) override; - tstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const override; + std::wstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const override; protected: - const tstring& GetURL() const; - MCONTACT CreateNewContact(const tstring& rsName); + const std::wstring& GetURL() const; + MCONTACT CreateNewContact(const std::wstring& rsName); static bool IsOnline(); static void SetContactStatus(MCONTACT hContact, int nNewStatus); - void WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol = L""); + void WriteContactRate(MCONTACT hContact, double dRate, const std::wstring& rsSymbol = L""); virtual void RefreshCurrencyRates(TContacts &anContacts) = 0; diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp index 531f54d428..ef439cb2fe 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp @@ -3,9 +3,9 @@ #include <boost\property_tree\ptree.hpp> #include <boost\property_tree\json_parser.hpp> -tstring build_url(const tstring &rsURL, const tstring &from, const tstring &to) +std::wstring build_url(const std::wstring &rsURL, const std::wstring &from, const std::wstring &to) { - tostringstream o; + std::wostringstream o; o << rsURL << L"?q=" << from << L"_" << to << "&compact=ultra"; ptrA szApiKey(g_plugin.getStringA(DB_KEY_ApiKey)); if (szApiKey != nullptr) @@ -13,14 +13,14 @@ tstring build_url(const tstring &rsURL, const tstring &from, const tstring &to) return o.str(); } -tstring build_url(MCONTACT hContact, const tstring &rsURL) +std::wstring build_url(MCONTACT hContact, const std::wstring &rsURL) { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); + std::wstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + std::wstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return build_url(rsURL, sFrom, sTo); } -bool parse_responce(const tstring &rsJSON, double &dRate) +bool parse_responce(const std::wstring &rsJSON, double &dRate) { try { boost::property_tree::ptree pt; @@ -57,21 +57,21 @@ INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara return nullptr; }; - auto make_currencyrate_name = [](const CCurrencyRate &rCurrencyRate)->tstring + auto make_currencyrate_name = [](const CCurrencyRate &rCurrencyRate)->std::wstring { - const tstring& rsDesc = rCurrencyRate.GetName(); + const std::wstring& rsDesc = rCurrencyRate.GetName(); return((false == rsDesc.empty()) ? rsDesc : rCurrencyRate.GetSymbol()); }; - auto make_contact_name = [](const tstring &rsSymbolFrom, const tstring &rsSymbolTo)->tstring + auto make_contact_name = [](const std::wstring &rsSymbolFrom, const std::wstring &rsSymbolTo)->std::wstring { - tostringstream o; + std::wostringstream o; o << rsSymbolFrom << L"/" << rsSymbolTo; return o.str(); }; - auto make_rate_name = [make_contact_name](const CCurrencyRatesProviderCurrencyConverter::TRateInfo &ri)->tstring + auto make_rate_name = [make_contact_name](const CCurrencyRatesProviderCurrencyConverter::TRateInfo &ri)->std::wstring { if ((false == ri.first.GetName().empty()) && (false == ri.second.GetName().empty())) return make_contact_name(ri.first.GetName(), ri.second.GetName()); @@ -140,7 +140,7 @@ INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara auto cCurrencyRates = rSection.GetCurrencyRateCount(); for (auto i = 0u; i < cCurrencyRates; ++i) { const auto& rCurrencyRate = rSection.GetCurrencyRate(i); - tstring sName = make_currencyrate_name(rCurrencyRate); + std::wstring sName = make_currencyrate_name(rCurrencyRate); LPCTSTR pszName = sName.c_str(); ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszName)); ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszName)); @@ -151,7 +151,7 @@ INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara CCurrencyRatesProviderCurrencyConverter::TRateInfo ri; if (true == pProvider->GetWatchedRateInfo(i, ri)) { g_aWatchedRates.push_back(ri); - tstring sRate = make_rate_name(ri); + std::wstring sRate = make_rate_name(ri); LPCTSTR pszRateName = sRate.c_str(); ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszRateName)); } @@ -207,7 +207,7 @@ INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara g_aWatchedRates.push_back(ri); - tstring sRate = make_rate_name(ri); + std::wstring sRate = make_rate_name(ri); LPCTSTR pszRateName = sRate.c_str(); ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszRateName)); PropSheet_Changed(::GetParent(hdlg), hdlg); @@ -261,14 +261,14 @@ void CCurrencyRatesProviderCurrencyConverter::ShowPropertyPage(WPARAM wp, OPTION void CCurrencyRatesProviderCurrencyConverter::RefreshCurrencyRates(TContacts &anContacts) { CHTTPSession http; - tstring sURL = GetURL(); + std::wstring sURL = GetURL(); for (TContacts::const_iterator i = anContacts.begin(); i != anContacts.end() && IsOnline(); ++i) { MCONTACT hContact = *i; - tstring sFullURL = build_url(hContact, sURL); + std::wstring sFullURL = build_url(hContact, sURL); if ((true == http.OpenURL(sFullURL)) && (true == IsOnline())) { - tstring sHTML; + std::wstring sHTML; if ((true == http.ReadResponce(sHTML)) && (true == IsOnline())) { double dRate = 0.0; if ((true == parse_responce(sHTML, dRate)) && (true == IsOnline())) { @@ -284,11 +284,11 @@ void CCurrencyRatesProviderCurrencyConverter::RefreshCurrencyRates(TContacts &an double CCurrencyRatesProviderCurrencyConverter::Convert(double dAmount, const CCurrencyRate &from, const CCurrencyRate &to) const { - tstring sFullURL = build_url(GetURL(), from.GetID(), to.GetID()); + std::wstring sFullURL = build_url(GetURL(), from.GetID(), to.GetID()); CHTTPSession http; if ((true == http.OpenURL(sFullURL))) { - tstring sHTML; + std::wstring sHTML; if ((true == http.ReadResponce(sHTML))) { double dResult = 0.0; if ((true == parse_responce(sHTML, dResult))) @@ -314,10 +314,10 @@ bool CCurrencyRatesProviderCurrencyConverter::GetWatchedRateInfo(size_t nIndex, return false; MCONTACT hContact = m_aContacts[nIndex]; - tstring sSymbolFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); - tstring sSymbolTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); - tstring sDescFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_DESCRIPTION); - tstring sDescTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_DESCRIPTION); + std::wstring sSymbolFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + std::wstring sSymbolTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); + std::wstring sDescFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_DESCRIPTION); + std::wstring sDescTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_DESCRIPTION); rRateInfo.first = CCurrencyRate(sSymbolFrom, sSymbolFrom, sDescFrom); rRateInfo.second = CCurrencyRate(sSymbolTo, sSymbolTo, sDescTo); @@ -328,22 +328,22 @@ bool CCurrencyRatesProviderCurrencyConverter::WatchForRate(const TRateInfo &ri, { auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [&ri](auto hContact)->bool { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); + std::wstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + std::wstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return ((0 == mir_wstrcmpi(ri.first.GetID().c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(ri.second.GetID().c_str(), sTo.c_str()))); }); - auto make_contact_name = [](const tstring &rsSymbolFrom, const tstring &rsSymbolTo)->tstring + auto make_contact_name = [](const std::wstring &rsSymbolFrom, const std::wstring &rsSymbolTo)->std::wstring { - tostringstream o; + std::wostringstream o; o << rsSymbolFrom << L"/" << rsSymbolTo; return o.str(); }; if ((true == bWatch) && (i == m_aContacts.end())) { - tstring sName = make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); + std::wstring sName = make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); MCONTACT hContact = CreateNewContact(sName); if (hContact) { g_plugin.setWString(hContact, DB_STR_FROM_ID, ri.first.GetID().c_str()); @@ -372,14 +372,14 @@ bool CCurrencyRatesProviderCurrencyConverter::WatchForRate(const TRateInfo &ri, return false; } -MCONTACT CCurrencyRatesProviderCurrencyConverter::GetContactByID(const tstring& rsFromID, const tstring& rsToID) const +MCONTACT CCurrencyRatesProviderCurrencyConverter::GetContactByID(const std::wstring& rsFromID, const std::wstring& rsToID) const { mir_cslock lck(m_cs); auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [rsFromID, rsToID](MCONTACT hContact)->bool { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); + std::wstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + std::wstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return ((0 == mir_wstrcmpi(rsFromID.c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(rsToID.c_str(), sTo.c_str()))); }); @@ -400,7 +400,7 @@ void CCurrencyRatesProviderCurrencyConverter::FillFormat(TFormatSpecificators &a array.push_back(CFormatSpecificator(L"%s", TranslateT("Short notation for \"%f/%i\""))); } -tstring CCurrencyRatesProviderCurrencyConverter::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const +std::wstring CCurrencyRatesProviderCurrencyConverter::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const { switch (c) { case 'F': diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h index bb65f08737..4b8e15be05 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h @@ -20,7 +20,7 @@ public: size_t GetWatchedRateCount() const; bool GetWatchedRateInfo(size_t nIndex, TRateInfo &rRateInfo); bool WatchForRate(const TRateInfo &ri, bool bWatch); - MCONTACT GetContactByID(const tstring &rsFromID, const tstring &rsToID) const; + MCONTACT GetContactByID(const std::wstring &rsFromID, const std::wstring &rsToID) const; private: void FillFormat(TFormatSpecificators &) const override; @@ -28,5 +28,5 @@ private: void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE &odp) override; MCONTACT ImportContact(const TiXmlNode*) override; - tstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const override; + std::wstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const override; }; diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp index 2dcda4244a..1b35055c26 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp @@ -62,7 +62,7 @@ ICurrencyRatesProvider* GetContactProviderPtr(MCONTACT hContact) if (nullptr == szProto || 0 != ::_stricmp(szProto, MODULENAME)) return nullptr; - tstring sProvider = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_PROVIDER); + std::wstring sProvider = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_PROVIDER); if (true == sProvider.empty()) return nullptr; @@ -71,7 +71,7 @@ ICurrencyRatesProvider* GetContactProviderPtr(MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////////////// -ICurrencyRatesProvider* FindProvider(const tstring& rsName) +ICurrencyRatesProvider* FindProvider(const std::wstring& rsName) { for (auto &pProvider : g_apProviders) { const ICurrencyRatesProvider::CProviderInfo& rInfo = pProvider->GetInfo(); diff --git a/protocols/CurrencyRates/src/DBUtils.cpp b/protocols/CurrencyRates/src/DBUtils.cpp index 20189c0f3f..acc4debddb 100644 --- a/protocols/CurrencyRates/src/DBUtils.cpp +++ b/protocols/CurrencyRates/src/DBUtils.cpp @@ -35,7 +35,7 @@ bool CurrencyRates_DBReadDouble(MCONTACT hContact, const char *szModule, const c return bResult; } -void FixInvalidChars(tstring &s) +void FixInvalidChars(std::wstring &s) { for (auto &c : s) if (wcschr(L"\\/:*?\"<>|", c)) diff --git a/protocols/CurrencyRates/src/DBUtils.h b/protocols/CurrencyRates/src/DBUtils.h index f6c7f83b71..4ff975d0f1 100644 --- a/protocols/CurrencyRates/src/DBUtils.h +++ b/protocols/CurrencyRates/src/DBUtils.h @@ -41,7 +41,7 @@ #define DB_KEY_TendencyFormat "CC_TendencyFormat" #define DB_DEF_TendencyFormat L"%r>%p" -void FixInvalidChars(tstring &s); +void FixInvalidChars(std::wstring &s); std::wstring GetNodeText(const TiXmlElement*); diff --git a/protocols/CurrencyRates/src/Forex.cpp b/protocols/CurrencyRates/src/Forex.cpp index e83c319bc8..406787f59d 100644 --- a/protocols/CurrencyRates/src/Forex.cpp +++ b/protocols/CurrencyRates/src/Forex.cpp @@ -293,9 +293,6 @@ void CurrencyRates_IconsInit(); int CMPlugin::Load(void) { - if (!CModuleInfo::Verify()) - return 1; - CurrencyRates_IconsInit(); CurrencyRates_InitExtraIcons(); diff --git a/protocols/CurrencyRates/src/HTMLParserMS.cpp b/protocols/CurrencyRates/src/HTMLParserMS.cpp deleted file mode 100644 index a712d7589f..0000000000 --- a/protocols/CurrencyRates/src/HTMLParserMS.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "StdAfx.h" - -using _com_util::CheckError; - -class CHTMLNode : public IHTMLNode -{ -public: - typedef CComPtr<IDispatch> TComPtr; - typedef CComPtr<IHTMLDocument3> TDocumentPtr; - -protected: - typedef CComPtr<IHTMLElementCollection> TElementCollectionPtr; - -public: - CHTMLNode(const TComPtr& pElement, const TDocumentPtr& pDocument) - : m_pElement(pElement), m_pDocument(pDocument) - { - } - - virtual THTMLNodePtr GetElementByID(const tstring& rsID) const - { - if (m_pDocument) { - CComPtr<IHTMLElement> pElement; - if (SUCCEEDED(m_pDocument->getElementById(bstr_t(rsID.c_str()), &pElement)) - && pElement) { - TComPtr p(pElement); - return THTMLNodePtr(new CHTMLNode(p, m_pDocument)); - } - } - - return THTMLNodePtr(); - } - - virtual size_t GetChildCount() const - { - TElementCollectionPtr pColl = GetElementCollectionPtr(); - if (pColl) { - LONG celem = 0; - HRESULT hr = pColl->get_length(&celem); - if (S_OK == hr) - return celem; - } - - return 0; - } - - virtual THTMLNodePtr GetChildPtr(size_t nIndex) - { - TElementCollectionPtr pColl = GetElementCollectionPtr(); - if (pColl) { - VARIANT varIndex; - varIndex.vt = VT_UINT; - varIndex.lVal = (LONG)nIndex; - VARIANT var2; - VariantInit(&var2); - TComPtr pDisp; - HRESULT hr = pColl->item(varIndex, var2, &pDisp); - if (S_OK == hr && pDisp) - return THTMLNodePtr(new CHTMLNode(pDisp, m_pDocument)); - } - - return THTMLNodePtr(); - } - - virtual bool Is(EType nType) const - { - switch (nType) { - case Table: - { - CComPtr<IHTMLTable> pTable; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTable, reinterpret_cast<void**>(&pTable))) && (pTable)); - } - case TableRow: - { - CComPtr<IHTMLTableRow> pRow; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableRow, reinterpret_cast<void**>(&pRow))) && (pRow)); - } - case TableColumn: - { - CComPtr<IHTMLTableCol> pCol; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableCol, reinterpret_cast<void**>(&pCol))) && (pCol)); - } - } - - return false; - } - - virtual tstring GetAttribute(const tstring& rsAttrName) const - { - tstring sAttr; - CComPtr<IHTMLElement> pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&pElement))) && pElement) { - _variant_t vAttribute; - BSTR pbstrAttrName = ::SysAllocString(rsAttrName.c_str()); - if (SUCCEEDED(pElement->getAttribute(pbstrAttrName, 1, &vAttribute)) && VT_NULL != vAttribute.vt && VT_EMPTY != vAttribute.vt) { - try { - _bstr_t b(vAttribute); - LPCTSTR psz = b; - if (psz) - sAttr = psz; - } - catch (_com_error&) { - } - } - ::SysFreeString(pbstrAttrName); - } - - return sAttr; - } - - virtual tstring GetText() const - { - tstring sText; - CComPtr<IHTMLElement> pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&pElement))) && pElement) { - BSTR bstrText; - if (SUCCEEDED(pElement->get_innerText(&bstrText)) && bstrText) { - try { - sText = _bstr_t(bstrText); - } - catch (_com_error&) { - } - - ::SysFreeString(bstrText); - } - } - - return sText; - } - -protected: - virtual TElementCollectionPtr GetElementCollectionPtr() const - { - TElementCollectionPtr pColl; - HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElementCollection, reinterpret_cast<void**>(&pColl)); - if (FAILED(hr)) { - CComPtr<IHTMLElement> pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&pElement))) && pElement) { - CComPtr<IDispatch> pDisp; - if (SUCCEEDED(pElement->get_children(&pDisp)) && pDisp) - pDisp->QueryInterface(IID_IHTMLElementCollection, reinterpret_cast<void**>(&pColl)); - } - } - - return pColl; - } - -private: - TComPtr m_pElement; - TDocumentPtr m_pDocument; -}; - -CHTMLParserMS::CHTMLParserMS() : m_bCallUninit(false) -{ - try { - CheckError(::CoInitialize(nullptr)); - - m_bCallUninit = true; - - _com_util::CheckError( - ::CoCreateInstance(CLSID_HTMLDocument, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IHTMLDocument2, - (LPVOID*)&m_pDoc) - ); - - CComPtr<IPersistStreamInit> pPersist; - _com_util::CheckError(m_pDoc->QueryInterface(IID_IPersistStreamInit, - (LPVOID*)&pPersist)); - - _com_util::CheckError(pPersist->InitNew()); - - _com_util::CheckError(m_pDoc->QueryInterface(IID_IMarkupServices, - (LPVOID*)&m_pMS)); - - if (m_pMS) { - _com_util::CheckError(m_pMS->CreateMarkupPointer(&m_pMkStart)); - _com_util::CheckError(m_pMS->CreateMarkupPointer(&m_pMkFinish)); - } - } - catch (_com_error&/* e*/) { - // show_com_error_msg(e); - } -} - -CHTMLParserMS::~CHTMLParserMS() -{ - if (m_bCallUninit) - ::CoUninitialize(); -} - -CHTMLParserMS::THTMLNodePtr CHTMLParserMS::ParseString(const tstring& rsHTML) -{ - mir_cslock lck(m_cs); - - CComPtr<IMarkupContainer> pMC; - HRESULT hr = m_pMS->ParseString((OLECHAR*)rsHTML.c_str(), 0, &pMC, m_pMkStart, m_pMkFinish); - if (SUCCEEDED(hr) && pMC) { - CComPtr<IHTMLDocument2> pNewDoc; - hr = pMC->QueryInterface(IID_IHTMLDocument, (LPVOID*)&pNewDoc); - if (SUCCEEDED(hr) && pNewDoc) { - CComPtr<IHTMLElementCollection> pColl; - pNewDoc->get_all(&pColl); - - CHTMLNode::TDocumentPtr pDoc; - pMC->QueryInterface(IID_IHTMLDocument3, (LPVOID*)&pDoc); - return THTMLNodePtr(new CHTMLNode(CHTMLNode::TComPtr(pColl), pDoc)); - } - } - - return THTMLNodePtr(); -} - -bool CHTMLParserMS::IsInstalled() -{ - bool bResult = true; - bool bCallUninit = false; - try { - CheckError(::CoInitialize(nullptr)); - - bCallUninit = true; - - CComPtr<IHTMLDocument2> pDoc; - _com_util::CheckError( - ::CoCreateInstance(CLSID_HTMLDocument, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IHTMLDocument2, - reinterpret_cast<LPVOID*>(&pDoc)) - ); - } - catch (_com_error&/* e*/) { - bResult = false; - } - - if (bCallUninit) - ::CoUninitialize(); - - return bResult; -} - -CHTMLEngineMS::CHTMLEngineMS() -{ -} - -CHTMLEngineMS::~CHTMLEngineMS() -{ -} - -CHTMLEngineMS::THTMLParserPtr CHTMLEngineMS::GetParserPtr() const -{ - return THTMLParserPtr(new CHTMLParserMS); -} diff --git a/protocols/CurrencyRates/src/HTMLParserMS.h b/protocols/CurrencyRates/src/HTMLParserMS.h deleted file mode 100644 index 6b2ceb26d8..0000000000 --- a/protocols/CurrencyRates/src/HTMLParserMS.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ -#define __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ - -class CHTMLParserMS : public IHTMLParser -{ -public: - CHTMLParserMS(); - ~CHTMLParserMS(); - - virtual THTMLNodePtr ParseString(const tstring& rsHTML); - - static bool IsInstalled(); - -private: - bool m_bCallUninit; - CComPtr<IHTMLDocument2> m_pDoc; - CComPtr<IMarkupServices> m_pMS; - CComPtr<IMarkupPointer> m_pMkStart; - CComPtr<IMarkupPointer> m_pMkFinish; - mutable mir_cs m_cs; -}; - -class CHTMLEngineMS : public IHTMLEngine -{ -public: - CHTMLEngineMS(); - ~CHTMLEngineMS(); - - virtual THTMLParserPtr GetParserPtr() const; -}; - -#endif //__3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp index 6227f1b12a..12b556ab38 100644 --- a/protocols/CurrencyRates/src/HTTPSession.cpp +++ b/protocols/CurrencyRates/src/HTTPSession.cpp @@ -19,14 +19,14 @@ static int find_header(const NETLIBHTTPREQUEST* pRequest, const char* hdr) return -1; } -bool CHTTPSession::OpenURL(const tstring &rsURL) +bool CHTTPSession::OpenURL(const std::wstring &rsURL) { std::string s = currencyrates_t2a(rsURL.c_str()); m_szUrl = s.c_str(); return true; } -bool CHTTPSession::ReadResponce(tstring &rsResponce) +bool CHTTPSession::ReadResponce(std::wstring &rsResponce) { if (m_szUrl.IsEmpty()) return false; diff --git a/protocols/CurrencyRates/src/HTTPSession.h b/protocols/CurrencyRates/src/HTTPSession.h index 9928c58304..35cdbcee63 100644 --- a/protocols/CurrencyRates/src/HTTPSession.h +++ b/protocols/CurrencyRates/src/HTTPSession.h @@ -13,8 +13,8 @@ public: static bool Init(); - bool OpenURL(const tstring &rsURL); - bool ReadResponce(tstring &rsResponce); + bool OpenURL(const std::wstring &rsURL); + bool ReadResponce(std::wstring &rsResponce); }; #endif //__8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ diff --git a/protocols/CurrencyRates/src/ICurrencyRatesProvider.h b/protocols/CurrencyRates/src/ICurrencyRatesProvider.h index a80cae3088..7c91e60ac1 100644 --- a/protocols/CurrencyRates/src/ICurrencyRatesProvider.h +++ b/protocols/CurrencyRates/src/ICurrencyRatesProvider.h @@ -8,7 +8,7 @@ class CCurrencyRatesProviderVisitor; ///////////////////////////////////////////////////////////////////////////////////////// // CFormatSpecificator - array of variables to replace -using CFormatSpecificator = std::pair<tstring, tstring>; +using CFormatSpecificator = std::pair<std::wstring, std::wstring>; typedef std::vector<CFormatSpecificator> TFormatSpecificators; ///////////////////////////////////////////////////////////////////////////////////////// @@ -19,8 +19,8 @@ class ICurrencyRatesProvider : private boost::noncopyable public: struct CProviderInfo { - tstring m_sName; - tstring m_sURL; + std::wstring m_sName; + std::wstring m_sURL; }; public: @@ -42,7 +42,7 @@ public: virtual void FillFormat(TFormatSpecificators&) const = 0; virtual bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d) = 0; - virtual tstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const = 0; + virtual std::wstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const = 0; virtual void Run() = 0; }; @@ -52,7 +52,7 @@ public: typedef std::vector<ICurrencyRatesProvider*> TCurrencyRatesProviders; extern TCurrencyRatesProviders g_apProviders; -ICurrencyRatesProvider* FindProvider(const tstring& rsName); +ICurrencyRatesProvider* FindProvider(const std::wstring& rsName); ICurrencyRatesProvider* GetContactProviderPtr(MCONTACT hContact); void InitProviders(); diff --git a/protocols/CurrencyRates/src/IHTMLEngine.h b/protocols/CurrencyRates/src/IHTMLEngine.h deleted file mode 100644 index 6cc9defce7..0000000000 --- a/protocols/CurrencyRates/src/IHTMLEngine.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__ -#define __85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__ - -class IHTMLParser; - -class IHTMLEngine -{ -public: - typedef boost::shared_ptr<IHTMLParser> THTMLParserPtr; - -public: - IHTMLEngine(void){} - virtual ~IHTMLEngine() {} - - virtual THTMLParserPtr GetParserPtr() const = 0; -}; - -#endif //__85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__ diff --git a/protocols/CurrencyRates/src/IHTMLParser.h b/protocols/CurrencyRates/src/IHTMLParser.h deleted file mode 100644 index c0b97a7277..0000000000 --- a/protocols/CurrencyRates/src/IHTMLParser.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__ -#define __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__ - -class IHTMLNode -{ -public: - typedef boost::shared_ptr<IHTMLNode> THTMLNodePtr; - - enum EType - { - Table = 1, - TableRow, - TableColumn - }; - -public: - IHTMLNode() {} - virtual ~IHTMLNode() {} - - virtual size_t GetChildCount() const = 0; - virtual THTMLNodePtr GetChildPtr(size_t nIndex) = 0; - virtual bool Is(EType nType) const = 0; - - virtual THTMLNodePtr GetElementByID(const tstring& rsID) const = 0; - - virtual tstring GetAttribute(const tstring& rsAttrName) const = 0; - virtual tstring GetText() const = 0; -}; - -class IHTMLParser -{ -public: - typedef IHTMLNode::THTMLNodePtr THTMLNodePtr; -public: - IHTMLParser() {} - virtual ~IHTMLParser() {} - - virtual THTMLNodePtr ParseString(const tstring& rsHTML) = 0; -}; - -#endif //__98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__ diff --git a/protocols/CurrencyRates/src/ImportExport.cpp b/protocols/CurrencyRates/src/ImportExport.cpp index fb78dd038b..fbdb257d32 100644 --- a/protocols/CurrencyRates/src/ImportExport.cpp +++ b/protocols/CurrencyRates/src/ImportExport.cpp @@ -161,7 +161,7 @@ LPCTSTR prepare_filter(LPTSTR pszBuffer, size_t cBuffer) return pszBuffer; } -bool show_open_file_dialog(bool bOpen, tstring& rsFile) +bool show_open_file_dialog(bool bOpen, std::wstring& rsFile) { wchar_t szBuffer[MAX_PATH]; wchar_t szFilter[MAX_PATH]; @@ -198,7 +198,7 @@ bool show_open_file_dialog(bool bOpen, tstring& rsFile) INT_PTR CurrencyRates_Export(WPARAM wp, LPARAM lp) { - tstring sFileName; + std::wstring sFileName; const char* pszFile = reinterpret_cast<const char*>(lp); if (nullptr == pszFile) { if (false == show_open_file_dialog(false, sFileName)) @@ -485,7 +485,7 @@ bool do_import(const TiXmlNode *pXmlRoot, UINT nFlags) INT_PTR CurrencyRates_Import(WPARAM wp, LPARAM lp) { - tstring sFileName; + std::wstring sFileName; const char* pszFile = reinterpret_cast<const char*>(lp); if (nullptr == pszFile) { if (false == show_open_file_dialog(true, sFileName)) diff --git a/protocols/CurrencyRates/src/Locale.cpp b/protocols/CurrencyRates/src/Locale.cpp index 501015eb21..0e112749c4 100644 --- a/protocols/CurrencyRates/src/Locale.cpp +++ b/protocols/CurrencyRates/src/Locale.cpp @@ -5,9 +5,9 @@ const std::locale GetSystemLocale() return std::locale(""); } -tstring get_int_registry_value(LPCTSTR pszValueName) +std::wstring get_int_registry_value(LPCTSTR pszValueName) { - tstring sResult; + std::wstring sResult; HKEY hKey = nullptr; LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, L"Control Panel\\International", 0, KEY_QUERY_VALUE, &hKey); @@ -31,7 +31,7 @@ tstring get_int_registry_value(LPCTSTR pszValueName) return sResult; } -LPCTSTR date_win_2_boost(const tstring& sFrmt) +LPCTSTR date_win_2_boost(const std::wstring& sFrmt) { if (sFrmt == L"dd/MM/yy") return L"%d/%m/%y"; @@ -40,7 +40,7 @@ LPCTSTR date_win_2_boost(const tstring& sFrmt) return L"%d.%m.%y"; } -LPCTSTR time_win_2_boost(const tstring& sFrmt) +LPCTSTR time_win_2_boost(const std::wstring& sFrmt) { if (sFrmt == L"H:mm" || sFrmt == L"HH:mm") return L"%H:%M"; diff --git a/protocols/CurrencyRates/src/Log.cpp b/protocols/CurrencyRates/src/Log.cpp index 7930ac5f4f..e0a4141a49 100644 --- a/protocols/CurrencyRates/src/Log.cpp +++ b/protocols/CurrencyRates/src/Log.cpp @@ -4,7 +4,7 @@ namespace { mir_cs g_Mutex; - tstring get_log_file_name() + std::wstring get_log_file_name() { return CreateFilePath(L"CurrencyRates.log"); } @@ -18,10 +18,10 @@ namespace #endif } - void do_log(const tstring& rsFileName, const tstring& rsMsg) + void do_log(const std::wstring& rsFileName, const std::wstring& rsMsg) { mir_cslock lck(g_Mutex); - tofstream file(rsFileName.c_str(), std::ios::ate | std::ios::app); + std::wofstream file(rsFileName.c_str(), std::ios::ate | std::ios::app); if (file.good()) { wchar_t szTime[20]; @@ -31,11 +31,11 @@ namespace } } -void LogIt(const tstring& rsMsg) +void LogIt(const std::wstring& rsMsg) { if (is_log_enabled()) { - tstring sFileName = get_log_file_name(); + std::wstring sFileName = get_log_file_name(); do_log(sFileName, rsMsg); } } diff --git a/protocols/CurrencyRates/src/Log.h b/protocols/CurrencyRates/src/Log.h index b62ae9ac52..e8eab88533 100644 --- a/protocols/CurrencyRates/src/Log.h +++ b/protocols/CurrencyRates/src/Log.h @@ -8,6 +8,6 @@ enum ESeverity Error }; -void LogIt(const tstring& rsMsg); +void LogIt(const std::wstring& rsMsg); #endif //__653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__ diff --git a/protocols/CurrencyRates/src/ModuleInfo.cpp b/protocols/CurrencyRates/src/ModuleInfo.cpp index 172f2ba884..e44985777a 100644 --- a/protocols/CurrencyRates/src/ModuleInfo.cpp +++ b/protocols/CurrencyRates/src/ModuleInfo.cpp @@ -1,7 +1,6 @@ #include "StdAfx.h" static CModuleInfo mi; -static CModuleInfo::THTMLEnginePtr g_pHTMLEngine; static mir_cs g_lmParsers; typedef std::map<std::string, MWindowList> THandles; @@ -28,37 +27,3 @@ 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; -} diff --git a/protocols/CurrencyRates/src/ModuleInfo.h b/protocols/CurrencyRates/src/ModuleInfo.h index 39399f5c43..23c2c40549 100644 --- a/protocols/CurrencyRates/src/ModuleInfo.h +++ b/protocols/CurrencyRates/src/ModuleInfo.h @@ -2,22 +2,15 @@ #define __d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__ class CCurrencyRatesProviders; -class IHTMLEngine; class CModuleInfo { public: typedef boost::shared_ptr<CCurrencyRatesProviders> TCurrencyRatesProvidersPtr; - typedef boost::shared_ptr<IHTMLEngine> THTMLEnginePtr; public: static void OnMirandaShutdown(void); static MWindowList GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist = true); - - static bool Verify(); - - static THTMLEnginePtr GetHTMLEngine(); - static void SetHTMLEngine(THTMLEnginePtr pEngine); }; #endif //__d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__ diff --git a/protocols/CurrencyRates/src/SettingsDlg.cpp b/protocols/CurrencyRates/src/SettingsDlg.cpp index f865c1a51a..18b5c768b6 100644 --- a/protocols/CurrencyRates/src/SettingsDlg.cpp +++ b/protocols/CurrencyRates/src/SettingsDlg.cpp @@ -73,7 +73,7 @@ std::vector<wchar_t> get_filter() std::vector<wchar_t> aFilter; LPCTSTR pszFilterParts[] = { LPGENW("Log Files (*.txt,*.log)"), L"*.txt;*.log", LPGENW("All files (*.*)"), L"*.*" }; for (int i = 0; i < sizeof(pszFilterParts) / sizeof(pszFilterParts[0]); ++i) { - tstring sPart = TranslateW(pszFilterParts[i]); + std::wstring sPart = TranslateW(pszFilterParts[i]); std::copy(sPart.begin(), sPart.end(), std::back_inserter(aFilter)); aFilter.push_back('\0'); @@ -242,7 +242,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L assert(hWL); WindowList_Add(hWL, hWnd, hContact); - tstring sName = GetContactName(hContact); + std::wstring sName = GetContactName(hContact); ::SetDlgItemText(hWnd, IDC_EDIT_NAME, sName.c_str()); BYTE bUseContactSpecific = g_plugin.getByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 0); @@ -255,7 +255,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L UINT nCheck = (dwLogMode & lmInternalHistory) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sHistoryFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat().c_str()); + std::wstring sHistoryFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, sHistoryFrmt.c_str()); WORD wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag()); @@ -265,13 +265,13 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L nCheck = (dwLogMode & lmExternalFile) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sLogFileName = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE); + std::wstring sLogFileName = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE); if (true == sLogFileName.empty()) { sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName); } ::SetDlgItemText(hWnd, IDC_EDIT_FILE_NAME, sLogFileName.c_str()); - tstring sLogFileFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat().c_str()); + std::wstring sLogFileFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_LOG_FILE_FORMAT, sLogFileFrmt.c_str()); wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag()); @@ -280,7 +280,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L // popup nCheck = (dwLogMode & lmPopup) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sPopupFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()); + std::wstring sPopupFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, sPopupFrmt.c_str()); bool bOnlyIfChanged = 1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag()); ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); @@ -363,9 +363,9 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L HWND hwndLogFile = ::GetDlgItem(hWnd, IDC_EDIT_FILE_NAME); HWND hwndLogFileFrmt = ::GetDlgItem(hWnd, IDC_EDIT_LOG_FILE_FORMAT); HWND hwndHistoryFrmt = ::GetDlgItem(hWnd, IDC_EDIT_HISTORY_FORMAT); - tstring sLogFile = get_window_text(hwndLogFile); - tstring sLogFileFormat = get_window_text(hwndLogFileFrmt); - tstring sHistoryFormat = get_window_text(hwndHistoryFrmt); + std::wstring sLogFile = get_window_text(hwndLogFile); + std::wstring sLogFileFormat = get_window_text(hwndLogFileFrmt); + std::wstring sHistoryFormat = get_window_text(hwndHistoryFrmt); if ((nLogMode & lmExternalFile)) { if (true == sLogFile.empty()) { prepare_edit_ctrl_for_error(hwndLogFile); @@ -386,7 +386,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L } HWND hwndPopupFrmt = ::GetDlgItem(hWnd, IDC_EDIT_POPUP_FORMAT); - tstring sPopupFormat = get_window_text(hwndPopupFrmt); + std::wstring sPopupFormat = get_window_text(hwndPopupFrmt); if ((true == bOk) && (nLogMode & lmPopup) && (true == sPopupFormat.empty())) { prepare_edit_ctrl_for_error(hwndPopupFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter popup window format."), MB_OK | MB_ICONERROR); @@ -519,8 +519,8 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, HWND hwndLogFile = ::GetDlgItem(hWnd, IDC_EDIT_FILE_NAME); HWND hwndLogFileFrmt = ::GetDlgItem(hWnd, IDC_EDIT_LOG_FILE_FORMAT); - tstring sLogFile = get_window_text(hwndLogFile); - tstring sLogFileFormat = get_window_text(hwndLogFileFrmt); + std::wstring sLogFile = get_window_text(hwndLogFile); + std::wstring sLogFileFormat = get_window_text(hwndLogFileFrmt); if ((nLogMode & lmExternalFile)) { if (true == sLogFile.empty()) { @@ -536,7 +536,7 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, } HWND hwndHistoryFrmt = ::GetDlgItem(hWnd, IDC_EDIT_HISTORY_FORMAT); - tstring sHistoryFormat = get_window_text(hwndHistoryFrmt); + std::wstring sHistoryFormat = get_window_text(hwndHistoryFrmt); if ((true == bOk) && (nLogMode & lmInternalHistory) && (true == sHistoryFormat.empty())) { prepare_edit_ctrl_for_error(hwndHistoryFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter history format."), MB_OK | MB_ICONERROR); @@ -544,7 +544,7 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, } HWND hwndPopupFrmt = ::GetDlgItem(hWnd, IDC_EDIT_POPUP_FORMAT); - tstring sPopupFormat = get_window_text(hwndPopupFrmt); + std::wstring sPopupFormat = get_window_text(hwndPopupFrmt); if ((true == bOk) && (nLogMode & lmPopup) && (true == sPopupFormat.empty())) { prepare_edit_ctrl_for_error(hwndPopupFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter popup window format."), MB_OK | MB_ICONERROR); @@ -684,12 +684,12 @@ void CAdvProviderSettings::SetLogMode(WORD wMode) m_wLogMode = wMode; } -tstring CAdvProviderSettings::GetHistoryFormat() const +std::wstring CAdvProviderSettings::GetHistoryFormat() const { return m_sFormatHistory; } -void CAdvProviderSettings::SetHistoryFormat(const tstring &rsFormat) +void CAdvProviderSettings::SetHistoryFormat(const std::wstring &rsFormat) { m_sFormatHistory = rsFormat; } @@ -704,22 +704,22 @@ void CAdvProviderSettings::SetHistoryOnlyChangedFlag(bool bMode) m_bIsOnlyChangedHistory = bMode; } -tstring CAdvProviderSettings::GetLogFileName() const +std::wstring CAdvProviderSettings::GetLogFileName() const { return m_sLogFileName; } -void CAdvProviderSettings::SetLogFileName(const tstring &rsFile) +void CAdvProviderSettings::SetLogFileName(const std::wstring &rsFile) { m_sLogFileName = rsFile; } -tstring CAdvProviderSettings::GetLogFormat() const +std::wstring CAdvProviderSettings::GetLogFormat() const { return m_sFormatLogFile; } -void CAdvProviderSettings::SetLogFormat(const tstring &rsFormat) +void CAdvProviderSettings::SetLogFormat(const std::wstring &rsFormat) { m_sFormatLogFile = rsFormat; } @@ -734,12 +734,12 @@ void CAdvProviderSettings::SetLogOnlyChangedFlag(bool bMode) m_bIsOnlyChangedLogFile = bMode; } -const tstring &CAdvProviderSettings::GetPopupFormat() const +const std::wstring &CAdvProviderSettings::GetPopupFormat() const { return m_sPopupFormat; } -void CAdvProviderSettings::SetPopupFormat(const tstring &val) +void CAdvProviderSettings::SetPopupFormat(const std::wstring &val) { m_sPopupFormat = val; } @@ -900,15 +900,15 @@ bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings *pAdvSettings) reinterpret_cast<LPARAM>(pAdvSettings))); } -tstring GenerateLogFileName(const tstring &rsLogFilePattern, const tstring &rsCurrencyRateSymbol, int nFlags) +std::wstring GenerateLogFileName(const std::wstring &rsLogFilePattern, const std::wstring &rsCurrencyRateSymbol, int nFlags) { - tstring sPath = rsLogFilePattern; + std::wstring sPath = rsLogFilePattern; if (nFlags & glfnResolveCurrencyRateName) { assert(false == rsCurrencyRateSymbol.empty()); - tstring::size_type n = sPath.find(g_pszVariableCurrencyRateName); - if (tstring::npos != n) { - tstring s = rsCurrencyRateSymbol; + std::wstring::size_type n = sPath.find(g_pszVariableCurrencyRateName); + if (std::wstring::npos != n) { + std::wstring s = rsCurrencyRateSymbol; FixInvalidChars(s); sPath.replace(n, _countof(g_pszVariableCurrencyRateName) - 1, s.c_str()); } @@ -925,13 +925,13 @@ tstring GenerateLogFileName(const tstring &rsLogFilePattern, const tstring &rsCu return sPath; } -tstring GetContactLogFileName(MCONTACT hContact) +std::wstring GetContactLogFileName(MCONTACT hContact) { - tstring result; + std::wstring result; auto pProvider = GetContactProviderPtr(hContact); if (pProvider) { - tstring sPattern; + std::wstring sPattern; bool bUseContactSpecific = (g_plugin.getByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); if (bUseContactSpecific) sPattern = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE); @@ -946,9 +946,9 @@ tstring GetContactLogFileName(MCONTACT hContact) return result; } -tstring GetContactName(MCONTACT hContact) +std::wstring GetContactName(MCONTACT hContact) { - tstring sDescription = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_DESCRIPTION); + std::wstring sDescription = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_DESCRIPTION); if (sDescription.empty()) sDescription = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL); diff --git a/protocols/CurrencyRates/src/SettingsDlg.h b/protocols/CurrencyRates/src/SettingsDlg.h index b6b49b97bd..424b8c2eed 100644 --- a/protocols/CurrencyRates/src/SettingsDlg.h +++ b/protocols/CurrencyRates/src/SettingsDlg.h @@ -66,20 +66,20 @@ public: WORD GetLogMode() const; void SetLogMode(WORD wMode); - tstring GetHistoryFormat() const; - void SetHistoryFormat(const tstring& rsFormat); + std::wstring GetHistoryFormat() const; + void SetHistoryFormat(const std::wstring& rsFormat); bool GetHistoryOnlyChangedFlag() const; void SetHistoryOnlyChangedFlag(bool bMode); - tstring GetLogFileName() const; - void SetLogFileName(const tstring& rsFile); - tstring GetLogFormat() const; - void SetLogFormat(const tstring& rsFormat); + std::wstring GetLogFileName() const; + void SetLogFileName(const std::wstring& rsFile); + std::wstring GetLogFormat() const; + void SetLogFormat(const std::wstring& rsFormat); bool GetLogOnlyChangedFlag() const; void SetLogOnlyChangedFlag(bool bMode); - const tstring& GetPopupFormat() const; - void SetPopupFormat(const tstring& val); + const std::wstring& GetPopupFormat() const; + void SetPopupFormat(const std::wstring& val); bool GetShowPopupIfValueChangedFlag() const; void SetShowPopupIfValueChangedFlag(bool val); @@ -89,12 +89,12 @@ public: private: const ICurrencyRatesProvider *m_pCurrencyRatesProvider; WORD m_wLogMode; - tstring m_sFormatHistory; + std::wstring m_sFormatHistory; bool m_bIsOnlyChangedHistory; - tstring m_sLogFileName; - tstring m_sFormatLogFile; + std::wstring m_sLogFileName; + std::wstring m_sFormatLogFile; bool m_bIsOnlyChangedLogFile; - tstring m_sPopupFormat; + std::wstring m_sPopupFormat; bool m_bShowPopupIfValueChanged; mutable CPopupSettings* m_pPopupSettings; }; @@ -108,9 +108,9 @@ enum glfnResolveUserProfile = 0x0002, glfnResolveAll = glfnResolveCurrencyRateName | glfnResolveUserProfile, }; -tstring GenerateLogFileName(const tstring& rsLogFilePattern, const tstring& rsCurrencyRateSymbol, int nFlags = glfnResolveAll); -tstring GetContactLogFileName(MCONTACT hContact); -tstring GetContactName(MCONTACT hContact); +std::wstring GenerateLogFileName(const std::wstring& rsLogFilePattern, const std::wstring& rsCurrencyRateSymbol, int nFlags = glfnResolveAll); +std::wstring GetContactLogFileName(MCONTACT hContact); +std::wstring GetContactName(MCONTACT hContact); #endif //__E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__ diff --git a/protocols/CurrencyRates/src/WinCtrlHelper.cpp b/protocols/CurrencyRates/src/WinCtrlHelper.cpp index f45c4db536..22dd5e0641 100644 --- a/protocols/CurrencyRates/src/WinCtrlHelper.cpp +++ b/protocols/CurrencyRates/src/WinCtrlHelper.cpp @@ -17,7 +17,7 @@ public: TFormatSpecificators aSpecificators; m_pProvider->FillFormat(aSpecificators); - tostringstream o; + std::wostringstream o; for (auto &spec : aSpecificators) o << spec.first << '\t' << spec.second << L"\r\n"; ::SetDlgItemText(m_hwnd, IDC_EDIT_VARIABLE, o.str().c_str()); diff --git a/protocols/CurrencyRates/src/WinCtrlHelper.h b/protocols/CurrencyRates/src/WinCtrlHelper.h index a770072bd6..7cb2c0515e 100644 --- a/protocols/CurrencyRates/src/WinCtrlHelper.h +++ b/protocols/CurrencyRates/src/WinCtrlHelper.h @@ -3,7 +3,7 @@ class ICurrencyRatesProvider; -inline tstring get_window_text(HWND hWnd) +inline std::wstring get_window_text(HWND hWnd) { int cBytes = ::GetWindowTextLength(hWnd); @@ -11,7 +11,7 @@ inline tstring get_window_text(HWND hWnd) LPTSTR pBuffer = &*(aBuf.begin()); ::GetWindowText(hWnd, pBuffer, cBytes + 1); - return tstring(pBuffer); + return std::wstring(pBuffer); } inline void prepare_edit_ctrl_for_error(HWND hwndEdit) diff --git a/protocols/CurrencyRates/src/stdafx.h b/protocols/CurrencyRates/src/stdafx.h index 0d44c339f5..987aeb87b8 100644 --- a/protocols/CurrencyRates/src/stdafx.h +++ b/protocols/CurrencyRates/src/stdafx.h @@ -40,13 +40,6 @@ #include <boost\date_time\posix_time\posix_time.hpp> #include <boost\date_time\c_local_time_adjustor.hpp> -typedef std::wstring tstring; -typedef std::wostringstream tostringstream; -typedef std::wistringstream tistringstream; -typedef std::wofstream tofstream; -typedef std::wifstream tifstream; -typedef std::wostream tostream; -typedef std::wistream tistream; typedef boost::posix_time::wtime_input_facet ttime_input_facet; typedef boost::posix_time::wtime_facet ttime_facet; @@ -61,9 +54,9 @@ inline std::string currencyrates_t2a(const wchar_t* t) return s; } -inline tstring currencyrates_a2t(const char* s) +inline std::wstring currencyrates_a2t(const char* s) { - tstring t; + std::wstring t; wchar_t* p = mir_a2u(s); if (p) { t = p; @@ -81,7 +74,6 @@ inline tstring currencyrates_a2t(const char* s) #include "CurrencyConverter.h" #include "WinCtrlHelper.h" #include "ImportExport.h" -#include "ComHelper.h" #include "Log.h" #include "CommonOptionDlg.h" #include "EconomicRateInfo.h" @@ -98,9 +90,6 @@ inline tstring currencyrates_a2t(const char* s) #include "CurrencyRateChart.h" #include "Chart.h" #endif -#include "IHTMLParser.h" -#include "IHTMLEngine.h" -#include "HTMLParserMS.h" struct CMPlugin : public PLUGIN<CMPlugin> { |