summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-17 23:16:31 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-17 23:16:31 +0300
commit4dad3f7d4adaaddcf2493c49ad1d094374d68104 (patch)
treee59e5e8eeb13209404048d33a7918f59b0838497 /protocols/CurrencyRates/src
parent5f3068756e3f1317ea01b0d3592839ffa318b164 (diff)
CurrencyRates: all global settings moved to UI classes
Diffstat (limited to 'protocols/CurrencyRates/src')
-rw-r--r--protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp5
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp62
-rw-r--r--protocols/CurrencyRates/src/CurrencyRatesProviderBase.h2
-rw-r--r--protocols/CurrencyRates/src/DBUtils.h24
-rw-r--r--protocols/CurrencyRates/src/Forex.cpp20
-rw-r--r--protocols/CurrencyRates/src/HTTPSession.cpp3
-rw-r--r--protocols/CurrencyRates/src/Options.cpp273
-rw-r--r--protocols/CurrencyRates/src/SettingsDlg.cpp550
-rw-r--r--protocols/CurrencyRates/src/SettingsDlg.h101
-rw-r--r--protocols/CurrencyRates/src/resource.h14
-rw-r--r--protocols/CurrencyRates/src/stdafx.h25
11 files changed, 319 insertions, 760 deletions
diff --git a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
index 4fddbf8bf1..cdfea7b3fd 100644
--- a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
@@ -137,10 +137,9 @@ int CurrencyRates_OnContactDoubleClick(WPARAM hContact, LPARAM/* lp*/)
/////////////////////////////////////////////////////////////////////////////////////////
-INT_PTR CurrencyRatesMenu_EditSettings(WPARAM wp, LPARAM)
+INT_PTR CurrencyRatesMenu_EditSettings(WPARAM hContact, LPARAM)
{
- MCONTACT hContact = MCONTACT(wp);
- if (NULL != hContact)
+ if (hContact)
ShowSettingsDlg(hContact);
return 0;
}
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
index 5084304bd3..37a82f7afe 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp
@@ -399,7 +399,7 @@ bool do_set_contact_extra_icon(MCONTACT hContact, const CTendency &tendency)
return false;
}
-bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, int nComparison, const CMStringW &rsFormat, const CPopupSettings &ps)
+bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, int nComparison, const CMStringW &rsFormat)
{
POPUPDATAW ppd;
memset(&ppd, 0, sizeof(ppd));
@@ -427,31 +427,32 @@ bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, int
mir_wstrncpy(ppd.lpwzText, L"1 USD = 8.4342 SMC", MAX_SECONDLINE);
}
- if (CPopupSettings::colourDefault == ps.GetColourMode()) {
- ppd.colorText = CPopupSettings::GetDefColourText();
- ppd.colorBack = CPopupSettings::GetDefColourBk();
+ if (colourDefault == g_plugin.modeColour) {
+ ppd.colorText = ::GetSysColor(COLOR_BTNTEXT);
+ ppd.colorBack = ::GetSysColor(COLOR_BTNFACE);
}
else {
- ppd.colorText = ps.GetColourText();
- ppd.colorBack = ps.GetColourBk();
+ ppd.colorText = g_plugin.rgbText;
+ ppd.colorBack = g_plugin.rgbBkg;
}
- switch (ps.GetDelayMode()) {
- default:
- assert(!"Unknown popup delay mode");
- case CPopupSettings::delayFromPopup:
+ switch (g_plugin.modeDelay) {
+ case delayFromPopup:
ppd.iSeconds = 0;
break;
- case CPopupSettings::delayPermanent:
+ case delayPermanent:
ppd.iSeconds = -1;
break;
- case CPopupSettings::delayCustom:
- ppd.iSeconds = ps.GetDelayTimeout();
+ case delayCustom:
+ ppd.iSeconds = g_plugin.wDelay;
break;
+ default:
+ assert(!"Unknown popup delay mode");
+ ppd.iSeconds = 0;
}
int lp = 0;
- if (false == ps.GetHistoryFlag())
+ if (!g_plugin.bUseHistory)
lp |= APF_NO_POPUP;
return (0 == PUAddPopupW(&ppd, lp));
@@ -499,23 +500,21 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat
bool bUseContactSpecific = g_plugin.getBool(hContact, DB_STR_CONTACT_SPEC_SETTINGS);
- CAdvProviderSettings global_settings(this);
-
uint16_t dwMode = (bUseContactSpecific)
- ? g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, static_cast<uint16_t>(lmDisabled))
- : global_settings.GetLogMode();
+ ? g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, g_plugin.wLogMode)
+ : g_plugin.wLogMode;
if (dwMode & lmExternalFile) {
bool bAdd = true;
bool bOnlyIfChanged = (bUseContactSpecific)
? (g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, 1) > 0)
- : global_settings.GetLogOnlyChangedFlag();
+ : g_plugin.bIsOnlyChangedLogFile;
if (true == bOnlyIfChanged) {
bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev)));
}
if (true == bAdd) {
CMStringW sLogFileName = (bUseContactSpecific)
- ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str())
- : global_settings.GetLogFileName();
+ ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_LOG_FILE, g_plugin.wszLogFileName)
+ : (wchar_t*)g_plugin.wszLogFileName;
if (true == sSymbol.IsEmpty()) {
sSymbol = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL);
@@ -523,9 +522,9 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat
sLogFileName = GenerateLogFileName(sLogFileName, sSymbol);
- CMStringW sFormat = global_settings.GetLogFormat();
+ CMStringW sFormat = g_plugin.wszLogFileFormat;
if (bUseContactSpecific)
- sFormat = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, DB_DEF_LogFormat);
+ sFormat = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, g_plugin.wszLogFileFormat);
log_to_file(this, hContact, sLogFileName, sFormat);
}
@@ -534,15 +533,15 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat
bool bAdd = true;
bool bOnlyIfChanged = (bUseContactSpecific)
? (g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, 1) > 0)
- : global_settings.GetHistoryOnlyChangedFlag();
+ : g_plugin.bIsOnlyChangedHistory;
if (true == bOnlyIfChanged) {
bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev)));
}
if (true == bAdd) {
CMStringW sFormat = (bUseContactSpecific)
- ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str())
- : global_settings.GetHistoryFormat();
+ ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_HISTORY, g_plugin.wszHistoryFormat)
+ : (wchar_t *)g_plugin.wszHistoryFormat;
log_to_history(this, hContact, nTime, sFormat);
}
@@ -551,19 +550,16 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat
if (dwMode & lmPopup) {
bool bOnlyIfChanged = (bUseContactSpecific)
? (1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, 1) > 0)
- : global_settings.GetShowPopupIfValueChangedFlag();
+ : g_plugin.bShowPopupIfValueChanged;
if (!bOnlyIfChanged || (bOnlyIfChanged && bValidPrev && !IsWithinAccuracy(dRate, dPrev))) {
CMStringW sFormat = (bUseContactSpecific)
- ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str())
- : global_settings.GetPopupFormat();
-
- CPopupSettings ps = *(global_settings.GetPopupSettingsPtr());
- ps.InitForContact(hContact);
+ ? g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_POPUP, g_plugin.wszPopupFormat)
+ : (wchar_t*)g_plugin.wszPopupFormat;
CTendency::EResult nComparison = CTendency::NotChanged;
if (tendency.IsValid())
nComparison = tendency.Compare();
- show_popup(this, hContact, nComparison, sFormat, ps);
+ show_popup(this, hContact, nComparison, sFormat);
}
}
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
index 79b3c3b26a..80111520ef 100644
--- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
+++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.h
@@ -106,6 +106,6 @@ protected:
mutable mir_cs m_cs;
};
-bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, int nComparison, const CMStringW &rsFormat, const CPopupSettings &ps);
+bool show_popup(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, int nComparison, const CMStringW &rsFormat);
#endif //__3e6cb4ec_fc47_468f_a2c8_a77941176bc9_CurrencyRatesProviderBase_h__
diff --git a/protocols/CurrencyRates/src/DBUtils.h b/protocols/CurrencyRates/src/DBUtils.h
index 4b5013c101..f5fb65aa4f 100644
--- a/protocols/CurrencyRates/src/DBUtils.h
+++ b/protocols/CurrencyRates/src/DBUtils.h
@@ -12,30 +12,6 @@
#define DB_KEY_DisplayNameFormat "CC_DspNameFrmt"
#define DB_DEF_DisplayNameFormat L"1 %f = %r %i"
-#define DB_KEY_HistoryFormat "CC_HistoryFormat"
-#define DB_DEF_HistoryFormat L"%s %r"
-
-#define DB_KEY_HistoryCondition "CC_AddToHistoryOnlyIfValueIsChanged"
-
-#define DB_KEY_LogMode "CC_LogMode"
-#define DB_KEY_LogFile "CC_LogFile"
-#define DB_KEY_LogCondition "CC_AddToLogOnlyIfValueIsChanged"
-
-#define DB_KEY_LogFormat "CC_LogFileFormat"
-#define DB_DEF_LogFormat L"%s\\t%t\\t%r\\n"
-
-#define DB_KEY_PopupFormat "CC_PopupFormat"
-#define DB_DEF_PopupFormat L"\\nCurrent = %r\\nPrevious = %p"
-
-#define DB_KEY_PopupCondition "CC_ShowPopupOnlyIfValueChanged"
-
-#define DB_KEY_PopupColourMode "CC_PopupColourMode"
-#define DB_KEY_PopupBkColour "CC_PopupColourBk"
-#define DB_KEY_PopupTextColour "CC_PopupColourText"
-#define DB_KEY_PopupDelayMode "CC_PopupDelayMode"
-#define DB_KEY_PopupDelayTimeout "CC_PopupDelayTimeout"
-#define DB_KEY_PopupHistoryFlag "CC_PopupHistoryFlag"
-
#define DB_KEY_TendencyFormat "CC_TendencyFormat"
#define DB_DEF_TendencyFormat L"%r>%p"
diff --git a/protocols/CurrencyRates/src/Forex.cpp b/protocols/CurrencyRates/src/Forex.cpp
index f2e1b9ce89..2ffa99cd54 100644
--- a/protocols/CurrencyRates/src/Forex.cpp
+++ b/protocols/CurrencyRates/src/Forex.cpp
@@ -258,7 +258,25 @@ PLUGININFOEX pluginInfoEx =
};
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ // log settings
+ wLogMode(MODULENAME, "CC_LogMode", lmDisabled),
+ bIsOnlyChangedHistory(MODULENAME, "CC_AddToHistoryOnlyIfValueIsChanged", false),
+ bIsOnlyChangedLogFile(MODULENAME, "CC_AddToLogOnlyIfValueIsChanged", false),
+ wszHistoryFormat(MODULENAME, "CC_HistoryFormat", L"%s %r"),
+ wszLogFileName(MODULENAME, "CC_LogFile", L"%miranda_userdata%\\CurrencyRates\\%currencyratename%.log"),
+ wszLogFileFormat(MODULENAME, "CC_LogFileFormat", L"%s\\t%t\\t%r\\n"),
+
+ // popup settings
+ bShowPopupIfValueChanged(MODULENAME, "CC_ShowPopupOnlyIfValueChanged", false),
+ bUsePopups(MODULENAME, "CC_UsePopups", false),
+ bUseHistory(MODULENAME, "CC_PopupHistoryFlag", false),
+ modeColour(MODULENAME, "CC_PopupColourMode", colourDefault),
+ modeDelay(MODULENAME, "CC_PopupDelayMode", delayFromPopup),
+ rgbBkg(MODULENAME, "CC_PopupColourBk", ::GetSysColor(COLOR_BTNFACE)),
+ rgbText(MODULENAME, "CC_PopupColourText", ::GetSysColor(COLOR_BTNTEXT)),
+ wDelay(MODULENAME, "CC_PopupDelayTimeout", 3),
+ wszPopupFormat(MODULENAME, "CC_PopupFormat", L"\\nCurrent = %r\\nPrevious = %p")
{
RegisterProtocol(PROTOTYPE_VIRTUAL);
SetUniqueId(DB_STR_CURRENCYRATE_SYMBOL);
diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp
index 242a2b08ac..4c36778cf9 100644
--- a/protocols/CurrencyRates/src/HTTPSession.cpp
+++ b/protocols/CurrencyRates/src/HTTPSession.cpp
@@ -6,8 +6,7 @@ HNETLIBUSER CHTTPSession::g_hNetLib = nullptr;
void CALLBACK waitStub()
{
- CAdvProviderSettings global_settings(g_pCurrentProvider);
- show_popup(g_pCurrentProvider, 0, -1, TranslateW(ERROR_MSG), *global_settings.GetPopupSettingsPtr());
+ show_popup(g_pCurrentProvider, 0, -1, TranslateW(ERROR_MSG));
}
static int find_header(const NETLIBHTTPREQUEST* pRequest, const char* hdr)
diff --git a/protocols/CurrencyRates/src/Options.cpp b/protocols/CurrencyRates/src/Options.cpp
index 4f53b5d66e..ae1b720691 100644
--- a/protocols/CurrencyRates/src/Options.cpp
+++ b/protocols/CurrencyRates/src/Options.cpp
@@ -70,33 +70,6 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
// General options dialog
-typedef boost::shared_ptr<CAdvProviderSettings> TAdvSettingsPtr;
-typedef std::map<const ICurrencyRatesProvider *, TAdvSettingsPtr> TAdvSettings;
-
-TAdvSettings g_aAdvSettings;
-
-CAdvProviderSettings* get_adv_settings(const ICurrencyRatesProvider *m_pProvider, bool bCreateIfNonExist)
-{
- TAdvSettings::iterator i = g_aAdvSettings.find(m_pProvider);
- if (i != g_aAdvSettings.end())
- return i->second.get();
-
- if (true == bCreateIfNonExist) {
- TAdvSettingsPtr pAdvSet(new CAdvProviderSettings(m_pProvider));
- g_aAdvSettings.insert(std::make_pair(m_pProvider, pAdvSet));
- return pAdvSet.get();
- }
-
- return nullptr;
-}
-
-void remove_adv_settings(const ICurrencyRatesProvider *m_pProvider)
-{
- TAdvSettings::iterator i = g_aAdvSettings.find(m_pProvider);
- if (i != g_aAdvSettings.end())
- g_aAdvSettings.erase(i);
-}
-
class COptionsDlg : public CDlgBase
{
CMStringW make_contact_name(const CMStringW &rsSymbolFrom, const CMStringW &rsSymbolTo)
@@ -118,7 +91,7 @@ class COptionsDlg : public CDlgBase
CCurrencyRatesProviderBase *m_pProvider;
CCtrlCombo cmbProvider, cmbRefresh;
- CCtrlButton btnAdd, btnRemove, btnDescr, btnAdvanced, btnGetKey;
+ CCtrlButton btnAdd, btnRemove, btnDescr, btnGetKey;
CCtrlListBox m_list;
public:
@@ -131,14 +104,12 @@ public:
btnAdd(this, IDC_BUTTON_ADD),
btnDescr(this, IDC_BUTTON_DESCRIPTION),
btnGetKey(this, IDC_GET_KEY),
- btnRemove(this, IDC_BUTTON_REMOVE),
- btnAdvanced(this, IDC_BUTTON_ADVANCED_SETTINGS)
+ btnRemove(this, IDC_BUTTON_REMOVE)
{
btnAdd.OnClick = Callback(this, &COptionsDlg::onClick_Add);
btnDescr.OnClick = Callback(this, &COptionsDlg::onClick_Descr);
btnGetKey.OnClick = Callback(this, &COptionsDlg::onClick_GetKey);
btnRemove.OnClick = Callback(this, &COptionsDlg::onClick_Remove);
- btnAdvanced.OnClick = Callback(this, &COptionsDlg::onClick_Advanced);
m_list.OnSelChange = Callback(this, &COptionsDlg::onSelChange_Rates);
cmbRefresh.OnSelChanged = Callback(this, &COptionsDlg::onSelChange_Refresh);
@@ -220,10 +191,6 @@ public:
g_plugin.setWString(DB_KEY_TendencyFormat, get_window_text(::GetDlgItem(m_hwnd, IDC_EDIT_TENDENCY_FORMAT)));
g_plugin.setWString(DB_KEY_ApiKey, get_window_text(::GetDlgItem(m_hwnd, IDC_EDIT_PERSONAL_KEY)));
- CAdvProviderSettings *pAdvSet = get_adv_settings(m_pProvider, false);
- if (pAdvSet)
- pAdvSet->SaveToDb();
-
TWatchedRates aTemp(g_aWatchedRates);
TWatchedRates aRemove;
@@ -232,8 +199,8 @@ public:
if (true == m_pProvider->GetWatchedRateInfo(cc, ri)) {
auto it = std::find_if(aTemp.begin(), aTemp.end(), [&ri](const auto &other)->bool
{
- return ((0 == mir_wstrcmpi(ri.first.GetID().c_str(), other.first.GetID().c_str()))
- && ((0 == mir_wstrcmpi(ri.second.GetID().c_str(), other.second.GetID().c_str()))));
+ return ((0 == mir_wstrcmpi(ri.first.GetID(), other.first.GetID()))
+ && ((0 == mir_wstrcmpi(ri.second.GetID(), other.second.GetID()))));
});
if (it == aTemp.end()) {
aRemove.push_back(ri);
@@ -255,11 +222,6 @@ public:
return true;
}
- void OnDestroy() override
- {
- remove_adv_settings(m_pProvider);
- }
-
void onSelChange_Rates(CCtrlListBox *)
{
btnRemove.Enable(LB_ERR != m_list.GetCurSel());
@@ -296,14 +258,6 @@ public:
}
}
- void onClick_Advanced(CCtrlButton *)
- {
- CAdvProviderSettings *pAdvSet = get_adv_settings(m_pProvider, true);
- assert(pAdvSet);
- if (true == ShowSettingsDlg(m_hwnd, pAdvSet))
- NotifyChange();
- }
-
void onClick_Descr(CCtrlButton *)
{
show_variable_list(m_hwnd, m_pProvider);
@@ -332,6 +286,215 @@ public:
};
/////////////////////////////////////////////////////////////////////////////////////////
+// Advanced settings dialog
+
+void select_log_file(HWND hDlg);
+void update_file_controls(HWND hDlg);
+void update_history_controls(HWND hDlg);
+
+class CAdvancedOptDlg : public CDlgBase
+{
+ CCtrlEdit edtHistoryFormat, edtLogFilename, edtLogFormat;
+ CCtrlCheck chkExternalFile, chkHistory, chkHistoryCond, chkLogFileCond;
+ CCtrlButton btnBrowse, btnDescr1, btnDescr2;
+
+public:
+ CAdvancedOptDlg() :
+ CDlgBase(g_plugin, IDD_OPTIONS_ADVANCED),
+ btnDescr1(this, IDC_BUTTON_HISTORY_DESCRIPTION),
+ btnDescr2(this, IDC_BUTTON_LOG_FILE_DESCRIPTION),
+ btnBrowse(this, IDC_BUTTON_BROWSE),
+ chkHistory(this, IDC_CHECK_INTERNAL_HISTORY),
+ chkHistoryCond(this, IDC_CHECK_HISTORY_CONDITION),
+ chkLogFileCond(this, IDC_CHECK_LOG_FILE_CONDITION),
+ chkExternalFile(this, IDC_CHECK_EXTERNAL_FILE),
+ edtLogFormat(this, IDC_EDIT_LOG_FILE_FORMAT),
+ edtLogFilename(this, IDC_EDIT_FILE_NAME),
+ edtHistoryFormat(this, IDC_EDIT_HISTORY_FORMAT)
+ {
+ CreateLink(edtLogFormat, g_plugin.wszLogFileFormat);
+ CreateLink(edtLogFilename, g_plugin.wszLogFileName);
+ CreateLink(edtHistoryFormat, g_plugin.wszHistoryFormat);
+ CreateLink(chkHistoryCond, g_plugin.bIsOnlyChangedHistory);
+ CreateLink(chkLogFileCond, g_plugin.bIsOnlyChangedLogFile);
+
+ btnDescr1.OnClick = btnDescr2.OnClick = Callback(this, &CAdvancedOptDlg::onClick_Description);
+ btnBrowse.OnClick = Callback(this, &CAdvancedOptDlg::onClick_Browse);
+
+ chkHistory.OnChange = Callback(this, &CAdvancedOptDlg::onChange_History);
+ chkExternalFile.OnChange = Callback(this, &CAdvancedOptDlg::onChange_ExternalFile);
+ }
+
+ bool OnInitDialog() override
+ {
+ // log to history
+ uint16_t dwLogMode = g_plugin.wLogMode;
+ chkHistory.SetState((dwLogMode & lmInternalHistory) != 0);
+
+ // log to file
+ chkExternalFile.SetState((dwLogMode & lmExternalFile) != 0);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ uint16_t nLogMode = lmDisabled;
+
+ if (chkExternalFile.IsChecked()) nLogMode |= lmExternalFile;
+ if (chkHistory.IsChecked()) nLogMode |= lmInternalHistory;
+
+ bool bOk = true;
+ ptrW sLogFile(edtLogFilename.GetText());
+ ptrW sLogFileFormat(edtLogFormat.GetText());
+
+ if ((nLogMode & lmExternalFile)) {
+ if (!mir_wstrlen(sLogFile)) {
+ prepare_edit_ctrl_for_error(edtLogFilename.GetHwnd());
+ CurrencyRates_MessageBox(m_hwnd, TranslateT("Enter log file name."), MB_OK | MB_ICONERROR);
+ bOk = false;
+ }
+ else if (!mir_wstrlen(sLogFileFormat)) {
+ prepare_edit_ctrl_for_error(edtLogFormat.GetHwnd());
+ CurrencyRates_MessageBox(m_hwnd, TranslateT("Enter log file format."), MB_OK | MB_ICONERROR);
+ bOk = false;
+ }
+ }
+
+ ptrW sHistoryFormat(edtHistoryFormat.GetText());
+ if ((true == bOk) && (nLogMode & lmInternalHistory) && (!mir_wstrlen(sHistoryFormat))) {
+ prepare_edit_ctrl_for_error(edtHistoryFormat.GetHwnd());
+ CurrencyRates_MessageBox(m_hwnd, TranslateT("Enter history format."), MB_OK | MB_ICONERROR);
+ bOk = false;
+ }
+
+ if (!bOk)
+ return false;
+
+ g_plugin.wLogMode = nLogMode;
+ return true;
+ }
+
+ void onClick_Description(CCtrlButton *)
+ {
+ show_variable_list(m_hwnd, g_pCurrentProvider);
+ }
+
+ void onChange_ExternalFile(CCtrlCheck *)
+ {
+ update_file_controls(m_hwnd);
+ }
+
+ void onChange_History(CCtrlCheck *)
+ {
+ update_history_controls(m_hwnd);
+ }
+
+ void onClick_Browse(CCtrlButton *)
+ {
+ select_log_file(m_hwnd);
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Popup options
+
+class CPopupOptDlg : public CDlgBase
+{
+ CCtrlEdit edtPopupFormat, edtDelay;
+ CCtrlColor clrBack, clrText;
+ CCtrlCheck chkPopup, chkChanged, chkHistory;
+ CCtrlButton btnPreview;
+
+public:
+ CPopupOptDlg() :
+ CDlgBase(g_plugin, IDD_OPTIONS_POPUP),
+ clrBack(this, IDC_BGCOLOR),
+ clrText(this, IDC_TEXTCOLOR),
+ chkPopup(this, IDC_CHECK_SHOW_POPUP),
+ chkHistory(this, IDC_CHECK_DONT_USE_POPUPHISTORY),
+ chkChanged(this, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED),
+ edtDelay(this, IDC_DELAY),
+ edtPopupFormat(this, IDC_EDIT_POPUP_FORMAT),
+ btnPreview(this, IDC_PREV)
+ {
+ CreateLink(chkPopup, g_plugin.bUsePopups);
+ CreateLink(chkHistory, g_plugin.bUseHistory);
+ CreateLink(chkChanged, g_plugin.bShowPopupIfValueChanged);
+
+ CreateLink(clrBack, g_plugin.rgbBkg);
+ CreateLink(clrText, g_plugin.rgbText);
+
+ CreateLink(edtDelay, g_plugin.wDelay);
+ CreateLink(edtPopupFormat, g_plugin.wszPopupFormat);
+
+ chkPopup.OnChange = Callback(this, &CPopupOptDlg::onChange_Popup);
+ btnPreview.OnClick = Callback(this, &CPopupOptDlg::onClick_Preview);
+ }
+
+ bool OnInitDialog() override
+ {
+ ::CheckRadioButton(m_hwnd, IDC_RADIO_DEFAULT_COLOURS, IDC_RADIO_USER_DEFINED_COLOURS, (colourDefault == g_plugin.modeColour) ? IDC_RADIO_DEFAULT_COLOURS : IDC_RADIO_USER_DEFINED_COLOURS);
+ UINT n;
+ switch (g_plugin.modeDelay) {
+ case delayFromPopup:
+ n = IDC_DELAYFROMPU;
+ break;
+ case delayCustom:
+ n = IDC_DELAYCUSTOM;
+ break;
+ case delayPermanent:
+ default:
+ n = IDC_DELAYPERMANENT;
+ break;
+ }
+ ::CheckRadioButton(m_hwnd, IDC_DELAYFROMPU, IDC_DELAYPERMANENT, n);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ uint8_t nModeDelay;
+ if (1 == ::IsDlgButtonChecked(m_hwnd, IDC_DELAYFROMPU))
+ nModeDelay = delayFromPopup;
+ else if (1 == ::IsDlgButtonChecked(m_hwnd, IDC_DELAYCUSTOM))
+ nModeDelay = delayCustom;
+ else
+ nModeDelay = delayPermanent;
+ g_plugin.modeDelay = nModeDelay;
+
+ if (1 == ::IsDlgButtonChecked(m_hwnd, IDC_RADIO_DEFAULT_COLOURS))
+ g_plugin.modeColour = colourDefault;
+ else
+ g_plugin.modeColour = colourUserDefined;
+ return true;
+ }
+
+ void OnChange() override
+ {
+ bool bIsColoursEnabled = 1 == IsDlgButtonChecked(m_hwnd, IDC_RADIO_USER_DEFINED_COLOURS);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_BGCOLOR), bIsColoursEnabled);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_TEXTCOLOR), bIsColoursEnabled);
+
+ bool bIsDelayEnabled = 1 == IsDlgButtonChecked(m_hwnd, IDC_DELAYCUSTOM);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_DELAY), bIsDelayEnabled);
+ }
+
+ void onChange_Popup(CCtrlCheck *)
+ {
+ bool bEnable = chkPopup.IsChecked();
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_EDIT_POPUP_FORMAT), bEnable);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED), bEnable);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_STATIC_POPUP_FORMAT), bEnable);
+ ::EnableWindow(::GetDlgItem(m_hwnd, IDC_BUTTON_POPUP_FORMAT_DESCRIPTION), bEnable);
+ }
+
+ void onClick_Preview(CCtrlButton *)
+ {
+ show_popup(0, 0, 1, L"");
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Module entry point
int CurrencyRatesEventFunc_OptInitialise(WPARAM wp, LPARAM)
@@ -345,5 +508,15 @@ int CurrencyRatesEventFunc_OptInitialise(WPARAM wp, LPARAM)
odp.pDialog = new COptionsDlg();
odp.szTab.a = LPGEN("General");
g_plugin.addOptions(wp, &odp);
+
+ odp.pDialog = new CAdvancedOptDlg();
+ odp.szTab.a = LPGEN("Advanced");
+ g_plugin.addOptions(wp, &odp);
+
+ odp.position = 910000002;
+ odp.szGroup.a = LPGEN("Popups");
+ odp.szTab.a = nullptr;
+ odp.pDialog = new CPopupOptDlg();
+ g_plugin.addOptions(wp, &odp);
return 0;
}
diff --git a/protocols/CurrencyRates/src/SettingsDlg.cpp b/protocols/CurrencyRates/src/SettingsDlg.cpp
index 042012ce19..50526159bf 100644
--- a/protocols/CurrencyRates/src/SettingsDlg.cpp
+++ b/protocols/CurrencyRates/src/SettingsDlg.cpp
@@ -2,9 +2,6 @@
#define WINDOW_PREFIX_SETTINGS "Edit Settings_"
-const wchar_t g_pszVariableCurrencyRateName[] = L"%currencyratename%";
-const wchar_t g_pszVariableUserProfile[] = L"%miranda_userdata%";
-
void update_file_controls(HWND hDlg)
{
bool bEnable = (1 == ::IsDlgButtonChecked(hDlg, IDC_CHECK_EXTERNAL_FILE));
@@ -28,16 +25,6 @@ void update_history_controls(HWND hDlg)
::EnableWindow(::GetDlgItem(hDlg, IDC_CHECK_HISTORY_CONDITION), bEnable);
}
-void update_popup_controls(HWND hDlg)
-{
- bool bEnable = (1 == ::IsDlgButtonChecked(hDlg, IDC_CHECK_SHOW_POPUP));
- ::EnableWindow(::GetDlgItem(hDlg, IDC_EDIT_POPUP_FORMAT), bEnable);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED), bEnable);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_STATIC_POPUP_FORMAT), bEnable);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_POPUP_FORMAT_DESCRIPTION), bEnable);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_POPUP_SETTINGS), bEnable);
-}
-
void update_all_controls(HWND hDlg)
{
bool bIsCheckedContactSpec = (1 == ::IsDlgButtonChecked(hDlg, IDC_CHECK_CONTACT_SPECIFIC));
@@ -65,7 +52,6 @@ void update_all_controls(HWND hDlg)
::EnableWindow(::GetDlgItem(hDlg, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED), (bIsCheckedContactSpec && bIsCheckedShowPopup));
::EnableWindow(::GetDlgItem(hDlg, IDC_STATIC_POPUP_FORMAT), (bIsCheckedContactSpec && bIsCheckedShowPopup));
::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_POPUP_FORMAT_DESCRIPTION), (bIsCheckedContactSpec && bIsCheckedShowPopup));
- ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_POPUP_SETTINGS), (bIsCheckedContactSpec));
}
static LPCTSTR pszFilterParts[] = { LPGENW("Log Files (*.txt,*.log)"), L"*.txt;*.log", LPGENW("All files (*.*)"), L"*.*" };
@@ -92,19 +78,17 @@ void select_log_file(HWND hDlg)
ofn.lpstrDefExt = L"log";
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER;
- BOOL b = GetOpenFileName(&ofn);
- if (TRUE == b) {
- SetDlgItemText(hDlg, IDC_EDIT_FILE_NAME, ofn.lpstrFile);
- }
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hDlg, IDC_EDIT_FILE_NAME, pszFile);
}
struct CSettingWindowParam
{
- CSettingWindowParam(MCONTACT hContact) : m_hContact(hContact), m_pPopupSettings(nullptr) {}
- ~CSettingWindowParam() { delete m_pPopupSettings; }
+ CSettingWindowParam(MCONTACT hContact) :
+ m_hContact(hContact)
+ {}
MCONTACT m_hContact;
- CPopupSettings *m_pPopupSettings;
};
inline CSettingWindowParam *get_param(HWND hWnd)
@@ -112,118 +96,6 @@ inline CSettingWindowParam *get_param(HWND hWnd)
return reinterpret_cast<CSettingWindowParam *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
}
-void update_popup_controls_settings(HWND hDlg)
-{
- bool bIsColoursEnabled = 1 == IsDlgButtonChecked(hDlg, IDC_RADIO_USER_DEFINED_COLOURS);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_BGCOLOR), bIsColoursEnabled);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_TEXTCOLOR), bIsColoursEnabled);
-
- bool bIsDelayEnabled = 1 == IsDlgButtonChecked(hDlg, IDC_DELAYCUSTOM);
- ::EnableWindow(::GetDlgItem(hDlg, IDC_DELAY), bIsDelayEnabled);
-}
-
-INT_PTR CALLBACK EditPopupSettingsDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
-{
- auto *pSettings = (CPopupSettings *)(GetWindowLongPtr(hWnd, GWLP_USERDATA));
-
- switch (msg) {
- case WM_INITDIALOG:
- {
- pSettings = (CPopupSettings *)lp;
- TranslateDialogDefault(hWnd);
- ::SendDlgItemMessage(hWnd, IDC_BGCOLOR, CPM_SETCOLOUR, 0, pSettings->GetColourBk());
- ::SendDlgItemMessage(hWnd, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, pSettings->GetColourText());
-
- ::CheckDlgButton(hWnd, IDC_CHECK_DONT_USE_POPUPHISTORY, pSettings->GetHistoryFlag() ? BST_CHECKED : BST_UNCHECKED);
-
- ::CheckRadioButton(hWnd, IDC_RADIO_DEFAULT_COLOURS, IDC_RADIO_USER_DEFINED_COLOURS, (CPopupSettings::colourDefault == pSettings->GetColourMode()) ? IDC_RADIO_DEFAULT_COLOURS : IDC_RADIO_USER_DEFINED_COLOURS);
- UINT n;
- switch (pSettings->GetDelayMode()) {
- case CPopupSettings::delayFromPopup:
- n = IDC_DELAYFROMPU;
- break;
- case CPopupSettings::delayCustom:
- n = IDC_DELAYCUSTOM;
- break;
- case CPopupSettings::delayPermanent:
- default:
- n = IDC_DELAYPERMANENT;
- break;
- }
- ::CheckRadioButton(hWnd, IDC_DELAYFROMPU, IDC_DELAYPERMANENT, n);
-
- ::SetDlgItemInt(hWnd, IDC_DELAY, pSettings->GetDelayTimeout(), FALSE);
-
- update_popup_controls_settings(hWnd);
-
- ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pSettings));
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wp)) {
- case IDC_PREV:
- show_popup(0, 0, 1, L"", *pSettings);
- break;
-
- case IDC_RADIO_DEFAULT_COLOURS:
- case IDC_RADIO_USER_DEFINED_COLOURS:
- case IDC_DELAYFROMPU:
- case IDC_DELAYCUSTOM:
- case IDC_DELAYPERMANENT:
- update_popup_controls_settings(hWnd);
- break;
-
- case IDCANCEL:
- ::EndDialog(hWnd, IDCANCEL);
- break;
-
- case IDOK:
- {
- bool bError = false;
- BOOL bOk = FALSE;
- UINT nDelay = ::GetDlgItemInt(hWnd, IDC_DELAY, &bOk, FALSE);
- CPopupSettings::EDelayMode nModeDelay = pSettings->GetDelayMode();
- if (1 == ::IsDlgButtonChecked(hWnd, IDC_DELAYFROMPU))
- nModeDelay = CPopupSettings::delayFromPopup;
- else if (1 == ::IsDlgButtonChecked(hWnd, IDC_DELAYCUSTOM)) {
- if (TRUE == bOk)
- nModeDelay = CPopupSettings::delayCustom;
- else {
- prepare_edit_ctrl_for_error(::GetDlgItem(hWnd, IDC_DELAY));
- CurrencyRates_MessageBox(hWnd, TranslateT("Enter integer value"), MB_OK | MB_ICONERROR);
- bError = true;
- }
- }
- else if (1 == ::IsDlgButtonChecked(hWnd, IDC_DELAYPERMANENT))
- nModeDelay = CPopupSettings::delayPermanent;
-
- if (false == bError) {
- pSettings->SetDelayMode(nModeDelay);
- if (TRUE == bOk)
- pSettings->SetDelayTimeout(nDelay);
-
- pSettings->SetHistoryFlag((1 == IsDlgButtonChecked(hWnd, IDC_CHECK_DONT_USE_POPUPHISTORY)));
-
- if (1 == ::IsDlgButtonChecked(hWnd, IDC_RADIO_DEFAULT_COLOURS))
- pSettings->SetColourMode(CPopupSettings::colourDefault);
- else if (1 == ::IsDlgButtonChecked(hWnd, IDC_RADIO_USER_DEFINED_COLOURS))
- pSettings->SetColourMode(CPopupSettings::colourUserDefined);
-
- pSettings->SetColourBk(static_cast<COLORREF>(::SendDlgItemMessage(hWnd, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)));
- pSettings->SetColourText(static_cast<COLORREF>(::SendDlgItemMessage(hWnd, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)));
-
- ::EndDialog(hWnd, IDOK);
- }
- }
- break;
- }
- break;
- }
-
- return FALSE;
-}
-
INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg) {
@@ -241,15 +113,14 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L
uint8_t bUseContactSpecific = g_plugin.getByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 0);
::CheckDlgButton(hWnd, IDC_CHECK_CONTACT_SPECIFIC, bUseContactSpecific ? BST_CHECKED : BST_UNCHECKED);
- CAdvProviderSettings setGlobal(g_pCurrentProvider);
// log to history
- uint16_t dwLogMode = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, setGlobal.GetLogMode());
+ uint16_t dwLogMode = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, g_plugin.wLogMode);
UINT nCheck = (dwLogMode & lmInternalHistory) ? 1 : 0;
::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED);
- ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat()));
+ ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_HISTORY, g_plugin.wszHistoryFormat));
- uint16_t wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag());
+ uint16_t wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, g_plugin.bIsOnlyChangedHistory);
::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED);
// log to file
@@ -258,21 +129,21 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L
CMStringW sLogFileName = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_LOG_FILE);
if (sLogFileName.IsEmpty())
- sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName);
+ sLogFileName = GenerateLogFileName((wchar_t*)g_plugin.wszLogFileName, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName);
::SetDlgItemText(hWnd, IDC_EDIT_FILE_NAME, sLogFileName);
- ::SetDlgItemText(hWnd, IDC_EDIT_LOG_FILE_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat()));
+ ::SetDlgItemText(hWnd, IDC_EDIT_LOG_FILE_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, g_plugin.wszLogFileFormat));
- wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag());
+ wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, g_plugin.bIsOnlyChangedLogFile);
::CheckDlgButton(hWnd, IDC_CHECK_LOG_FILE_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED);
// popup
nCheck = (dwLogMode & lmPopup) ? 1 : 0;
::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED);
- ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()));
+ ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_FORMAT_POPUP, g_plugin.wszPopupFormat));
- bool bOnlyIfChanged = 1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag());
+ bool bOnlyIfChanged = 1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, g_plugin.bShowPopupIfValueChanged);
::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED);
update_all_controls(hWnd);
@@ -305,30 +176,11 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L
if (BN_CLICKED == HIWORD(wp))
update_history_controls(hWnd);
break;
- case IDC_CHECK_SHOW_POPUP:
- if (BN_CLICKED == HIWORD(wp))
- update_popup_controls(hWnd);
- break;
case IDC_BUTTON_BROWSE:
if (BN_CLICKED == HIWORD(wp))
select_log_file(hWnd);
break;
- case IDC_BUTTON_POPUP_SETTINGS:
- if (BN_CLICKED == HIWORD(wp)) {
- CSettingWindowParam *pParam = get_param(hWnd);
- if (!pParam->m_pPopupSettings) {
- pParam->m_pPopupSettings = new CPopupSettings();
- pParam->m_pPopupSettings->InitForContact(pParam->m_hContact);
- }
-
- DialogBoxParam(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_DIALOG_POPUP),
- hWnd,
- EditPopupSettingsDlgProc, LPARAM(pParam->m_pPopupSettings));
- }
- break;
-
case IDOK:
{
CSettingWindowParam *pParam = get_param(hWnd);
@@ -397,11 +249,6 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L
g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, sLogFileFormat.c_str());
g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_FORMAT_HISTORY, sHistoryFormat.c_str());
g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_FORMAT_POPUP, sPopupFormat.c_str());
-
- if (pParam->m_pPopupSettings) {
- pParam->m_pPopupSettings->SaveForContact(hContact);
- }
-
::DestroyWindow(hWnd);
}
}
@@ -444,372 +291,6 @@ void ShowSettingsDlg(MCONTACT hContact)
else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACT_SETTINGS), nullptr, EditSettingsPerContactDlgProc, LPARAM(hContact));
}
-//////////////////////////////////////////////////////////////////////////
-
-INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
-{
- switch (msg) {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hWnd);
- CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(lp);
-
- ::SetDlgItemText(hWnd, IDC_EDIT_NAME, pAdvSettings->GetProviderPtr()->GetInfo().m_sName.c_str());
-
- // log to history
- uint16_t dwLogMode = pAdvSettings->GetLogMode();
- UINT nCheck = (dwLogMode & lmInternalHistory) ? 1 : 0;
- ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED);
- ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, pAdvSettings->GetHistoryFormat().c_str());
- ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (pAdvSettings->GetHistoryOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED);
-
- // log to file
- nCheck = (dwLogMode & lmExternalFile) ? 1 : 0;
- ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED);
- ::SetDlgItemText(hWnd, IDC_EDIT_FILE_NAME, pAdvSettings->GetLogFileName().c_str());
- ::SetDlgItemText(hWnd, IDC_EDIT_LOG_FILE_FORMAT, pAdvSettings->GetLogFormat().c_str());
- ::CheckDlgButton(hWnd, IDC_CHECK_LOG_FILE_CONDITION, (pAdvSettings->GetLogOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED);
-
- update_file_controls(hWnd);
- update_history_controls(hWnd);
-
- // popup
- nCheck = (dwLogMode & lmPopup) ? 1 : 0;
- ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED);
- ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, pAdvSettings->GetPopupFormat().c_str());
- ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (pAdvSettings->GetShowPopupIfValueChangedFlag()) ? BST_CHECKED : BST_UNCHECKED);
-
- update_popup_controls(hWnd);
-
- ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pAdvSettings));
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wp)) {
- case IDOK:
- {
- uint16_t nLogMode = lmDisabled;
- UINT nCheck = ::IsDlgButtonChecked(hWnd, IDC_CHECK_EXTERNAL_FILE);
- if (1 == nCheck) {
- nLogMode |= lmExternalFile;
- }
-
- nCheck = ::IsDlgButtonChecked(hWnd, IDC_CHECK_INTERNAL_HISTORY);
- if (1 == nCheck) {
- nLogMode |= lmInternalHistory;
- }
-
- nCheck = ::IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_POPUP);
- if (1 == nCheck) {
- nLogMode |= lmPopup;
- }
-
- bool bOk = true;
- HWND hwndLogFile = ::GetDlgItem(hWnd, IDC_EDIT_FILE_NAME);
- HWND hwndLogFileFrmt = ::GetDlgItem(hWnd, IDC_EDIT_LOG_FILE_FORMAT);
-
- CMStringW sLogFile = get_window_text(hwndLogFile);
- CMStringW sLogFileFormat = get_window_text(hwndLogFileFrmt);
-
- if ((nLogMode & lmExternalFile)) {
- if (true == sLogFile.IsEmpty()) {
- prepare_edit_ctrl_for_error(hwndLogFile);
- CurrencyRates_MessageBox(hWnd, TranslateT("Enter log file name."), MB_OK | MB_ICONERROR);
- bOk = false;
- }
- else if (true == sLogFileFormat.IsEmpty()) {
- prepare_edit_ctrl_for_error(hwndLogFileFrmt);
- CurrencyRates_MessageBox(hWnd, TranslateT("Enter log file format."), MB_OK | MB_ICONERROR);
- bOk = false;
- }
- }
-
- HWND hwndHistoryFrmt = ::GetDlgItem(hWnd, IDC_EDIT_HISTORY_FORMAT);
- CMStringW sHistoryFormat = get_window_text(hwndHistoryFrmt);
- if ((true == bOk) && (nLogMode & lmInternalHistory) && (true == sHistoryFormat.IsEmpty())) {
- prepare_edit_ctrl_for_error(hwndHistoryFrmt);
- CurrencyRates_MessageBox(hWnd, TranslateT("Enter history format."), MB_OK | MB_ICONERROR);
- bOk = false;
- }
-
- HWND hwndPopupFrmt = ::GetDlgItem(hWnd, IDC_EDIT_POPUP_FORMAT);
- CMStringW sPopupFormat = get_window_text(hwndPopupFrmt);
- if ((true == bOk) && (nLogMode & lmPopup) && (true == sPopupFormat.IsEmpty())) {
- prepare_edit_ctrl_for_error(hwndPopupFrmt);
- CurrencyRates_MessageBox(hWnd, TranslateT("Enter popup window format."), MB_OK | MB_ICONERROR);
- bOk = false;
- }
-
- if (true == bOk) {
- CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
-
- pAdvSettings->SetLogMode(nLogMode);
- pAdvSettings->SetHistoryOnlyChangedFlag(1 == IsDlgButtonChecked(hWnd, IDC_CHECK_HISTORY_CONDITION));
- pAdvSettings->SetLogOnlyChangedFlag(1 == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_FILE_CONDITION));
- pAdvSettings->SetShowPopupIfValueChangedFlag(1 == IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED));
- pAdvSettings->SetLogFileName(sLogFile);
- pAdvSettings->SetLogFormat(sLogFileFormat);
- pAdvSettings->SetHistoryFormat(sHistoryFormat);
- pAdvSettings->SetPopupFormat(sPopupFormat);
-
- ::EndDialog(hWnd, IDOK);
- }
- }
- break;
-
- case IDCANCEL:
- ::EndDialog(hWnd, IDCANCEL);
- break;
-
- case IDC_BUTTON_HISTORY_DESCRIPTION:
- case IDC_BUTTON_LOG_FILE_DESCRIPTION:
- case IDC_BUTTON_POPUP_FORMAT_DESCRIPTION:
- if (BN_CLICKED == HIWORD(wp)) {
- const CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
- show_variable_list(hWnd, pAdvSettings->GetProviderPtr());
- }
- break;
-
- case IDC_CHECK_EXTERNAL_FILE:
- if (BN_CLICKED == HIWORD(wp))
- update_file_controls(hWnd);
- break;
-
- case IDC_CHECK_INTERNAL_HISTORY:
- if (BN_CLICKED == HIWORD(wp))
- update_history_controls(hWnd);
- break;
-
- case IDC_CHECK_SHOW_POPUP:
- if (BN_CLICKED == HIWORD(wp))
- update_popup_controls(hWnd);
- break;
-
- case IDC_BUTTON_BROWSE:
- if (BN_CLICKED == HIWORD(wp))
- select_log_file(hWnd);
- break;
-
- case IDC_BUTTON_POPUP_SETTINGS:
- const CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
- DialogBoxParam(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_DIALOG_POPUP),
- hWnd,
- EditPopupSettingsDlgProc, LPARAM(pAdvSettings->GetPopupSettingsPtr()));
- break;
- }
- break;
- }
- return FALSE;
-}
-
-CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider *pCurrencyRatesProvider) :
- m_pCurrencyRatesProvider(pCurrencyRatesProvider),
- m_wLogMode(lmDisabled),
- m_bIsOnlyChangedHistory(false),
- m_bIsOnlyChangedLogFile(false),
- m_bShowPopupIfValueChanged(false),
- m_pPopupSettings(nullptr)
-{
- assert(m_pCurrencyRatesProvider);
-
- m_wLogMode = g_plugin.getWord(DB_KEY_LogMode, static_cast<uint16_t>(lmDisabled));
- m_sFormatHistory = g_plugin.getMStringW(DB_KEY_HistoryFormat, DB_DEF_HistoryFormat);
- m_bIsOnlyChangedHistory = 1 == g_plugin.getByte(DB_KEY_HistoryCondition, 0);
-
- m_sLogFileName = g_plugin.getMStringW(DB_KEY_LogFile);
- if (true == m_sLogFileName.IsEmpty()) {
- m_sLogFileName = g_pszVariableUserProfile;
- m_sLogFileName += L"\\CurrencyRates\\";
- m_sLogFileName += g_pszVariableCurrencyRateName;
- m_sLogFileName += L".log";
- }
-
- m_sFormatLogFile = g_plugin.getMStringW(DB_KEY_LogFormat, DB_DEF_LogFormat);
- m_bIsOnlyChangedLogFile = (1 == g_plugin.getByte(DB_KEY_LogCondition, 0));
-
- m_sPopupFormat = g_plugin.getMStringW(DB_KEY_PopupFormat, DB_DEF_PopupFormat);
- m_bShowPopupIfValueChanged = (1 == g_plugin.getByte(DB_KEY_PopupCondition, 0));
-}
-
-CAdvProviderSettings::~CAdvProviderSettings()
-{
- delete m_pPopupSettings;
-}
-
-const ICurrencyRatesProvider *CAdvProviderSettings::GetProviderPtr() const
-{
- return m_pCurrencyRatesProvider;
-}
-
-void CAdvProviderSettings::SaveToDb() const
-{
- g_plugin.setWord(DB_KEY_LogMode, m_wLogMode);
- g_plugin.setWString(DB_KEY_HistoryFormat, m_sFormatHistory.c_str());
- g_plugin.setByte(DB_KEY_HistoryCondition, m_bIsOnlyChangedHistory);
- g_plugin.setWString(DB_KEY_LogFile, m_sLogFileName.c_str());
- g_plugin.setWString(DB_KEY_LogFormat, m_sFormatLogFile.c_str());
- g_plugin.setByte(DB_KEY_LogCondition, m_bIsOnlyChangedLogFile);
- g_plugin.setWString(DB_KEY_PopupFormat, m_sPopupFormat.c_str());
- g_plugin.setByte(DB_KEY_PopupCondition, m_bShowPopupIfValueChanged);
-
- if (nullptr != m_pPopupSettings) {
- g_plugin.setByte(DB_KEY_PopupColourMode, static_cast<uint8_t>(m_pPopupSettings->GetColourMode()));
- g_plugin.setDword(DB_KEY_PopupBkColour, m_pPopupSettings->GetColourBk());
- g_plugin.setDword(DB_KEY_PopupTextColour, m_pPopupSettings->GetColourText());
- g_plugin.setByte(DB_KEY_PopupDelayMode, static_cast<uint8_t>(m_pPopupSettings->GetDelayMode()));
- g_plugin.setWord(DB_KEY_PopupDelayTimeout, m_pPopupSettings->GetDelayTimeout());
- g_plugin.setByte(DB_KEY_PopupHistoryFlag, m_pPopupSettings->GetHistoryFlag());
- }
-}
-
-CPopupSettings *CAdvProviderSettings::GetPopupSettingsPtr() const
-{
- if (nullptr == m_pPopupSettings)
- m_pPopupSettings = new CPopupSettings();
-
- return m_pPopupSettings;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// class CPopupSettings
-
-CPopupSettings::CPopupSettings() :
- m_modeColour(colourDefault),
- m_modeDelay(delayFromPopup),
- m_rgbBkg(GetDefColourBk()),
- m_rgbText(GetDefColourText()),
- m_wDelay(3),
- m_bUseHistory(false)
-
-{
- uint8_t m = g_plugin.getByte(DB_KEY_PopupColourMode, static_cast<uint8_t>(m_modeColour));
- if (m >= colourDefault && m <= colourUserDefined)
- m_modeColour = static_cast<EColourMode>(m);
-
- m_rgbBkg = g_plugin.getDword(DB_KEY_PopupBkColour, m_rgbBkg);
- m_rgbText = g_plugin.getDword(DB_KEY_PopupTextColour, m_rgbText);
-
- m = g_plugin.getByte(DB_KEY_PopupDelayMode, static_cast<uint8_t>(m_modeDelay));
- if (m >= delayFromPopup && m <= delayPermanent)
- m_modeDelay = static_cast<EDelayMode>(m);
-
- m_wDelay = g_plugin.getWord(DB_KEY_PopupDelayTimeout, m_wDelay);
- m_bUseHistory = (1 == g_plugin.getByte(DB_KEY_PopupHistoryFlag, m_bUseHistory));
-}
-
-/*static */
-COLORREF CPopupSettings::GetDefColourBk()
-{
- return ::GetSysColor(COLOR_BTNFACE);
-}
-
-/*static */
-COLORREF CPopupSettings::GetDefColourText()
-{
- return ::GetSysColor(COLOR_BTNTEXT);
-}
-
-void CPopupSettings::InitForContact(MCONTACT hContact)
-{
- uint8_t m = g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<uint8_t>(m_modeColour));
- if (m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined) {
- m_modeColour = static_cast<CPopupSettings::EColourMode>(m);
- }
-
- m_rgbBkg = g_plugin.getDword(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_BK, m_rgbBkg);
- m_rgbText = g_plugin.getDword(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_TEXT, m_rgbText);
-
- m = g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_DELAY_MODE, static_cast<uint8_t>(m_modeDelay));
- if (m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent) {
- m_modeDelay = static_cast<CPopupSettings::EDelayMode>(m);
- }
- m_wDelay = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_POPUP_DELAY_TIMEOUT, m_wDelay);
- m_bUseHistory = 1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_HISTORY_FLAG, m_bUseHistory);
-}
-
-void CPopupSettings::SaveForContact(MCONTACT hContact) const
-{
- g_plugin.setByte(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<uint8_t>(m_modeColour));
- g_plugin.setDword(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_BK, m_rgbBkg);
- g_plugin.setDword(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_TEXT, m_rgbText);
- g_plugin.setByte(hContact, DB_STR_CURRENCYRATE_POPUP_DELAY_MODE, static_cast<uint8_t>(m_modeDelay));
- g_plugin.setWord(hContact, DB_STR_CURRENCYRATE_POPUP_DELAY_TIMEOUT, m_wDelay);
- g_plugin.setByte(hContact, DB_STR_CURRENCYRATE_POPUP_HISTORY_FLAG, m_bUseHistory);
-}
-
-CPopupSettings::EColourMode CPopupSettings::GetColourMode() const
-{
- return m_modeColour;
-}
-
-void CPopupSettings::SetColourMode(EColourMode nMode)
-{
- m_modeColour = nMode;
-}
-
-COLORREF CPopupSettings::GetColourBk() const
-{
- return m_rgbBkg;
-}
-
-void CPopupSettings::SetColourBk(COLORREF rgb)
-{
- m_rgbBkg = rgb;
-}
-
-COLORREF CPopupSettings::GetColourText() const
-{
- return m_rgbText;
-}
-
-void CPopupSettings::SetColourText(COLORREF rgb)
-{
- m_rgbText = rgb;
-}
-
-CPopupSettings::EDelayMode CPopupSettings::GetDelayMode() const
-{
- return m_modeDelay;
-}
-
-void CPopupSettings::SetDelayMode(EDelayMode nMode)
-{
- m_modeDelay = nMode;
-}
-
-uint16_t CPopupSettings::GetDelayTimeout() const
-{
- return m_wDelay;
-}
-
-void CPopupSettings::SetDelayTimeout(uint16_t delay)
-{
- m_wDelay = delay;
-}
-
-bool CPopupSettings::GetHistoryFlag() const
-{
- return m_bUseHistory;
-}
-
-void CPopupSettings::SetHistoryFlag(bool flag)
-{
- m_bUseHistory = flag;
-}
-
-bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings *pAdvSettings)
-{
- assert(pAdvSettings);
-
- return (IDOK == DialogBoxParam(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_PROVIDER_ADV_SETTINGS),
- hWndParent,
- EditSettingsPerProviderDlgProc,
- LPARAM(pAdvSettings)));
-}
-
CMStringW GenerateLogFileName(const CMStringW &rsLogFilePattern, const CMStringW &rsCurrencyRateSymbol, int nFlags)
{
CMStringW sPath = rsLogFilePattern;
@@ -818,7 +299,7 @@ CMStringW GenerateLogFileName(const CMStringW &rsLogFilePattern, const CMStringW
CMStringW s = rsCurrencyRateSymbol;
FixInvalidChars(s);
- sPath.Replace(g_pszVariableCurrencyRateName, s);
+ sPath.Replace(L"%currencyratename%", s);
}
if (nFlags & glfnResolveUserProfile) {
@@ -842,8 +323,7 @@ CMStringW GetContactLogFileName(MCONTACT hContact)
if (bUseContactSpecific)
sPattern = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_LOG_FILE);
else {
- CAdvProviderSettings global_settings(g_pCurrentProvider);
- sPattern = global_settings.GetLogFileName();
+ sPattern = g_plugin.wszLogFileName;
}
result = GenerateLogFileName(sPattern, g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL));
diff --git a/protocols/CurrencyRates/src/SettingsDlg.h b/protocols/CurrencyRates/src/SettingsDlg.h
index 76c0868493..318009af95 100644
--- a/protocols/CurrencyRates/src/SettingsDlg.h
+++ b/protocols/CurrencyRates/src/SettingsDlg.h
@@ -1,108 +1,7 @@
#ifndef __E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__
#define __E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__
-class CPopupSettings
-{
-public:
- enum EColourMode
- {
- colourDefault,
- colourUserDefined,
- };
-
- enum EDelayMode
- {
- delayFromPopup,
- delayCustom,
- delayPermanent
- };
-
-public:
- CPopupSettings();
-
- static COLORREF GetDefColourBk();
- static COLORREF GetDefColourText();
-
- void InitForContact(MCONTACT hContact);
- void SaveForContact(MCONTACT hContact) const;
-
- EColourMode GetColourMode() const;
- void SetColourMode(EColourMode nMode);
-
- COLORREF GetColourBk() const;
- void SetColourBk(COLORREF rgb);
-
- COLORREF GetColourText() const;
- void SetColourText(COLORREF rgb);
-
- EDelayMode GetDelayMode() const;
- void SetDelayMode(EDelayMode nMode);
-
- uint16_t GetDelayTimeout() const;
- void SetDelayTimeout(uint16_t delay);
-
- bool GetHistoryFlag() const;
- void SetHistoryFlag(bool flag);
-
-private:
- EColourMode m_modeColour;
- EDelayMode m_modeDelay;
- COLORREF m_rgbBkg;
- COLORREF m_rgbText;
- uint16_t m_wDelay;
- bool m_bUseHistory;
-};
-
-
-class CAdvProviderSettings
-{
- const ICurrencyRatesProvider *m_pCurrencyRatesProvider;
- uint16_t m_wLogMode;
- bool m_bIsOnlyChangedHistory;
- bool m_bIsOnlyChangedLogFile;
- bool m_bShowPopupIfValueChanged;
- CMStringW m_sFormatHistory;
- CMStringW m_sLogFileName;
- CMStringW m_sFormatLogFile;
- CMStringW m_sPopupFormat;
- mutable CPopupSettings* m_pPopupSettings;
-
-public:
- CAdvProviderSettings(const ICurrencyRatesProvider *pCurrencyRatesProvider);
- ~CAdvProviderSettings();
-
- void SaveToDb() const;
-
- __forceinline uint16_t GetLogMode() const { return m_wLogMode; }
- __forceinline void SetLogMode(uint16_t wMode) { m_wLogMode = wMode; }
-
- __forceinline const CMStringW& GetHistoryFormat() const { return m_sFormatHistory; }
- __forceinline void SetHistoryFormat(const CMStringW &rsFormat) { m_sFormatHistory = rsFormat; }
-
- __forceinline bool GetHistoryOnlyChangedFlag() const { return m_bIsOnlyChangedHistory; }
- __forceinline void SetHistoryOnlyChangedFlag(bool bMode) { m_bIsOnlyChangedHistory = bMode; }
-
- __forceinline const CMStringW& GetLogFileName() const { return m_sLogFileName; }
- __forceinline void SetLogFileName(const CMStringW &rsFile) { m_sLogFileName = rsFile; }
-
- __forceinline const CMStringW& GetLogFormat() const { return m_sFormatLogFile; }
- __forceinline void SetLogFormat(const CMStringW &rsFormat) { m_sFormatLogFile = rsFormat; }
-
- __forceinline bool GetLogOnlyChangedFlag() const { return m_bIsOnlyChangedLogFile; }
- __forceinline void SetLogOnlyChangedFlag(bool bMode) { m_bIsOnlyChangedLogFile = bMode; }
-
- __forceinline const CMStringW& GetPopupFormat() const { return m_sPopupFormat; }
- __forceinline void SetPopupFormat(const CMStringW &val) { m_sPopupFormat = val; }
-
- __forceinline bool GetShowPopupIfValueChangedFlag() const { return m_bShowPopupIfValueChanged; }
- __forceinline void SetShowPopupIfValueChangedFlag(bool val) { m_bShowPopupIfValueChanged = val; }
-
- const ICurrencyRatesProvider* GetProviderPtr() const;
- CPopupSettings* GetPopupSettingsPtr() const;
-};
-
void ShowSettingsDlg(MCONTACT hContact);
-bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings* pAdvSettings);
enum
{
diff --git a/protocols/CurrencyRates/src/resource.h b/protocols/CurrencyRates/src/resource.h
index eac6b6af70..59d3ad8f49 100644
--- a/protocols/CurrencyRates/src/resource.h
+++ b/protocols/CurrencyRates/src/resource.h
@@ -17,9 +17,9 @@
#define IDI_ICON_REFRESH 118
#define IDI_ICON_IMPORT 119
#define IDI_ICON_EXPORT 120
-#define IDD_PROVIDER_ADV_SETTINGS 120
+#define IDD_OPTIONS_ADVANCED 120
#define IDI_ICON_SWAP 121
-#define IDD_DIALOG_POPUP 121
+#define IDD_OPTIONS_POPUP 121
#define IDI_ICON_MAIN1 122
#define IDI_ICON_DISABLED 122
#define IDD_DIALOG_VARIABLE_LIST 123
@@ -71,19 +71,13 @@
#define IDC_BUTTON_POPUP_FORMAT_DESCRIPTION 1037
#define IDC_EDIT_RESULT 1039
#define IDC_BUTTON_SWAP 1060
-#define IDC_BUTTON_ADVANCED_SETTINGS 1061
-#define IDC_BUTTON_POPUP_SETTINGS 1061
#define IDC_CHECK_CONTACT_SPECIFIC 1062
#define IDC_RADIO_DEFAULT_COLOURS 1063
#define IDC_CHECK_SHOW_POPUP 1064
-#define IDC_RADIO_USER_DEFINED_COLOURS 1064
-#define IDC_MFCCOLORBUTTON1 1066
-#define IDC_CHECK1 1067
+#define IDC_RADIO_USER_DEFINED_COLOURS 1065
#define IDC_CHECK_DONT_USE_POPUPHISTORY 1067
-#define IDC_EDIT_FROM2 1071
#define IDC_STATIC_PROVIDER_NAME 1071
#define IDC_DELAY 1072
-#define IDC_EDIT1 1072
#define IDC_EDIT_VARIABLE 1072
#define IDC_PROVIDER 1073
#define IDC_BGCOLOR 1074
@@ -99,7 +93,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 128
+#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1076
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/CurrencyRates/src/stdafx.h b/protocols/CurrencyRates/src/stdafx.h
index 7f4fdd758c..4731e1051f 100644
--- a/protocols/CurrencyRates/src/stdafx.h
+++ b/protocols/CurrencyRates/src/stdafx.h
@@ -69,8 +69,33 @@ typedef boost::posix_time::wtime_facet ttime_facet;
CMStringW CreateFilePath(const CMStringW &rsName);
+enum EColourMode
+{
+ colourDefault,
+ colourUserDefined,
+};
+
+enum EDelayMode
+{
+ delayFromPopup,
+ delayCustom,
+ delayPermanent
+};
+
struct CMPlugin : public PLUGIN<CMPlugin>
{
+ // Log settings
+ CMOption<uint16_t> wLogMode;
+ CMOption<bool> bIsOnlyChangedHistory, bIsOnlyChangedLogFile;
+ CMOption<wchar_t *> wszHistoryFormat, wszLogFileName, wszLogFileFormat;
+
+ // Popup settings
+ CMOption<uint8_t> modeColour, modeDelay;
+ CMOption<COLORREF> rgbBkg, rgbText;
+ CMOption<uint16_t> wDelay;
+ CMOption<wchar_t*> wszPopupFormat;
+ CMOption<bool> bUsePopups, bUseHistory, bShowPopupIfValueChanged;
+
CMPlugin();
int Load() override;