summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-21 14:59:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-21 14:59:21 +0300
commit98e5dab950ab976bbf244dc21e7bfe2353722d45 (patch)
tree5f937fa1375e3803091fbf984fd983aaf3d0527b /plugins/CurrencyRates
parenta7d1b6c89d200736226183753ffc88f094c3bc16 (diff)
crap with Visitor class totally destroyed
Diffstat (limited to 'plugins/CurrencyRates')
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp123
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderBase.h5
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp43
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h4
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderVisitor.h25
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp122
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.h26
-rw-r--r--plugins/CurrencyRates/src/ICurrencyRatesProvider.h5
-rw-r--r--plugins/CurrencyRates/src/ImportExport.cpp49
-rw-r--r--plugins/CurrencyRates/src/ImportExport.h3
-rw-r--r--plugins/CurrencyRates/src/stdafx.h3
11 files changed, 146 insertions, 262 deletions
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
index b44d01aedb..6193a85389 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
@@ -380,10 +380,7 @@ tstring format_rate(const ICurrencyRatesProvider *pProvider, MCONTACT hContact,
else chr = *i;
}
- CCurrencyRatesProviderVisitorFormater visitor(hContact, chr, nWidth);
- pProvider->Accept(visitor);
- const tstring& s = visitor.GetResult();
- sResult += s;
+ sResult += pProvider->FormatSymbol(hContact, chr, nWidth);
++i;
}
else sResult += chr;
@@ -399,15 +396,7 @@ void log_to_file(const ICurrencyRatesProvider* pProvider,
const tstring& rsLogFileName,
const tstring& rsFormat)
{
- std::string sPath = currencyrates_t2a(rsLogFileName.c_str());
-
- std::string::size_type n = sPath.find_last_of("\\/");
- if (std::string::npos != n)
- sPath.erase(n);
-
- DWORD dwAttributes = ::GetFileAttributesA(sPath.c_str());
- if ((0xffffffff == dwAttributes) || (0 == (dwAttributes&FILE_ATTRIBUTE_DIRECTORY)))
- CreateDirectoryTree(sPath.c_str());
+ CreatePathToFileW(rsLogFileName.c_str());
tofstream file(rsLogFileName.c_str(), std::ios::app | std::ios::out);
file.imbue(GetSystemLocale());
@@ -474,10 +463,7 @@ bool show_popup(const ICurrencyRatesProvider* pProvider,
ppd.lchIcon = CurrencyRates_LoadIconEx(IDI_ICON_DOWN);
}
- CCurrencyRatesProviderVisitorFormater visitor(hContact, 's', 0);
- pProvider->Accept(visitor);
- const tstring& sTitle = visitor.GetResult();
- mir_wstrncpy(ppd.lptzContactName, sTitle.c_str(), MAX_CONTACTNAME);
+ mir_wstrncpy(ppd.lptzContactName, 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));
@@ -769,10 +755,8 @@ void CCurrencyRatesProviderBase::Run()
m_aRefreshingContacts.clear();
}
- {
- CBoolGuard bg(m_bRefreshInProgress);
- RefreshCurrencyRates(anContacts);
- }
+ CBoolGuard bg(m_bRefreshInProgress);
+ RefreshCurrencyRates(anContacts);
}
break;
@@ -810,11 +794,6 @@ void CCurrencyRatesProviderBase::OnEndRun()
SetContactStatus(it, ID_STATUS_OFFLINE);
}
-void CCurrencyRatesProviderBase::Accept(CCurrencyRatesProviderVisitor &visitor) const
-{
- visitor.Visit(*this);
-}
-
void CCurrencyRatesProviderBase::RefreshSettings()
{
::SetEvent(m_hEventSettingsChanged);
@@ -866,4 +845,94 @@ bool CCurrencyRatesProviderBase::ParseSymbol(MCONTACT hContact, wchar_t c, doubl
}
return false;
-} \ No newline at end of file
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static bool get_fetch_time(MCONTACT hContact, time_t &rTime)
+{
+ DBVARIANT dbv;
+ if (db_get(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type))
+ return false;
+
+ rTime = dbv.dVal;
+ return true;
+}
+
+static tstring format_fetch_time(MCONTACT hContact, const tstring &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;
+ k.imbue(std::locale(GetSystemLocale(), new ttime_facet(rsFormat.c_str())));
+ k << time;
+ return k.str();
+ }
+
+ return tstring();
+}
+
+static tstring format_double(double dValue, int nWidth)
+{
+ tostringstream o;
+ o.imbue(GetSystemLocale());
+
+ if (nWidth > 0 && nWidth <= 9)
+ o << std::setprecision(nWidth) << std::showpoint << std::fixed;
+
+ o << dValue;
+
+ return o.str();
+}
+
+tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const
+{
+ tstring ret;
+ double d = 0.0;
+
+ switch (c) {
+ case '%':
+ case '\t':
+ case '\\':
+ ret = c;
+ break;
+ case 'S':
+ ret = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER);
+ break;
+ case 's':
+ ret = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL);
+ break;
+ case 'X':
+ ret = format_fetch_time(hContact, CurrencyRates_GetTimeFormat(true));
+ break;
+ case 'x':
+ ret = format_fetch_time(hContact, CurrencyRates_GetDateFormat(true));
+ break;
+ case 't':
+ {
+ tstring sFrmt = CurrencyRates_GetDateFormat(true);
+ sFrmt += L" ";
+ sFrmt += CurrencyRates_GetTimeFormat(true);
+ ret = format_fetch_time(hContact, sFrmt);
+ }
+ break;
+ case 'r':
+ case 'R':
+ if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, d))
+ ret = format_double(d, nWidth);
+ else
+ ret = L"-";
+ break;
+
+ case 'p':
+ case 'P':
+ if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, d))
+ ret = format_double(d, nWidth);
+ else
+ ret = L"-";
+ break;
+ }
+
+ return ret;
+}
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
index 49813f640f..975d6fd0a3 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
@@ -99,14 +99,13 @@ public:
void Run() override;
- void Accept(CCurrencyRatesProviderVisitor &visitor) const override;
-
void RefreshAllContacts() override;
void RefreshSettings() override;
void RefreshContact(MCONTACT hContact) override;
void FillFormat(TFormatSpecificators&) const override;
- bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d);
+ bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d) override;
+ tstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const override;
protected:
const tstring& GetURL() const;
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
index 669812a0ee..252271467d 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
@@ -254,12 +254,6 @@ CCurrencyRatesProviderCurrencyConverter::~CCurrencyRatesProviderCurrencyConverte
{
}
-void CCurrencyRatesProviderCurrencyConverter::Accept(CCurrencyRatesProviderVisitor &visitor) const
-{
- CCurrencyRatesProviderBase::Accept(visitor);
- visitor.Visit(*this);
-}
-
void CCurrencyRatesProviderCurrencyConverter::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE &odp)
{
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_GOOGLE);
@@ -409,3 +403,40 @@ void CCurrencyRatesProviderCurrencyConverter::FillFormat(TFormatSpecificators &a
array.push_back(CFormatSpecificator(L"%i", TranslateT("Into Currency Short Name")));
array.push_back(CFormatSpecificator(L"%s", TranslateT("Short notation for \"%f/%i\"")));
}
+
+tstring CCurrencyRatesProviderCurrencyConverter::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const
+{
+ switch (c) {
+ case 'F':
+ return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION);
+
+ case 'f':
+ return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID);
+
+ case 'I':
+ return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION);
+
+ case 'i':
+ return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID);
+ }
+
+ return CSuper::FormatSymbol(hContact, c, nWidth);
+}
+
+MCONTACT CCurrencyRatesProviderCurrencyConverter::ImportContact(const TiXmlNode *pRoot)
+{
+ const char *sFromID = nullptr, *sToID = nullptr;
+
+ for (auto *pNode : TiXmlFilter(pRoot, "Setting")) {
+ TNameValue Item = parse_setting_node(pNode);
+ if (!mir_strcmpi(Item.first, DB_STR_FROM_ID))
+ sFromID = Item.second;
+ else if (!mir_strcmpi(Item.first, DB_STR_TO_ID))
+ sToID = Item.second;
+ }
+
+ if (sFromID && sToID)
+ return GetContactByID(Utf2T(sFromID).get(), Utf2T(sToID).get());
+
+ return 0;
+}
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
index 3a59c7f97a..bb65f08737 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
@@ -23,8 +23,10 @@ public:
MCONTACT GetContactByID(const tstring &rsFromID, const tstring &rsToID) const;
private:
- void Accept(CCurrencyRatesProviderVisitor &visitor) const override;
void FillFormat(TFormatSpecificators &) const override;
void RefreshCurrencyRates(TContacts &anContacts) override;
void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE &odp) override;
+
+ MCONTACT ImportContact(const TiXmlNode*) override;
+ tstring FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const override;
};
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitor.h b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitor.h
deleted file mode 100644
index 7cccbb802d..0000000000
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitor.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __7fca59e7_17b2_4849_bd7a_02c7675f2d76_CurrencyRatesProviderVisitor_h__
-#define __7fca59e7_17b2_4849_bd7a_02c7675f2d76_CurrencyRatesProviderVisitor_h__
-
-class CCurrencyRatesProviderBase;
-class CCurrencyRatesProviderFinance;
-class CCurrencyRatesProviderDukasCopy;
-class CCurrencyRatesProviderGoogleFinance;
-class CCurrencyRatesProviderYahoo;
-class CCurrencyRatesProviderCurrencyConverter;
-
-class CCurrencyRatesProviderVisitor
-{
-public:
- CCurrencyRatesProviderVisitor() {}
- virtual ~CCurrencyRatesProviderVisitor() {}
-
- virtual void Visit(const CCurrencyRatesProviderBase&) {}
- virtual void Visit(const CCurrencyRatesProviderFinance&) {}
- virtual void Visit(const CCurrencyRatesProviderDukasCopy& ){}
- virtual void Visit(const CCurrencyRatesProviderGoogleFinance&) {}
- virtual void Visit(const CCurrencyRatesProviderYahoo&) {}
- virtual void Visit(const CCurrencyRatesProviderCurrencyConverter&) {}
-};
-
-#endif //__7fca59e7_17b2_4849_bd7a_02c7675f2d76_CurrencyRatesProviderVisitor_h__
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp
deleted file mode 100644
index 56556440f0..0000000000
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "StdAfx.h"
-#include "CurrencyRatesProviderCurrencyConverter.h"
-
-CCurrencyRatesProviderVisitorFormater::CCurrencyRatesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth) :
- m_hContact(hContact),
- m_chr(chr),
- m_nWidth(nWidth)
-{
-}
-
-CCurrencyRatesProviderVisitorFormater::~CCurrencyRatesProviderVisitorFormater()
-{
-}
-
-const tstring& CCurrencyRatesProviderVisitorFormater::GetResult() const
-{
- return m_sResult;
-}
-
-static bool get_fetch_time(MCONTACT hContact, time_t &rTime)
-{
- DBVARIANT dbv;
- if (db_get(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type))
- return false;
-
- rTime = dbv.dVal;
- return true;
-}
-
-static tstring format_fetch_time(MCONTACT hContact, const tstring &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;
- k.imbue(std::locale(GetSystemLocale(), new ttime_facet(rsFormat.c_str())));
- k << time;
- return k.str();
- }
-
- return tstring();
-}
-
-void CCurrencyRatesProviderVisitorFormater::Visit(const CCurrencyRatesProviderBase&)
-{
- switch (m_chr) {
- case '%':
- case '\t':
- case '\\':
- m_sResult = m_chr;
- break;
- case 'S':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER);
- break;
- case 's':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL);
- break;
- case 'X':
- m_sResult = format_fetch_time(m_hContact, CurrencyRates_GetTimeFormat(true));
- break;
- case 'x':
- m_sResult = format_fetch_time(m_hContact, CurrencyRates_GetDateFormat(true));
- break;
- case 't':
- {
- tstring sFrmt = CurrencyRates_GetDateFormat(true);
- sFrmt += L" ";
- sFrmt += CurrencyRates_GetTimeFormat(true);
- m_sResult = format_fetch_time(m_hContact, sFrmt);
- }
- break;
- case 'r':
- case 'R':
- FormatDoubleHelper(DB_STR_CURRENCYRATE_CURR_VALUE);
- break;
- case 'p':
- FormatDoubleHelper(DB_STR_CURRENCYRATE_PREV_VALUE);
- break;
- }
-}
-
-
-tstring format_double(double dValue, int nWidth)
-{
- tostringstream o;
- o.imbue(GetSystemLocale());
-
- if (nWidth > 0 && nWidth <= 9)
- o << std::setprecision(nWidth) << std::showpoint << std::fixed;
-
- o << dValue;
-
- return o.str();
-}
-
-void CCurrencyRatesProviderVisitorFormater::FormatDoubleHelper(LPCSTR pszDbSet,
- const tstring sInvalid/* = L"-"*/)
-{
- double d = 0.0;
- if (true == CurrencyRates_DBReadDouble(m_hContact, CURRENCYRATES_MODULE_NAME, pszDbSet, d))
- m_sResult = format_double(d, m_nWidth);
- else
- m_sResult = sInvalid;
-}
-
-void CCurrencyRatesProviderVisitorFormater::Visit(const CCurrencyRatesProviderCurrencyConverter&)
-{
- switch (m_chr) {
- case 'F':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION);
- break;
- case 'f':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID);
- break;
- case 'I':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION);
- break;
- case 'i':
- m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID);
- break;
- }
-}
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.h b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.h
deleted file mode 100644
index 2453ce9219..0000000000
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __2b5ddd05_9255_4be0_9408_e59768b70568_CurrencyRatesProviderVisitorFormater_h__
-#define __2b5ddd05_9255_4be0_9408_e59768b70568_CurrencyRatesProviderVisitorFormater_h__
-
-class CCurrencyRatesProviderVisitorFormater : public CCurrencyRatesProviderVisitor
-{
-public:
- CCurrencyRatesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth);
- ~CCurrencyRatesProviderVisitorFormater();
-
- const tstring& GetResult() const;
-
-private:
- virtual void Visit(const CCurrencyRatesProviderBase& rProvider) override;
- virtual void Visit(const CCurrencyRatesProviderCurrencyConverter& rProvider) override;
-
-private:
- void FormatDoubleHelper(LPCSTR pszDbSet, const tstring sInvalid = L"-");
-
-private:
- MCONTACT m_hContact;
- wchar_t m_chr;
- tstring m_sResult;
- int m_nWidth;
-};
-
-#endif //__2b5ddd05_9255_4be0_9408_e59768b70568_CurrencyRatesProviderVisitorFormater_h__
diff --git a/plugins/CurrencyRates/src/ICurrencyRatesProvider.h b/plugins/CurrencyRates/src/ICurrencyRatesProvider.h
index 174cef1148..506d2695b5 100644
--- a/plugins/CurrencyRates/src/ICurrencyRatesProvider.h
+++ b/plugins/CurrencyRates/src/ICurrencyRatesProvider.h
@@ -32,6 +32,7 @@ public:
virtual void AddContact(MCONTACT hContact) = 0;
virtual void DeleteContact(MCONTACT hContact) = 0;
+ virtual MCONTACT ImportContact(const TiXmlNode*) = 0;
virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) = 0;
@@ -40,10 +41,10 @@ public:
virtual void RefreshContact(MCONTACT hContact) = 0;
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 void Run() = 0;
-
- virtual void Accept(CCurrencyRatesProviderVisitor &visitor) const = 0;
};
#endif //__ac71e133_786c_41a7_ab07_625b76ff2a8c_CurrencyRatesProvider_h__
diff --git a/plugins/CurrencyRates/src/ImportExport.cpp b/plugins/CurrencyRates/src/ImportExport.cpp
index 47bb3e1b40..03d35eadb7 100644
--- a/plugins/CurrencyRates/src/ImportExport.cpp
+++ b/plugins/CurrencyRates/src/ImportExport.cpp
@@ -1,5 +1,4 @@
#include "StdAfx.h"
-#include "CurrencyRatesProviderCurrencyConverter.h"
const char g_szXmlValue[] = "Value";
const char g_szXmlName[] = "Name";
@@ -385,7 +384,6 @@ const TiXmlNode* find_currencyrates_module(const TiXmlNode *pXmlContact)
return nullptr;
}
-typedef std::pair<const char*, const char*> TNameValue; // first is name,second is value
TNameValue parse_setting_node(const TiXmlNode *pXmlSetting)
{
assert(pXmlSetting);
@@ -414,49 +412,6 @@ CCurrencyRatesProviders::TCurrencyRatesProviderPtr find_provider(const TiXmlNode
bool get_contact_state(const TiXmlNode *pXmlContact, CContactState& cst)
{
- class visitor : public CCurrencyRatesProviderVisitor
- {
- public:
- visitor(const TiXmlNode *pXmlCurrencyRates)
- : m_hContact(NULL), m_pXmlCurrencyRates(pXmlCurrencyRates)
- {
- }
-
- MCONTACT GetContact() const { return m_hContact; }
-
- private:
- void Visit(const CCurrencyRatesProviderCurrencyConverter &rProvider) override
- {
- const char *sFromID = nullptr, *sToID = nullptr;
-
- for (auto *pNode : TiXmlFilter(m_pXmlCurrencyRates, g_szXmlSetting)) {
- TNameValue Item = parse_setting_node(pNode);
- if (!mir_strcmpi(Item.first, DB_STR_FROM_ID))
- sFromID = Item.second;
- else if (!mir_strcmpi(Item.first, DB_STR_TO_ID))
- sToID = Item.second;
- }
-
- if (sFromID && sToID)
- m_hContact = rProvider.GetContactByID(Utf2T(sFromID).get(), Utf2T(sToID).get());
- }
-
- tstring GetXMLNodeValue(const char* pszXMLNodeName) const
- {
- for (auto *pNode : TiXmlFilter(m_pXmlCurrencyRates, g_szXmlSetting)) {
- TNameValue Item = parse_setting_node(pNode);
- if (!mir_strcmpi(Item.first, pszXMLNodeName))
- return Utf2T(Item.second).get();
- }
-
- return tstring();
- }
-
- private:
- MCONTACT m_hContact;
- const TiXmlNode *m_pXmlCurrencyRates;
- };
-
auto *pXmlCurrencyRates = find_currencyrates_module(pXmlContact);
if (!pXmlCurrencyRates)
return false;
@@ -465,9 +420,7 @@ bool get_contact_state(const TiXmlNode *pXmlContact, CContactState& cst)
if (!cst.m_pProvider)
return false;
- visitor vs(pXmlCurrencyRates);
- cst.m_pProvider->Accept(vs);
- cst.m_hContact = vs.GetContact();
+ cst.m_hContact = cst.m_pProvider->ImportContact(pXmlCurrencyRates);
return true;
}
diff --git a/plugins/CurrencyRates/src/ImportExport.h b/plugins/CurrencyRates/src/ImportExport.h
index 4fd3a42470..b07bc4c4c3 100644
--- a/plugins/CurrencyRates/src/ImportExport.h
+++ b/plugins/CurrencyRates/src/ImportExport.h
@@ -4,4 +4,7 @@
INT_PTR CurrencyRates_Export(WPARAM wp, LPARAM lp);
INT_PTR CurrencyRates_Import(WPARAM wp, LPARAM lp);
+using TNameValue = std::pair<const char*, const char*> ; // first is name,second is value
+TNameValue parse_setting_node(const TiXmlNode *pXmlSetting);
+
#endif //__F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__
diff --git a/plugins/CurrencyRates/src/stdafx.h b/plugins/CurrencyRates/src/stdafx.h
index 3ed55d1173..4f8d6ace9b 100644
--- a/plugins/CurrencyRates/src/stdafx.h
+++ b/plugins/CurrencyRates/src/stdafx.h
@@ -5,6 +5,7 @@
#pragma once
+#undef _HAS_EXCEPTIONS
#define _HAS_EXCEPTIONS 1
#include <windows.h>
@@ -97,8 +98,6 @@ inline tstring currencyrates_a2t(const char* s)
#include "ICurrencyRatesProvider.h"
#include "CurrencyRatesProviders.h"
#include "CurrencyRatesProviderBase.h"
-#include "CurrencyRatesProviderVisitor.h"
-#include "CurrencyRatesProviderVisitorFormater.h"
#define CHART_IMPLEMENT
#ifdef CHART_IMPLEMENT