summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-02-09 11:23:45 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-02-09 11:23:45 +0300
commit4cdd4f85ebe39389b7f45d6da8c39a368259b866 (patch)
treeafe20ee1b4d37e72f9a527db738d6b19693957dc /protocols
parent354f557eb6cfcaf4010161032c6da27d253e71ad (diff)
CurrencyRates: all settings migrated to CMOption<>
Diffstat (limited to 'protocols')
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp16
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp5
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderExchangeRates.cpp5
-rw-r--r--protocols/CurrencyRates/src/DBUtils.h14
-rw-r--r--protocols/CurrencyRates/src/Forex.cpp9
-rw-r--r--protocols/CurrencyRates/src/HTTPSession.cpp3
-rw-r--r--protocols/CurrencyRates/src/Options.cpp36
-rw-r--r--protocols/CurrencyRates/src/stdafx.h4
8 files changed, 41 insertions, 51 deletions
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
index f4558d2d17..3b11bf4700 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
@@ -583,11 +583,11 @@ uint32_t get_refresh_timeout_miliseconds()
if (!g_bAutoUpdate)
return INFINITE;
- int nRefreshRateType = g_plugin.getWord(DB_KEY_RefreshRateType, RRT_MINUTES);
+ int nRefreshRateType = g_plugin.wRateType;
if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS)
nRefreshRateType = RRT_MINUTES;
- uint32_t nTimeout = g_plugin.getWord(DB_KEY_RefreshRateValue, 1);
+ uint32_t nTimeout = g_plugin.wRateValue;
switch (nRefreshRateType) {
default:
case RRT_SECONDS:
@@ -635,9 +635,9 @@ static void refreshContacts(TContacts &list)
void CCurrencyRatesProviderBase::Run()
{
uint32_t nTimeout = get_refresh_timeout_miliseconds();
- m_sContactListFormat = g_plugin.getMStringW(DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat);
- m_sStatusMsgFormat = g_plugin.getMStringW(DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat);
- m_sTendencyFormat = g_plugin.getMStringW(DB_KEY_TendencyFormat, DB_DEF_TendencyFormat);
+ m_sContactListFormat = g_plugin.wszDisplayFormat;
+ m_sStatusMsgFormat = g_plugin.wszStatusFormat;
+ m_sTendencyFormat = g_plugin.wszTendencyFormat;
enum
{
@@ -685,9 +685,9 @@ void CCurrencyRatesProviderBase::Run()
case WAIT_OBJECT_0 + SETTINGS_CHANGED:
nTimeout = get_refresh_timeout_miliseconds();
- m_sContactListFormat = g_plugin.getMStringW(DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat);
- m_sStatusMsgFormat = g_plugin.getMStringW(DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat);
- m_sTendencyFormat = g_plugin.getMStringW(DB_KEY_TendencyFormat, DB_DEF_TendencyFormat);
+ m_sContactListFormat = g_plugin.wszDisplayFormat;
+ m_sStatusMsgFormat = g_plugin.wszStatusFormat;
+ m_sTendencyFormat = g_plugin.wszTendencyFormat;
refreshContacts(anContacts);
break;
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
index 3e8195fa4b..46924e4e6d 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp
@@ -3,9 +3,8 @@
static CMStringW build_url(const CMStringW &rsURL, const CMStringW &from, const CMStringW &to)
{
CMStringW res = rsURL + L"?q=" + from + L"_" + to + L"&compact=ultra";
- ptrA szApiKey(g_plugin.getStringA(DB_KEY_ApiKey));
- if (szApiKey != nullptr)
- res.AppendFormat(L"&apiKey=%S", szApiKey.get());
+ if (mir_wstrlen(g_plugin.wszApiKey))
+ res.AppendFormat(L"&apiKey=%S", (wchar_t*)g_plugin.wszApiKey);
return res;
}
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderExchangeRates.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderExchangeRates.cpp
index 7b90322a8f..d2707c35ce 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderExchangeRates.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderExchangeRates.cpp
@@ -3,9 +3,8 @@
static CMStringW build_url(const CMStringW &rsURL)
{
CMStringW res = rsURL + L"?";
- ptrA szApiKey(g_plugin.getStringA(DB_KEY_ApiKey));
- if (szApiKey != nullptr)
- res.AppendFormat(L"&access_key=%S", szApiKey.get());
+ if (mir_wstrlen(g_plugin.wszApiKey))
+ res.AppendFormat(L"&apiKey=%S", (wchar_t *)g_plugin.wszApiKey);
return res;
}
diff --git a/protocols/CurrencyRates/src/DBUtils.h b/protocols/CurrencyRates/src/DBUtils.h
index f5fb65aa4f..6e530e7fce 100644
--- a/protocols/CurrencyRates/src/DBUtils.h
+++ b/protocols/CurrencyRates/src/DBUtils.h
@@ -1,20 +1,6 @@
#ifndef __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__
#define __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__
-#define DB_KEY_RefreshRateType "CC_RefreshRateType"
-#define DB_KEY_RefreshRateValue "CC_RefreshRateValue"
-
-#define DB_KEY_StatusMsgFormat "CC_StatusMessageFormat"
-#define DB_DEF_StatusMsgFormat L""
-
-#define DB_KEY_ApiKey "CC_ApiKey"
-
-#define DB_KEY_DisplayNameFormat "CC_DspNameFrmt"
-#define DB_DEF_DisplayNameFormat L"1 %f = %r %i"
-
-#define DB_KEY_TendencyFormat "CC_TendencyFormat"
-#define DB_DEF_TendencyFormat L"%r>%p"
-
void FixInvalidChars(CMStringW &s);
CMStringW GetNodeText(const TiXmlElement*);
diff --git a/protocols/CurrencyRates/src/Forex.cpp b/protocols/CurrencyRates/src/Forex.cpp
index 2ffa99cd54..45477a453f 100644
--- a/protocols/CurrencyRates/src/Forex.cpp
+++ b/protocols/CurrencyRates/src/Forex.cpp
@@ -259,6 +259,15 @@ PLUGININFOEX pluginInfoEx =
CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+
+ // main settings
+ wRateType(MODULENAME, "CC_RefreshRateType", RRT_MINUTES),
+ wRateValue(MODULENAME, "CC_RefreshRateValue", 1),
+ wszApiKey(MODULENAME, "CC_ApiKey"),
+ wszStatusFormat(MODULENAME, "CC_StatusMessageFormat"),
+ wszDisplayFormat(MODULENAME, "CC_DspNameFrmt", L"1 %f = %r %i"),
+ wszTendencyFormat(MODULENAME, "CC_TendencyFormat", L"%r>%p"),
+
// log settings
wLogMode(MODULENAME, "CC_LogMode", lmDisabled),
bIsOnlyChangedHistory(MODULENAME, "CC_AddToHistoryOnlyIfValueIsChanged", false),
diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp
index 62fdce7fd4..2843814b71 100644
--- a/protocols/CurrencyRates/src/HTTPSession.cpp
+++ b/protocols/CurrencyRates/src/HTTPSession.cpp
@@ -56,8 +56,7 @@ bool CHTTPSession::Init()
{
assert(nullptr == g_hNetLib);
- ptrA szApiKey(g_plugin.getStringA(DB_KEY_ApiKey));
- if (mir_strlen(szApiKey) == 0 && g_pCurrentProvider->HasAuth())
+ if (mir_wstrlen(g_plugin.wszApiKey) == 0 && g_pCurrentProvider->HasAuth())
Miranda_WaitOnHandle(waitStub);
NETLIBUSER nlu = {};
diff --git a/protocols/CurrencyRates/src/Options.cpp b/protocols/CurrencyRates/src/Options.cpp
index faa433f251..796c871795 100644
--- a/protocols/CurrencyRates/src/Options.cpp
+++ b/protocols/CurrencyRates/src/Options.cpp
@@ -90,7 +90,7 @@ class COptionsDlg : public CDlgBase
CCurrencyRatesProviderBase *m_pProvider;
- CCtrlEdit edtKey;
+ CCtrlEdit edtKey, edtDisplayFormat, edtStatusFormat, edtTendencyFormat;
CCtrlCombo cmbProvider, cmbRefresh;
CCtrlButton btnAdd, btnRemove, btnDescr, btnGetKey;
CCtrlListBox m_list;
@@ -102,13 +102,19 @@ public:
m_list(this, IDC_LIST_RATES),
cmbRefresh(this, IDC_COMBO_REFRESH_RATE),
cmbProvider(this, IDC_PROVIDER),
- edtKey(this, IDC_EDIT_PERSONAL_KEY),
btnAdd(this, IDC_BUTTON_ADD),
btnDescr(this, IDC_BUTTON_DESCRIPTION),
btnGetKey(this, IDC_GET_KEY),
- btnRemove(this, IDC_BUTTON_REMOVE)
+ btnRemove(this, IDC_BUTTON_REMOVE),
+ edtKey(this, IDC_EDIT_PERSONAL_KEY),
+ edtDisplayFormat(this, IDC_EDIT_CONTACT_LIST_FORMAT),
+ edtStatusFormat(this, IDC_EDIT_STATUS_MESSAGE_FORMAT),
+ edtTendencyFormat(this, IDC_EDIT_TENDENCY_FORMAT)
{
- CreateLink(edtKey, DB_KEY_ApiKey, L"");
+ CreateLink(edtKey, g_plugin.wszApiKey);
+ CreateLink(edtStatusFormat, g_plugin.wszStatusFormat);
+ CreateLink(edtDisplayFormat, g_plugin.wszDisplayFormat);
+ CreateLink(edtTendencyFormat, g_plugin.wszTendencyFormat);
btnAdd.OnClick = Callback(this, &COptionsDlg::onClick_Add);
btnDescr.OnClick = Callback(this, &COptionsDlg::onClick_Descr);
@@ -128,26 +134,18 @@ public:
if (it == g_pCurrentProvider)
cmbProvider.SetCurSel(idx);
}
-
- // set contact list display format
- ::SetDlgItemTextW(m_hwnd, IDC_EDIT_CONTACT_LIST_FORMAT, g_plugin.getMStringW(DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat));
-
- // set status message display format
- ::SetDlgItemTextW(m_hwnd, IDC_EDIT_STATUS_MESSAGE_FORMAT, g_plugin.getMStringW(DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat));
-
- // set tendency format
- ::SetDlgItemTextW(m_hwnd, IDC_EDIT_TENDENCY_FORMAT, g_plugin.getMStringW(DB_KEY_TendencyFormat, DB_DEF_TendencyFormat));
+ onSelChange_Provider(0);
// refresh rate
cmbRefresh.AddString(TranslateT("Seconds"));
cmbRefresh.AddString(TranslateT("Minutes"));
cmbRefresh.AddString(TranslateT("Hours"));
- int nRefreshRateType = g_plugin.getWord(DB_KEY_RefreshRateType, RRT_MINUTES);
+ int nRefreshRateType = g_plugin.wRateType;
if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS)
nRefreshRateType = RRT_MINUTES;
- UINT nRate = g_plugin.getWord(DB_KEY_RefreshRateValue, 1);
+ UINT nRate = g_plugin.wRateValue;
switch (nRefreshRateType) {
case RRT_SECONDS:
case RRT_MINUTES:
@@ -186,12 +184,8 @@ public:
BOOL bOk = FALSE;
UINT nRefreshRate = ::GetDlgItemInt(m_hwnd, IDC_EDIT_REFRESH_RATE, &bOk, FALSE);
- g_plugin.setWord(DB_KEY_RefreshRateType, cmbRefresh.GetCurSel());
- g_plugin.setWord(DB_KEY_RefreshRateValue, nRefreshRate);
-
- g_plugin.setWString(DB_KEY_DisplayNameFormat, get_window_text(::GetDlgItem(m_hwnd, IDC_EDIT_CONTACT_LIST_FORMAT)));
- g_plugin.setWString(DB_KEY_StatusMsgFormat, get_window_text(::GetDlgItem(m_hwnd, IDC_EDIT_STATUS_MESSAGE_FORMAT)));
- g_plugin.setWString(DB_KEY_TendencyFormat, get_window_text(::GetDlgItem(m_hwnd, IDC_EDIT_TENDENCY_FORMAT)));
+ g_plugin.wRateType = cmbRefresh.GetCurSel();
+ g_plugin.wRateValue = nRefreshRate;
TWatchedRates aTemp(g_aWatchedRates);
TWatchedRates aRemove;
diff --git a/protocols/CurrencyRates/src/stdafx.h b/protocols/CurrencyRates/src/stdafx.h
index 4731e1051f..98497de98e 100644
--- a/protocols/CurrencyRates/src/stdafx.h
+++ b/protocols/CurrencyRates/src/stdafx.h
@@ -84,6 +84,10 @@ enum EDelayMode
struct CMPlugin : public PLUGIN<CMPlugin>
{
+ // Main settings
+ CMOption<wchar_t *> wszApiKey, wszDisplayFormat, wszStatusFormat, wszTendencyFormat;
+ CMOption<uint16_t> wRateType, wRateValue;
+
// Log settings
CMOption<uint16_t> wLogMode;
CMOption<bool> bIsOnlyChangedHistory, bIsOnlyChangedLogFile;