diff options
-rw-r--r-- | include/m_db_int.h | 4 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 231490 -> 231450 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 227768 -> 227734 bytes | |||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 14 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 48 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbsettings.cpp | 15 | ||||
-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 |
10 files changed, 80 insertions, 105 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index 7d3fdf2d80..19d66ce353 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -140,7 +140,7 @@ interface MIR_APP_EXPORT MIDatabase STDMETHOD_(BOOL, GetContactSettingStr)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE; STDMETHOD_(BOOL, GetContactSettingStatic)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE; STDMETHOD_(BOOL, FreeVariant)(DBVARIANT *dbv) PURE; - STDMETHOD_(BOOL, WriteContactSetting)(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws) PURE; + STDMETHOD_(BOOL, WriteContactSetting)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE; STDMETHOD_(BOOL, DeleteContactSetting)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting) PURE; STDMETHOD_(BOOL, EnumContactSettings)(MCONTACT contactID, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, void *param) PURE; STDMETHOD_(BOOL, SetSettingResident)(BOOL bIsResident, const char *pszSettingName) PURE; @@ -221,7 +221,7 @@ public: STDMETHODIMP_(BOOL) GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) override; STDMETHODIMP_(BOOL) GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) override; STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv); - STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws) override; + STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) override; STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam) override; STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName) override; diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 6bb559b960..2cf2e63174 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex ba28df93d7..8d2866d05f 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 2408d9dc33..a42b010187 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -396,8 +396,8 @@ void CDb3Mmap::FillContacts() if (GetContactSetting(hh, META_PROTO, "ContactNumber", &dbv))
continue;
- DBCONTACTWRITESETTING dbws = { META_PROTO };
- dbws.value.type = DBVT_DWORD;
+ DBVARIANT dbw;
+ dbw.type = DBVT_DWORD;
DBCachedContact *ccMeta = p->cc;
if (int(dbv.dVal) < ccMeta->nSubs) {
@@ -405,15 +405,13 @@ void CDb3Mmap::FillContacts() char setting[100];
mir_snprintf(setting, "Handle%d", dbv.dVal);
- dbws.szSetting = setting;
- dbws.value.dVal = hh;
- WriteContactSetting(ccMeta->contactID, &dbws);
+ dbw.dVal = hh;
+ WriteContactSetting(ccMeta->contactID, META_PROTO, setting, &dbw);
}
// store contact id instead of the old mc number
- dbws.szSetting = "ParentMeta";
- dbws.value.dVal = ccMeta->contactID;
- WriteContactSetting(hh, &dbws);
+ dbw.dVal = ccMeta->contactID;
+ WriteContactSetting(hh, META_PROTO, "ParentMeta", &dbw);
// wipe out old data from subcontacts
DeleteContactSetting(hh, META_PROTO, "ContactNumber");
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 6ef68aa852..ee90c2fdf8 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -77,11 +77,11 @@ STDMETHODIMP_(BOOL) CDb3Mmap::StoreCryptoKey() uint8_t *pKey = (uint8_t*)_alloca(iKeyLength);
m_crypto->getKey(pKey, iKeyLength);
- DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "StoredKey" };
- dbcws.value.type = DBVT_BLOB;
- dbcws.value.cpbVal = (uint16_t)iKeyLength;
- dbcws.value.pbVal = pKey;
- WriteContactSetting(0, &dbcws);
+ DBVARIANT dbv;
+ dbv.type = DBVT_BLOB;
+ dbv.cpbVal = (uint16_t)iKeyLength;
+ dbv.pbVal = pKey;
+ WriteContactSetting(0, "CryptoEngine", "StoredKey", &dbv);
SecureZeroMemory(pKey, iKeyLength);
return TRUE;
@@ -117,11 +117,11 @@ STDMETHODIMP_(CRYPTO_PROVIDER *) CDb3Mmap::ReadProvider() STDMETHODIMP_(BOOL) CDb3Mmap::StoreProvider(CRYPTO_PROVIDER *pProvider)
{
- DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" };
- dbcws.value.type = DBVT_BLOB;
- dbcws.value.pbVal = (uint8_t*)pProvider->pszName;
- dbcws.value.cpbVal = (uint16_t)mir_strlen(pProvider->pszName) + 1;
- WriteContactSetting(0, &dbcws);
+ DBVARIANT dbv = {};
+ dbv.type = DBVT_BLOB;
+ dbv.pbVal = (uint8_t*)pProvider->pszName;
+ dbv.cpbVal = (uint16_t)mir_strlen(pProvider->pszName) + 1;
+ WriteContactSetting(0, "CryptoEngine", "Provider", &dbv);
return TRUE;
}
@@ -148,10 +148,10 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnableEncryption(BOOL bEnable) m_bEncrypted = !m_bEncrypted;
- DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "DatabaseEncryption" };
- dbcws.value.type = DBVT_BYTE;
- dbcws.value.bVal = m_bEncrypted;
- WriteContactSetting(0, &dbcws);
+ DBVARIANT dbv = {};
+ dbv.type = DBVT_BYTE;
+ dbv.bVal = m_bEncrypted;
+ WriteContactSetting(0, "CryptoEngine", "DatabaseEncryption", &dbv);
g_hevSettingChanged = hSave1;
g_hevEventAdded = hSave2;
@@ -236,11 +236,11 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) size_t encodedLen;
uint8_t *pResult = m_crypto->encodeString(p->szValue, &encodedLen);
if (pResult != nullptr) {
- DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
- dbcws.value.type = DBVT_ENCRYPTED;
- dbcws.value.pbVal = pResult;
- dbcws.value.cpbVal = (uint16_t)encodedLen;
- WriteContactSetting(contactID, &dbcws);
+ DBVARIANT dbv = {};
+ dbv.type = DBVT_ENCRYPTED;
+ dbv.pbVal = pResult;
+ dbv.cpbVal = (uint16_t)encodedLen;
+ WriteContactSetting(contactID, szModule, p->szVar, &dbv);
mir_free(pResult);
}
@@ -249,11 +249,11 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) size_t realLen;
ptrA decoded(m_crypto->decodeString((uint8_t*)(char*)p->szValue, p->iLen, &realLen));
if (decoded != nullptr) {
- DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
- dbcws.value.type = DBVT_UNENCRYPTED;
- dbcws.value.pszVal = decoded;
- dbcws.value.cchVal = (uint16_t)realLen;
- WriteContactSetting(contactID, &dbcws);
+ DBVARIANT dbv = {};
+ dbv.type = DBVT_UNENCRYPTED;
+ dbv.pszVal = decoded;
+ dbv.cchVal = (uint16_t)realLen;
+ WriteContactSetting(contactID, szModule, p->szVar, &dbv);
}
}
}
diff --git a/plugins/Dbx_sqlite/src/dbsettings.cpp b/plugins/Dbx_sqlite/src/dbsettings.cpp index 4b73fcb020..2fe4d3c18e 100644 --- a/plugins/Dbx_sqlite/src/dbsettings.cpp +++ b/plugins/Dbx_sqlite/src/dbsettings.cpp @@ -59,11 +59,11 @@ void CDbxSQLite::InitSettings() FillContactSettings(); - DBVARIANT dbv; dbv.type = DBVT_DWORD; + DBVARIANT dbv; dbv.type = DBVT_BYTE; if (GetContactSetting(0, "Compatibility", "Sqlite", &dbv)) - dbv.dVal = 0; + dbv.bVal = 0; - if (dbv.dVal < 1) { + if (dbv.bVal < 1) { int rc = sqlite3_exec(m_db, "ALTER TABLE events ADD COLUMN is_read INTEGER NOT NULL DEFAULT 0;", 0, 0, 0); logError(rc, __FILE__, __LINE__); @@ -73,12 +73,9 @@ void CDbxSQLite::InitSettings() rc = sqlite3_exec(m_db, "UPDATE events SET is_read=1 WHERE (flags & 6) <> 0;", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); - DBCONTACTWRITESETTING dbcws = {}; - dbcws.szModule = "Compatibility"; - dbcws.szSetting = "Sqlite"; - dbcws.value.type = DBVT_BYTE; - dbcws.value.dVal = 1; - WriteContactSetting(0, &dbcws); + dbv.type = DBVT_BYTE; + dbv.dVal = 1; + WriteContactSetting(0, "Compatibility", "Sqlite", &dbv); } } 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); } ///////////////////////////////////////////////////////////////////////////////////////// |