From b95dc7e61ba02fdd12b1c11142db6c7aebfffd53 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 9 Mar 2023 13:22:35 +0300 Subject: db_get_usm / getMStringU - helpers to read UTF8 strings as CMStringA --- include/m_database.h | 1 + include/m_protoint.h | 5 +++++ libs/win32/mir_app.lib | Bin 236988 -> 237994 bytes libs/win32/mir_core.lib | Bin 490348 -> 490770 bytes libs/win64/mir_app.lib | Bin 233918 -> 234944 bytes libs/win64/mir_core.lib | Bin 495524 -> 495950 bytes src/mir_app/src/mir_app.def | 2 ++ src/mir_app/src/mir_app64.def | 2 ++ src/mir_core/src/db.cpp | 12 ++++++++++++ src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + 11 files changed, 24 insertions(+) diff --git a/include/m_database.h b/include/m_database.h index 1831946c67..c8921e59f0 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -388,6 +388,7 @@ EXTERN_C MIR_CORE_DLL(char*) db_get_utfa(MCONTACT hContact, const char *szMod 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, const char *szModule, const char *szSetting, const char *szValue = nullptr); +MIR_CORE_DLL(CMStringA) db_get_usm(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szValue = nullptr); MIR_CORE_DLL(CMStringW) db_get_wsm(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szValue = nullptr); EXTERN_C MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest); diff --git a/include/m_protoint.h b/include/m_protoint.h index f4dbf2473a..55ff3a5949 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -162,6 +162,11 @@ public: __forceinline CMStringA getMStringA(MCONTACT hContact, const char *name, const char *szValue = nullptr) { return db_get_sm(hContact, m_szModuleName, name, szValue); } + __forceinline CMStringA getMStringU(const char *name, const char *szValue = nullptr) { + return db_get_usm(0, m_szModuleName, name, szValue); } + __forceinline CMStringA getMStringU(MCONTACT hContact, const char *name, const char *szValue = nullptr) { + return db_get_usm(hContact, m_szModuleName, name, szValue); } + __forceinline CMStringW getMStringW(const char *name, const wchar_t *szValue = nullptr) { return db_get_wsm(0, m_szModuleName, name, szValue); } __forceinline CMStringW getMStringW(MCONTACT hContact, const char *name, const wchar_t *szValue = nullptr) { diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 183d7f15e4..1f82b6f4bc 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index 7f562cba3f..6df0ce7e9e 100644 Binary files a/libs/win32/mir_core.lib and b/libs/win32/mir_core.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index fdf7f9696f..a239c67c8e 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib index df12506f0d..2b27d2acd6 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index fa21d3f9bb..765a1f46b0 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -820,3 +820,5 @@ Srmm_CreateHotkey @886 NONAME ?UpdateChatLog@CSrmmBaseDialog@@IAEXXZ @935 NONAME ?OnMarkRead@PROTO_INTERFACE@@UAEXII@Z @936 NONAME ?OnCreateAccMgrUI@PROTO_INTERFACE@@UAEPAUHWND__@@PAU2@@Z @937 NONAME +?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD0@Z @938 NONAME +?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PBD0@Z @939 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 4aeacf9c19..1431875262 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -820,3 +820,5 @@ Srmm_CreateHotkey @886 NONAME ?UpdateChatLog@CSrmmBaseDialog@@IEAAXXZ @935 NONAME ?OnMarkRead@PROTO_INTERFACE@@UEAAXII@Z @936 NONAME ?OnCreateAccMgrUI@PROTO_INTERFACE@@UEAAPEAUHWND__@@PEAU2@@Z @937 NONAME +?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD0@Z @938 NONAME +?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PEBD0@Z @939 NONAME diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 737fdd84b9..5f77f45774 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -255,6 +255,18 @@ MIR_CORE_DLL(CMStringA) db_get_sm(MCONTACT hContact, LPCSTR szModule, LPCSTR szS return CMStringA(ptrA(dbv.pszVal).get()); } +MIR_CORE_DLL(CMStringA) db_get_usm(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, const char *szValue) +{ + if (g_pCurrDb == nullptr) + return (szValue == nullptr) ? CMStringA() : CMStringA(szValue); + + DBVARIANT dbv = { DBVT_UTF8 }; + if (g_pCurrDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv)) + return (szValue == nullptr) ? CMStringA() : CMStringA(szValue); + + return CMStringA(ptrA(dbv.pszVal).get()); +} + MIR_CORE_DLL(CMStringW) db_get_wsm(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, const wchar_t *szValue) { if (g_pCurrDb == nullptr) diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index a2b489708e..677bf03c83 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1549,3 +1549,4 @@ _Utils_CorrectFontSize@4 @1762 NONAME ?appendBefore@MBinBuffer@@QAEXABV1@@Z @1770 NONAME db_event_replace @1771 db_event_updateId @1772 +?db_get_usm@@YG?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD00@Z @1773 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 07b98136f8..4aace13f6e 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1549,3 +1549,4 @@ Utils_CorrectFontSize @1762 NONAME ?appendBefore@MBinBuffer@@QEAAXAEBV1@@Z @1770 NONAME db_event_replace @1771 db_event_updateId @1772 +?db_get_usm@@YA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD00@Z @1773 NONAME -- cgit v1.2.3