diff options
author | George Hazan <ghazan@miranda.im> | 2020-05-19 11:58:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-05-19 11:58:41 +0300 |
commit | 0a206851b86dee002ffa3467d9dbfd35eb0c9128 (patch) | |
tree | 69d9ab82723ee14c700b325c02d99a63c3949408 /protocols/CurrencyRates | |
parent | 2c24fa93c95554e9c1ea46df9a202157951714cc (diff) |
CurrencyRates: code cleaning
Diffstat (limited to 'protocols/CurrencyRates')
-rw-r--r-- | protocols/CurrencyRates/src/CommonOptionDlg.cpp | 42 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyConverter.cpp | 16 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp | 12 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp | 80 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp | 36 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyRatesProviders.cpp | 14 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/EconomicRateInfo.h | 5 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/ExtraImages.cpp | 2 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/Forex.cpp | 18 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/HTTPSession.cpp | 4 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/IconLib.cpp | 2 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/ImportExport.cpp | 4 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/Log.cpp | 2 | ||||
-rw-r--r-- | protocols/CurrencyRates/src/SettingsDlg.cpp | 230 |
14 files changed, 231 insertions, 236 deletions
diff --git a/protocols/CurrencyRates/src/CommonOptionDlg.cpp b/protocols/CurrencyRates/src/CommonOptionDlg.cpp index 335457ed89..27190b2545 100644 --- a/protocols/CurrencyRates/src/CommonOptionDlg.cpp +++ b/protocols/CurrencyRates/src/CommonOptionDlg.cpp @@ -31,36 +31,32 @@ void CommonOptionDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp, CCommonDlgPr { switch (msg) { case WM_INITDIALOG: - { - assert(rData.m_pCurrencyRatesProvider); - - // set contact list display format - tstring sDspNameFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat); - ::SetDlgItemText(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT, sDspNameFrmt.c_str()); + assert(rData.m_pCurrencyRatesProvider); + TranslateDialogDefault(hWnd); - // set status message display format - tstring sStatusMsgFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat); - ::SetDlgItemText(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT, sStatusMsgFrmt.c_str()); + // set contact list display format + ::SetDlgItemTextW(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT, g_plugin.getMStringW(DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat)); - // set tendency format - tstring sTendencyFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_TendencyFormat, DB_DEF_TendencyFormat); - ::SetDlgItemText(hWnd, IDC_EDIT_TENDENCY_FORMAT, sTendencyFrmt.c_str()); + // set status message display format + ::SetDlgItemTextW(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT, g_plugin.getMStringW(DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat)); - // set api key - tstring sApiKey = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_ApiKey, L""); - ::SetDlgItemText(hWnd, IDC_EDIT_PERSONAL_KEY, sApiKey.c_str()); + // set tendency format + ::SetDlgItemTextW(hWnd, IDC_EDIT_TENDENCY_FORMAT, g_plugin.getMStringW(DB_KEY_TendencyFormat, DB_DEF_TendencyFormat)); + // set api key + ::SetDlgItemTextW(hWnd, IDC_EDIT_PERSONAL_KEY, g_plugin.getMStringW(DB_KEY_ApiKey)); + { // refresh rate HWND hwndCombo = ::GetDlgItem(hWnd, IDC_COMBO_REFRESH_RATE); LPCTSTR pszRefreshRateTypes[] = { TranslateT("Seconds"), TranslateT("Minutes"), TranslateT("Hours") }; for (int i = 0; i < _countof(pszRefreshRateTypes); ++i) ::SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(pszRefreshRateTypes[i])); - int nRefreshRateType = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateType, RRT_MINUTES); + int nRefreshRateType = g_plugin.getWord(DB_KEY_RefreshRateType, RRT_MINUTES); if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) nRefreshRateType = RRT_MINUTES; - UINT nRate = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateValue, 1); + UINT nRate = g_plugin.getWord(DB_KEY_RefreshRateValue, 1); switch (nRefreshRateType) { default: case RRT_SECONDS: @@ -191,20 +187,20 @@ void CommonOptionDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp, CCommonDlgPr assert(rData.m_pCurrencyRatesProvider); rData.m_bFireSetingsChangedEvent = true; - db_set_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateType, nType); - db_set_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateValue, nRefreshRate); + g_plugin.setWord(DB_KEY_RefreshRateType, nType); + g_plugin.setWord(DB_KEY_RefreshRateValue, nRefreshRate); tstring s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT)); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_DisplayNameFormat, s.c_str()); + g_plugin.setWString(DB_KEY_DisplayNameFormat, s.c_str()); s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT)); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_StatusMsgFormat, s.c_str()); + g_plugin.setWString(DB_KEY_StatusMsgFormat, s.c_str()); s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_TENDENCY_FORMAT)); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_TendencyFormat, s.c_str()); + g_plugin.setWString(DB_KEY_TendencyFormat, s.c_str()); s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_PERSONAL_KEY)); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_ApiKey, s.c_str()); + g_plugin.setWString(DB_KEY_ApiKey, s.c_str()); CAdvProviderSettings* pAdvSet = get_adv_settings(rData.m_pCurrencyRatesProvider, false); if (pAdvSet) diff --git a/protocols/CurrencyRates/src/CurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyConverter.cpp index 5a7f4d1487..67c2b80e4f 100644 --- a/protocols/CurrencyRates/src/CurrencyConverter.cpp +++ b/protocols/CurrencyRates/src/CurrencyConverter.cpp @@ -90,8 +90,8 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM HWND hcbxFrom = ::GetDlgItem(hDlg, IDC_COMBO_CONVERT_FROM); HWND hcbxTo = ::GetDlgItem(hDlg, IDC_COMBO_CONVERT_INTO); - tstring sFromCurrencyRateID = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_FROM_ID); - tstring sToCurrencyRateID = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_TO_ID); + tstring sFromCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_FROM_ID); + tstring sToCurrencyRateID = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_STR_CC_CURRENCYRATE_TO_ID); const auto pProvider = get_currency_converter_provider(); const auto& rSection = get_currencyrates(pProvider); @@ -113,7 +113,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM } double dAmount = 1.0; - CurrencyRates_DBReadDouble(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_AMOUNT, dAmount); + CurrencyRates_DBReadDouble(NULL, MODULENAME, DB_STR_CC_AMOUNT, dAmount); ::SetDlgItemText(hDlg, IDC_EDIT_VALUE, double2str(dAmount).c_str()); const ICurrencyRatesProvider::CProviderInfo& pi = pProvider->GetInfo(); @@ -127,7 +127,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM update_convert_button(hDlg); update_swap_button(hDlg); - Utils_RestoreWindowPositionNoSize(hDlg, NULL, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX); + Utils_RestoreWindowPositionNoSize(hDlg, NULL, MODULENAME, WINDOW_PREFIX); ::ShowWindow(hDlg, SW_SHOW); } return TRUE; @@ -137,7 +137,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX, false); assert(hWL); WindowList_Remove(hWL, hDlg); - Utils_SaveWindowPosition(hDlg, NULL, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX); + Utils_SaveWindowPosition(hDlg, NULL, MODULENAME, WINDOW_PREFIX); EndDialog(hDlg, 0); } return TRUE; @@ -184,7 +184,7 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM double dAmount = 1.0; if ((true == str2double(sText, dAmount)) && (dAmount > 0.0)) { - CurrencyRates_DBWriteDouble(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_AMOUNT, dAmount); + CurrencyRates_DBWriteDouble(NULL, MODULENAME, DB_STR_CC_AMOUNT, dAmount); size_t nFrom = static_cast<size_t>(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); size_t nTo = static_cast<size_t>(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_INTO, CB_GETCURSEL, 0, 0)); @@ -195,8 +195,8 @@ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM auto from = rSection.GetCurrencyRate(nFrom); auto to = rSection.GetCurrencyRate(nTo); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_FROM_ID, from.GetID().c_str()); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_TO_ID, to.GetID().c_str()); + g_plugin.setWString(DB_STR_CC_CURRENCYRATE_FROM_ID, from.GetID().c_str()); + g_plugin.setWString(DB_STR_CC_CURRENCYRATE_TO_ID, to.GetID().c_str()); const auto pProvider = get_currency_converter_provider(); assert(pProvider); diff --git a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp index c08340e0cf..a6259b79cc 100644 --- a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp +++ b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp @@ -24,7 +24,7 @@ inline MCONTACT get_contact(HWND hWnd) static bool get_fetch_time(time_t& rTime, MCONTACT hContact) { - rTime = db_get_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FETCH_TIME, -1); + rTime = g_plugin.getDword(hContact, DB_STR_CURRENCYRATE_FETCH_TIME, -1); return (rTime != -1); } @@ -40,7 +40,7 @@ INT_PTR CALLBACK CurrencyRateInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT ::SetDlgItemText(hdlg, IDC_STATIC_CURRENCYRATE_NAME, sDescription.c_str()); double dRate = 0.0; - if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, dRate)) { + if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, dRate)) { tostringstream o; o.imbue(GetSystemLocale()); o << dRate; @@ -49,7 +49,7 @@ INT_PTR CALLBACK CurrencyRateInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT } dRate = 0.0; - if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate)) { + if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate)) { tostringstream o; o.imbue(GetSystemLocale()); o << dRate; @@ -168,7 +168,7 @@ static INT_PTR CALLBACK CurrencyRateInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wPa WindowList_Add(hWL, hdlg, hContact); ::SetWindowLongPtr(hdlg, GWLP_USERDATA, hContact); - Utils_RestoreWindowPositionNoSize(hdlg, hContact, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX_INFO); + Utils_RestoreWindowPositionNoSize(hdlg, hContact, MODULENAME, WINDOW_PREFIX_INFO); ::ShowWindow(hdlg, SW_SHOW); break; @@ -184,7 +184,7 @@ static INT_PTR CALLBACK CurrencyRateInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wPa hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, false); assert(hWL); WindowList_Remove(hWL, hdlg); - Utils_SaveWindowPosition(hdlg, hContact, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX_INFO); + Utils_SaveWindowPosition(hdlg, hContact, MODULENAME, WINDOW_PREFIX_INFO); } return FALSE; @@ -233,7 +233,7 @@ int CurrencyRates_PrebuildContactMenu(WPARAM wp, LPARAM) MCONTACT hContact = MCONTACT(wp); char *szProto = Proto_GetBaseAccountName(hContact); - if (mir_strcmp(szProto, CURRENCYRATES_PROTOCOL_NAME)) { + if (mir_strcmp(szProto, MODULENAME)) { Menu_ShowItem(g_hMenuRoot, false); return 0; } diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp index 3c8bdbfed6..a0df4d5893 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp @@ -185,15 +185,15 @@ void CCurrencyRatesProviderBase::DeleteContact(MCONTACT hContact) void CCurrencyRatesProviderBase::SetContactStatus(MCONTACT hContact, int nNewStatus) { - int nStatus = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_STATUS, ID_STATUS_OFFLINE); + int nStatus = g_plugin.getWord(hContact, DB_STR_STATUS, ID_STATUS_OFFLINE); if (nNewStatus != nStatus) { - db_set_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_STATUS, nNewStatus); + g_plugin.setWord(hContact, DB_STR_STATUS, nNewStatus); if (ID_STATUS_ONLINE != nNewStatus) { db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); - tstring sSymbol = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); - if (false == sSymbol.empty()) - db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, sSymbol.c_str()); + CMStringW sSymbol = g_plugin.getMStringW(hContact, DB_STR_CURRENCYRATE_SYMBOL); + if (!sSymbol.IsEmpty()) + db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, sSymbol); SetContactExtraImage(hContact, eiEmpty); } @@ -412,7 +412,7 @@ void log_to_history(const ICurrencyRatesProvider *pProvider, T2Utf psz(s.c_str()); DBEVENTINFO dbei = {}; - dbei.szModule = CURRENCYRATES_MODULE_NAME; + dbei.szModule = MODULENAME; dbei.timestamp = static_cast<DWORD>(nTime); dbei.flags = DBEF_READ | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; @@ -499,15 +499,15 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat time_t nTime = ::time(0); if (false == rsSymbol.empty()) - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL, rsSymbol.c_str()); + g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_SYMBOL, rsSymbol.c_str()); double dPrev = 0.0; - bool bValidPrev = CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, dPrev); + bool bValidPrev = CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dPrev); if (true == bValidPrev) - CurrencyRates_DBWriteDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, dPrev); + CurrencyRates_DBWriteDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, dPrev); - CurrencyRates_DBWriteDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate); - db_set_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FETCH_TIME, nTime); + CurrencyRates_DBWriteDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate); + g_plugin.setDword(hContact, DB_STR_CURRENCYRATE_FETCH_TIME, nTime); tstring sSymbol = rsSymbol; @@ -519,7 +519,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat } else { if (true == sSymbol.empty()) - sSymbol = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sSymbol = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL); oNick << std::setfill(L' ') << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate; } @@ -536,35 +536,35 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat else db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); - bool bUseContactSpecific = (db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); + bool bUseContactSpecific = g_plugin.getBool(hContact, DB_STR_CONTACT_SPEC_SETTINGS); CAdvProviderSettings global_settings(this); WORD dwMode = (bUseContactSpecific) - ? db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG, static_cast<WORD>(lmDisabled)) + ? g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, static_cast<WORD>(lmDisabled)) : global_settings.GetLogMode(); if (dwMode&lmExternalFile) { bool bAdd = true; bool bOnlyIfChanged = (bUseContactSpecific) - ? (db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, 1) > 0) + ? (g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, 1) > 0) : global_settings.GetLogOnlyChangedFlag(); if (true == bOnlyIfChanged) { bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); } if (true == bAdd) { tstring sLogFileName = (bUseContactSpecific) - ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str()) + ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str()) : global_settings.GetLogFileName(); if (true == sSymbol.empty()) { - sSymbol = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sSymbol = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL); } sLogFileName = GenerateLogFileName(sLogFileName, sSymbol); tstring sFormat = global_settings.GetLogFormat(); if (bUseContactSpecific) - sFormat = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, DB_DEF_LogFormat); + sFormat = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, DB_DEF_LogFormat); log_to_file(this, hContact, sLogFileName, sFormat); } @@ -572,7 +572,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat if (dwMode&lmInternalHistory) { bool bAdd = true; bool bOnlyIfChanged = (bUseContactSpecific) - ? (db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_HISTORY_CONDITION, 1) > 0) + ? (g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, 1) > 0) : global_settings.GetHistoryOnlyChangedFlag(); if (true == bOnlyIfChanged) { @@ -580,7 +580,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat } if (true == bAdd) { tstring sFormat = (bUseContactSpecific) - ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) + ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) : global_settings.GetHistoryFormat(); log_to_history(this, hContact, nTime, sFormat); @@ -589,12 +589,12 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat if (dwMode&lmPopup) { bool bOnlyIfChanged = (bUseContactSpecific) - ? (1 == db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_CONDITION, 1) > 0) + ? (1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, 1) > 0) : global_settings.GetShowPopupIfValueChangedFlag(); if ((false == bOnlyIfChanged) || ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) { tstring sFormat = (bUseContactSpecific) - ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) + ? CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) : global_settings.GetPopupFormat(); CPopupSettings ps = *(global_settings.GetPopupSettingsPtr()); @@ -609,11 +609,11 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat MCONTACT CCurrencyRatesProviderBase::CreateNewContact(const tstring& rsName) { MCONTACT hContact = db_add_contact(); - Proto_AddToContact(hContact, CURRENCYRATES_PROTOCOL_NAME); + Proto_AddToContact(hContact, MODULENAME); tstring sProvName = GetInfo().m_sName; - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER, sProvName.c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL, rsName.c_str()); + g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_PROVIDER, sProvName.c_str()); + g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_SYMBOL, rsName.c_str()); db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); mir_cslock lck(m_cs); @@ -626,11 +626,11 @@ DWORD get_refresh_timeout_miliseconds() if (!g_bAutoUpdate) return INFINITE; - int nRefreshRateType = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateType, RRT_MINUTES); + int nRefreshRateType = g_plugin.getWord(DB_KEY_RefreshRateType, RRT_MINUTES); if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) nRefreshRateType = RRT_MINUTES; - DWORD nTimeout = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_RefreshRateValue, 1); + DWORD nTimeout = g_plugin.getWord(DB_KEY_RefreshRateValue, 1); switch (nRefreshRateType) { default: case RRT_SECONDS: @@ -669,9 +669,9 @@ private: void CCurrencyRatesProviderBase::Run() { DWORD nTimeout = get_refresh_timeout_miliseconds(); - m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat); - m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat); - m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_TendencyFormat, DB_DEF_TendencyFormat); + m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat); + m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat); + m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_TendencyFormat, DB_DEF_TendencyFormat); enum { @@ -721,9 +721,9 @@ void CCurrencyRatesProviderBase::Run() case WAIT_OBJECT_0 + SETTINGS_CHANGED: nTimeout = get_refresh_timeout_miliseconds(); - m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat); - m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat); - m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_TendencyFormat, DB_DEF_TendencyFormat); + m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_DisplayNameFormat, DB_DEF_DisplayNameFormat); + m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_StatusMsgFormat, DB_DEF_StatusMsgFormat); + m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_TendencyFormat, DB_DEF_TendencyFormat); { mir_cslock lck(m_cs); anContacts = m_aContacts; @@ -824,11 +824,11 @@ bool CCurrencyRatesProviderBase::ParseSymbol(MCONTACT hContact, wchar_t c, doubl switch (c) { case 'r': case 'R': - return CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, d); + return CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, d); case 'p': case 'P': - return CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, d); + return CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, d); } return false; @@ -839,7 +839,7 @@ bool CCurrencyRatesProviderBase::ParseSymbol(MCONTACT hContact, wchar_t c, doubl 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)) + if (db_get(hContact, MODULENAME, DB_STR_CURRENCYRATE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type)) return false; rTime = dbv.dVal; @@ -885,10 +885,10 @@ tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, i ret = c; break; case 'S': - ret = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); + ret = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_PROVIDER); break; case 's': - ret = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + ret = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL); break; case 'X': ret = format_fetch_time(hContact, CurrencyRates_GetTimeFormat(true)); @@ -906,7 +906,7 @@ tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, i break; case 'r': case 'R': - if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, d)) + if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, d)) ret = format_double(d, nWidth); else ret = L"-"; @@ -914,7 +914,7 @@ tstring CCurrencyRatesProviderBase::FormatSymbol(MCONTACT hContact, wchar_t c, i case 'p': case 'P': - if (true == CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, d)) + if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, d)) ret = format_double(d, nWidth); else ret = L"-"; diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp index 36693d52b1..531f54d428 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp @@ -15,8 +15,8 @@ tstring build_url(const tstring &rsURL, const tstring &from, const tstring &to) tstring build_url(MCONTACT hContact, const tstring &rsURL) { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return build_url(rsURL, sFrom, sTo); } @@ -314,10 +314,10 @@ bool CCurrencyRatesProviderCurrencyConverter::GetWatchedRateInfo(size_t nIndex, return false; MCONTACT hContact = m_aContacts[nIndex]; - tstring sSymbolFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sSymbolTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); - tstring sDescFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); - tstring sDescTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION); + tstring sSymbolFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + tstring sSymbolTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); + tstring sDescFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_DESCRIPTION); + tstring sDescTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_DESCRIPTION); rRateInfo.first = CCurrencyRate(sSymbolFrom, sSymbolFrom, sDescFrom); rRateInfo.second = CCurrencyRate(sSymbolTo, sSymbolTo, sDescTo); @@ -328,8 +328,8 @@ bool CCurrencyRatesProviderCurrencyConverter::WatchForRate(const TRateInfo &ri, { auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [&ri](auto hContact)->bool { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return ((0 == mir_wstrcmpi(ri.first.GetID().c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(ri.second.GetID().c_str(), sTo.c_str()))); }); @@ -346,13 +346,13 @@ bool CCurrencyRatesProviderCurrencyConverter::WatchForRate(const TRateInfo &ri, tstring sName = make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); MCONTACT hContact = CreateNewContact(sName); if (hContact) { - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID, ri.first.GetID().c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID, ri.second.GetID().c_str()); + g_plugin.setWString(hContact, DB_STR_FROM_ID, ri.first.GetID().c_str()); + g_plugin.setWString(hContact, DB_STR_TO_ID, ri.second.GetID().c_str()); if (false == ri.first.GetName().empty()) { - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION, ri.first.GetName().c_str()); + g_plugin.setWString(hContact, DB_STR_FROM_DESCRIPTION, ri.first.GetName().c_str()); } if (false == ri.second.GetName().empty()) { - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION, ri.second.GetName().c_str()); + g_plugin.setWString(hContact, DB_STR_TO_DESCRIPTION, ri.second.GetName().c_str()); } return true; @@ -378,8 +378,8 @@ MCONTACT CCurrencyRatesProviderCurrencyConverter::GetContactByID(const tstring& auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [rsFromID, rsToID](MCONTACT hContact)->bool { - tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); return ((0 == mir_wstrcmpi(rsFromID.c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(rsToID.c_str(), sTo.c_str()))); }); @@ -404,16 +404,16 @@ tstring CCurrencyRatesProviderCurrencyConverter::FormatSymbol(MCONTACT hContact, { switch (c) { case 'F': - return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); + return CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_DESCRIPTION); case 'f': - return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); + return CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_FROM_ID); case 'I': - return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION); + return CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_DESCRIPTION); case 'i': - return CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + return CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_TO_ID); } return CSuper::FormatSymbol(hContact, c, nWidth); diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp index fdf020fa5e..2dcda4244a 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviders.cpp @@ -30,9 +30,9 @@ void ClearProviders() void convert_contact_settings(MCONTACT hContact) { - WORD dwLogMode = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG, static_cast<WORD>(lmDisabled)); + WORD dwLogMode = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, static_cast<WORD>(lmDisabled)); if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile)) - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 1); + g_plugin.setByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 1); } void InitProviders() @@ -40,9 +40,9 @@ void InitProviders() CreateProviders(); const WORD nCurrentVersion = 17; - WORD nVersion = db_get_w(0, CURRENCYRATES_MODULE_NAME, LAST_RUN_VERSION, 1); + WORD nVersion = g_plugin.getWord(LAST_RUN_VERSION, 1); - for (auto &hContact : Contacts(CURRENCYRATES_MODULE_NAME)) { + for (auto &hContact : Contacts(MODULENAME)) { ICurrencyRatesProvider *pProvider = GetContactProviderPtr(hContact); if (pProvider) { pProvider->AddContact(hContact); @@ -51,7 +51,7 @@ void InitProviders() } } - db_set_w(0, CURRENCYRATES_MODULE_NAME, LAST_RUN_VERSION, nCurrentVersion); + g_plugin.setWord(LAST_RUN_VERSION, nCurrentVersion); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -59,10 +59,10 @@ void InitProviders() ICurrencyRatesProvider* GetContactProviderPtr(MCONTACT hContact) { char* szProto = Proto_GetBaseAccountName(hContact); - if (nullptr == szProto || 0 != ::_stricmp(szProto, CURRENCYRATES_PROTOCOL_NAME)) + if (nullptr == szProto || 0 != ::_stricmp(szProto, MODULENAME)) return nullptr; - tstring sProvider = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); + tstring sProvider = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_PROVIDER); if (true == sProvider.empty()) return nullptr; diff --git a/protocols/CurrencyRates/src/EconomicRateInfo.h b/protocols/CurrencyRates/src/EconomicRateInfo.h index 664649a47a..3b55b7f0ad 100644 --- a/protocols/CurrencyRates/src/EconomicRateInfo.h +++ b/protocols/CurrencyRates/src/EconomicRateInfo.h @@ -1,9 +1,8 @@ #ifndef __87d726e0_26c6_485d_8016_1fba819b037d_EconomicRateInfo__ #define __87d726e0_26c6_485d_8016_1fba819b037d_EconomicRateInfo__ -#define CURRENCYRATES_PROTOCOL_NAME "CurrencyRates"// protocol name - -#define CURRENCYRATES_MODULE_NAME "CurrencyRates" // db settings module path +// db settings module path +#define MODULENAME "CurrencyRates" enum ERefreshRateType { diff --git a/protocols/CurrencyRates/src/ExtraImages.cpp b/protocols/CurrencyRates/src/ExtraImages.cpp index 686f4e34e7..966e1050b4 100644 --- a/protocols/CurrencyRates/src/ExtraImages.cpp +++ b/protocols/CurrencyRates/src/ExtraImages.cpp @@ -4,7 +4,7 @@ static HANDLE hExtraIcon; void CurrencyRates_InitExtraIcons() { - hExtraIcon = ExtraIcon_RegisterIcolib(ICON_STR_CURRENCYRATE, CURRENCYRATES_PROTOCOL_NAME, CURRENCYRATES_PROTOCOL_NAME "_" ICON_STR_MAIN); + hExtraIcon = ExtraIcon_RegisterIcolib(ICON_STR_CURRENCYRATE, MODULENAME, MODULENAME "_" ICON_STR_MAIN); } bool SetContactExtraImage(MCONTACT hContact, EImageIndex nIndex) diff --git a/protocols/CurrencyRates/src/Forex.cpp b/protocols/CurrencyRates/src/Forex.cpp index b3b2424d48..73b0707959 100644 --- a/protocols/CurrencyRates/src/Forex.cpp +++ b/protocols/CurrencyRates/src/Forex.cpp @@ -45,7 +45,7 @@ INT_PTR CurrencyRatesMenu_RefreshAll(WPARAM, LPARAM) INT_PTR CurrencyRatesMenu_EnableDisable(WPARAM, LPARAM) { g_bAutoUpdate = (g_bAutoUpdate) ? false : true; - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_STR_AUTO_UPDATE, g_bAutoUpdate); + g_plugin.setByte(DB_STR_AUTO_UPDATE, g_bAutoUpdate); for (auto &pProvider : g_apProviders) { pProvider->RefreshSettings(); @@ -112,7 +112,7 @@ void InitMenu() mi.name.w = LPGENW("Refresh"); mi.hIcolibItem = CurrencyRates_GetIconHandle(IDI_ICON_REFRESH); mi.pszService = "CurrencyRates/RefreshContact"; - g_hMenuRefresh = Menu_AddContactMenuItem(&mi, CURRENCYRATES_PROTOCOL_NAME); + g_hMenuRefresh = Menu_AddContactMenuItem(&mi, MODULENAME); Menu_ConfigureItem(g_hMenuRefresh, MCI_OPT_EXECPARAM, INT_PTR(0)); CreateServiceFunction(mi.pszService, CurrencyRatesMenu_RefreshContact); @@ -120,7 +120,7 @@ void InitMenu() mi.name.w = LPGENW("Open Log File..."); mi.hIcolibItem = nullptr; mi.pszService = "CurrencyRates/OpenLogFile"; - g_hMenuOpenLogFile = Menu_AddContactMenuItem(&mi, CURRENCYRATES_PROTOCOL_NAME); + g_hMenuOpenLogFile = Menu_AddContactMenuItem(&mi, MODULENAME); Menu_ConfigureItem(g_hMenuOpenLogFile, MCI_OPT_EXECPARAM, 1); CreateServiceFunction(mi.pszService, CurrencyRatesMenu_OpenLogFile); @@ -129,7 +129,7 @@ void InitMenu() mi.name.w = LPGENW("Chart..."); mi.hIcolibItem = nullptr; mi.pszService = "CurrencyRates/Chart"; - g_hMenuChart = Menu_AddContactMenuItem(&mi, CURRENCYRATES_PROTOCOL_NAME); + g_hMenuChart = Menu_AddContactMenuItem(&mi, MODULENAME); CreateServiceFunction(mi.pszService, CurrencyRatesMenu_Chart); #endif @@ -137,7 +137,7 @@ void InitMenu() mi.name.w = LPGENW("Edit Settings..."); mi.hIcolibItem = nullptr; mi.pszService = "CurrencyRates/EditSettings"; - g_hMenuEditSettings = Menu_AddContactMenuItem(&mi, CURRENCYRATES_PROTOCOL_NAME); + g_hMenuEditSettings = Menu_AddContactMenuItem(&mi, MODULENAME); #ifdef CHART_IMPLEMENT Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 3); #else @@ -190,7 +190,7 @@ int CurrencyRatesEventFunc_OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_TTB_MODULELOADED, CurrencyRates_OnToolbarLoaded); - g_bAutoUpdate = 1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_STR_AUTO_UPDATE, 1); + g_bAutoUpdate = 1 == g_plugin.getByte(DB_STR_AUTO_UPDATE, 1); InitMenu(); @@ -281,7 +281,7 @@ PLUGININFOEX pluginInfoEx = }; CMPlugin::CMPlugin() : - PLUGIN<CMPlugin>(CURRENCYRATES_PROTOCOL_NAME, pluginInfoEx) + PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx) { RegisterProtocol(PROTOTYPE_VIRTUAL); SetUniqueId(DB_STR_CURRENCYRATE_SYMBOL); @@ -299,8 +299,8 @@ int CMPlugin::Load(void) InitProviders(); - CreateProtoServiceFunction(CURRENCYRATES_PROTOCOL_NAME, PS_GETCAPS, CurrencyRateProtoFunc_GetCaps); - CreateProtoServiceFunction(CURRENCYRATES_PROTOCOL_NAME, PS_GETSTATUS, CurrencyRateProtoFunc_GetStatus); + CreateProtoServiceFunction(MODULENAME, PS_GETCAPS, CurrencyRateProtoFunc_GetCaps); + CreateProtoServiceFunction(MODULENAME, PS_GETSTATUS, CurrencyRateProtoFunc_GetStatus); HookEvent(ME_SYSTEM_MODULESLOADED, CurrencyRatesEventFunc_OnModulesLoaded); HookEvent(ME_DB_CONTACT_DELETED, CurrencyRatesEventFunc_OnContactDeleted); diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp index 004450736f..6227f1b12a 100644 --- a/protocols/CurrencyRates/src/HTTPSession.cpp +++ b/protocols/CurrencyRates/src/HTTPSession.cpp @@ -6,7 +6,7 @@ HNETLIBUSER CHTTPSession::g_hNetLib = nullptr; void CALLBACK waitStub() { - if (IDYES == MessageBox(0, TranslateW(ERROR_MSG), _A2W(CURRENCYRATES_MODULE_NAME), MB_YESNOCANCEL)) + if (IDYES == MessageBox(0, TranslateW(ERROR_MSG), _A2W(MODULENAME), MB_YESNOCANCEL)) Utils_OpenUrl("https://free.currencyconverterapi.com/free-api-key"); } @@ -82,7 +82,7 @@ bool CHTTPSession::Init() NETLIBUSER nlu = {}; nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE; - nlu.szSettingsModule = CURRENCYRATES_PROTOCOL_NAME; + nlu.szSettingsModule = MODULENAME; nlu.szDescriptiveName.w = TranslateT("CurrencyRates HTTP connections"); g_hNetLib = Netlib_RegisterUser(&nlu); return (nullptr != g_hNetLib); diff --git a/protocols/CurrencyRates/src/IconLib.cpp b/protocols/CurrencyRates/src/IconLib.cpp index da67d1310f..bc69d474dd 100644 --- a/protocols/CurrencyRates/src/IconLib.cpp +++ b/protocols/CurrencyRates/src/IconLib.cpp @@ -18,7 +18,7 @@ static IconItem iconList[] = void CurrencyRates_IconsInit() { - ::g_plugin.registerIcon(CURRENCYRATES_PROTOCOL_NAME, iconList, CURRENCYRATES_PROTOCOL_NAME); + ::g_plugin.registerIcon(MODULENAME, iconList, MODULENAME); } HICON CurrencyRates_LoadIconEx(int iconId, bool bBig /*= false*/) diff --git a/protocols/CurrencyRates/src/ImportExport.cpp b/protocols/CurrencyRates/src/ImportExport.cpp index 95fb9d95f7..fb78dd038b 100644 --- a/protocols/CurrencyRates/src/ImportExport.cpp +++ b/protocols/CurrencyRates/src/ImportExport.cpp @@ -220,7 +220,7 @@ INT_PTR CurrencyRates_Export(WPARAM wp, LPARAM lp) } } else { - for (auto &cc : Contacts(CURRENCYRATES_MODULE_NAME)) { + for (auto &cc : Contacts(MODULENAME)) { auto pProvider = GetContactProviderPtr(cc); if (pProvider) { auto *pNode = export_contact(cc, doc); @@ -376,7 +376,7 @@ struct CContactState const TiXmlNode* find_currencyrates_module(const TiXmlNode *pXmlContact) { for (auto *pNode : TiXmlEnum(pXmlContact)) - if ((!mir_strcmpi(g_szXmlModule, pNode->Name())) && (!mir_strcmpi(CURRENCYRATES_MODULE_NAME, pNode->GetText()))) + if ((!mir_strcmpi(g_szXmlModule, pNode->Name())) && (!mir_strcmpi(MODULENAME, pNode->GetText()))) return pNode; return nullptr; diff --git a/protocols/CurrencyRates/src/Log.cpp b/protocols/CurrencyRates/src/Log.cpp index c769f1a98d..7930ac5f4f 100644 --- a/protocols/CurrencyRates/src/Log.cpp +++ b/protocols/CurrencyRates/src/Log.cpp @@ -14,7 +14,7 @@ namespace #ifdef _DEBUG return true; #else - return (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_STR_ENABLE_LOG, false)); + return (1 == g_plugin.getByte(DB_STR_ENABLE_LOG, false)); #endif } diff --git a/protocols/CurrencyRates/src/SettingsDlg.cpp b/protocols/CurrencyRates/src/SettingsDlg.cpp index 2673774049..f865c1a51a 100644 --- a/protocols/CurrencyRates/src/SettingsDlg.cpp +++ b/protocols/CurrencyRates/src/SettingsDlg.cpp @@ -61,7 +61,7 @@ void update_all_controls(HWND hDlg) bool bIsCheckedShowPopup = (1 == ::IsDlgButtonChecked(hDlg, IDC_CHECK_SHOW_POPUP)); ::EnableWindow(::GetDlgItem(hDlg, IDC_CHECK_SHOW_POPUP), (bIsCheckedContactSpec)); - ::EnableWindow(::GetDlgItem(hDlg, IDC_EDIT_POPUP_FORMAT), (bIsCheckedContactSpec && bIsCheckedShowPopup)); + ::EnableWindow(::GetDlgItem(hDlg, IDC_EDIT_POPUP_FORMAT), (bIsCheckedContactSpec && bIsCheckedShowPopup)); ::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)); @@ -112,12 +112,12 @@ struct CSettingWindowParam ~CSettingWindowParam() { delete m_pPopupSettings; } MCONTACT m_hContact; - CPopupSettings* m_pPopupSettings; + CPopupSettings *m_pPopupSettings; }; -inline CSettingWindowParam* get_param(HWND hWnd) +inline CSettingWindowParam *get_param(HWND hWnd) { - return reinterpret_cast<CSettingWindowParam*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + return reinterpret_cast<CSettingWindowParam *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); } void update_popup_controls_settings(HWND hDlg) @@ -136,7 +136,7 @@ INT_PTR CALLBACK EditPopupSettingsDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM switch (msg) { case WM_INITDIALOG: { - CPopupSettings* pSettings = reinterpret_cast<CPopupSettings*>(lp); + CPopupSettings *pSettings = reinterpret_cast<CPopupSettings *>(lp); TranslateDialogDefault(hWnd); ::SendDlgItemMessage(hWnd, IDC_BGCOLOR, CPM_SETCOLOUR, 0, pSettings->GetColourBk()); ::SendDlgItemMessage(hWnd, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, pSettings->GetColourText()); @@ -184,7 +184,7 @@ INT_PTR CALLBACK EditPopupSettingsDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM case IDOK: { - CPopupSettings* pSettings = reinterpret_cast<CPopupSettings*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + CPopupSettings *pSettings = reinterpret_cast<CPopupSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); bool bError = false; BOOL bOk = FALSE; @@ -245,51 +245,51 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L tstring sName = GetContactName(hContact); ::SetDlgItemText(hWnd, IDC_EDIT_NAME, sName.c_str()); - BYTE bUseContactSpecific = db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0); + BYTE bUseContactSpecific = g_plugin.getByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 0); ::CheckDlgButton(hWnd, IDC_CHECK_CONTACT_SPECIFIC, bUseContactSpecific ? BST_CHECKED : BST_UNCHECKED); auto pProvider = GetContactProviderPtr(hContact); CAdvProviderSettings setGlobal(pProvider); // log to history - WORD dwLogMode = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG, setGlobal.GetLogMode()); - UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0; + WORD dwLogMode = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG, setGlobal.GetLogMode()); + UINT nCheck = (dwLogMode & lmInternalHistory) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sHistoryFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat().c_str()); + tstring sHistoryFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, sHistoryFrmt.c_str()); - WORD wOnlyIfChanged = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag()); + WORD wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag()); ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); // log to file - nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; + nCheck = (dwLogMode & lmExternalFile) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sLogFileName = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); + tstring sLogFileName = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE); if (true == sLogFileName.empty()) { - sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName); + sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName); } ::SetDlgItemText(hWnd, IDC_EDIT_FILE_NAME, sLogFileName.c_str()); - tstring sLogFileFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat().c_str()); + tstring sLogFileFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_LOG_FILE_FORMAT, sLogFileFrmt.c_str()); - wOnlyIfChanged = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag()); + wOnlyIfChanged = g_plugin.getWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag()); ::CheckDlgButton(hWnd, IDC_CHECK_LOG_FILE_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); // popup - nCheck = (dwLogMode&lmPopup) ? 1 : 0; + nCheck = (dwLogMode & lmPopup) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sPopupFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()); + tstring sPopupFrmt = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()); ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, sPopupFrmt.c_str()); - bool bOnlyIfChanged = 1 == db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag()); + bool bOnlyIfChanged = 1 == g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag()); ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); update_all_controls(hWnd); - CSettingWindowParam* pParam = new CSettingWindowParam(hContact); + CSettingWindowParam *pParam = new CSettingWindowParam(hContact); ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pParam)); - Utils_RestoreWindowPositionNoSize(hWnd, hContact, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX_SETTINGS); + Utils_RestoreWindowPositionNoSize(hWnd, hContact, MODULENAME, WINDOW_PREFIX_SETTINGS); ::ShowWindow(hWnd, SW_SHOW); } break; @@ -326,7 +326,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L case IDC_BUTTON_POPUP_SETTINGS: if (BN_CLICKED == HIWORD(wp)) { - CSettingWindowParam* pParam = get_param(hWnd); + CSettingWindowParam *pParam = get_param(hWnd); if (!pParam->m_pPopupSettings) { pParam->m_pPopupSettings = new CPopupSettings(); pParam->m_pPopupSettings->InitForContact(pParam->m_hContact); @@ -341,7 +341,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L case IDOK: { - CSettingWindowParam* pParam = get_param(hWnd); + CSettingWindowParam *pParam = get_param(hWnd); MCONTACT hContact = pParam->m_hContact; bool bUseContactSpec = 1 == ::IsDlgButtonChecked(hWnd, IDC_CHECK_CONTACT_SPECIFIC); @@ -366,7 +366,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L tstring sLogFile = get_window_text(hwndLogFile); tstring sLogFileFormat = get_window_text(hwndLogFileFrmt); tstring sHistoryFormat = get_window_text(hwndHistoryFrmt); - if ((nLogMode&lmExternalFile)) { + if ((nLogMode & lmExternalFile)) { if (true == sLogFile.empty()) { prepare_edit_ctrl_for_error(hwndLogFile); CurrencyRates_MessageBox(hWnd, TranslateT("Enter log file name."), MB_OK | MB_ICONERROR); @@ -379,7 +379,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L } } - if ((true == bOk) && (nLogMode&lmInternalHistory) && (true == sHistoryFormat.empty())) { + if ((true == bOk) && (nLogMode & lmInternalHistory) && (true == sHistoryFormat.empty())) { prepare_edit_ctrl_for_error(hwndHistoryFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter history format."), MB_OK | MB_ICONERROR); bOk = false; @@ -387,7 +387,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L HWND hwndPopupFrmt = ::GetDlgItem(hWnd, IDC_EDIT_POPUP_FORMAT); tstring sPopupFormat = get_window_text(hwndPopupFrmt); - if ((true == bOk) && (nLogMode&lmPopup) && (true == sPopupFormat.empty())) { + if ((true == bOk) && (nLogMode & lmPopup) && (true == sPopupFormat.empty())) { prepare_edit_ctrl_for_error(hwndPopupFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter popup window format."), MB_OK | MB_ICONERROR); bOk = false; @@ -398,15 +398,15 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L UINT nIfChangedFile = IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_FILE_CONDITION); bool bIfChangedPopup = (1 == IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED)); - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, bUseContactSpec); - db_set_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG, nLogMode); - db_set_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, nIfChangedFile); - db_set_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_HISTORY_CONDITION, nIfChangedHistory); - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_CONDITION, bIfChangedPopup); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE, sLogFile.c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, sLogFileFormat.c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, sHistoryFormat.c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, sPopupFormat.c_str()); + g_plugin.setByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, bUseContactSpec); + g_plugin.setWord(hContact, DB_STR_CURRENCYRATE_LOG, nLogMode); + g_plugin.setWord(hContact, DB_STR_CURRENCYRATE_LOG_FILE_CONDITION, nIfChangedFile); + g_plugin.setWord(hContact, DB_STR_CURRENCYRATE_HISTORY_CONDITION, nIfChangedHistory); + g_plugin.setByte(hContact, DB_STR_CURRENCYRATE_POPUP_CONDITION, bIfChangedPopup); + g_plugin.setWString(hContact, DB_STR_CURRENCYRATE_LOG_FILE, sLogFile.c_str()); + 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); @@ -428,13 +428,13 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L break; case WM_DESTROY: - CSettingWindowParam* pParam = get_param(hWnd); + CSettingWindowParam *pParam = get_param(hWnd); SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_SETTINGS, false); assert(hWL); WindowList_Remove(hWL, hWnd); - Utils_SaveWindowPosition(hWnd, pParam->m_hContact, CURRENCYRATES_MODULE_NAME, WINDOW_PREFIX_SETTINGS); + Utils_SaveWindowPosition(hWnd, pParam->m_hContact, MODULENAME, WINDOW_PREFIX_SETTINGS); delete pParam; break; } @@ -462,19 +462,19 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, case WM_INITDIALOG: { TranslateDialogDefault(hWnd); - CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(lp); + CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(lp); ::SetDlgItemText(hWnd, IDC_EDIT_NAME, pAdvSettings->GetProviderPtr()->GetInfo().m_sName.c_str()); // log to history WORD dwLogMode = pAdvSettings->GetLogMode(); - UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0; + 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; + 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()); @@ -484,17 +484,17 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, update_history_controls(hWnd); // popup - nCheck = (dwLogMode&lmPopup) ? 1 : 0; + 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: @@ -522,7 +522,7 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, tstring sLogFile = get_window_text(hwndLogFile); tstring sLogFileFormat = get_window_text(hwndLogFileFrmt); - if ((nLogMode&lmExternalFile)) { + if ((nLogMode & lmExternalFile)) { if (true == sLogFile.empty()) { prepare_edit_ctrl_for_error(hwndLogFile); CurrencyRates_MessageBox(hWnd, TranslateT("Enter log file name."), MB_OK | MB_ICONERROR); @@ -537,7 +537,7 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, HWND hwndHistoryFrmt = ::GetDlgItem(hWnd, IDC_EDIT_HISTORY_FORMAT); tstring sHistoryFormat = get_window_text(hwndHistoryFrmt); - if ((true == bOk) && (nLogMode&lmInternalHistory) && (true == sHistoryFormat.empty())) { + if ((true == bOk) && (nLogMode & lmInternalHistory) && (true == sHistoryFormat.empty())) { prepare_edit_ctrl_for_error(hwndHistoryFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter history format."), MB_OK | MB_ICONERROR); bOk = false; @@ -545,14 +545,14 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, HWND hwndPopupFrmt = ::GetDlgItem(hWnd, IDC_EDIT_POPUP_FORMAT); tstring sPopupFormat = get_window_text(hwndPopupFrmt); - if ((true == bOk) && (nLogMode&lmPopup) && (true == sPopupFormat.empty())) { + if ((true == bOk) && (nLogMode & lmPopup) && (true == sPopupFormat.empty())) { prepare_edit_ctrl_for_error(hwndPopupFrmt); CurrencyRates_MessageBox(hWnd, TranslateT("Enter popup window format."), MB_OK | MB_ICONERROR); bOk = false; } if (true == bOk) { - CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); pAdvSettings->SetLogMode(nLogMode); pAdvSettings->SetHistoryOnlyChangedFlag(1 == IsDlgButtonChecked(hWnd, IDC_CHECK_HISTORY_CONDITION)); @@ -567,20 +567,20 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, } } 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)); + 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); @@ -600,9 +600,9 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, 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)); + const CAdvProviderSettings *pAdvSettings = reinterpret_cast<CAdvProviderSettings *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG_POPUP), hWnd, @@ -614,8 +614,8 @@ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, return FALSE; } -CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider *pCurrencyRatesProvider) - : m_pCurrencyRatesProvider(pCurrencyRatesProvider), +CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider *pCurrencyRatesProvider) : + m_pCurrencyRatesProvider(pCurrencyRatesProvider), m_wLogMode(lmDisabled), m_bIsOnlyChangedHistory(false), m_bIsOnlyChangedLogFile(false), @@ -624,11 +624,11 @@ CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider *pCurren { assert(m_pCurrencyRatesProvider); - m_wLogMode = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogMode, static_cast<WORD>(lmDisabled)); - m_sFormatHistory = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_HistoryFormat, DB_DEF_HistoryFormat); - m_bIsOnlyChangedHistory = 1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_HistoryCondition, 0); + m_wLogMode = g_plugin.getWord(DB_KEY_LogMode, static_cast<WORD>(lmDisabled)); + m_sFormatHistory = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_HistoryFormat, DB_DEF_HistoryFormat); + m_bIsOnlyChangedHistory = 1 == g_plugin.getByte(DB_KEY_HistoryCondition, 0); - m_sLogFileName = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_LogFile); + m_sLogFileName = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_LogFile); if (true == m_sLogFileName.empty()) { m_sLogFileName = g_pszVariableUserProfile; m_sLogFileName += L"\\CurrencyRates\\"; @@ -636,11 +636,11 @@ CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider *pCurren m_sLogFileName += L".log"; } - m_sFormatLogFile = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_LogFormat, DB_DEF_LogFormat); - m_bIsOnlyChangedLogFile = (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogCondition, 0)); + m_sFormatLogFile = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_LogFormat, DB_DEF_LogFormat); + m_bIsOnlyChangedLogFile = (1 == g_plugin.getByte(DB_KEY_LogCondition, 0)); - m_sPopupFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupFormat, DB_DEF_PopupFormat); - m_bShowPopupIfValueChanged = (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupCondition, 0)); + m_sPopupFormat = CurrencyRates_DBGetStringW(NULL, MODULENAME, DB_KEY_PopupFormat, DB_DEF_PopupFormat); + m_bShowPopupIfValueChanged = (1 == g_plugin.getByte(DB_KEY_PopupCondition, 0)); } CAdvProviderSettings::~CAdvProviderSettings() @@ -648,29 +648,29 @@ CAdvProviderSettings::~CAdvProviderSettings() delete m_pPopupSettings; } -const ICurrencyRatesProvider* CAdvProviderSettings::GetProviderPtr() const +const ICurrencyRatesProvider *CAdvProviderSettings::GetProviderPtr() const { return m_pCurrencyRatesProvider; } void CAdvProviderSettings::SaveToDb() const { - db_set_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogMode, m_wLogMode); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_HistoryFormat, m_sFormatHistory.c_str()); - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_HistoryCondition, m_bIsOnlyChangedHistory); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogFile, m_sLogFileName.c_str()); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogFormat, m_sFormatLogFile.c_str()); - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_LogCondition, m_bIsOnlyChangedLogFile); - db_set_ws(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupFormat, m_sPopupFormat.c_str()); - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupCondition, m_bShowPopupIfValueChanged); + 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) { - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupColourMode, static_cast<BYTE>(m_pPopupSettings->GetColourMode())); - db_set_dw(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupBkColour, m_pPopupSettings->GetColourBk()); - db_set_dw(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupTextColour, m_pPopupSettings->GetColourText()); - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupDelayMode, static_cast<BYTE>(m_pPopupSettings->GetDelayMode())); - db_set_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupDelayTimeout, m_pPopupSettings->GetDelayTimeout()); - db_set_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupHistoryFlag, m_pPopupSettings->GetHistoryFlag()); + g_plugin.setByte(DB_KEY_PopupColourMode, static_cast<BYTE>(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<BYTE>(m_pPopupSettings->GetDelayMode())); + g_plugin.setWord(DB_KEY_PopupDelayTimeout, m_pPopupSettings->GetDelayTimeout()); + g_plugin.setByte(DB_KEY_PopupHistoryFlag, m_pPopupSettings->GetHistoryFlag()); } } @@ -689,7 +689,7 @@ tstring CAdvProviderSettings::GetHistoryFormat() const return m_sFormatHistory; } -void CAdvProviderSettings::SetHistoryFormat(const tstring& rsFormat) +void CAdvProviderSettings::SetHistoryFormat(const tstring &rsFormat) { m_sFormatHistory = rsFormat; } @@ -709,7 +709,7 @@ tstring CAdvProviderSettings::GetLogFileName() const return m_sLogFileName; } -void CAdvProviderSettings::SetLogFileName(const tstring& rsFile) +void CAdvProviderSettings::SetLogFileName(const tstring &rsFile) { m_sLogFileName = rsFile; } @@ -719,7 +719,7 @@ tstring CAdvProviderSettings::GetLogFormat() const return m_sFormatLogFile; } -void CAdvProviderSettings::SetLogFormat(const tstring& rsFormat) +void CAdvProviderSettings::SetLogFormat(const tstring &rsFormat) { m_sFormatLogFile = rsFormat; } @@ -734,12 +734,12 @@ void CAdvProviderSettings::SetLogOnlyChangedFlag(bool bMode) m_bIsOnlyChangedLogFile = bMode; } -const tstring& CAdvProviderSettings::GetPopupFormat() const +const tstring &CAdvProviderSettings::GetPopupFormat() const { return m_sPopupFormat; } -void CAdvProviderSettings::SetPopupFormat(const tstring& val) +void CAdvProviderSettings::SetPopupFormat(const tstring &val) { m_sPopupFormat = val; } @@ -754,7 +754,7 @@ void CAdvProviderSettings::SetShowPopupIfValueChangedFlag(bool val) m_bShowPopupIfValueChanged = val; } -CPopupSettings* CAdvProviderSettings::GetPopupSettingsPtr() const +CPopupSettings *CAdvProviderSettings::GetPopupSettingsPtr() const { if (nullptr == m_pPopupSettings) m_pPopupSettings = new CPopupSettings(); @@ -774,19 +774,19 @@ CPopupSettings::CPopupSettings() : m_bUseHistory(false) { - BYTE m = db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupColourMode, static_cast<BYTE>(m_modeColour)); - if (m >= colourDefault && m <= colourUserDefined) + BYTE m = g_plugin.getByte(DB_KEY_PopupColourMode, static_cast<BYTE>(m_modeColour)); + if (m >= colourDefault && m <= colourUserDefined) m_modeColour = static_cast<EColourMode>(m); - m_rgbBkg = db_get_dw(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupBkColour, m_rgbBkg); - m_rgbText = db_get_dw(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupTextColour, m_rgbText); + m_rgbBkg = g_plugin.getDword(DB_KEY_PopupBkColour, m_rgbBkg); + m_rgbText = g_plugin.getDword(DB_KEY_PopupTextColour, m_rgbText); - m = db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupDelayMode, static_cast<BYTE>(m_modeDelay)); - if (m >= delayFromPopup && m <= delayPermanent) { + m = g_plugin.getByte(DB_KEY_PopupDelayMode, static_cast<BYTE>(m_modeDelay)); + if (m >= delayFromPopup && m <= delayPermanent) m_modeDelay = static_cast<EDelayMode>(m); - } - m_wDelay = db_get_w(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupDelayTimeout, m_wDelay); - m_bUseHistory = (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, DB_KEY_PopupHistoryFlag, m_bUseHistory)); + + m_wDelay = g_plugin.getWord(DB_KEY_PopupDelayTimeout, m_wDelay); + m_bUseHistory = (1 == g_plugin.getByte(DB_KEY_PopupHistoryFlag, m_bUseHistory)); } /*static */ @@ -803,30 +803,30 @@ COLORREF CPopupSettings::GetDefColourText() void CPopupSettings::InitForContact(MCONTACT hContact) { - BYTE m = db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<BYTE>(m_modeColour)); - if (m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined) { + BYTE m = g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<BYTE>(m_modeColour)); + if (m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined) { m_modeColour = static_cast<CPopupSettings::EColourMode>(m); } - m_rgbBkg = db_get_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_BK, m_rgbBkg); - m_rgbText = db_get_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_TEXT, m_rgbText); + 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 = db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_DELAY_MODE, static_cast<BYTE>(m_modeDelay)); - if (m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent) { + m = g_plugin.getByte(hContact, DB_STR_CURRENCYRATE_POPUP_DELAY_MODE, static_cast<BYTE>(m_modeDelay)); + if (m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent) { m_modeDelay = static_cast<CPopupSettings::EDelayMode>(m); } - m_wDelay = db_get_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_DELAY_TIMEOUT, m_wDelay); - m_bUseHistory = 1 == db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_HISTORY_FLAG, m_bUseHistory); + 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 { - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<BYTE>(m_modeColour)); - db_set_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_BK, m_rgbBkg); - db_set_dw(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_COLOUR_TEXT, m_rgbText); - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_DELAY_MODE, static_cast<BYTE>(m_modeDelay)); - db_set_w(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_DELAY_TIMEOUT, m_wDelay); - db_set_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_POPUP_HISTORY_FLAG, m_bUseHistory); + g_plugin.setByte(hContact, DB_STR_CURRENCYRATE_POPUP_COLOUR_MODE, static_cast<BYTE>(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<BYTE>(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 @@ -889,7 +889,7 @@ void CPopupSettings::SetHistoryFlag(bool flag) m_bUseHistory = flag; } -bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings* pAdvSettings) +bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings *pAdvSettings) { assert(pAdvSettings); @@ -903,14 +903,14 @@ bool ShowSettingsDlg(HWND hWndParent, CAdvProviderSettings* pAdvSettings) tstring GenerateLogFileName(const tstring &rsLogFilePattern, const tstring &rsCurrencyRateSymbol, int nFlags) { tstring sPath = rsLogFilePattern; - if (nFlags&glfnResolveCurrencyRateName) { + if (nFlags & glfnResolveCurrencyRateName) { assert(false == rsCurrencyRateSymbol.empty()); tstring::size_type n = sPath.find(g_pszVariableCurrencyRateName); if (tstring::npos != n) { tstring s = rsCurrencyRateSymbol; FixInvalidChars(s); - sPath.replace(n, _countof(g_pszVariableCurrencyRateName)-1, s.c_str()); + sPath.replace(n, _countof(g_pszVariableCurrencyRateName) - 1, s.c_str()); } } @@ -932,15 +932,15 @@ tstring GetContactLogFileName(MCONTACT hContact) auto pProvider = GetContactProviderPtr(hContact); if (pProvider) { tstring sPattern; - bool bUseContactSpecific = (db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); + bool bUseContactSpecific = (g_plugin.getByte(hContact, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); if (bUseContactSpecific) - sPattern = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); + sPattern = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_LOG_FILE); else { CAdvProviderSettings global_settings(pProvider); sPattern = global_settings.GetLogFileName(); } - result = GenerateLogFileName(sPattern, CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL)); + result = GenerateLogFileName(sPattern, CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL)); } return result; @@ -948,9 +948,9 @@ tstring GetContactLogFileName(MCONTACT hContact) tstring GetContactName(MCONTACT hContact) { - tstring sDescription = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_DESCRIPTION); + tstring sDescription = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_DESCRIPTION); if (sDescription.empty()) - sDescription = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sDescription = CurrencyRates_DBGetStringW(hContact, MODULENAME, DB_STR_CURRENCYRATE_SYMBOL); return sDescription; } |