diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-08 20:12:16 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-08 20:12:26 +0300 |
commit | 8ffc77be71507825a8f7585bcabff8ccc370206a (patch) | |
tree | aa13a8070f31286db6ad22e17a577e547942f951 | |
parent | 41b2fdfc654e3eec07c97ceba00cda13d988ffff (diff) |
db_get_sa / db_get_wsa to receive the default value, massive code simplification
68 files changed, 279 insertions, 460 deletions
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 3ec65f0089..b7d3ddb00b 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -202,8 +202,6 @@ function db_get_b(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting: function db_get_w(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall; external CoreDLL;
function db_get_dw(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:dword):dword; stdcall; external CoreDLL;
function db_get_s(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT; const nType:int=DBVT_ASCIIZ):int_ptr; stdcall; external CoreDLL;
-function db_get_sa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PAnsiChar; stdcall; external CoreDLL;
-function db_get_wsa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PWideChar; stdcall; external CoreDLL;
function db_get_static(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall; external CoreDLL;
function db_get_static_utf(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall; external CoreDLL;
diff --git a/include/m_database.h b/include/m_database.h index b85aee92e9..21917ee723 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -379,42 +379,42 @@ EXTERN_C MIR_CORE_DLL(MEVENT) db_event_setId(const char *szModule, MEVENT hDbEve /////////////////////////////////////////////////////////////////////////////////////////
// Database settings
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
-EXTERN_C MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0);
-EXTERN_C MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0);
-EXTERN_C MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue = 0);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
+EXTERN_C MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue = 0);
+EXTERN_C MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue = 0);
+EXTERN_C MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, const char *szModule, const char *szSetting, DWORD errorValue = 0);
-EXTERN_C MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting);
-EXTERN_C MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting);
+EXTERN_C MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szValue = nullptr);
+EXTERN_C MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szValue = nullptr);
-MIR_CORE_DLL(CMStringA) db_get_sm(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting);
-MIR_CORE_DLL(CMStringW) db_get_wsm(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting);
+MIR_CORE_DLL(CMStringA) db_get_sm(MCONTACT hContact, const char *szModule, const char *szSetting);
+MIR_CORE_DLL(CMStringW) db_get_wsm(MCONTACT hContact, const char *szModule, const char *szSetting);
-EXTERN_C MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest);
-EXTERN_C MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest);
-EXTERN_C MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, wchar_t *pDest, int cbDest);
+EXTERN_C MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest);
+EXTERN_C MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest);
+EXTERN_C MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, const char *szModule, const char *szSetting, wchar_t *pDest, int cbDest);
#if defined(__cplusplus)
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType = DBVT_ASCIIZ);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType = DBVT_ASCIIZ);
#else
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType);
#endif
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, BYTE val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, WORD val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCWSTR val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, void *val, unsigned len);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, const char *szModule, const char *szSetting, BYTE val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, const char *szModule, const char *szSetting, WORD val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, const char *szModule, const char *szSetting, DWORD val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, const char *szModule, const char *szSetting, void *val, unsigned len);
-EXTERN_C MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting);
+EXTERN_C MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, const char *szModule, const char *szSetting);
#if defined(__cplusplus)
-EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable = TRUE);
+EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable = TRUE);
#else
-EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable);
+EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable);
#endif
#define db_get_ws(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
@@ -701,7 +701,7 @@ class MIR_APP_EXPORT DB_AUTH_BLOB PBYTE makeBlob();
public:
- explicit DB_AUTH_BLOB(MCONTACT hContact, LPCSTR nick, LPCSTR fname, LPCSTR lname, LPCSTR id, LPCSTR reason);
+ explicit DB_AUTH_BLOB(MCONTACT hContact, const char *nick, const char *fname, const char *lname, const char *id, const char *reason);
explicit DB_AUTH_BLOB(PBYTE blob);
~DB_AUTH_BLOB();
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib Binary files differindex 1797cf3b93..ab262cf593 100644 --- a/libs/win32/mir_core.lib +++ b/libs/win32/mir_core.lib diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib Binary files differindex ae0cf50018..1ce32c8d63 100644 --- a/libs/win64/mir_core.lib +++ b/libs/win64/mir_core.lib diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index 4e1d9ea226..844d59b956 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -92,10 +92,10 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz }
else {
if (hContact == 0) { // create a protocol picture in the proto picture cache
- if (tszValue = db_get_wsa(NULL, PPICT_MODULE, szProto))
+ if (tszValue = db_get_wsa(0, PPICT_MODULE, szProto))
MyPathToAbsolute(tszValue, tszFilename);
else if (mir_strcmp(szProto, AVS_DEFAULT)) {
- if (tszValue = db_get_wsa(NULL, PPICT_MODULE, AVS_DEFAULT))
+ if (tszValue = db_get_wsa(0, PPICT_MODULE, AVS_DEFAULT))
MyPathToAbsolute(tszValue, tszFilename);
if (!strstr(szProto, "Global avatar for")) {
@@ -104,7 +104,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz return -1;
char key[MAX_PATH];
mir_snprintf(key, "Global avatar for %s accounts", pdescr->szProtoName);
- if (tszValue = db_get_wsa(NULL, PPICT_MODULE, key))
+ if (tszValue = db_get_wsa(0, PPICT_MODULE, key))
MyPathToAbsolute(tszValue, tszFilename);
}
}
@@ -130,7 +130,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz else
MultiByteToWideChar(CP_ACP, 0, szFileName, -1, tszFilename, _countof(tszFilename));
}
- else if (tszValue = db_get_wsa(NULL, szProto, "AvatarFile"))
+ else if (tszValue = db_get_wsa(0, szProto, "AvatarFile"))
MyPathToAbsolute(tszValue, tszFilename);
else return -1;
}
diff --git a/plugins/ClientChangeNotify/src/CString.cpp b/plugins/ClientChangeNotify/src/CString.cpp index b0396d375e..ece8b81645 100644 --- a/plugins/ClientChangeNotify/src/CString.cpp +++ b/plugins/ClientChangeNotify/src/CString.cpp @@ -259,14 +259,12 @@ template class TString<WCHAR>; CString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szDefaultValue)
{
- ptrA p(db_get_sa(hContact, szModule, szSetting));
- return CString(p == NULL ? szDefaultValue : p);
+ return CString(ptrA(db_get_sa(hContact, szModule, szSetting, szDefaultValue)));
}
TCString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue)
{
- ptrW p(db_get_wsa(hContact, szModule, szSetting));
- return TCString(p == NULL ? szDefaultValue : p);
+ return TCString(ptrW(db_get_wsa(hContact, szModule, szSetting, szDefaultValue)));
}
TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue)
diff --git a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp index f28e596aae..f5d455ee83 100644 --- a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp +++ b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp @@ -336,9 +336,7 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- rowOptTmplStr = db_get_sa(0, "ModernData", "RowTemplate");
- if (!rowOptTmplStr)
- rowOptTmplStr = mir_strdup("<TR />");
+ rowOptTmplStr = db_get_sa(0, "ModernData", "RowTemplate", "<TR />");
SendDlgItemMessage(hwndDlg, IDC_SPINCONTWIDTH, UDM_SETRANGE, 0, MAKELONG(999, 0));
SendDlgItemMessage(hwndDlg, IDC_SPINCONTHEIGHT, UDM_SETRANGE, 0, MAKELONG(999, 0));
diff --git a/plugins/Clist_modern/src/modern_skinbutton.cpp b/plugins/Clist_modern/src/modern_skinbutton.cpp index 6884fbbbe6..bebfd0ffca 100644 --- a/plugins/Clist_modern/src/modern_skinbutton.cpp +++ b/plugins/Clist_modern/src/modern_skinbutton.cpp @@ -127,12 +127,8 @@ static int ModernSkinButtonPaintWorker(HWND hwnd, HDC whdc) } while (key[0] != '\0'); switch (bct->ValueTypeDef[0]) { case 's': - { - Value = db_get_sa(0, section, key); - if (!Value) - Value = mir_strdup(bct->ValueTypeDef + 1); - break; - } + Value = db_get_sa(0, section, key, bct->ValueTypeDef + 1); + break; case 'd': defval = db_get_dw(0, section, key, defval); Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); diff --git a/plugins/Clist_nicer/src/cluiframes.cpp b/plugins/Clist_nicer/src/cluiframes.cpp index dc13bee1e7..fb0f1794ba 100644 --- a/plugins/Clist_nicer/src/cluiframes.cpp +++ b/plugins/Clist_nicer/src/cluiframes.cpp @@ -2124,7 +2124,7 @@ int OnFrameTitleBarBackgroundChange() hBmpBackground = nullptr; } if (db_get_b(0, "FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) { - ptrW tszBitmapName(db_get_wsa(NULL, "FrameTitleBar", "BkBitmap")); + ptrW tszBitmapName(db_get_wsa(0, "FrameTitleBar", "BkBitmap")); if (tszBitmapName != NULL) hBmpBackground = Bitmap_Load(tszBitmapName); } diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index feb5c23f5e..7bdf28ee2b 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -1032,7 +1032,7 @@ void ApplyViewMode(const char *name) }
mir_snprintf(szSetting, "%c%s_GF", 246, name);
- ptrW tszGroups(db_get_wsa(NULL, CLVM_MODULE, szSetting));
+ ptrW tszGroups(db_get_wsa(0, CLVM_MODULE, szSetting));
if (mir_wstrlen(tszGroups) >= 2) {
wcsncpy_s(cfg::dat.groupFilter, tszGroups, _TRUNCATE);
cfg::dat.bFilterEffective |= CLVM_FILTER_GROUPS;
diff --git a/plugins/CurrencyRates/src/CommonOptionDlg.cpp b/plugins/CurrencyRates/src/CommonOptionDlg.cpp index db0fa32b65..f963ce9d12 100644 --- a/plugins/CurrencyRates/src/CommonOptionDlg.cpp +++ b/plugins/CurrencyRates/src/CommonOptionDlg.cpp @@ -43,15 +43,15 @@ void CommonOptionDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp, CCommonDlgPr assert(visitor.m_pszDbTendencyFormat); // set contact list display format - tstring sDspNameFrmt = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); + tstring sDspNameFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); ::SetDlgItemText(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT, sDspNameFrmt.c_str()); // set status message display format - tstring sStatusMsgFrmt = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); + tstring sStatusMsgFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); ::SetDlgItemText(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT, sStatusMsgFrmt.c_str()); // set tendency format - tstring sTendencyFrmt = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); + tstring sTendencyFrmt = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); ::SetDlgItemText(hWnd, IDC_EDIT_TENDENCY_FORMAT, sTendencyFrmt.c_str()); // refresh rate diff --git a/plugins/CurrencyRates/src/CurrencyConverter.cpp b/plugins/CurrencyRates/src/CurrencyConverter.cpp index b4ea9b18c1..91c2ae989e 100644 --- a/plugins/CurrencyRates/src/CurrencyConverter.cpp +++ b/plugins/CurrencyRates/src/CurrencyConverter.cpp @@ -96,8 +96,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_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_FROM_ID); - tstring sToCurrencyRateID = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, DB_STR_CC_CURRENCYRATE_TO_ID); + 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); const auto pProvider = get_currency_converter_provider(); const auto& rSection = get_currencyrates(pProvider); diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp index 634e645b1d..69c6a1d892 100644 --- a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp +++ b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp @@ -222,7 +222,7 @@ void CCurrencyRatesProviderBase::SetContactStatus(MCONTACT hContact, int nNewSta if (ID_STATUS_ONLINE != nNewStatus) { db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); - tstring sSymbol = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + 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()); @@ -570,7 +570,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat } else { if (true == sSymbol.empty()) - sSymbol = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sSymbol = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); oNick << std::setfill(L' ') << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate; } @@ -604,11 +604,11 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat } if (true == bAdd) { tstring sLogFileName = (bUseContactSpecific) - ? CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str()) + ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE, global_settings.GetLogFileName().c_str()) : global_settings.GetLogFileName(); if (true == sSymbol.empty()) { - sSymbol = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sSymbol = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); } sLogFileName = GenerateLogFileName(sLogFileName, sSymbol); @@ -617,7 +617,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat if (bUseContactSpecific) { CCurrencyRatesProviderVisitorDbSettings visitor; Accept(visitor); - sFormat = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, visitor.m_pszDefLogFileFormat); + sFormat = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, visitor.m_pszDefLogFileFormat); } log_to_file(this, hContact, sLogFileName, sFormat); @@ -634,7 +634,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat } if (true == bAdd) { tstring sFormat = (bUseContactSpecific) - ? CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) + ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) : global_settings.GetHistoryFormat(); log_to_history(this, hContact, nTime, sFormat); @@ -648,7 +648,7 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat if ((false == bOnlyIfChanged) || ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) { tstring sFormat = (bUseContactSpecific) - ? CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) + ? CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) : global_settings.GetPopupFormat(); CPopupSettings ps = *(global_settings.GetPopupSettingsPtr()); @@ -736,9 +736,9 @@ void CCurrencyRatesProviderBase::Run() Accept(visitor); DWORD nTimeout = get_refresh_timeout_miliseconds(visitor); - m_sContactListFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); - m_sStatusMsgFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); - m_sTendencyFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); + m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); + m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); + m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); enum { @@ -788,9 +788,9 @@ void CCurrencyRatesProviderBase::Run() case WAIT_OBJECT_0 + SETTINGS_CHANGED: nTimeout = get_refresh_timeout_miliseconds(visitor); - m_sContactListFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); - m_sStatusMsgFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); - m_sTendencyFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); + m_sContactListFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); + m_sStatusMsgFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); + m_sTendencyFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); { mir_cslock lck(m_cs); anContacts = m_aContacts; @@ -855,8 +855,7 @@ void CCurrencyRatesProviderBase::Accept(CCurrencyRatesProviderVisitor &visitor)c void CCurrencyRatesProviderBase::RefreshSettings() { - BOOL b = ::SetEvent(m_hEventSettingsChanged); - assert(b && "Failed to set event"); + ::SetEvent(m_hEventSettingsChanged); } void CCurrencyRatesProviderBase::RefreshAllContacts() @@ -867,8 +866,7 @@ void CCurrencyRatesProviderBase::RefreshAllContacts() std::for_each(std::begin(m_aContacts), std::end(m_aContacts), [&](MCONTACT hContact) { m_aRefreshingContacts.push_back(hContact); }); } - BOOL b = ::SetEvent(m_hEventRefreshContact); - assert(b && "Failed to set event"); + ::SetEvent(m_hEventRefreshContact); } void CCurrencyRatesProviderBase::RefreshContact(MCONTACT hContact) @@ -878,6 +876,5 @@ void CCurrencyRatesProviderBase::RefreshContact(MCONTACT hContact) m_aRefreshingContacts.push_back(hContact); } - BOOL b = ::SetEvent(m_hEventRefreshContact); - assert(b && "Failed to set event"); + ::SetEvent(m_hEventRefreshContact); } diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp index 49cd4529ee..2dc1ce8b69 100644 --- a/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp +++ b/plugins/CurrencyRates/src/CurrencyRatesProviderCurrencyConverter.cpp @@ -14,8 +14,8 @@ namespace tstring build_url(MCONTACT hContact, const tstring& rsURL) { - tstring sFrom = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); return build_url(rsURL, sFrom, sTo); } @@ -340,10 +340,10 @@ bool CCurrencyRatesProviderCurrencyConverter::GetWatchedRateInfo(size_t nIndex, { if(nIndex < m_aContacts.size()) { MCONTACT hContact = m_aContacts[nIndex]; - tstring sSymbolFrom = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sSymbolTo = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); - tstring sDescFrom = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); - tstring sDescTo = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION); + 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); rRateInfo.first = CCurrencyRate(sSymbolFrom, sSymbolFrom, sDescFrom); rRateInfo.second = CCurrencyRate(sSymbolTo, sSymbolTo, sDescTo); @@ -358,8 +358,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_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, 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()))); }); @@ -413,8 +413,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_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); - tstring sTo = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + tstring sFrom = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); + tstring sTo = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); return ((0 == mir_wstrcmpi(rsFromID.c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(rsToID.c_str(), sTo.c_str()))); }); diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp index e46354c2e4..9c4477f22a 100644 --- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp +++ b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorFormater.cpp @@ -50,10 +50,10 @@ void CCurrencyRatesProviderVisitorFormater::Visit(const CCurrencyRatesProviderBa m_sResult = m_chr; break; case 'S': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); break; case 's': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); break; case 'X': m_sResult = format_fetch_time(rProvider, m_hContact, CurrencyRates_GetTimeFormat(true)); @@ -107,16 +107,16 @@ void CCurrencyRatesProviderVisitorFormater::Visit(const CCurrencyRatesProviderCu { switch (m_chr) { case 'F': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); break; case 'f': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_FROM_ID); break; case 'I': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_DESCRIPTION); break; case 'i': - m_sResult = CurrencyRates_DBGetStringT(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); + m_sResult = CurrencyRates_DBGetStringW(m_hContact, CURRENCYRATES_MODULE_NAME, DB_STR_TO_ID); break; } }
\ No newline at end of file diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviders.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviders.cpp index ea2861e378..1d07bc32a2 100644 --- a/plugins/CurrencyRates/src/CurrencyRatesProviders.cpp +++ b/plugins/CurrencyRates/src/CurrencyRatesProviders.cpp @@ -67,7 +67,7 @@ CCurrencyRatesProviders::TCurrencyRatesProviderPtr CCurrencyRatesProviders::GetC if (nullptr == szProto || 0 != ::_stricmp(szProto, CURRENCYRATES_PROTOCOL_NAME)) return TCurrencyRatesProviderPtr(); - tstring sProvider = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); + tstring sProvider = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER); if (true == sProvider.empty()) return TCurrencyRatesProviderPtr(); diff --git a/plugins/CurrencyRates/src/DBUtils.cpp b/plugins/CurrencyRates/src/DBUtils.cpp index ebb816a8ea..cdc6560db7 100644 --- a/plugins/CurrencyRates/src/DBUtils.cpp +++ b/plugins/CurrencyRates/src/DBUtils.cpp @@ -1,31 +1,13 @@ #include "StdAfx.h" -std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue /*= NULL*/) +std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue) { - std::string sResult; - char* pszSymbol = db_get_sa(hContact, szModule, szSetting); - if (nullptr != pszSymbol) { - sResult = pszSymbol; - mir_free(pszSymbol); - } - else if (nullptr != pszDefValue) - sResult = pszDefValue; - - return sResult; + return std::string(ptrA(db_get_sa(hContact, szModule, szSetting, pszDefValue))); } -std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue/* = NULL*/) +std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue) { - std::wstring sResult; - wchar_t* pszSymbol = db_get_wsa(hContact, szModule, szSetting); - if (nullptr != pszSymbol) { - sResult = pszSymbol; - mir_free(pszSymbol); - } - else if (nullptr != pszDefValue) - sResult = pszDefValue; - - return sResult; + return std::wstring(ptrW(db_get_wsa(hContact, szModule, szSetting, pszDefValue))); } bool CurrencyRates_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue) diff --git a/plugins/CurrencyRates/src/DBUtils.h b/plugins/CurrencyRates/src/DBUtils.h index ff53653e6a..3e5f10e841 100644 --- a/plugins/CurrencyRates/src/DBUtils.h +++ b/plugins/CurrencyRates/src/DBUtils.h @@ -1,11 +1,8 @@ #ifndef __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__ #define __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__ -std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue = NULL); -std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue = NULL); - - -#define CurrencyRates_DBGetStringT CurrencyRates_DBGetStringW +std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue = nullptr); +std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue = nullptr); bool CurrencyRates_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue); bool CurrencyRates_DBReadDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double& rdValue); diff --git a/plugins/CurrencyRates/src/Forex.cpp b/plugins/CurrencyRates/src/Forex.cpp index 5047bfa31d..691c13a240 100644 --- a/plugins/CurrencyRates/src/Forex.cpp +++ b/plugins/CurrencyRates/src/Forex.cpp @@ -198,8 +198,7 @@ int CurrencyRatesEventFunc_OnModulesLoaded(WPARAM, LPARAM) InitMenu(); - BOOL b = ::ResetEvent(g_hEventWorkThreadStop); - assert(b && "Failed to reset event"); + ::ResetEvent(g_hEventWorkThreadStop); const CModuleInfo::TCurrencyRatesProvidersPtr& pProviders = CModuleInfo::GetCurrencyRateProvidersPtr(); const CCurrencyRatesProviders::TCurrencyRatesProviders& rapProviders = pProviders->GetProviders(); diff --git a/plugins/CurrencyRates/src/SettingsDlg.cpp b/plugins/CurrencyRates/src/SettingsDlg.cpp index 99cb998adc..fd79d43421 100644 --- a/plugins/CurrencyRates/src/SettingsDlg.cpp +++ b/plugins/CurrencyRates/src/SettingsDlg.cpp @@ -270,7 +270,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sHistoryFrmt = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_HISTORY, setGlobal.GetHistoryFormat().c_str()); + tstring sHistoryFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, 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()); @@ -280,13 +280,13 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sLogFileName = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); + tstring sLogFileName = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); if (true == sLogFileName.empty()) { - sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName); + sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(), CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL), glfnResolveCurrencyRateName); } ::SetDlgItemText(hWnd, IDC_EDIT_FILE_NAME, sLogFileName.c_str()); - tstring sLogFileFrmt = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_LOG_FILE, setGlobal.GetLogFormat().c_str()); + tstring sLogFileFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, 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()); @@ -295,7 +295,7 @@ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd, UINT msg, WPARAM wp, L // popup nCheck = (dwLogMode&lmPopup) ? 1 : 0; ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); - tstring sPopupFrmt = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_FORMAT_POPUP, setGlobal.GetPopupFormat().c_str()); + tstring sPopupFrmt = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, 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()); ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); @@ -657,10 +657,10 @@ CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider* pCurren assert(visitor.m_pszDbLogCondition); m_wLogMode = db_get_w(0, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogMode, static_cast<WORD>(lmDisabled)); - m_sFormatHistory = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbHistoryFormat, visitor.m_pszDefHistoryFormat); + m_sFormatHistory = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbHistoryFormat, visitor.m_pszDefHistoryFormat); m_bIsOnlyChangedHistory = 1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbHistoryCondition, 0); - m_sLogFileName = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogFile); + m_sLogFileName = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogFile); if (true == m_sLogFileName.empty()) { m_sLogFileName = g_pszVariableUserProfile; m_sLogFileName += L"\\CurrencyRates\\"; @@ -668,10 +668,10 @@ CAdvProviderSettings::CAdvProviderSettings(const ICurrencyRatesProvider* pCurren m_sLogFileName += L".log"; } - m_sFormatLogFile = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogFormat, visitor.m_pszDefLogFileFormat); + m_sFormatLogFile = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogFormat, visitor.m_pszDefLogFileFormat); m_bIsOnlyChangedLogFile = (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbLogCondition, 0)); - m_sPopupFormat = CurrencyRates_DBGetStringT(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbPopupFormat, visitor.m_pszDefPopupFormat); + m_sPopupFormat = CurrencyRates_DBGetStringW(NULL, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbPopupFormat, visitor.m_pszDefPopupFormat); m_bShowPopupIfValueChanged = (1 == db_get_b(0, CURRENCYRATES_MODULE_NAME, visitor.m_pszDbPopupCondition, 0)); } @@ -1001,13 +1001,13 @@ tstring GetContactLogFileName(MCONTACT hContact) tstring sPattern; bool bUseContactSpecific = (db_get_b(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); if (bUseContactSpecific) - sPattern = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); + sPattern = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_LOG_FILE); else { CAdvProviderSettings global_settings(pProvider.get()); sPattern = global_settings.GetLogFileName(); } - result = GenerateLogFileName(sPattern, CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL)); + result = GenerateLogFileName(sPattern, CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL)); } return result; @@ -1015,9 +1015,9 @@ tstring GetContactLogFileName(MCONTACT hContact) tstring GetContactName(MCONTACT hContact) { - tstring sDescription = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_DESCRIPTION); + tstring sDescription = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_DESCRIPTION); if (sDescription.empty()) - sDescription = CurrencyRates_DBGetStringT(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); + sDescription = CurrencyRates_DBGetStringW(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL); return sDescription; } diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index c0bfb91a8d..3bf8899ffc 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -19,11 +19,10 @@ public: {
name = mir_wstrdup(Clist_GetContactDisplayName(hContact));
- if (g_Options.bUseGroups) {
- if ((group = db_get_wsa(hContact, "CList", "Group")) == nullptr)
- group = mir_wstrdup(TranslateT("<no group>"));
- }
- else group = mir_wstrdup(TranslateT("Favorite Contacts"));
+ if (g_Options.bUseGroups)
+ group = db_get_wsa(hContact, "CList", "Group", TranslateT("<no group>"));
+ else
+ group = mir_wstrdup(TranslateT("Favorite Contacts"));
status = db_get_w(hContact, GetContactProto(hContact), "Status", ID_STATUS_OFFLINE);
}
diff --git a/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp index 88cafca600..ace11e7801 100644 --- a/plugins/GmailNotifier/src/check.cpp +++ b/plugins/GmailNotifier/src/check.cpp @@ -48,9 +48,7 @@ void CheckMailInbox(Account *curAcc) curAcc->IsChecking = true;
- ptrA szNick(db_get_sa(curAcc->hContact, "CList", "MyHandle"));
- if (szNick == nullptr)
- szNick = mir_strdup(curAcc->name);
+ ptrA szNick(db_get_sa(curAcc->hContact, "CList", "MyHandle", curAcc->name));
char *tail = strstr(szNick, " [");
if (tail) *tail = 0;
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 7b8852c657..adb014400f 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -477,18 +477,14 @@ void ProtocolArray::GetDefaultNick() {
ptrW tszNick(g_plugin.getWStringA(SETTING_DEFAULT_NICK));
if (tszNick)
- mir_wstrncpy(default_nick, tszNick, _countof(default_nick));
+ wcsncpy_s(default_nick, tszNick, _TRUNCATE);
else
default_nick[0] = '\0';
}
void ProtocolArray::GetDefaultAvatar()
{
- ptrW tszFile(db_get_wsa(0, "ContactPhoto", "File"));
- if (tszFile)
- mir_wstrncpy(default_avatar_file, tszFile, _countof(default_avatar_file));
- else
- default_avatar_file[0] = '\0';
+ wcsncpy_s(default_avatar_file, ptrW(db_get_wsa(0, "ContactPhoto", "File", L"")), _TRUNCATE);
}
wchar_t *ProtocolArray::GetDefaultStatusMsg()
diff --git a/plugins/NewAwaySysMod/src/CString.cpp b/plugins/NewAwaySysMod/src/CString.cpp index cb9b2f4903..69edcf49fc 100644 --- a/plugins/NewAwaySysMod/src/CString.cpp +++ b/plugins/NewAwaySysMod/src/CString.cpp @@ -273,14 +273,12 @@ template class TString<WCHAR>; CString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szDefaultValue)
{
- ptrA p( db_get_sa(hContact, szModule, szSetting));
- return CString(p == NULL ? szDefaultValue : p);
+ return CString(ptrA(db_get_sa(hContact, szModule, szSetting, szDefaultValue)));
}
TCString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue)
{
- ptrW p( db_get_wsa(hContact, szModule, szSetting));
- return TCString(p == NULL ? szDefaultValue : p);
+ return TCString(ptrW(db_get_wsa(hContact, szModule, szSetting, szDefaultValue)));
}
TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue)
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index ca0a7a694f..53ad7e2c8e 100755 --- a/plugins/New_GPG/src/gpg_wrapper.cpp +++ b/plugins/New_GPG/src/gpg_wrapper.cpp @@ -21,7 +21,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae if (!globals.gpg_valid) return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); { if (!boost::filesystem::exists(bin_path)) { mir_free(bin_path); @@ -42,7 +42,7 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae env.push_back(L"LC_ALL=English"); env.push_back(L"LANG=C"); argv.push_back(bin_path); - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); if (mir_wstrlen(home_dir)) //this check are required for first run gpg binary validation { argv.push_back(L"--homedir"); @@ -156,7 +156,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &aargv, pxResult *res if (!globals.gpg_valid) return pxNotConfigured; - wchar_t *bin_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *bin_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); { if (!boost::filesystem::exists(bin_path)) { mir_free(bin_path); @@ -177,7 +177,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &aargv, pxResult *res env.push_back(L"LC_ALL=English"); argv.push_back(bin_path); argv.push_back(L"--homedir"); - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); argv.push_back(home_dir); mir_free(home_dir); argv.push_back(L"--display-charset"); diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 8b074c96e7..5bf008296d 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -72,14 +72,14 @@ void init_vars() { globals.bAppendTags = g_plugin.getByte("bAppendTags", 0) != 0; globals.bStripTags = g_plugin.getByte("bStripTags", 0) != 0; - globals.inopentag = UniGetContactSettingUtf(0, MODULENAME, "szInOpenTag", L"<GPGdec>"); - globals.inclosetag = UniGetContactSettingUtf(0, MODULENAME, "szInCloseTag", L"</GPGdec>"); - globals.outopentag = UniGetContactSettingUtf(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"); - globals.outclosetag = UniGetContactSettingUtf(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"); + globals.inopentag = db_get_wsa(0, MODULENAME, "szInOpenTag", L"<GPGdec>"); + globals.inclosetag = db_get_wsa(0, MODULENAME, "szInCloseTag", L"</GPGdec>"); + globals.outopentag = db_get_wsa(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"); + globals.outclosetag = db_get_wsa(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"); globals.bDebugLog = g_plugin.getByte("bDebugLog", 0) != 0; globals.bAutoExchange = g_plugin.getByte("bAutoExchange", 0) != 0; globals.bSameAction = g_plugin.getByte("bSameAction", 0) != 0; - globals.password = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + globals.password = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); globals.debuglog.init(); globals.bJabberAPI = g_plugin.getByte("bJabberAPI", true) != 0; globals.bPresenceSigning = g_plugin.getByte("bPresenceSigning", 0) != 0; diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index 93fe0f43d5..ab44baef71 100755 --- a/plugins/New_GPG/src/log.cpp +++ b/plugins/New_GPG/src/log.cpp @@ -75,7 +75,7 @@ void logtofile::init() if (globals.bDebugLog) { if (path) mir_free(path); - path = UniGetContactSettingUtf(0, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log"); + path = db_get_wsa(0, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log"); } _bDebugLog = globals.bDebugLog; } diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index c9fd96bcdf..788254b725 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -30,13 +30,13 @@ void InitCheck() { { // parse gpg output - wchar_t *current_home = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *current_home = db_get_wsa(0, MODULENAME, "szHomePath", L""); g_plugin.setWString("szHomePath", L""); //we do not need home for gpg binary validation globals.gpg_valid = isGPGValid(); g_plugin.setWString("szHomePath", current_home); //return current home dir back mir_free(current_home); bool home_dir_access = false, temp_access = false; - wchar_t *home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); std::wstring test_path = home_dir; mir_free(home_dir); test_path += L"/"; @@ -91,7 +91,7 @@ void InitCheck() if (result == pxNotFound) return; } - home_dir = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + home_dir = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring tmp_dir = home_dir; mir_free(home_dir); tmp_dir += L"\\tmp"; @@ -109,11 +109,11 @@ void InitCheck() acc += pa->szModuleName; acc += ")"; acc += "_KeyID"; - keyid = UniGetContactSettingUtf(0, MODULENAME, acc.c_str(), ""); + keyid = db_get_sa(0, MODULENAME, acc.c_str(), ""); if (keyid[0]) { question = Translate("Your secret key with ID: "); mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" for account "); @@ -173,8 +173,8 @@ void InitCheck() } } question = Translate("Your secret key with ID: "); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); - char *key = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); + char *key = db_get_sa(0, MODULENAME, "GPGPubKey", ""); if (!g_plugin.getByte("FirstRun", 1) && (!keyid[0] || !key[0])) { question = Translate("You didn't set a private key.\nWould you like to set it now?"); if (MessageBoxA(nullptr, question.c_str(), Translate("Own private key warning"), MB_YESNO) == IDYES) { @@ -235,7 +235,7 @@ void InitCheck() mir_free(key); } { - wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path = db_get_wsa(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -290,16 +290,16 @@ void ImportKey(MCONTACT hContact, std::wstring new_key) std::vector<wstring> cmd; wchar_t tmp2[MAX_PATH] = { 0 }; { - wcsncpy(tmp2, ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")), MAX_PATH - 1); + wcsncpy(tmp2, ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L"")), MAX_PATH - 1); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); mir_wstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_wstrlen(tmp2)); boost::filesystem::remove(tmp2); ptrW ptmp; if (db_mc_isMeta(hContact)) - ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(metaGetMostOnline(hContact), MODULENAME, "GPGPubKey", L""); else - ptmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); wfstream f(tmp2, std::ios::out); f << ptmp.get(); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 1189fca923..de025503ce 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -76,7 +76,7 @@ static void RecvMsgSvc_func(RecvParams *param) boost::algorithm::erase_all(param->str, "\r"); s2 += mir_wstrlen(L"-----END PGP MESSAGE-----"); - ptrW ptszHomePath(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW ptszHomePath(db_get_wsa(0, MODULENAME, "szHomePath", L"")); wstring encfile = toUTF16(get_random(10)); wstring decfile = toUTF16(get_random(10)); { @@ -114,18 +114,18 @@ static void RecvMsgSvc_func(RecvParams *param) std::vector<wstring> cmd; cmd.push_back(L"--batch"); { - char *inkeyid = UniGetContactSettingUtf(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "InKeyID", ""); + char *inkeyid = db_get_sa(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, MODULENAME, "InKeyID", ""); wchar_t *pass = nullptr; if (inkeyid[0]) { string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password"); } else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password"); } @@ -401,7 +401,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) string output; DWORD exitcode; { - ptrW ptmp(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW ptmp(db_get_wsa(0, MODULENAME, "szHomePath", L"")); mir_wstrcpy(tmp2, ptmp); mir_free(ptmp); mir_wstrcat(tmp2, L"\\"); @@ -431,7 +431,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) f.open(tmp2, std::ios::out); } } - ptmp = UniGetContactSettingUtf(ccs->hContact, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(ccs->hContact, MODULENAME, "GPGPubKey", L""); f << (wchar_t*)ptmp; f.close(); cmd.push_back(L"--batch"); @@ -541,7 +541,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info(autoexchange): received key request from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact))); - ptrA tmp(UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", "")); + ptrA tmp(db_get_sa(0, MODULENAME, "GPGPubKey", "")); if (tmp[0]) { int enc_state = db_get_b(ccs->hContact, MODULENAME, "GPGEncryption", 0); if (enc_state) @@ -569,7 +569,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L""); if (jid[0]) { for (auto p : globals.Accounts) { wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid); @@ -616,7 +616,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) { wchar_t *tmp2; { - char *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + char *tmp = db_get_sa(hContact, MODULENAME, "KeyID", ""); if (!tmp[0]) { mir_free(tmp); HistoryLog(hContact, db_event("Failed to encrypt message with GPG (not found key for encryption in db)", 0, 0, DBEF_SENT)); @@ -643,7 +643,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) mir_free(tmp2); } { - wchar_t *tmp2 = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp2 = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = tmp2; cmd.push_back(std::wstring(tmp2) + L"\\tmp\\" + file); mir_free(tmp2); @@ -879,7 +879,7 @@ int HookSendMsg(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(hContact, proto, "jid", L""); if (jid[0]) { if (globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact))); diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index b42c4f8d30..81db5b496b 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -70,26 +70,26 @@ public: list_USERLIST.SetItemText(row, 4, tmp); mir_free(tmp); - char *tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hContact, MODULENAME, "KeyID", ""); tmp = mir_a2u(tmp2); mir_free(tmp2); list_USERLIST.SetItemText(row, 1, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); - tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainName", ""); + tmp2 = db_get_sa(hContact, MODULENAME, "KeyMainName", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainName", L""); + tmp = db_get_wsa(hContact, MODULENAME, "KeyMainName", L""); mir_free(tmp2); list_USERLIST.SetItemText(row, 2, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); - tmp2 = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", ""); + tmp2 = db_get_sa(hContact, MODULENAME, "KeyMainEmail", ""); if (!toUTF16(tmp2).empty()) tmp = mir_wstrdup(toUTF16(tmp2).c_str()); else - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyMainEmail", L""); + tmp = db_get_wsa(hContact, MODULENAME, "KeyMainEmail", L""); mir_free(tmp2); list_USERLIST.SetItemText(row, 3, (mir_wstrlen(tmp) > 1) ? tmp : L"not set"); mir_free(tmp); @@ -106,7 +106,7 @@ public: i++; } } - edit_LOG_FILE_EDIT.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szLogFilePath", L""))); + edit_LOG_FILE_EDIT.SetText(ptrW(db_get_wsa(0, MODULENAME, "szLogFilePath", L""))); check_DEBUG_LOG.SetState(g_plugin.getByte("bDebugLog", 0)); check_JABBER_API.Enable(); @@ -115,7 +115,7 @@ public: { string keyinfo = Translate("Default private key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_CURRENT_KEY.SetTextA(keyinfo.c_str()); @@ -172,10 +172,10 @@ public: hContact = metaGetMostOnline(meta); ismetacontact = true; } - tmp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", ""); + tmp = db_get_sa(hContact, MODULENAME, "KeyID", ""); for (auto &hcnttmp : Contacts()) { if (hcnttmp != hContact) { - char *tmp2 = UniGetContactSettingUtf(hcnttmp, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hcnttmp, MODULENAME, "KeyID", ""); if (!mir_strcmp(tmp, tmp2)) { mir_free(tmp2); keep = true; @@ -269,7 +269,7 @@ public: { wchar_t *tmp = GetFilePath(TranslateT("Export public key"), L"*", TranslateT(".asc pubkey file"), true); if (tmp) { - wstring str(ptrW(UniGetContactSettingUtf(user_data[item_num + 1], MODULENAME, "GPGPubKey", L""))); + wstring str(ptrW(db_get_wsa(user_data[item_num + 1], MODULENAME, "GPGPubKey", L""))); wstring::size_type s = 0; while ((s = str.find(L"\r", s)) != wstring::npos) str.erase(s, 1); @@ -284,7 +284,7 @@ public: void onClick_COPY_KEY(CCtrlButton*) { if (OpenClipboard(m_hwnd)) { - char *szKey = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + char *szKey = db_get_sa(0, MODULENAME, "GPGPubKey", ""); std::string str = szKey; mir_free(szKey); boost::algorithm::replace_all(str, "\n", "\r\n"); @@ -386,8 +386,8 @@ public: bool OnInitDialog() override { - edit_BIN_PATH.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); - edit_HOME_DIR.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"gpg"))); + edit_BIN_PATH.SetText(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + edit_HOME_DIR.SetText(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L"gpg"))); return true; } @@ -405,7 +405,7 @@ public: void onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(TranslateT("Choose gpg.exe"), "szGpgBinPath", L"*.exe", TranslateT("EXE Executables")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); bool gpg_exists = false; { @@ -413,7 +413,7 @@ public: gpg_exists = true; if (gpg_exists) { bool bad_version = false; - wchar_t *tmp_path = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + wchar_t *tmp_path = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); g_plugin.setWString("szGpgBinPath", tmp); string out; DWORD code; @@ -455,7 +455,7 @@ public: void onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(TranslateT("Set home directory")); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -481,10 +481,10 @@ public: { check_APPEND_TAGS.SetState(g_plugin.getByte("bAppendTags", 0)); check_STRIP_TAGS.SetState(g_plugin.getByte("bStripTags", 0)); - edit_IN_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szInOpenTag", L"<GPGdec>"))); - edit_IN_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szInCloseTag", L"</GPGdec>"))); - edit_OUT_OPEN_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"))); - edit_OUT_CLOSE_TAG.SetText(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"))); + edit_IN_OPEN_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szInOpenTag", L"<GPGdec>"))); + edit_IN_CLOSE_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szInCloseTag", L"</GPGdec>"))); + edit_OUT_OPEN_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szOutOpenTag", L"<GPGenc>"))); + edit_OUT_CLOSE_TAG.SetText(ptrW(db_get_wsa(0, MODULENAME, "szOutCloseTag", L"</GPGenc>"))); return true; } @@ -611,7 +611,7 @@ public: chk_ENABLE_ENCRYPTION.SetState(1); } if (hcnt) { - wchar_t *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = tmp; mir_free(tmp); tmp = nullptr; if (!str.empty()) { @@ -626,9 +626,9 @@ public: } } } - // char *tmp = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID_Prescense", ""); + // char *tmp = db_get_wsa(hcnt, MODULENAME, "KeyID_Prescense", ""); if (!globals.hcontact_data[hcnt].key_in_prescense.empty()) { - char *tmp2 = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); + char *tmp2 = db_get_sa(hcnt, MODULENAME, "KeyID", ""); if (!tmp2[0]) { string out; DWORD code; @@ -742,14 +742,14 @@ public: DWORD exitcode; { MCONTACT hcnt = db_mc_tryMeta(hContact); - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); mir_wstrncat(tmp2, L"temporary_exported.asc", _countof(tmp2) - mir_wstrlen(tmp2)); boost::filesystem::remove(tmp2); wfstream f(tmp2, std::ios::out); - ptmp = UniGetContactSettingUtf(hcnt, MODULENAME, "GPGPubKey", L""); + ptmp = db_get_wsa(hcnt, MODULENAME, "GPGPubKey", L""); wstring str = ptmp; mir_free(ptmp); wstring::size_type s = 0; @@ -947,7 +947,7 @@ public: } } if (!hContact) { - wchar_t *fp = UniGetContactSettingUtf(hContact, MODULENAME, "KeyID", L""); + wchar_t *fp = db_get_wsa(hContact, MODULENAME, "KeyID", L""); { string out; DWORD code; diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index e651779b50..e9bd0aab8d 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -114,7 +114,7 @@ void CDlgChangePasswdMsgBox::onClick_OK(CCtrlButton*) new_pass = toUTF8(edit_NEW_PASSWD1.GetText()); old_pass = toUTF8(edit_OLD_PASSWD.GetText()); bool old_pass_match = false; - wchar_t *pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + wchar_t *pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -124,7 +124,7 @@ void CDlgChangePasswdMsgBox::onClick_OK(CCtrlButton*) string dbsetting = "szKey_"; dbsetting += toUTF8(globals.key_id_global); dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (!mir_wstrcmp(pass, edit_OLD_PASSWD.GetText())) old_pass_match = true; mir_free(pass); @@ -230,7 +230,7 @@ bool CDlgFirstRun::OnInitDialog() combo_ACCOUNT.SelectString(TranslateT("Default")); string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -569,7 +569,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) if (!mir_strcmp(buf, Translate("Default"))) { string keyinfo = Translate("key ID"); keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(0, MODULENAME, "KeyID", ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -579,7 +579,7 @@ void CDlgFirstRun::onChange_ACCOUNT(CCtrlCombo*) keyinfo += ": "; std::string acc_str = buf; acc_str += "_KeyID"; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, acc_str.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, acc_str.c_str(), ""); keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); mir_free(keyid); lbl_KEY_ID.SetTextA(keyinfo.c_str()); @@ -730,7 +730,7 @@ void CDlgFirstRun::refresh_key_list() setting += pa->szModuleName; setting += ")"; setting += "_KeyID"; - wchar_t *str = UniGetContactSettingUtf(0, MODULENAME, setting.c_str(), L""); + wchar_t *str = db_get_wsa(0, MODULENAME, setting.c_str(), L""); if (key_id == str) { if (!accs.empty()) accs += L","; @@ -798,7 +798,7 @@ bool CDlgGpgBinOpts::OnInitDialog() { ptrW tmp; if (!gpg_exists) { - tmp = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L""); + tmp = db_get_wsa(0, MODULENAME, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L""); if (tmp[0]) if (!boost::filesystem::exists((wchar_t*)tmp)) MessageBox(nullptr, TranslateT("Wrong GPG binary location found in system.\nPlease choose another location"), TranslateT("Warning"), MB_OK); @@ -837,7 +837,7 @@ bool CDlgGpgBinOpts::OnInitDialog() } } { - ptrW tmp(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L"")); + ptrW tmp(db_get_wsa(0, MODULENAME, "szHomePath", L"")); if (!tmp[0]) { wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -864,7 +864,7 @@ bool CDlgGpgBinOpts::OnInitDialog() void CDlgGpgBinOpts::onClick_SET_BIN_PATH(CCtrlButton*) { GetFilePath(L"Choose gpg.exe", "szGpgBinPath", L"*.exe", L"EXE Executables"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szGpgBinPath", L"gpg.exe"))); edit_BIN_PATH.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -877,7 +877,7 @@ void CDlgGpgBinOpts::onClick_SET_BIN_PATH(CCtrlButton*) void CDlgGpgBinOpts::onClick_SET_HOME_DIR(CCtrlButton*) { GetFolderPath(L"Set home directory"); - CMStringW tmp(ptrW(UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""))); + CMStringW tmp(ptrW(db_get_wsa(0, MODULENAME, "szHomePath", L""))); edit_HOME_DIR.SetText(tmp); wchar_t mir_path[MAX_PATH]; PathToAbsoluteW(L"\\", mir_path); @@ -942,7 +942,7 @@ bool CDlgNewKey::OnInitDialog() { //new_key_hcnt_mutex.unlock(); SetWindowPos(m_hwnd, nullptr, globals.new_key_rect.left, globals.new_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); - wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); lbl_MESSAGE.SetText(tmp[0] ? TranslateT("There is existing key for contact, would you like to replace it with new key?") : TranslateT("New public key was received, do you want to import it?")); btn_IMPORT_AND_USE.Enable(g_plugin.getByte(hContact, "GPGEncryption", 0)); btn_IMPORT.SetText(tmp[0] ? TranslateT("Replace") : TranslateT("Accept")); @@ -1081,7 +1081,7 @@ void CDlgKeyGen::onClick_OK(CCtrlButton*) mir_free(tmp); } { //generating key file - wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); char *tmp2;// = mir_u2a(tmp); path = tmp; mir_free(tmp); @@ -1422,7 +1422,7 @@ CDlgKeyPasswordMsgBox::CDlgKeyPasswordMsgBox(MCONTACT _hContact) : bool CDlgKeyPasswordMsgBox::OnInitDialog() { - inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); + inkeyid = db_get_sa(hContact, MODULENAME, "InKeyID", ""); SetWindowPos(m_hwnd, nullptr, globals.key_password_rect.left, globals.key_password_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); @@ -1447,7 +1447,7 @@ void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*) wchar_t *tmp = mir_wstrdup(edit_KEY_PASSWORD.GetText()); if (tmp && tmp[0]) { if (chk_SAVE_PASSWORD.GetState()) { - inkeyid = UniGetContactSettingUtf(hContact, MODULENAME, "InKeyID", ""); + inkeyid = db_get_sa(hContact, MODULENAME, "InKeyID", ""); if (inkeyid && inkeyid[0] && !chk_DEFAULT_PASSWORD.GetState()) { string dbsetting = "szKey_"; dbsetting += inkeyid; diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 84096558b8..8d8d9c5b18 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -21,35 +21,6 @@ void ShowExportKeysDlg(); void ShowLoadPublicKeyDialog(bool = false); -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char *szSetting, wchar_t *szDef) -{ - DBVARIANT dbv = { DBVT_DELETED }; - wchar_t* szRes = nullptr; - if (db_get_ws(hContact, szModule, szSetting, &dbv)) - return mir_wstrdup(szDef); - else if (dbv.pszVal) - szRes = mir_wstrdup(dbv.pwszVal); - else - szRes = mir_wstrdup(szDef); - - db_free(&dbv); - return szRes; -} - -char* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char *szSetting, char *szDef) -{ - DBVARIANT dbv = { DBVT_DELETED }; - char* szRes = nullptr; - if (db_get_s(hContact, szModule, szSetting, &dbv)) - return mir_strdup(szDef); - else if (dbv.pszVal) - szRes = mir_strdup(dbv.pszVal); - else - szRes = mir_strdup(szDef); - db_free(&dbv); - return szRes; -} - void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t *szExtDesc) { wchar_t str[MAX_PATH + 2] = { 0 }, *tmp; @@ -64,7 +35,7 @@ void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t pfilter[mir_wstrlen(pfilter) + 1] = '\0'; pfilter[mir_wstrlen(pfilter) + 2] = '\0'; ofn.lpstrFilter = filter; - tmp = UniGetContactSettingUtf(0, MODULENAME, szSetting, L""); + tmp = db_get_wsa(0, MODULENAME, szSetting, L""); wcsncpy(str, tmp, _countof(str) - 1); mir_free(tmp); if (mir_wstrlen(str) < 2) @@ -156,10 +127,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) key_id_str += "_KeyID"; acc_str += "_GPGPubKey"; } - szMessage = UniGetContactSettingUtf(0, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); + szMessage = db_get_sa(0, MODULENAME, acc_str.empty() ? "GPGPubKey" : acc_str.c_str(), ""); if (!szMessage[0]) { mir_free(szMessage); - szMessage = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way + szMessage = db_get_sa(0, MODULENAME, "GPGPubKey", ""); //try to get default key as fallback in any way } } if (szMessage[0]) { @@ -167,10 +138,10 @@ INT_PTR SendKey(WPARAM w, LPARAM) g_plugin.setByte(hContact, "GPGEncryption", 0); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage); std::string msg = "Public key "; - char *keyid = UniGetContactSettingUtf(0, MODULENAME, key_id_str.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, key_id_str.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); } msg += keyid; mir_free(keyid); @@ -229,10 +200,10 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) setting += ")"; setting += "_KeyID"; } - char *keyid = UniGetContactSettingUtf(0, MODULENAME, setting.c_str(), ""); + char *keyid = db_get_sa(0, MODULENAME, setting.c_str(), ""); if (!keyid[0]) { mir_free(keyid); - keyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + keyid = db_get_sa(0, MODULENAME, "KeyID", ""); } wchar_t buf[128] = { 0 }; mir_snwprintf(buf, L"%s: %s", TranslateT("Send public key"), toUTF16(keyid).c_str()); @@ -241,7 +212,7 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM) } int flags; - wchar_t *tmp = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *tmp = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (!tmp[0]) { g_plugin.delSetting(hContact, "GPGEncryption"); flags = CMIF_GRAYED; @@ -314,17 +285,17 @@ int onProtoAck(WPARAM, LPARAM l) boost::filesystem::remove(file); { // password wchar_t *pass = nullptr; - char *keyid = UniGetContactSettingUtf(ack->hContact, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(ack->hContact, MODULENAME, "KeyID", ""); if (mir_strlen(keyid) > 0) { string dbsetting = "szKey_"; dbsetting += keyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (mir_wstrlen(pass) > 0 && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + keyid + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password"); } else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (mir_wstrlen(pass) > 0 && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password"); } @@ -424,7 +395,7 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) cmd.push_back(L"--batch"); cmd.push_back(L"--tes"); cmd.push_back(L"-r"); - char *keyid = UniGetContactSettingUtf(hcnt, MODULENAME, "KeyID", ""); + char *keyid = db_get_sa(hcnt, MODULENAME, "KeyID", ""); wchar_t *szKeyid = mir_a2u(keyid); wchar_t *name = wcsrchr(filename, '\\'); if (!name) @@ -494,7 +465,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) } } else { - wchar_t *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", L""); + wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L""); if (jid[0]) { for (auto p : globals.Accounts) { wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid); @@ -669,7 +640,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } if (globals.bPresenceSigning && nodename && wcsstr(nodename, L"status")) { - wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path_c = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c; wstring file = toUTF16(get_random(10)); mir_free(path_c); @@ -693,10 +664,10 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) char setting[64]; mir_snprintf(setting, sizeof(setting) - 1, "%s_KeyID", ji->GetModuleName()); - inkeyid = UniGetContactSettingUtf(0, MODULENAME, setting, ""); + inkeyid = db_get_sa(0, MODULENAME, setting, ""); if (!inkeyid[0]) { mir_free(inkeyid); - inkeyid = UniGetContactSettingUtf(0, MODULENAME, "KeyID", ""); + inkeyid = db_get_sa(0, MODULENAME, "KeyID", ""); } ptrW pass; @@ -704,14 +675,14 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; - pass = UniGetContactSettingUtf(0, MODULENAME, dbsetting.c_str(), L""); + pass = db_get_wsa(0, MODULENAME, dbsetting.c_str(), L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid + ", trying to encrypt message from self with password"); } if (inkeyid && inkeyid[0]) mir_free(inkeyid); else { - pass = UniGetContactSettingUtf(0, MODULENAME, "szKeyPassword", L""); + pass = db_get_wsa(0, MODULENAME, "szKeyPassword", L""); if (pass[0] && globals.bDebugLog) globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to encrypt message from self with password"); } @@ -730,7 +701,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) } cmd.push_back(L"--local-user"); - path_c = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); + path_c = db_get_wsa(0, MODULENAME, "KeyID", L""); cmd.push_back(path_c); cmd.push_back(L"--default-key"); cmd.push_back(path_c); @@ -832,7 +803,7 @@ static JABBER_HANDLER_FUNC PresenceHandler(IJabberInterface*, HXML node, void*) wstring file = toUTF16(get_random(10)), status_file = toUTF16(get_random(10)); sign += data; sign += L"\n-----END PGP SIGNATURE-----\n"; - wchar_t *path_c = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path_c = db_get_wsa(0, MODULENAME, "szHomePath", L""); wstring path_out = path_c, status_file_out = path_c; mir_free(path_c); path_out += L"\\tmp\\"; @@ -945,7 +916,7 @@ bool isContactSecured(MCONTACT hContact) return false; } if (!db_mc_isMeta(hContact)) { - wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (!key[0]) { mir_free(key); if (globals.bDebugLog) @@ -961,7 +932,7 @@ bool isContactSecured(MCONTACT hContact) bool isContactHaveKey(MCONTACT hContact) { - wchar_t *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", L""); + wchar_t *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", L""); if (mir_wstrlen(key) > 0) { mir_free(key); return true; @@ -972,8 +943,8 @@ bool isContactHaveKey(MCONTACT hContact) bool isGPGKeyExist() { - wchar_t *id = UniGetContactSettingUtf(0, MODULENAME, "KeyID", L""); - char *key = UniGetContactSettingUtf(0, MODULENAME, "GPGPubKey", ""); + wchar_t *id = db_get_wsa(0, MODULENAME, "KeyID", L""); + char *key = db_get_sa(0, MODULENAME, "GPGPubKey", ""); if (id[0] && key[0]) { mir_free(id); mir_free(key); @@ -987,7 +958,7 @@ bool isGPGValid() { wchar_t *tmp = nullptr; bool gpg_exists = false, is_valid = true; - tmp = UniGetContactSettingUtf(0, MODULENAME, "szGpgBinPath", L""); + tmp = db_get_wsa(0, MODULENAME, "szGpgBinPath", L""); boost::filesystem::path p(tmp); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) @@ -1046,7 +1017,7 @@ bool isGPGValid() { wstring path_ = _wgetenv(L"APPDATA"); path_ += L"\\GnuPG"; - tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); + tmp = db_get_wsa(0, MODULENAME, "szHomePath", (wchar_t*)path_.c_str()); } if(tmp) mir_free(tmp); */ @@ -1181,7 +1152,7 @@ void send_encrypted_msgs_thread(void *param) { MCONTACT hContact = (MCONTACT)(DWORD_PTR)param; while (true) { - //char *key = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); + //char *key = db_get_wsa(hContact, MODULENAME, "GPGPubKey", ""); while (!isContactSecured(hContact)) Sleep(1000); @@ -1246,7 +1217,7 @@ void ExportGpGKeysFunc(int type) return; //TODO: handle error if (!type || type == 2) { for (auto &hContact : Contacts()) { - char *k = UniGetContactSettingUtf(hContact, MODULENAME, "GPGPubKey", ""); + char *k = db_get_sa(hContact, MODULENAME, "GPGPubKey", ""); std::string key; if (!k[0]) { mir_free(k); @@ -1595,7 +1566,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = ptmp; mir_free(ptmp); wstring rand = toUTF16(get_random(10)); @@ -1700,7 +1671,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string output; DWORD exitcode; { - ptmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + ptmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); wcsncpy(tmp2, ptmp, MAX_PATH - 1); mir_free(ptmp); mir_wstrncat(tmp2, L"\\", _countof(tmp2) - mir_wstrlen(tmp2)); @@ -1813,7 +1784,7 @@ void clean_temp_dir() wstring path = toUTF16(mir_path); SetCurrentDirectoryA(mir_path); delete[] mir_path; - wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path += tmp; mir_free(tmp); path += L"\\tmp"; @@ -1884,7 +1855,7 @@ bool gpg_validate_paths(wchar_t *gpg_bin_path, wchar_t *gpg_home_path) return false; } { - wchar_t *path = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + wchar_t *path = db_get_wsa(0, MODULENAME, "szHomePath", L""); DWORD dwFileAttr = GetFileAttributes(path); if (dwFileAttr != INVALID_FILE_ATTRIBUTES) { dwFileAttr &= ~FILE_ATTRIBUTE_READONLY; @@ -1913,7 +1884,7 @@ bool gpg_use_new_random_key(char *account_name, wchar_t *gpg_bin_path, wchar_t * if (gpg_home_dir) tmp = gpg_home_dir; else - tmp = UniGetContactSettingUtf(0, MODULENAME, "szHomePath", L""); + tmp = db_get_wsa(0, MODULENAME, "szHomePath", L""); path = tmp; if (!gpg_home_dir) mir_free(tmp); diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h index ffcf265b44..352468789c 100755 --- a/plugins/New_GPG/src/utilities.h +++ b/plugins/New_GPG/src/utilities.h @@ -17,8 +17,6 @@ #ifndef UTILITIES_H #define UTILITIES_H -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, wchar_t* szDef); -char* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, char* szDef); void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t *szExtDesc); wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, bool save_file = false); void GetFolderPath(wchar_t *WindowTittle); diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h index b078a6a1f8..fbcfc88af7 100644 --- a/plugins/Popup/src/common.h +++ b/plugins/Popup/src/common.h @@ -51,12 +51,6 @@ inline int Byte2Percentile(int vByte) { return (vByte * 100) / 255; } inline int Percentile2Byte(int vPerc) { return (vPerc * 255) / 100; }
//===== Strings & MirandaDB ==================
-inline char *db_get_s(MCONTACT hContact, const char *ModuleName, const char *SettingName, const char *Default)
-{
- char *result = db_get_sa(hContact, ModuleName, SettingName);
- return result ? result : mir_strdup(Default);
-}
-
inline INT_PTR DBGetContactSettingStringX(MCONTACT hContact, const char *ModuleName, const char *SettingName, const char *Default, const int retType)
{
INT_PTR ret = NULL;
diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 8dbee80a98..48dc3c4f5c 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -156,12 +156,12 @@ void LoadNotificationSettings(POPUPTREEDATA *ptd, char* szModul) db_get_b(0, szModul, setting, 0);
mir_snprintf(setting, "{%s/%s}leftAction", ptd->notification.lpzGroup, ptd->notification.lpzName);
- char *szTmp = db_get_s(0, szModul, setting, ptd->notification.lpzLAction);
+ char *szTmp = db_get_sa(0, szModul, setting, ptd->notification.lpzLAction);
mir_strncpy(ptd->leftAction, szTmp, sizeof(ptd->leftAction));
mir_free(szTmp); szTmp = nullptr;
mir_snprintf(setting, "{%s/%s}rightAction", ptd->notification.lpzGroup, ptd->notification.lpzName);
- szTmp = db_get_s(0, szModul, setting, ptd->notification.lpzRAction);
+ szTmp = db_get_sa(0, szModul, setting, ptd->notification.lpzRAction);
mir_strncpy(ptd->rightAction, szTmp, sizeof(ptd->rightAction));
mir_free(szTmp); szTmp = nullptr;
}
diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index 4b38d22a18..0d9bd89dec 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -495,12 +495,12 @@ void LoadClassSettings(POPUPTREEDATA *ptd, char* szModul) ptd->pupClass.iSeconds ? ptd->pupClass.iSeconds : PopupOptions.Seconds);
mir_snprintf(setting, "%s/leftAction", ptd->pupClass.pszName);
- char *szTmp = db_get_s(0, szModul, setting, POPUP_ACTION_NOTHING); // standart ??
+ char *szTmp = db_get_sa(0, szModul, setting, POPUP_ACTION_NOTHING); // standart ??
mir_strncpy(ptd->leftAction, szTmp, _countof(ptd->leftAction));
mir_free(szTmp);
mir_snprintf(setting, "%s/rightAction", ptd->pupClass.pszName);
- szTmp = db_get_s(0, szModul, setting, POPUP_ACTION_DISMISS); // standart ??
+ szTmp = db_get_sa(0, szModul, setting, POPUP_ACTION_DISMISS); // standart ??
mir_strncpy(ptd->rightAction, szTmp, _countof(ptd->rightAction));
mir_free(szTmp);
}
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index f4ad26a11c..98ce15c35f 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -25,7 +25,9 @@ mir_cs localQueueMutex; LPSTR myDBGetStringDecode(MCONTACT hContact, const char *szModule, const char *szSetting)
{
char *val = db_get_sa(hContact, szModule, szSetting);
- if (!val) return nullptr;
+ if (!val)
+ return nullptr;
+
size_t len = mir_strlen(val) + 64;
char *buf = (LPSTR)mir_alloc(len);
strncpy(buf, val, len); mir_free(val);
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index 41e30468cf..c88c2d96be 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -307,7 +307,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) IcoLib_ReleaseIcon(hIcon);
ptrA szMsg(db_get_sa(hContact, "CList", "StatusMsg"));
- if (szMsg != NULL) {
+ if (szMsg != nullptr) {
mir_snwprintf(str, TranslateT("Copy %s message"), Clist_GetStatusModeDescription(iStatus, 0));
Menu_ModifyItem(hCopyMsgMenuItem, str);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 72a36008a4..aac8d8d7bf 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -346,7 +346,7 @@ static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto) else
mir_snprintf(szSetting, "Msg");
- format = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
+ format = db_get_wsa(0, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
}
else if (flags & STATUS_LAST_MSG) {
if (szProto)
@@ -367,7 +367,7 @@ static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto) else
mir_snprintf(szSetting, "Default");
- format = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
+ format = db_get_wsa(0, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
if (format == nullptr)
format = mir_wstrdup(L"");
}
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index b47581c636..8a50c8f9d7 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -746,7 +746,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) else mir_snprintf(setting, "Default"); - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting)); + wchar_t *tszStatusMsg = db_get_wsa(0, "SRAway", StatusModeToDbSetting(iStatus, setting)); if (tszStatusMsg != nullptr) { SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg); fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)tszStatusMsg); @@ -761,7 +761,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) else mir_snprintf(setting, "Msg"); - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting)); + wchar_t *tszStatusMsg = db_get_wsa(0, "SRAway", StatusModeToDbSetting(iStatus, setting)); if (tszStatusMsg != nullptr) { SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg); fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)tszStatusMsg); diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index e208c19ca8..e5cdae1fde 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -133,8 +133,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l val = g_plugin.getByte((char *)StatusModeToDbSetting(i, "Flags"), STATUS_DEFAULT);
data->status_msg[0].flags[i - ID_STATUS_ONLINE] = val;
- ptrW text(db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, "Default")));
- mir_wstrncpy(data->status_msg[0].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024);
+ ptrW text(db_get_wsa(0, "SRAway", StatusModeToDbSetting(i, "Default"), GetDefaultMessage(i)));
+ mir_wstrncpy(data->status_msg[0].msg[i - ID_STATUS_ONLINE], text, 1024);
for (j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
@@ -145,8 +145,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l val = g_plugin.getByte((char *)StatusModeToDbSetting(i, setting), STATUS_DEFAULT);
data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE] = val;
mir_snprintf(setting, "%sDefault", pa->szModuleName);
- text = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, setting));
- mir_wstrncpy(data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024);
+ text = db_get_wsa(0, "SRAway", StatusModeToDbSetting(i, setting), GetDefaultMessage(i));
+ mir_wstrncpy(data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE], text, 1024);
}
}
}
@@ -446,19 +446,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG) {
char setting[80];
-
if (i)
mir_snprintf(setting, "%sMsg", accounts->pa[k]->szModuleName);
else
mir_snprintf(setting, "Msg");
-
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg) {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
- mir_free(tszStatusMsg);
- }
- else
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, ptrW(db_get_wsa(0, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting), L"")));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -582,19 +574,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG) {
char setting[80];
-
if (i)
mir_snprintf(setting, "%sMsg", accounts->pa[i - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
-
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr) {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
- mir_free(tszStatusMsg);
- }
- else
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, ptrW(db_get_wsa(0, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting), L"")));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -661,19 +645,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
else if (data->status_msg[j].flags[i] & STATUS_LAST_STATUS_MSG) {
char setting[80];
-
if (j)
mir_snprintf(setting, "%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
-
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr) {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
- mir_free(tszStatusMsg);
- }
- else
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, db_get_wsa(0, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting), L""));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -764,19 +740,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
else if (LOWORD(wParam) == IDC_ROPTMSG5) {
char setting[80];
-
if (j)
mir_snprintf(setting, "%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
-
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr) {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
- mir_free(tszStatusMsg);
- }
- else
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, ptrW(db_get_wsa(0, "SRAway", StatusModeToDbSetting(i + ID_STATUS_ONLINE, setting), L"")));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 3b973cc1b2..e7d7be142c 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -218,13 +218,7 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM lf->lfCharSet = SYMBOL_CHARSET;
wcsncpy_s(lf->lfFaceName, L"Webdings", _TRUNCATE);
}
- else {
- ptrW tszDefFace(db_get_wsa(0, szMod, str));
- if (tszDefFace == nullptr)
- wcsncpy_s(lf->lfFaceName, fol[i].szDefFace, _TRUNCATE);
- else
- wcsncpy_s(lf->lfFaceName, tszDefFace, _TRUNCATE);
- }
+ else wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, szMod, str, fol[i].szDefFace)), _TRUNCATE);
}
}
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 733f760aa3..a3c633d5eb 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2119,34 +2119,21 @@ void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc) // retrieve the container name for the given contact handle.
// if none is assigned, return the name of the default container
-int TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen)
+void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen)
{
// single window mode using cloned (temporary) containers
if (M.GetByte("singlewinmode", 0)) {
wcsncpy_s(szName, iNameLen, L"Message Session", _TRUNCATE);
- return 0;
+ return;
}
// use clist group names for containers...
if (M.GetByte("useclistgroups", 0)) {
- ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
- if (tszGroup == nullptr) {
- wcsncpy_s(szName, iNameLen, L"default", _TRUNCATE);
- return 0;
- }
-
- wcsncpy_s(szName, iNameLen, tszGroup, _TRUNCATE);
- return 1;
- }
-
- ptrW tszContainerName(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY));
- if (tszContainerName == nullptr) {
- wcsncpy_s(szName, iNameLen, L"default", _TRUNCATE);
- return 0;
+ wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, "CList", "Group", L"default")), _TRUNCATE);
+ return;
}
- wcsncpy_s(szName, iNameLen, tszContainerName, _TRUNCATE);
- return 1;
+ wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, L"default")), _TRUNCATE);
}
void TSAPI DeleteContainer(int iIndex)
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index a4877a57b9..9d3f58b3e9 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -90,7 +90,7 @@ void TSAPI ReflashContainer(TContainerData *pContainer); void TSAPI CloseAllContainers();
void TSAPI DeleteContainer(int iIndex);
void TSAPI RenameContainer(int iIndex, const wchar_t *newName);
-int TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen);
+void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen);
HMENU TSAPI BuildContainerMenu();
void TSAPI ApplyContainerSetting(TContainerData *pContainer, DWORD flags, UINT mode, bool fForceResize);
void TSAPI BroadCastContainer(const TContainerData *pContainer, UINT message, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index db2e28460c..79fa139f47 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -328,13 +328,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa char szIconProto[64]; if (mir_strcmp(szProto, META_PROTO) != 0) strncpy_s(szIconProto, szProto, _TRUNCATE); - else { - ptrA szXProto(db_get_sa(pwd->hContact, szProto, "XStatusProto")); - if (szXProto != NULL) - strncpy_s(szIconProto, szXProto, _TRUNCATE); - else - szIconProto[0] = 0; - } + else + strncpy_s(szIconProto, ptrA(db_get_sa(pwd->hContact, szProto, "XStatusProto", "")), _TRUNCATE); pwd->extraIcons[i].hIcon = (HICON)CallProtoService(szIconProto, PS_GETCUSTOMSTATUSICON, (WPARAM)iXstatus, LR_SHARED); pwd->extraIcons[i].bDestroy = false; diff --git a/plugins/TranslitSwitcher/src/Layoutproc.cpp b/plugins/TranslitSwitcher/src/Layoutproc.cpp index 915301ad6e..f32d639fc6 100644 --- a/plugins/TranslitSwitcher/src/Layoutproc.cpp +++ b/plugins/TranslitSwitcher/src/Layoutproc.cpp @@ -703,7 +703,7 @@ int OnButtonPressed(WPARAM, LPARAM lParam) }
}
- ptrW tszSymbol(db_get_wsa(NULL, "TranslitSwitcher", "ResendSymbol"));
+ ptrW tszSymbol(db_get_wsa(0, "TranslitSwitcher", "ResendSymbol"));
if (!tszSymbol && sel) {
SetWindowText(hEdit, sel);
SendMessage(hEdit, EM_SETSEL, 0, (LPARAM)slen);
diff --git a/plugins/UserGuide/src/main.cpp b/plugins/UserGuide/src/main.cpp index 1be4b8763f..2ea909a8e1 100644 --- a/plugins/UserGuide/src/main.cpp +++ b/plugins/UserGuide/src/main.cpp @@ -29,7 +29,7 @@ static INT_PTR ShowGuideFile(WPARAM, LPARAM) LPTSTR pszDirName = (LPTSTR)mir_alloc(250 * sizeof(wchar_t));
LPTSTR pszFileName = (LPTSTR)mir_alloc(250 * sizeof(wchar_t));
- wchar_t *ptszHelpFile = db_get_wsa(NULL, "UserGuide", "PathToHelpFile");
+ wchar_t *ptszHelpFile = db_get_wsa(0, "UserGuide", "PathToHelpFile");
if (ptszHelpFile == nullptr) {
mir_wstrcpy(pszDirName, L"%miranda_path%\\Plugins");
diff --git a/plugins/Watrack_MPD/src/init.cpp b/plugins/Watrack_MPD/src/init.cpp index 45f263e94d..381769f8ef 100755 --- a/plugins/Watrack_MPD/src/init.cpp +++ b/plugins/Watrack_MPD/src/init.cpp @@ -54,8 +54,8 @@ static int OnModulesLoaded(WPARAM, LPARAM) ghNetlibUser = Netlib_RegisterUser(&nlu);
gbPort = g_plugin.getWord("Port", 6600);
- gbHost = UniGetContactSettingUtf(0, MODULENAME, "Server", L"127.0.0.1");
- gbPassword = UniGetContactSettingUtf(0, MODULENAME, "Password", L"");
+ gbHost = db_get_wsa(0, MODULENAME, "Server", L"127.0.0.1");
+ gbPassword = db_get_wsa(0, MODULENAME, "Password", L"");
if (ServiceExists(MS_WAT_PLAYER))
bWatrackService = TRUE;
diff --git a/plugins/Watrack_MPD/src/options.cpp b/plugins/Watrack_MPD/src/options.cpp index f861e8ed90..a83003f9e0 100755 --- a/plugins/Watrack_MPD/src/options.cpp +++ b/plugins/Watrack_MPD/src/options.cpp @@ -26,12 +26,8 @@ public: bool OnInitDialog() override { edit_PORT.SetInt(g_plugin.getWord("Port", 6600)); - wchar_t *tmp = UniGetContactSettingUtf(0, MODULENAME, "Server", L"127.0.0.1"); - edit_SERVER.SetText(tmp); - mir_free(tmp); - tmp = UniGetContactSettingUtf(0, MODULENAME, "Password", L""); - edit_PASSWORD.SetText(tmp); - mir_free(tmp); + edit_SERVER.SetText(ptrW(db_get_wsa(0, MODULENAME, "Server", L"127.0.0.1"))); + edit_PASSWORD.SetText(ptrW(db_get_wsa(0, MODULENAME, "Password", L""))); return true; } diff --git a/plugins/Watrack_MPD/src/stdafx.h b/plugins/Watrack_MPD/src/stdafx.h index ac03eee33a..fddc052a34 100755 --- a/plugins/Watrack_MPD/src/stdafx.h +++ b/plugins/Watrack_MPD/src/stdafx.h @@ -29,7 +29,6 @@ #include <m_music.h>
#include "resource.h"
-#include "utilities.h"
#include "version.h"
#define MODULENAME "Watrack_MPD"
diff --git a/plugins/Watrack_MPD/src/utilities.cpp b/plugins/Watrack_MPD/src/utilities.cpp deleted file mode 100755 index b8c209150f..0000000000 --- a/plugins/Watrack_MPD/src/utilities.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright © 2008 sss, chaos.persei -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "stdafx.h" - -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, wchar_t* szDef) -{ - wchar_t *szRes = db_get_wsa(hContact, szModule, szSetting); - return szRes ? szRes : mir_wstrdup(szDef); -} diff --git a/plugins/Watrack_MPD/src/utilities.h b/plugins/Watrack_MPD/src/utilities.h deleted file mode 100755 index 3f594c7084..0000000000 --- a/plugins/Watrack_MPD/src/utilities.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef UTILITIES_H -#define UTILITIES_H - -wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, wchar_t* szDef); - -#endif diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 5455779b36..be0e1ef411 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -148,6 +148,7 @@ static int ProcessChatEvent(WPARAM, LPARAM lParam) ptrW nick(db_get_wsa(hContact, gce->pszModule, "MyNick"));
if (nick == NULL || gce->ptszText == nullptr)
return 0;
+
if (wcsstr(gce->ptszText, nick)) {
isIgnoreSound = g_plugin.getByte(hContact, SETTINGSIGNOREKEY, 0);
DBVARIANT dbv;
diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp index 50be132450..05b1385fb5 100644 --- a/protocols/MinecraftDynmap/src/chat.cpp +++ b/protocols/MinecraftDynmap/src/chat.cpp @@ -161,11 +161,7 @@ void MinecraftDynmapProto::SetChatStatus(int status) if (status == ID_STATUS_ONLINE) { // Load actual name from database - ptrA nick(db_get_sa(0, m_szModuleName, MINECRAFTDYNMAP_KEY_NAME)); - if (!nick) { - nick = mir_strdup(Translate("You")); - db_set_s(0, m_szModuleName, MINECRAFTDYNMAP_KEY_NAME, nick); - } + ptrA nick(db_get_sa(0, m_szModuleName, MINECRAFTDYNMAP_KEY_NAME, Translate("You"))); m_nick = nick; // Add self contact diff --git a/protocols/MinecraftDynmap/src/dialogs.cpp b/protocols/MinecraftDynmap/src/dialogs.cpp index f682fd5c7b..6c93788c81 100644 --- a/protocols/MinecraftDynmap/src/dialogs.cpp +++ b/protocols/MinecraftDynmap/src/dialogs.cpp @@ -48,7 +48,7 @@ HANDLE GetIconHandle(const char* name) { static void LoadDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) { - ptrW tstr(db_get_wsa(NULL, ppro->m_szModuleName, szSetting)); + ptrW tstr(db_get_wsa(0, ppro->m_szModuleName, szSetting)); if (tstr) SetDlgItemText(hwnd, idCtrl, tstr); } diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index 5919ab285c..6ca250bc57 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -283,7 +283,7 @@ void OmegleProto::SetChatStatus(int status) {
if (status == ID_STATUS_ONLINE) {
// Load actual name from database
- facy.nick_ = db_get_wsa(NULL, m_szModuleName, OMEGLE_KEY_NAME);
+ facy.nick_ = db_get_wsa(0, m_szModuleName, OMEGLE_KEY_NAME);
if (facy.nick_ == NULL) {
facy.nick_ = mir_wstrdup(TranslateT("You"));
db_set_ws(0, m_szModuleName, OMEGLE_KEY_NAME, facy.nick_);
diff --git a/protocols/Omegle/src/dialogs.cpp b/protocols/Omegle/src/dialogs.cpp index 4a4b069813..b51dca114e 100644 --- a/protocols/Omegle/src/dialogs.cpp +++ b/protocols/Omegle/src/dialogs.cpp @@ -38,7 +38,7 @@ static BOOL StoreDBCheckState(OmegleProto* ppro, HWND hwnd, int idCtrl, const ch static void LoadDBText(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* szSetting)
{
- ptrW tstr(db_get_wsa(NULL, ppro->m_szModuleName, szSetting));
+ ptrW tstr(db_get_wsa(0, ppro->m_szModuleName, szSetting));
if (tstr)
SetDlgItemText(hwnd, idCtrl, tstr);
}
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index dc64c54e33..c64bba1620 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -323,7 +323,7 @@ void CSteamProto::GetAwayMsgThread(void *arg) Sleep(50); MCONTACT hContact = (UINT_PTR)arg; - CMStringW message(db_get_wsa(hContact, "CList", "StatusMsg")); + CMStringW message(db_get_wsm(hContact, "CList", "StatusMsg")); // if contact has no status message, get xstatus message if (message.IsEmpty()) { diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 2d5c570b45..aea111580d 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -465,11 +465,11 @@ void CToxOptionsNodeList::ReloadNodeList() int nodeCount = db_get_w(0, module, TOX_SETTINGS_NODE_COUNT, 0);
for (int i = 0; i < nodeCount; i++) {
mir_snprintf(setting, TOX_SETTINGS_NODE_IPV4, i);
- ptrW value(db_get_wsa(NULL, module, setting));
+ ptrW value(db_get_wsa(0, module, setting));
iItem = m_nodes.AddItem(value, -1, NULL, 1);
mir_snprintf(setting, TOX_SETTINGS_NODE_IPV6, i);
- value = db_get_wsa(NULL, module, setting);
+ value = db_get_wsa(0, module, setting);
m_nodes.SetItem(iItem, 1, value);
mir_snprintf(setting, TOX_SETTINGS_NODE_PORT, i);
@@ -481,7 +481,7 @@ void CToxOptionsNodeList::ReloadNodeList() }
mir_snprintf(setting, TOX_SETTINGS_NODE_PKEY, i);
- value = db_get_wsa(NULL, module, setting);
+ value = db_get_wsa(0, module, setting);
m_nodes.SetItem(iItem, 3, value);
m_nodes.SetItem(iItem, 4, L"", 0);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index eda0ad160b..1785b36830 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -559,8 +559,7 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * int iRet = jnResponse.as_int();
setByte(param->hContact, "Auth", 0);
if (iRet == 2) {
- CMStringW msg,
- wszNick(ptrW(db_get_wsa(param->hContact, m_szModuleName, "Nick")));
+ CMStringW msg, wszNick(db_get_wsm(param->hContact, m_szModuleName, "Nick"));
if (wszNick.IsEmpty())
wszNick = TranslateT("(Unknown contact)");
msg.AppendFormat(TranslateT("User %s added as friend"), wszNick.c_str());
diff --git a/protocols/VKontakte/src/vk_status.cpp b/protocols/VKontakte/src/vk_status.cpp index 29efd4b9e3..89011c4e89 100644 --- a/protocols/VKontakte/src/vk_status.cpp +++ b/protocols/VKontakte/src/vk_status.cpp @@ -76,7 +76,7 @@ void CVkProto::SetServerStatus(int iNewStatus) return;
int iOldStatus = m_iStatus;
- CMStringW oldStatusMsg(ptrW(db_get_wsa(0, m_szModuleName, "OldStatusMsg")));
+ CMStringW oldStatusMsg(db_get_wsm(0, m_szModuleName, "OldStatusMsg"));
ptrW pwszListeningToMsg(db_get_wsa(0, m_szModuleName, "ListeningTo"));
if (iNewStatus == ID_STATUS_OFFLINE) {
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 53c5bd2ff8..f2534e82f1 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -824,8 +824,8 @@ INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM flag) return 1;
ptrW pwszNick(db_get_wsa(hContact, m_szModuleName, "Nick"));
- CMStringW pwszMsg;
if (flag == 0) {
+ CMStringW pwszMsg;
pwszMsg.AppendFormat(TranslateT("Are you sure to delete %s from your friend list?"), IsEmpty(pwszNick) ? TranslateT("(Unknown contact)") : pwszNick);
if (IDNO == MessageBoxW(nullptr, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
@@ -844,7 +844,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST *reply, AsyncHttpRequest JSONNode jnRoot;
const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (jnResponse) {
- CMStringW wszNick(ptrW(db_get_wsa(param->hContact, m_szModuleName, "Nick")));
+ CMStringW wszNick(db_get_wsm(param->hContact, m_szModuleName, "Nick"));
if (wszNick.IsEmpty())
wszNick = TranslateT("(Unknown contact)");
CMStringW msgformat, msg;
@@ -941,7 +941,7 @@ INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM) if (!IsOnline() || userID == VK_INVALID_USER || userID == VK_FEED_USER)
return 1;
- CMStringW wszNick(ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"))),
+ CMStringW wszNick(db_get_wsm(hContact, m_szModuleName, "Nick")),
pwszMsg(FORMAT, TranslateT("Are you sure to report abuse on %s?"), wszNick.IsEmpty() ? TranslateT("(Unknown contact)") : wszNick);
if (IDNO == MessageBoxW(nullptr, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
@@ -957,7 +957,7 @@ INT_PTR __cdecl CVkProto::SvcOpenBroadcast(WPARAM hContact, LPARAM) {
debugLogA("CVkProto::SvcOpenBroadcast");
- CMStringW wszAudio(ptrW(db_get_wsa(hContact, m_szModuleName, "AudioUrl")));
+ CMStringW wszAudio(db_get_wsm(hContact, m_szModuleName, "AudioUrl"));
if (!wszAudio.IsEmpty())
Utils_OpenUrlW(wszAudio);
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index 30145b13b3..450a1629c7 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -121,11 +121,7 @@ void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour) lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
mir_snprintf(str, "Font%d", i);
- ptrW tszFace(db_get_wsa(0, CHATFONT_MODULE, str));
- if (tszFace == nullptr)
- mir_wstrcpy(lf->lfFaceName, FO.szDefFace);
- else
- wcsncpy_s(lf->lfFaceName, tszFace, _TRUNCATE);
+ wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, CHATFONT_MODULE, str, FO.szDefFace)), _TRUNCATE);
}
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index deba485f86..93895418a5 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -687,8 +687,7 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) MIR_APP_DLL(wchar_t*) Chat_GetGroup()
{
- ptrW pszGroup(db_get_wsa(0, CHAT_MODULE, "AddToGroup"));
- return (pszGroup) ? pszGroup.detach() : mir_wstrdup(TranslateT("Chat rooms"));
+ return db_get_wsa(0, CHAT_MODULE, "AddToGroup", TranslateT("Chat rooms"));
}
MIR_APP_DLL(void) Chat_SetGroup(const wchar_t *pwszGroupName)
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 37fb40cd66..fa5dab7d14 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -62,11 +62,8 @@ ClcCacheEntry* fnCreateCacheItem(MCONTACT hContact) void fnCheckCacheItem(ClcCacheEntry *p)
{
- if (p->tszGroup == nullptr) {
- p->tszGroup = db_get_wsa(p->hContact, "CList", "Group");
- if (p->tszGroup == nullptr)
- p->tszGroup = mir_wstrdup(L"");
- }
+ if (p->tszGroup == nullptr)
+ p->tszGroup = db_get_wsa(p->hContact, "CList", "Group", L"");
if (p->szProto == nullptr)
p->szProto = GetContactProto(p->hContact);
diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index a574e704c4..4799285e90 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -41,10 +41,7 @@ MIR_APP_DLL(void) Menu_SetVisible(TMO_IntMenuItem *pimi, bool bVisible) mir_snprintf(szModule, "%s_Items", pimi->parent->pszName); bin2hex(&pimi->mi.uid, sizeof(pimi->mi.uid), menuItemName); - ptrW wszValue(db_get_wsa(0, szModule, menuItemName)); - if (wszValue == nullptr) - wszValue = mir_wstrdup(L"1;;;"); - + ptrW wszValue(db_get_wsa(0, szModule, menuItemName, L"1;;;")); wszValue[0] = bVisible ? '1' : '0'; db_set_ws(0, szModule, menuItemName, wszValue); diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 87eb0ed80c..eef66081df 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -163,22 +163,26 @@ MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, const char *szModule, const ch return currDb->GetContactSettingStr(hContact, szModule, szSetting, dbv);
}
-MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, const char *szModule, const char *szSetting)
+MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szValue)
{
- if (currDb == nullptr)
- return nullptr;
+ if (currDb) {
+ DBVARIANT dbv = { DBVT_ASCIIZ };
+ if (!currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv))
+ return dbv.pszVal;
+ }
- DBVARIANT dbv = { DBVT_ASCIIZ };
- return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? nullptr : dbv.pszVal;
+ return (szValue == nullptr) ? nullptr : mir_strdup(szValue);
}
-MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const char *szSetting)
+MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szValue)
{
- if (currDb == nullptr)
- return nullptr;
+ if (currDb) {
+ DBVARIANT dbv = { DBVT_WCHAR };
+ if (!currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv))
+ return dbv.pwszVal;
+ }
- DBVARIANT dbv = { DBVT_WCHAR };
- return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? nullptr : dbv.pwszVal;
+ return (szValue == nullptr) ? nullptr : mir_wstrdup(szValue);
}
MIR_CORE_DLL(CMStringA) db_get_sm(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting)
@@ -459,7 +463,7 @@ MIR_CORE_DLL(void) db_setCurrent(MDatabaseCommon *_db) return;
// try to get the langpack's name from a profile
- ptrW langpack(db_get_wsa(NULL, "Langpack", "Current"));
+ ptrW langpack(db_get_wsa(0, "Langpack", "Current"));
if (langpack && langpack[0] != '\0')
LoadLangPack(langpack);
else
diff --git a/src/mir_core/src/openurl.cpp b/src/mir_core/src/openurl.cpp index 2fcd374dce..94fdabd3fd 100644 --- a/src/mir_core/src/openurl.cpp +++ b/src/mir_core/src/openurl.cpp @@ -54,7 +54,7 @@ static void __cdecl OpenURLThread(TOpenUrlInfo *hUrlInfo) }
// check user defined browser for opening urls
- ptrW tszBrowser(db_get_wsa(NULL, "Miranda", "OpenUrlBrowser"));
+ ptrW tszBrowser(db_get_wsa(0, "Miranda", "OpenUrlBrowser"));
if (tszBrowser)
ShellExecute(nullptr, L"open", tszBrowser, tszUrl, nullptr, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
else
|