diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-03 20:11:26 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-03 20:11:26 +0000 |
commit | e84b97a0622a26fe474ccd840dcadb320520601c (patch) | |
tree | 7c1725e6eddbb47d618c8574147dd998feb8ea52 /plugins | |
parent | e82c4d5d574191f432716049218b4b7b5162ec38 (diff) |
- new helpers for reading db strings into static buffers;
- MS_DB_CONTACT_GETSETTINGSTATIC died;
- DBCONTACTGETSETTING is detouched from all services;
- these service calls are rewritten using parameters
git-svn-id: http://svn.miranda-ng.org/main/trunk@8035 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 12 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 10 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 188 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/Compatibility.cpp | 260 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/DataBase.h | 8 | ||||
-rw-r--r-- | plugins/Import/src/import.cpp | 9 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp | 4 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp | 2 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_db.cpp | 57 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_db.h | 2 | ||||
-rw-r--r-- | plugins/Utils.pas/mirutils.pas | 17 |
12 files changed, 248 insertions, 325 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index d330631b3b..13d5a0fb78 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -32,12 +32,10 @@ int CDb3Base::CheckProto(HANDLE hContact, const char *proto) if (cc->szProto == NULL) {
char protobuf[MAX_PATH] = {0};
DBVARIANT dbv;
- DBCONTACTGETSETTING sVal = { "Protocol", "p", &dbv };
-
dbv.type = DBVT_ASCIIZ;
dbv.pszVal = protobuf;
dbv.cchVal = sizeof(protobuf);
- if ( GetContactSettingStatic(hContact, &sVal) != 0 || (dbv.type != DBVT_ASCIIZ))
+ if (GetContactSettingStatic(hContact, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
return 0;
cc->szProto = m_cache->GetCachedSetting(NULL, protobuf, 0, (int)strlen(protobuf));
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 84b66402e3..057438fd08 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -74,8 +74,7 @@ int sttSettingUgrader(const char *szSetting, LPARAM lParam) SettingUgraderParam *param = (SettingUgraderParam*)lParam;
if (param->db->IsSettingEncrypted(param->szModule, szSetting)) {
DBVARIANT dbv = { DBVT_UTF8 };
- DBCONTACTGETSETTING dbcgs = { param->szModule, szSetting, &dbv };
- if (!param->db->GetContactSettingStr(param->hContact, &dbcgs)) {
+ if (!param->db->GetContactSettingStr(param->hContact, param->szModule, szSetting, &dbv)) {
if (dbv.type == DBVT_UTF8) {
DecodeString(dbv.pszVal);
param->pList->insert(new VarDescr(szSetting, (LPCSTR)dbv.pszVal));
@@ -133,8 +132,7 @@ int CDb3Mmap::InitCrypt() DBVARIANT dbv = { 0 };
dbv.type = DBVT_BLOB;
- DBCONTACTGETSETTING dbcgs = { "CryptoEngine", "Provider", &dbv };
- if (GetContactSettingStr(NULL, &dbcgs)) {
+ if (GetContactSettingStr(NULL, "CryptoEngine", "Provider", &dbv)) {
LBL_CreateProvider:
CRYPTO_PROVIDER **ppProvs;
int iNumProvs;
@@ -161,8 +159,7 @@ LBL_CreateProvider: return 3;
dbv.type = DBVT_BLOB;
- dbcgs.szSetting = "StoredKey";
- if (GetContactSetting(NULL, &dbcgs)) {
+ if (GetContactSetting(NULL, "CryptoEngine", "StoredKey", &dbv)) {
LBL_SetNewKey:
m_crypto->generateKey(); // unencrypted key
StoreKey();
@@ -202,8 +199,7 @@ LBL_SetNewKey: }
dbv.type = DBVT_BYTE;
- dbcgs.szSetting = "DatabaseEncryption";
- if (!GetContactSetting(NULL, &dbcgs))
+ if (!GetContactSetting(NULL, "CryptoEngine", "DatabaseEncryption", &dbv))
m_bEncrypted = dbv.bVal != 0;
InitDialogs();
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 32bda67466..129ef0b3c8 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -195,12 +195,12 @@ public: STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
- STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
- STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
- STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws);
- STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
@@ -308,7 +308,7 @@ protected: DWORD ConvertModuleNameOfs(DWORD ofsOld);
void ConvertOldEvent(DBEvent*& dbei);
- int GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcgs, int isStatic);
+ int GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
int WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime);
int WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime);
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 18d14fa7ab..a0d91e5281 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -45,14 +45,14 @@ BOOL CDb3Base::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting) /////////////////////////////////////////////////////////////////////////////////////////
-int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcgs, int isStatic)
+int CDb3Base::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic)
{
- if (dbcgs->szSetting == NULL || dbcgs->szModule == NULL)
+ if (szSetting == NULL || szModule == NULL)
return 1;
// the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name
- int settingNameLen = (int)strlen(dbcgs->szSetting);
- int moduleNameLen = (int)strlen(dbcgs->szModule);
+ int settingNameLen = (int)strlen(szSetting);
+ int moduleNameLen = (int)strlen(szModule);
if (settingNameLen > 0xFE) {
#ifdef _DEBUG
OutputDebugStringA("GetContactSettingWorker() got a > 255 setting name length. \n");
@@ -68,36 +68,36 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg mir_cslock lck(m_csDbAccess);
- char *szCachedSettingName = m_cache->GetCachedSetting(dbcgs->szModule, dbcgs->szSetting, moduleNameLen, settingNameLen);
+ char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
log3("get [%08p] %s (%p)", hContact, szCachedSettingName, szCachedSettingName);
DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 0);
if (pCachedValue != NULL) {
if (pCachedValue->type == DBVT_ASCIIZ || pCachedValue->type == DBVT_UTF8) {
- int cbOrigLen = dbcgs->pValue->cchVal;
- char *cbOrigPtr = dbcgs->pValue->pszVal;
- memcpy(dbcgs->pValue, pCachedValue, sizeof(DBVARIANT));
+ int cbOrigLen = dbv->cchVal;
+ char *cbOrigPtr = dbv->pszVal;
+ memcpy(dbv, pCachedValue, sizeof(DBVARIANT));
if (isStatic) {
int cbLen = 0;
if (pCachedValue->pszVal != NULL)
cbLen = (int)strlen(pCachedValue->pszVal);
cbOrigLen--;
- dbcgs->pValue->pszVal = cbOrigPtr;
+ dbv->pszVal = cbOrigPtr;
if (cbLen < cbOrigLen)
cbOrigLen = cbLen;
- CopyMemory(dbcgs->pValue->pszVal, pCachedValue->pszVal, cbOrigLen);
- dbcgs->pValue->pszVal[cbOrigLen] = 0;
- dbcgs->pValue->cchVal = cbLen;
+ CopyMemory(dbv->pszVal, pCachedValue->pszVal, cbOrigLen);
+ dbv->pszVal[cbOrigLen] = 0;
+ dbv->cchVal = cbLen;
}
else {
- dbcgs->pValue->pszVal = (char*)mir_alloc(strlen(pCachedValue->pszVal) + 1);
- strcpy(dbcgs->pValue->pszVal, pCachedValue->pszVal);
+ dbv->pszVal = (char*)mir_alloc(strlen(pCachedValue->pszVal) + 1);
+ strcpy(dbv->pszVal, pCachedValue->pszVal);
}
}
- else memcpy(dbcgs->pValue, pCachedValue, sizeof(DBVARIANT));
+ else memcpy(dbv, pCachedValue, sizeof(DBVARIANT));
- log2("get cached %s (%p)", printVariant(dbcgs->pValue), pCachedValue);
+ log2("get cached %s (%p)", printVariant(dbv), pCachedValue);
return (pCachedValue->type == DBVT_DELETED) ? 1 : 0;
}
@@ -105,7 +105,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg if (szCachedSettingName[-1] != 0)
return 1;
- DWORD ofsModuleName = GetModuleNameOfs(dbcgs->szModule);
+ DWORD ofsModuleName = GetModuleNameOfs(szModule);
DWORD ofsContact = (hContact == NULL) ? m_dbHeader.ofsUser : (DWORD)hContact;
DBContact dbc = *(DBContact*)DBRead(ofsContact,sizeof(DBContact),NULL);
@@ -120,38 +120,38 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg PBYTE pBlob = DBRead(ofsBlobPtr, sizeof(DBContactSettings), &bytesRemaining);
while (pBlob[0]) {
NeedBytes(1+settingNameLen);
- if (pBlob[0] == settingNameLen && !memcmp(pBlob+1,dbcgs->szSetting,settingNameLen)) {
+ if (pBlob[0] == settingNameLen && !memcmp(pBlob+1,szSetting,settingNameLen)) {
MoveAlong(1 + settingNameLen);
NeedBytes(5);
- if (isStatic && (pBlob[0] & DBVTF_VARIABLELENGTH) && VLT(dbcgs->pValue->type) != VLT(pBlob[0]))
+ if (isStatic && (pBlob[0] & DBVTF_VARIABLELENGTH) && VLT(dbv->type) != VLT(pBlob[0]))
return 1;
- BYTE iType = dbcgs->pValue->type = pBlob[0];
+ BYTE iType = dbv->type = pBlob[0];
switch (iType) {
case DBVT_DELETED: /* this setting is deleted */
- dbcgs->pValue->type = DBVT_DELETED;
+ dbv->type = DBVT_DELETED;
return 2;
- case DBVT_BYTE: dbcgs->pValue->bVal = pBlob[1]; break;
- case DBVT_WORD: DecodeCopyMemory(&(dbcgs->pValue->wVal), (PWORD)(pBlob + 1), 2); break;
- case DBVT_DWORD: DecodeCopyMemory(&(dbcgs->pValue->dVal), (PDWORD)(pBlob + 1), 4); break;
+ case DBVT_BYTE: dbv->bVal = pBlob[1]; break;
+ case DBVT_WORD: DecodeCopyMemory(&(dbv->wVal), (PWORD)(pBlob + 1), 2); break;
+ case DBVT_DWORD: DecodeCopyMemory(&(dbv->dVal), (PDWORD)(pBlob + 1), 4); break;
case DBVT_UTF8:
case DBVT_ASCIIZ:
varLen = *(PWORD)(pBlob + 1);
NeedBytes(int(3 + varLen));
if (isStatic) {
- dbcgs->pValue->cchVal--;
- if (varLen < dbcgs->pValue->cchVal)
- dbcgs->pValue->cchVal = varLen;
- DecodeCopyMemory(dbcgs->pValue->pszVal, pBlob + 3, dbcgs->pValue->cchVal); // decode
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal] = 0;
- dbcgs->pValue->cchVal = varLen;
+ dbv->cchVal--;
+ if (varLen < dbv->cchVal)
+ dbv->cchVal = varLen;
+ DecodeCopyMemory(dbv->pszVal, pBlob + 3, dbv->cchVal); // decode
+ dbv->pszVal[dbv->cchVal] = 0;
+ dbv->cchVal = varLen;
}
else {
- dbcgs->pValue->pszVal = (char*)mir_alloc(1 + varLen);
- DecodeCopyMemory(dbcgs->pValue->pszVal, pBlob + 3, varLen);
- dbcgs->pValue->pszVal[varLen] = 0;
+ dbv->pszVal = (char*)mir_alloc(1 + varLen);
+ DecodeCopyMemory(dbv->pszVal, pBlob + 3, varLen);
+ dbv->pszVal[varLen] = 0;
}
break;
@@ -159,15 +159,15 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg varLen = *(PWORD)(pBlob + 1);
NeedBytes(int(3 + varLen));
if (isStatic) {
- if (varLen < dbcgs->pValue->cpbVal)
- dbcgs->pValue->cpbVal = varLen;
- DecodeCopyMemory(dbcgs->pValue->pbVal, pBlob + 3, dbcgs->pValue->cpbVal);
+ if (varLen < dbv->cpbVal)
+ dbv->cpbVal = varLen;
+ DecodeCopyMemory(dbv->pbVal, pBlob + 3, dbv->cpbVal);
}
else {
- dbcgs->pValue->pbVal = (BYTE *)mir_alloc(varLen);
- DecodeCopyMemory(dbcgs->pValue->pbVal, pBlob + 3, varLen);
+ dbv->pbVal = (BYTE *)mir_alloc(varLen);
+ DecodeCopyMemory(dbv->pbVal, pBlob + 3, varLen);
}
- dbcgs->pValue->cpbVal = varLen;
+ dbv->cpbVal = varLen;
break;
case DBVT_ENCRYPTED:
@@ -182,19 +182,19 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg return 1;
varLen = (WORD)realLen;
- dbcgs->pValue->type = DBVT_UTF8;
+ dbv->type = DBVT_UTF8;
if (isStatic) {
- dbcgs->pValue->cchVal--;
- if (varLen < dbcgs->pValue->cchVal)
- dbcgs->pValue->cchVal = varLen;
- MoveMemory(dbcgs->pValue->pszVal, decoded, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal] = 0;
- dbcgs->pValue->cchVal = varLen;
+ dbv->cchVal--;
+ if (varLen < dbv->cchVal)
+ dbv->cchVal = varLen;
+ MoveMemory(dbv->pszVal, decoded, dbv->cchVal);
+ dbv->pszVal[dbv->cchVal] = 0;
+ dbv->cchVal = varLen;
}
else {
- dbcgs->pValue->pszVal = (char*)mir_alloc(1 + varLen);
- MoveMemory(dbcgs->pValue->pszVal, decoded, varLen);
- dbcgs->pValue->pszVal[varLen] = 0;
+ dbv->pszVal = (char*)mir_alloc(1 + varLen);
+ MoveMemory(dbv->pszVal, decoded, varLen);
+ dbv->pszVal[varLen] = 0;
}
}
break;
@@ -204,7 +204,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg if (iType != DBVT_BLOB && iType != DBVT_ENCRYPTED) {
DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
if (pCachedValue != NULL) {
- m_cache->SetCachedVariant(dbcgs->pValue, pCachedValue);
+ m_cache->SetCachedVariant(dbv, pCachedValue);
log3("set cached [%08p] %s (%p)", hContact, szCachedSettingName, pCachedValue);
}
}
@@ -223,34 +223,34 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact, DBCONTACTGETSETTING *dbcg return 1;
}
-STDMETHODIMP_(BOOL) CDb3Base::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- dgs->pValue->type = 0;
- if (GetContactSettingWorker(hContact, dgs, 0))
+ dbv->type = 0;
+ if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 0))
return 1;
- if (dgs->pValue->type == DBVT_UTF8 ) {
+ if (dbv->type == DBVT_UTF8 ) {
WCHAR *tmp = NULL;
- char *p = NEWSTR_ALLOCA(dgs->pValue->pszVal);
+ char *p = NEWSTR_ALLOCA(dbv->pszVal);
if (mir_utf8decode(p, &tmp) != NULL) {
BOOL bUsed = FALSE;
int result = WideCharToMultiByte(m_codePage, WC_NO_BEST_FIT_CHARS, tmp, -1, NULL, 0, NULL, &bUsed);
- mir_free(dgs->pValue->pszVal);
+ mir_free(dbv->pszVal);
if (bUsed || result == 0) {
- dgs->pValue->type = DBVT_WCHAR;
- dgs->pValue->pwszVal = tmp;
+ dbv->type = DBVT_WCHAR;
+ dbv->pwszVal = tmp;
}
else {
- dgs->pValue->type = DBVT_ASCIIZ;
- dgs->pValue->pszVal = (char *)mir_alloc(result);
- WideCharToMultiByte(m_codePage, WC_NO_BEST_FIT_CHARS, tmp, -1, dgs->pValue->pszVal, result, NULL, NULL);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->pszVal = (char *)mir_alloc(result);
+ WideCharToMultiByte(m_codePage, WC_NO_BEST_FIT_CHARS, tmp, -1, dbv->pszVal, result, NULL, NULL);
mir_free(tmp);
}
}
else {
- dgs->pValue->type = DBVT_ASCIIZ;
+ dbv->type = DBVT_ASCIIZ;
mir_free(tmp);
}
}
@@ -258,61 +258,61 @@ STDMETHODIMP_(BOOL) CDb3Base::GetContactSetting(HANDLE hContact, DBCONTACTGETSET return 0;
}
-STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- int iSaveType = dgs->pValue->type;
+ int iSaveType = dbv->type;
- if (GetContactSettingWorker(hContact, dgs, 0))
+ if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 0))
return 1;
- if (iSaveType == 0 || iSaveType == dgs->pValue->type)
+ if (iSaveType == 0 || iSaveType == dbv->type)
return 0;
- if (dgs->pValue->type != DBVT_ASCIIZ && dgs->pValue->type != DBVT_UTF8)
+ if (dbv->type != DBVT_ASCIIZ && dbv->type != DBVT_UTF8)
return 1;
if (iSaveType == DBVT_WCHAR) {
- if (dgs->pValue->type != DBVT_UTF8) {
- int len = MultiByteToWideChar(CP_ACP, 0, dgs->pValue->pszVal, -1, NULL, 0);
+ if (dbv->type != DBVT_UTF8) {
+ int len = MultiByteToWideChar(CP_ACP, 0, dbv->pszVal, -1, NULL, 0);
wchar_t* wszResult = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
if (wszResult == NULL)
return 1;
- MultiByteToWideChar(CP_ACP, 0, dgs->pValue->pszVal, -1, wszResult, len);
+ MultiByteToWideChar(CP_ACP, 0, dbv->pszVal, -1, wszResult, len);
wszResult[len] = 0;
- mir_free(dgs->pValue->pszVal);
- dgs->pValue->pwszVal = wszResult;
+ mir_free(dbv->pszVal);
+ dbv->pwszVal = wszResult;
}
else {
- char* savePtr = NEWSTR_ALLOCA(dgs->pValue->pszVal);
- mir_free(dgs->pValue->pszVal);
- if (!mir_utf8decode(savePtr, &dgs->pValue->pwszVal))
+ char* savePtr = NEWSTR_ALLOCA(dbv->pszVal);
+ mir_free(dbv->pszVal);
+ if (!mir_utf8decode(savePtr, &dbv->pwszVal))
return 1;
}
}
else if (iSaveType == DBVT_UTF8) {
- char* tmpBuf = mir_utf8encode(dgs->pValue->pszVal);
+ char* tmpBuf = mir_utf8encode(dbv->pszVal);
if (tmpBuf == NULL)
return 1;
- mir_free(dgs->pValue->pszVal);
- dgs->pValue->pszVal = tmpBuf;
+ mir_free(dbv->pszVal);
+ dbv->pszVal = tmpBuf;
}
else if (iSaveType == DBVT_ASCIIZ)
- mir_utf8decode(dgs->pValue->pszVal, NULL);
+ mir_utf8decode(dbv->pszVal, NULL);
- dgs->pValue->type = iSaveType;
+ dbv->type = iSaveType;
return 0;
}
-STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- if (GetContactSettingWorker(hContact, dgs, 1))
+ if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 1))
return 1;
- if (dgs->pValue->type == DBVT_UTF8) {
- mir_utf8decode(dgs->pValue->pszVal, NULL);
- dgs->pValue->type = DBVT_ASCIIZ;
+ if (dbv->type == DBVT_UTF8) {
+ mir_utf8decode(dbv->pszVal, NULL);
+ dbv->type = DBVT_ASCIIZ;
}
return 0;
@@ -671,14 +671,14 @@ LBL_WriteString: return 0;
}
-STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting)
{
- if (!dbcgs->szModule || !dbcgs->szSetting)
+ if (!szModule || !szSetting)
return 1;
// the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name
- int settingNameLen = (int)strlen(dbcgs->szSetting);
- int moduleNameLen = (int)strlen(dbcgs->szModule);
+ int settingNameLen = (int)strlen(szSetting);
+ int moduleNameLen = (int)strlen(szModule);
if (settingNameLen > 0xFE) {
#ifdef _DEBUG
OutputDebugStringA("DeleteContactSetting() got a > 255 setting name length. \n");
@@ -693,10 +693,10 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGET }
WPARAM saveWparam = (WPARAM)hContact;
- char *szCachedSettingName = m_cache->GetCachedSetting(dbcgs->szModule, dbcgs->szSetting, moduleNameLen, settingNameLen);
+ char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
if (szCachedSettingName[-1] == 0) { // it's not a resident variable
mir_cslock lck(m_csDbAccess);
- DWORD ofsModuleName = GetModuleNameOfs(dbcgs->szModule);
+ DWORD ofsModuleName = GetModuleNameOfs(szModule);
if (hContact == 0)
hContact = (HANDLE)m_dbHeader.ofsUser;
@@ -715,7 +715,7 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGET PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining);
while (pBlob[0]) {
NeedBytes(settingNameLen + 1);
- if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, dbcgs->szSetting, settingNameLen))
+ if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen))
break;
NeedBytes(1);
MoveAlong(pBlob[0] + 1);
@@ -748,8 +748,8 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGET // notify
DBCONTACTWRITESETTING dbcws = { 0 };
- dbcws.szModule = dbcgs->szModule;
- dbcws.szSetting = dbcgs->szSetting;
+ dbcws.szModule = szModule;
+ dbcws.szSetting = szSetting;
dbcws.value.type = DBVT_DELETED;
NotifyEventHooks(hSettingChangeEvent, saveWparam, (LPARAM)&dbcws);
return 0;
diff --git a/plugins/Dbx_tree/src/Compatibility.cpp b/plugins/Dbx_tree/src/Compatibility.cpp index 4c04e63cf4..d8d119fc25 100644 --- a/plugins/Dbx_tree/src/Compatibility.cpp +++ b/plugins/Dbx_tree/src/Compatibility.cpp @@ -46,12 +46,10 @@ int CDataBase::CheckProto(HANDLE hContact, const char *proto) if (cc->szProto == NULL) {
char protobuf[MAX_PATH] = {0};
DBVARIANT dbv;
- DBCONTACTGETSETTING sVal = { "Protocol", "p", &dbv };
-
dbv.type = DBVT_ASCIIZ;
dbv.pszVal = protobuf;
dbv.cchVal = sizeof(protobuf);
- if ( GetContactSettingStatic(hContact, &sVal) != 0 || (dbv.type != DBVT_ASCIIZ))
+ if (GetContactSettingStatic(hContact, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
return 0;
cc->szProto = m_cache->GetCachedSetting(NULL, protobuf, 0, (int)strlen(protobuf));
@@ -191,21 +189,21 @@ __forceinline void DecodeString(LPSTR buf) /////////////////////////////////////////////////////////////////////////////////////////
-STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- dbcgs->pValue->type = 0;
+ dbv->type = 0;
char namebuf[512];
namebuf[0] = 0;
- if (!(dbcgs->szModule || dbcgs->szSetting))
+ if (!(szModule || szSetting))
return -1;
- if (dbcgs->szModule)
- strcpy_s(namebuf, dbcgs->szModule);
+ if (szModule)
+ strcpy_s(namebuf, szModule);
strcat_s(namebuf, "/");
- if (dbcgs->szSetting)
- strcat_s(namebuf, dbcgs->szSetting);
+ if (szSetting)
+ strcat_s(namebuf, szSetting);
TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
@@ -221,55 +219,55 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSE switch (set.Type) {
case DBT_ST_ANSI:
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->pszVal = set.Value.pAnsi;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->pszVal = set.Value.pAnsi;
+ dbv->cchVal = set.Value.Length - 1;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
break;
case DBT_ST_UTF8:
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ if (isEncrypted(szModule, szSetting))
DecodeString(set.Value.pUTF8);
- dbcgs->pValue->type = DBVT_WCHAR;
- dbcgs->pValue->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
- if (dbcgs->pValue->pwszVal)
- dbcgs->pValue->cchVal = static_cast<uint32_t>(wcslen(dbcgs->pValue->pwszVal));
+ dbv->type = DBVT_WCHAR;
+ dbv->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
+ if (dbv->pwszVal)
+ dbv->cchVal = static_cast<uint32_t>(wcslen(dbv->pwszVal));
else
- dbcgs->pValue->cchVal = 0;
+ dbv->cchVal = 0;
mir_free(set.Value.pUTF8);
break;
case DBT_ST_WCHAR:
- dbcgs->pValue->type = DBVT_WCHAR;
- dbcgs->pValue->pwszVal = set.Value.pWide;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
+ dbv->type = DBVT_WCHAR;
+ dbv->pwszVal = set.Value.pWide;
+ dbv->cchVal = set.Value.Length - 1;
break;
case DBT_ST_BLOB:
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->pbVal = set.Value.pBlob;
- dbcgs->pValue->cpbVal = set.Value.Length;
+ dbv->type = DBVT_BLOB;
+ dbv->pbVal = set.Value.pBlob;
+ dbv->cpbVal = set.Value.Length;
break;
case DBT_ST_BOOL:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = (uint8_t)set.Value.Bool;
break;
case DBT_ST_BYTE: case DBT_ST_CHAR:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = set.Value.Byte;
break;
case DBT_ST_SHORT: case DBT_ST_WORD:
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
+ dbv->type = DBVT_WORD;
+ dbv->wVal = set.Value.Word;
break;
case DBT_ST_INT: case DBT_ST_DWORD:
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
+ dbv->type = DBVT_DWORD;
+ dbv->dVal = set.Value.DWord;
break;
case DBT_ST_INT64: case DBT_ST_QWORD:
case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cpbVal = sizeof(set.Value);
- dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
- memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
+ dbv->type = DBVT_BLOB;
+ dbv->cpbVal = sizeof(set.Value);
+ dbv->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
+ memcpy(dbv->pbVal, &set.Value, sizeof(set.Value));
break;
default:
@@ -279,21 +277,21 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSE return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- if ((dbcgs->pValue->type & DBVTF_VARIABLELENGTH) == 0)
+ if ((dbv->type & DBVTF_VARIABLELENGTH) == 0)
{
- FreeVariant(dbcgs->pValue);
- dbcgs->pValue->type = 0;
+ FreeVariant(dbv);
+ dbv->type = 0;
}
char namebuf[512];
namebuf[0] = 0;
- if (dbcgs->szModule)
- strcpy_s(namebuf, dbcgs->szModule);
+ if (szModule)
+ strcpy_s(namebuf, szModule);
strcat_s(namebuf, "/");
- if (dbcgs->szSetting)
- strcat_s(namebuf, dbcgs->szSetting);
+ if (szSetting)
+ strcat_s(namebuf, szSetting);
TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
@@ -304,7 +302,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE set.cbSize = sizeof(set);
set.Descriptor = &desc;
- switch (dbcgs->pValue->type) {
+ switch (dbv->type) {
case DBVT_ASCIIZ: set.Type = DBT_ST_ANSI; break;
case DBVT_BLOB: set.Type = DBT_ST_BLOB; break;
case DBVT_UTF8: set.Type = DBT_ST_UTF8; break;
@@ -316,60 +314,60 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE switch (set.Type) {
case DBT_ST_ANSI:
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->pszVal = set.Value.pAnsi;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->pszVal = set.Value.pAnsi;
+ dbv->cchVal = set.Value.Length - 1;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
break;
case DBT_ST_UTF8:
- dbcgs->pValue->type = DBVT_UTF8;
- dbcgs->pValue->pszVal = set.Value.pUTF8;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_UTF8;
+ dbv->pszVal = set.Value.pUTF8;
+ dbv->cchVal = set.Value.Length - 1;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
break;
case DBT_ST_WCHAR:
- if (dbcgs->pValue->type == DBVT_WCHAR) {
- dbcgs->pValue->pwszVal = set.Value.pWide;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (dbv->type == DBVT_WCHAR) {
+ dbv->pwszVal = set.Value.pWide;
+ dbv->cchVal = set.Value.Length - 1;
}
else {
- dbcgs->pValue->type = DBVT_UTF8;
- dbcgs->pValue->pszVal = mir_utf8encodeW(set.Value.pWide);
- dbcgs->pValue->cchVal = static_cast<uint32_t>(strlen(dbcgs->pValue->pszVal));
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_UTF8;
+ dbv->pszVal = mir_utf8encodeW(set.Value.pWide);
+ dbv->cchVal = static_cast<uint32_t>(strlen(dbv->pszVal));
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
mir_free(set.Value.pWide);
}
break;
case DBT_ST_BLOB:
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->pbVal = set.Value.pBlob;
- dbcgs->pValue->cpbVal = set.Value.Length;
+ dbv->type = DBVT_BLOB;
+ dbv->pbVal = set.Value.pBlob;
+ dbv->cpbVal = set.Value.Length;
break;
case DBT_ST_BOOL:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = (uint8_t)set.Value.Bool;
break;
case DBT_ST_BYTE: case DBT_ST_CHAR:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = set.Value.Byte;
break;
case DBT_ST_SHORT: case DBT_ST_WORD:
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
+ dbv->type = DBVT_WORD;
+ dbv->wVal = set.Value.Word;
break;
case DBT_ST_INT: case DBT_ST_DWORD:
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
+ dbv->type = DBVT_DWORD;
+ dbv->dVal = set.Value.DWord;
break;
case DBT_ST_INT64: case DBT_ST_QWORD:
case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cpbVal = sizeof(set.Value);
- dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
- memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
+ dbv->type = DBVT_BLOB;
+ dbv->cpbVal = sizeof(set.Value);
+ dbv->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
+ memcpy(dbv->pbVal, &set.Value, sizeof(set.Value));
break;
default:
return -1;
@@ -378,15 +376,15 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
char namebuf[512];
namebuf[0] = 0;
- if (dbcgs->szModule)
- strcpy_s(namebuf, dbcgs->szModule);
+ if (szModule)
+ strcpy_s(namebuf, szModule);
strcat_s(namebuf, "/");
- if (dbcgs->szSetting)
- strcat_s(namebuf, dbcgs->szSetting);
+ if (szSetting)
+ strcat_s(namebuf, szSetting);
TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
@@ -400,7 +398,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC if (DBSettingRead(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
return -1;
- if ((set.Type & DBT_STF_VariableLength) ^ (dbcgs->pValue->type & DBVTF_VARIABLELENGTH))
+ if ((set.Type & DBT_STF_VariableLength) ^ (dbv->type & DBVTF_VARIABLELENGTH))
{
if (set.Type & DBT_STF_VariableLength)
mir_free(set.Value.pBlob);
@@ -409,16 +407,16 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC switch (set.Type) {
case DBT_ST_ANSI:
- if (dbcgs->pValue->cchVal < set.Value.Length) {
- memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
+ if (dbv->cchVal < set.Value.Length) {
+ memcpy(dbv->pszVal, set.Value.pAnsi, dbv->cchVal);
+ dbv->pszVal[dbv->cchVal - 1] = 0;
}
- else memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, set.Value.Length);
+ else memcpy(dbv->pszVal, set.Value.pAnsi, set.Value.Length);
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->cchVal = set.Value.Length - 1;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
mir_free(set.Value.pAnsi);
break;
@@ -426,16 +424,16 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC set.Value.pUTF8 = mir_utf8decode(set.Value.pUTF8, NULL);
set.Value.Length = static_cast<uint32_t>(strlen(set.Value.pUTF8));
- if (dbcgs->pValue->cchVal < set.Value.Length) {
- memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
+ if (dbv->cchVal < set.Value.Length) {
+ memcpy(dbv->pszVal, set.Value.pUTF8, dbv->cchVal);
+ dbv->pszVal[dbv->cchVal - 1] = 0;
}
- else memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, set.Value.Length);
+ else memcpy(dbv->pszVal, set.Value.pUTF8, set.Value.Length);
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->cchVal = set.Value.Length - 1;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
mir_free(set.Value.pUTF8);
break;
@@ -445,45 +443,45 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC WORD l = static_cast<WORD>(strlen(tmp));
mir_free(set.Value.pWide);
- if (dbcgs->pValue->cchVal < l + 1) {
- memcpy(dbcgs->pValue->pszVal, tmp, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[l] = 0;
+ if (dbv->cchVal < l + 1) {
+ memcpy(dbv->pszVal, tmp, dbv->cchVal);
+ dbv->pszVal[l] = 0;
}
- else memcpy(dbcgs->pValue->pszVal, tmp, l + 1);
+ else memcpy(dbv->pszVal, tmp, l + 1);
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->cchVal = l;
- if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
- DecodeString(dbcgs->pValue->pszVal);
+ dbv->type = DBVT_ASCIIZ;
+ dbv->cchVal = l;
+ if (isEncrypted(szModule, szSetting))
+ DecodeString(dbv->pszVal);
mir_free(tmp);
}
break;
case DBT_ST_BLOB:
- if (dbcgs->pValue->cchVal < set.Value.Length)
- memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, dbcgs->pValue->cchVal);
+ if (dbv->cchVal < set.Value.Length)
+ memcpy(dbv->pbVal, set.Value.pBlob, dbv->cchVal);
else
- memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, set.Value.Length);
+ memcpy(dbv->pbVal, set.Value.pBlob, set.Value.Length);
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cchVal = set.Value.Length;
+ dbv->type = DBVT_BLOB;
+ dbv->cchVal = set.Value.Length;
mir_free(set.Value.pBlob);
break;
case DBT_ST_BOOL:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Bool ? TRUE : FALSE;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = set.Value.Bool ? TRUE : FALSE;
break;
case DBT_ST_BYTE: case DBT_ST_CHAR:
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
+ dbv->type = DBVT_BYTE;
+ dbv->bVal = set.Value.Byte;
break;
case DBT_ST_SHORT: case DBT_ST_WORD:
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
+ dbv->type = DBVT_WORD;
+ dbv->wVal = set.Value.Word;
break;
case DBT_ST_INT: case DBT_ST_DWORD:
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
+ dbv->type = DBVT_DWORD;
+ dbv->dVal = set.Value.DWord;
break;
default:
return -1;
@@ -598,15 +596,15 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting)
{
char namebuf[512];
namebuf[0] = 0;
- if (dbcgs->szModule)
- strcpy_s(namebuf, dbcgs->szModule);
+ if (szModule)
+ strcpy_s(namebuf, szModule);
strcat_s(namebuf, "/");
- if (dbcgs->szSetting)
- strcat_s(namebuf, dbcgs->szSetting);
+ if (szSetting)
+ strcat_s(namebuf, szSetting);
TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
desc.cbSize = sizeof(desc);
@@ -618,8 +616,8 @@ STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, DBCONTACTGE {
DBCONTACTWRITESETTING tmp = {0,0,0,0};
- tmp.szModule = dbcgs->szModule;
- tmp.szSetting = dbcgs->szSetting;
+ tmp.szModule = szModule;
+ tmp.szSetting = szSetting;
tmp.value.type = 0;
NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)&tmp);
}
diff --git a/plugins/Dbx_tree/src/DataBase.h b/plugins/Dbx_tree/src/DataBase.h index 0d03cd6f3d..0cff291944 100644 --- a/plugins/Dbx_tree/src/DataBase.h +++ b/plugins/Dbx_tree/src/DataBase.h @@ -217,12 +217,12 @@ protected: // to be compatible with the standard Miranda databases STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
- STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
- STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
- STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws);
- STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index f220b3b6bc..7d15029661 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -34,23 +34,20 @@ static MIDatabase *srcDb, *dstDb; static int myGet(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
- DBCONTACTGETSETTING dgs = { szModule, szSetting, dbv };
- return srcDb->GetContactSetting(hContact, &dgs);
+ return srcDb->GetContactSetting(hContact, szModule, szSetting, dbv);
}
static TCHAR* myGetWs(HANDLE hContact, const char *szModule, const char *szSetting)
{
DBVARIANT dbv = { DBVT_TCHAR };
- DBCONTACTGETSETTING dgs = { szModule, szSetting, &dbv };
- return ( srcDb->GetContactSettingStr(hContact, &dgs)) ? NULL : dbv.ptszVal;
+ return srcDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.ptszVal;
}
static BOOL myGetS(HANDLE hContact, const char *szModule, const char *szSetting, char* dest)
{
DBVARIANT dbv = { DBVT_ASCIIZ };
dbv.pszVal = dest; dbv.cchVal = 100;
- DBCONTACTGETSETTING dgs = { szModule, szSetting, &dbv };
- return srcDb->GetContactSettingStatic(hContact, &dgs);
+ return srcDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv);
}
static void mySet(HANDLE hContact, const char *module, const char *var, DBVARIANT *dbv)
diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp index b0b3e170a7..6dab5f380d 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp @@ -207,8 +207,8 @@ static void GetInitialDir(LPSTR pszInitialDir) ZeroMemory(szRelative, SIZEOF(szRelative));
// is some standard path defined
- if (!DB::Setting::GetStatic(0, MODNAME, "vCardPath", szRelative, SIZEOF(szRelative))) {
- if ( !PathToAbsolute(szRelative, pszInitialDir))
+ if (!db_get_static(0, MODNAME, "vCardPath", szRelative, SIZEOF(szRelative))) {
+ if (!PathToAbsolute(szRelative, pszInitialDir))
strcpy(pszInitialDir, szRelative);
}
else if (//try to use environment variables supported by pathpatch of db3xSA
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp index 5e5c25e482..e3b6f45f2c 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp @@ -1084,7 +1084,7 @@ BYTE CVCardFileVCF::Export(BYTE bExportUtf) uid = (LPCSTR)CallProtoService(_pszBaseProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
- if (!DB::Setting::GetStatic(_hContact, _pszBaseProto, uid, szUID, sizeof(szUID)))
+ if (!db_get_static(_hContact, _pszBaseProto, uid, szUID, sizeof(szUID)))
fprintf(_pFile, "IM;%s;%s:%s\n", _pszBaseProto, uid, szUID);
}
}
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 9243a317fd..ed48c02193 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -401,51 +401,6 @@ WORD GetCtrl(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSubModule, LPCSTR pszP }
/**
-* This function reads a setting from database into a predefined portion of memory
-* and convert numbers into a string, too.
-* @param hContact - handle to the contact
-* @param pszModule - the module to read the setting from (e.g. USERINFO)
-* @param pszSetting - the setting to read
-* @param pszValue - buffer, that retrieves the value
-* @param cchValue - number of characters the buffer can take
-*
-* @retval 0 - success
-* @retval 1 - error
-**/
-
-BYTE GetStatic(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting, LPSTR pszValue, int cchValue)
-{
- DBVARIANT dbv;
- DBCONTACTGETSETTING sVal;
-
- if (pszValue && cchValue) {
- pszValue[0] = 0;
- dbv.pszVal = pszValue;
- dbv.cchVal = cchValue;
- dbv.type = DBVT_ASCIIZ;
-
- sVal.pValue = &dbv;
- sVal.szModule = pszModule;
- sVal.szSetting = pszSetting;
-
- if (!CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&sVal)) {
- switch (dbv.type) {
- case DBVT_BYTE:
- _itoa(dbv.bVal, pszValue, 10);
- break;
- case DBVT_WORD:
- _itoa(dbv.wVal, pszValue, 10);
- break;
- case DBVT_DWORD:
- _itoa(dbv.dVal, pszValue, 10);
- }
- return (pszValue[0] == 0);
- }
- }
- return 1;
-}
-
-/**
* This function checks for the existence of the given setting in the database
* @param hContact - handle to the contact
* @param pszModule - the module to read the setting from (e.g. USERINFO)
@@ -459,17 +414,7 @@ BYTE Exists(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting) {
if (pszModule && pszSetting) {
CHAR szDummy[1];
- DBVARIANT dbv;
- dbv.pszVal = szDummy;
- dbv.cchVal = sizeof(szDummy);
- dbv.type = 0;
-
- DBCONTACTGETSETTING cgs;
- cgs.pValue = &dbv;
- cgs.szModule = pszModule;
- cgs.szSetting = pszSetting;
- if (!CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM) hContact, (LPARAM) &cgs))
- return (dbv.type > DBVT_DELETED);
+ return 0 == db_get_static(hContact, pszModule, pszSetting, szDummy, 1);
}
return FALSE;
}
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index 471d0db5d4..27424857fb 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -96,8 +96,6 @@ namespace Setting { static FORCEINLINE WORD GetUStringCtrl(HANDLE hContact, LPCSTR pszModule, LPCSTR szSubModule, LPCSTR szProto, LPCSTR pszSetting, DBVARIANT *dbv)
{ return GetCtrl(hContact, pszModule, szSubModule, szProto, pszSetting, dbv, DBVT_UTF8); }
- BYTE GetStatic(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting, LPSTR szValue, int cchValue);
-
#define GetTString GetWString
#define GetTStringEx GetWStringEx
#define GetTStringCtrl GetWStringCtrl
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 120a827b17..e5e761b24b 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -691,25 +691,16 @@ end; function IsContactActive(hContact:THANDLE;proto:pAnsiChar=nil):integer;
var
p:PPROTOACCOUNT;
- dbv :TDBVARIANT;
- dbcgs:TDBCONTACTGETSETTING;
name: array [0..31] of AnsiChar;
begin
- dbv._type :=DBVT_ASCIIZ;
- dbv.szVal.a:=@name;
- dbv.cchVal :=SizeOf(name);
- dbcgs.pValue :=@dbv;
- dbcgs.szModule :='Protocol';
- dbcgs.szSetting:='p';
-
- if CallService(MS_DB_CONTACT_GETSETTINGSTATIC,hContact,lparam(@dbcgs))=0 then
+ if db_get_static(hContact,'Protocol','p',@name,SizeOf(name))=0 then
begin
result:=0;
if ServiceExists(MS_PROTO_GETACCOUNT)<>0 then
begin
- p:=PPROTOACCOUNT(CallService(MS_PROTO_GETACCOUNT,0,lparam(dbv.szVal.a)));
+ p:=PPROTOACCOUNT(CallService(MS_PROTO_GETACCOUNT,0,lparam(@name)));
if p=nil then
result:=-2 // deleted
else if (p^.bIsEnabled=0) or p^.bDynDisabled then
@@ -717,7 +708,7 @@ begin end
else
begin
- if CallService(MS_PROTO_ISPROTOCOLLOADED,0,lparam(dbv.szVal.a))=0 then
+ if CallService(MS_PROTO_ISPROTOCOLLOADED,0,lparam(@name))=0 then
result:=-1;
end;
@@ -735,7 +726,7 @@ begin end;
end;
if proto<>nil then
- StrCopy(proto,dbv.szVal.a);
+ StrCopy(proto,@name);
end
else
begin
|