summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-17 13:38:43 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-17 13:38:43 +0300
commitf163ebca6e34e418978e30a83989d001186eff53 (patch)
treeee2c32bd44ae92dcbf2e9338863cd1735cb0bf96 /protocols/CurrencyRates/src
parent8de798016edb9d7e87bda93431ba9548f5c6353a (diff)
code cleaning
Diffstat (limited to 'protocols/CurrencyRates/src')
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp19
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderBase.h1
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp35
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h10
-rw-r--r--protocols/CurrencyRates/src/DBUtils.h2
-rw-r--r--protocols/CurrencyRates/src/EconomicRateInfo.h5
-rw-r--r--protocols/CurrencyRates/src/SettingsDlg.cpp3
7 files changed, 31 insertions, 44 deletions
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
index 94dd3cf6b0..70eef9954e 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
@@ -138,7 +138,7 @@ bool CCurrencyRatesProviderBase::Init()
{
bool bSucceded = (m_pXMLInfo == nullptr);
if (!m_pXMLInfo)
- m_pXMLInfo = new CXMLFileInfo(init_xml_info(DB_DEF_IniFileName, bSucceded));
+ m_pXMLInfo = new CXMLFileInfo(init_xml_info(GetXmlFilename(), bSucceded));
return bSucceded;
}
@@ -786,6 +786,11 @@ void CCurrencyRatesProviderBase::RefreshContact(MCONTACT hContact)
void CCurrencyRatesProviderBase::FillFormat(TFormatSpecificators &array) const
{
+ array.push_back(CFormatSpecificator(L"%F", LPGENW("From Currency Full Name")));
+ array.push_back(CFormatSpecificator(L"%f", LPGENW("From Currency Short Name")));
+ array.push_back(CFormatSpecificator(L"%I", LPGENW("Into Currency Full Name")));
+ array.push_back(CFormatSpecificator(L"%i", LPGENW("Into Currency Short Name")));
+ array.push_back(CFormatSpecificator(L"%s", LPGENW("Short notation for \"%f/%i\"")));
array.push_back(CFormatSpecificator(L"%S", LPGENW("Source of information")));
array.push_back(CFormatSpecificator(L"%r", LPGENW("Rate value")));
array.push_back(CFormatSpecificator(L"%d", LPGENW("Rate delta")));
@@ -870,6 +875,18 @@ CMStringW CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c,
case 's':
ret = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL);
break;
+ case 'F':
+ ret = g_plugin.getMStringW(hContact, DB_STR_FROM_DESCRIPTION);
+ break;
+ case 'f':
+ ret = g_plugin.getMStringW(hContact, DB_STR_FROM_ID);
+ break;
+ case 'I':
+ ret = g_plugin.getMStringW(hContact, DB_STR_TO_DESCRIPTION);
+ break;
+ case 'i':
+ ret = g_plugin.getMStringW(hContact, DB_STR_TO_ID);
+ break;
case 'X':
ret = format_fetch_time(hContact, CurrencyRates_GetTimeFormat(true));
break;
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
index 47227297d4..034efff5d6 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
@@ -109,6 +109,7 @@ protected:
static void SetContactStatus(MCONTACT hContact, int nNewStatus);
void WriteContactRate(MCONTACT hContact, double dRate, const CMStringW &rsSymbol = L"");
+ virtual wchar_t* GetXmlFilename() const = 0;
virtual void RefreshCurrencyRates(TContacts &anContacts) = 0;
protected:
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
index cea1fff5b7..01c06810f7 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
@@ -35,6 +35,11 @@ CCurrencyRatesProviderCurrencyConverter::~CCurrencyRatesProviderCurrencyConverte
{
}
+wchar_t *CCurrencyRatesProviderCurrencyConverter::GetXmlFilename() const
+{
+ return L"CC.xml";
+}
+
void CCurrencyRatesProviderCurrencyConverter::RefreshCurrencyRates(TContacts &anContacts)
{
CHTTPSession http;
@@ -162,36 +167,6 @@ MCONTACT CCurrencyRatesProviderCurrencyConverter::GetContactByID(const CMStringW
return NULL;
}
-void CCurrencyRatesProviderCurrencyConverter::FillFormat(TFormatSpecificators &array) const
-{
- CSuper::FillFormat(array);
-
- array.push_back(CFormatSpecificator(L"%F", LPGENW("From Currency Full Name")));
- array.push_back(CFormatSpecificator(L"%f", LPGENW("From Currency Short Name")));
- array.push_back(CFormatSpecificator(L"%I", LPGENW("Into Currency Full Name")));
- array.push_back(CFormatSpecificator(L"%i", LPGENW("Into Currency Short Name")));
- array.push_back(CFormatSpecificator(L"%s", LPGENW("Short notation for \"%f/%i\"")));
-}
-
-CMStringW CCurrencyRatesProviderCurrencyConverter::FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const
-{
- switch (c) {
- case 'F':
- return g_plugin.getMStringW(hContact, DB_STR_FROM_DESCRIPTION);
-
- case 'f':
- return g_plugin.getMStringW(hContact, DB_STR_FROM_ID);
-
- case 'I':
- return g_plugin.getMStringW(hContact, DB_STR_TO_DESCRIPTION);
-
- case 'i':
- return g_plugin.getMStringW(hContact, DB_STR_TO_ID);
- }
-
- return CSuper::FormatSymbol(hContact, c, nWidth);
-}
-
MCONTACT CCurrencyRatesProviderCurrencyConverter::ImportContact(const TiXmlNode *pRoot)
{
const char *sFromID = nullptr, *sToID = nullptr;
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
index 2d87b02256..fdf22be32c 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.h
@@ -1,11 +1,5 @@
#pragma once
-#define DB_STR_FROM_ID "FromID"
-#define DB_STR_TO_ID "ToID"
-#define DB_STR_FROM_DESCRIPTION "FromDesc"
-#define DB_STR_TO_DESCRIPTION "ToDesc"
-
-
class CCurrencyRatesProviderCurrencyConverter : public CCurrencyRatesProviderBase
{
public:
@@ -23,9 +17,9 @@ public:
MCONTACT GetContactByID(const CMStringW &rsFromID, const CMStringW &rsToID) const;
private:
- void FillFormat(TFormatSpecificators &) const override;
void RefreshCurrencyRates(TContacts &anContacts) override;
+ wchar_t* GetXmlFilename() const override;
+
MCONTACT ImportContact(const TiXmlNode*) override;
- CMStringW FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth) const override;
};
diff --git a/protocols/CurrencyRates/src/DBUtils.h b/protocols/CurrencyRates/src/DBUtils.h
index ed133c2a22..4b5013c101 100644
--- a/protocols/CurrencyRates/src/DBUtils.h
+++ b/protocols/CurrencyRates/src/DBUtils.h
@@ -7,8 +7,6 @@
#define DB_KEY_StatusMsgFormat "CC_StatusMessageFormat"
#define DB_DEF_StatusMsgFormat L""
-#define DB_DEF_IniFileName L"CC.xml"
-
#define DB_KEY_ApiKey "CC_ApiKey"
#define DB_KEY_DisplayNameFormat "CC_DspNameFrmt"
diff --git a/protocols/CurrencyRates/src/EconomicRateInfo.h b/protocols/CurrencyRates/src/EconomicRateInfo.h
index 3b55b7f0ad..3eaccc45e3 100644
--- a/protocols/CurrencyRates/src/EconomicRateInfo.h
+++ b/protocols/CurrencyRates/src/EconomicRateInfo.h
@@ -11,6 +11,10 @@ enum ERefreshRateType
RRT_HOURS = 2
};
+#define DB_STR_FROM_ID "FromID"
+#define DB_STR_TO_ID "ToID"
+#define DB_STR_FROM_DESCRIPTION "FromDesc"
+#define DB_STR_TO_DESCRIPTION "ToDesc"
#define DB_STR_ENABLE_LOG "EnableLog"
#define DB_STR_CURRENCYRATE_PROVIDER "CurrencyRateProvider"
#define DB_STR_CURRENCYRATE_ID "CurrencyRateID"
@@ -20,7 +24,6 @@ enum ERefreshRateType
#define DB_STR_CURRENCYRATE_CURR_VALUE "CurrentCurrencyRateValue"
#define DB_STR_CURRENCYRATE_FETCH_TIME "FetchTime"
-
enum ELogMode
{
lmDisabled = 0x0000,
diff --git a/protocols/CurrencyRates/src/SettingsDlg.cpp b/protocols/CurrencyRates/src/SettingsDlg.cpp
index e22a12c3a5..134d504553 100644
--- a/protocols/CurrencyRates/src/SettingsDlg.cpp
+++ b/protocols/CurrencyRates/src/SettingsDlg.cpp
@@ -146,10 +146,9 @@ INT_PTR CALLBACK EditPopupSettingsDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM
n = IDC_DELAYCUSTOM;
break;
case CPopupSettings::delayPermanent:
+ default:
n = IDC_DELAYPERMANENT;
break;
- default:
- assert(!"Unknown delay mode. Please, fix it");
}
::CheckRadioButton(hWnd, IDC_DELAYFROMPU, IDC_DELAYPERMANENT, n);