diff options
author | George Hazan <ghazan@miranda.im> | 2022-12-29 15:33:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-12-29 15:33:47 +0300 |
commit | e952f242f6314048ec98b60c4d53b0b9c00ab4c0 (patch) | |
tree | 2d8cbd4deeebe447371a1f9a1db064919f6f32cd /src | |
parent | a7e949ad518d36d9edc52496d9a303854cae37ed (diff) |
ancient perversion with DBCONTACTWRITESETTING removed
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/MDatabaseCommon.cpp | 22 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_core/src/db.cpp | 78 |
4 files changed, 42 insertions, 62 deletions
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp index 59a7e647ba..033cbea2b9 100644 --- a/src/mir_app/src/MDatabaseCommon.cpp +++ b/src/mir_app/src/MDatabaseCommon.cpp @@ -197,12 +197,10 @@ BOOL MDatabaseCommon::MetaDetouchSub(DBCachedContact *cc, int nSub) BOOL MDatabaseCommon::MetaSetDefault(DBCachedContact *cc) { - DBCONTACTWRITESETTING cws; - cws.szModule = META_PROTO; - cws.szSetting = "Default"; - cws.value.type = DBVT_DWORD; - cws.value.dVal = cc->nDefault; - return WriteContactSetting(cc->contactID, &cws); + DBVARIANT dbv; + dbv.type = DBVT_DWORD; + dbv.dVal = cc->nDefault; + return WriteContactSetting(cc->contactID, META_PROTO, "Default", &dbv); } BOOL MDatabaseCommon::MetaRemoveSubHistory(DBCachedContact*) @@ -451,17 +449,17 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::FreeVariant(DBVARIANT *dbv) ///////////////////////////////////////////////////////////////////////////////////////// -STDMETHODIMP_(BOOL) MDatabaseCommon::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws) +STDMETHODIMP_(BOOL) MDatabaseCommon::WriteContactSetting(MCONTACT contactID, const char *szModule, const char *szSetting, DBVARIANT *dbv) { - if (dbcws == nullptr || dbcws->szSetting == nullptr || dbcws->szModule == nullptr) + if (dbv == nullptr || szSetting == nullptr || szModule == nullptr) return 1; // the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name - size_t settingNameLen = strlen(dbcws->szSetting); - size_t moduleNameLen = strlen(dbcws->szModule); + size_t settingNameLen = strlen(szSetting); + size_t moduleNameLen = strlen(szModule); // used for notifications - DBCONTACTWRITESETTING dbcwNotif = *dbcws; + DBCONTACTWRITESETTING dbcwNotif = {szModule, szSetting, *dbv}; if (dbcwNotif.value.type == DBVT_WCHAR) { if (dbcwNotif.value.pszVal != nullptr) { T2Utf val(dbcwNotif.value.pwszVal); @@ -487,7 +485,7 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::WriteContactSetting(MCONTACT contactID, DBC case DBVT_ASCIIZ: case DBVT_UTF8: - bIsEncrypted = m_bEncrypted || IsSettingEncrypted(dbcws->szModule, dbcws->szSetting); + bIsEncrypted = m_bEncrypted || IsSettingEncrypted(szModule, szSetting); if (dbcwWork.value.pszVal == nullptr) return 1; diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index a7a3b3312b..37f37cec9d 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -740,7 +740,7 @@ _Netlib_GetTlsUnique@12 @831 NONAME ?FilterSearch@Clist@@3V?$CMOption@_N@@A @841 NONAME
?FillContactSettings@MDatabaseCommon@@IAEXXZ @842 NONAME
?GetContactSettingWorker@MDatabaseCommon@@MAGHIPBD0PAUDBVARIANT@@H@Z @843 NONAME
-?WriteContactSetting@MDatabaseCommon@@UAGHIPAUDBCONTACTWRITESETTING@@@Z @844 NONAME
+?WriteContactSetting@MDatabaseCommon@@UAGHIPBD0PAUDBVARIANT@@@Z @844 NONAME
?getCrypt@MDatabaseCommon@@QBEPAUMICryptoEngine@@XZ @845 NONAME
?isEncrypted@MDatabaseCommon@@QBE_NXZ @846 NONAME
?SelectProvider@MDatabaseCommon@@QAEPAUCRYPTO_PROVIDER@@XZ @847 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 7cfbe15e28..9f94234c59 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -740,7 +740,7 @@ Netlib_GetTlsUnique @831 NONAME ?FilterSearch@Clist@@3V?$CMOption@_N@@A @841 NONAME
?FillContactSettings@MDatabaseCommon@@IEAAXXZ @842 NONAME
?GetContactSettingWorker@MDatabaseCommon@@MEAAHIPEBD0PEAUDBVARIANT@@H@Z @843 NONAME
-?WriteContactSetting@MDatabaseCommon@@UEAAHIPEAUDBCONTACTWRITESETTING@@@Z @844 NONAME
+?WriteContactSetting@MDatabaseCommon@@UEAAHIPEBD0PEAUDBVARIANT@@@Z @844 NONAME
?getCrypt@MDatabaseCommon@@QEBAPEAUMICryptoEngine@@XZ @845 NONAME
?isEncrypted@MDatabaseCommon@@QEBA_NXZ @846 NONAME
?SelectProvider@MDatabaseCommon@@QEAAPEAUCRYPTO_PROVIDER@@XZ @847 NONAME
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 2965c72842..8fb13fd4d3 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -309,96 +309,78 @@ MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, const char *szModule, const char { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value = *dbv; - return g_pCurrDb->WriteContactSetting(hContact, &cws); + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, dbv); } MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, const char *szModule, const char *szSetting, uint8_t val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_BYTE; - cws.value.bVal = val; - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_BYTE; + dbv.bVal = val; + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, const char *szModule, const char *szSetting, uint16_t val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_WORD; - cws.value.wVal = val; - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_WORD; + dbv.wVal = val; + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, const char *szModule, const char *szSetting, uint32_t val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_DWORD; - cws.value.dVal = val; - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_DWORD; + dbv.dVal = val; + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_ASCIIZ; - cws.value.pszVal = (char*)(val == nullptr ? "" : val); - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_ASCIIZ; + dbv.pszVal = (char*)(val == nullptr ? "" : val); + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_WCHAR; - cws.value.pwszVal = (wchar_t*)(val == nullptr ? L"" : val); - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_WCHAR; + dbv.pwszVal = (wchar_t*)(val == nullptr ? L"" : val); + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_UTF8; - cws.value.pszVal = (char*)(val == nullptr ? "" : val); - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_UTF8; + dbv.pszVal = (char*)(val == nullptr ? "" : val); + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, const char *szModule, const char *szSetting, const void *val, unsigned len) { if (g_pCurrDb == nullptr) return 1; - DBCONTACTWRITESETTING cws; - cws.szModule = szModule; - cws.szSetting = szSetting; - cws.value.type = DBVT_BLOB; - cws.value.cpbVal = (uint16_t)len; - cws.value.pbVal = (unsigned char*)val; - return g_pCurrDb->WriteContactSetting(hContact, &cws); + DBVARIANT dbv; + dbv.type = DBVT_BLOB; + dbv.cpbVal = (uint16_t)len; + dbv.pbVal = (unsigned char*)val; + return g_pCurrDb->WriteContactSetting(hContact, szModule, szSetting, &dbv); } ///////////////////////////////////////////////////////////////////////////////////////// |