summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-03 20:11:26 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-03 20:11:26 +0000
commite84b97a0622a26fe474ccd840dcadb320520601c (patch)
tree7c1725e6eddbb47d618c8574147dd998feb8ea52 /src
parente82c4d5d574191f432716049218b4b7b5162ec38 (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 'src')
-rw-r--r--src/mir_core/db.cpp83
-rw-r--r--src/mir_core/mir_core.def3
-rw-r--r--src/modules/clist/contacts.cpp3
-rw-r--r--src/modules/database/dbintf.cpp6
-rw-r--r--src/modules/protocols/protochains.cpp7
5 files changed, 57 insertions, 45 deletions
diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp
index eec60f9750..2cfbbfc0a1 100644
--- a/src/mir_core/db.cpp
+++ b/src/mir_core/db.cpp
@@ -33,11 +33,7 @@ MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *sz
{
if (currDb != NULL) {
DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !currDb->GetContactSetting(hContact, &cgs)) {
+ if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv)) {
switch(dbv.type) {
case DBVT_BYTE: return dbv.bVal;
case DBVT_WORD: return BYTE(dbv.wVal);
@@ -53,11 +49,7 @@ MIR_CORE_DLL(int) db_get_w(HANDLE hContact, const char *szModule, const char *sz
{
if (currDb != NULL) {
DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !currDb->GetContactSetting(hContact, &cgs)) {
+ if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv)) {
switch(dbv.type) {
case DBVT_BYTE: return dbv.bVal;
case DBVT_WORD: return dbv.wVal;
@@ -73,11 +65,7 @@ MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char
{
if (currDb != NULL) {
DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !currDb->GetContactSetting(hContact, &cgs)) {
+ if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv)) {
switch(dbv.type) {
case DBVT_BYTE: return dbv.bVal;
case DBVT_WORD: return dbv.wVal;
@@ -93,25 +81,19 @@ MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char
MIR_CORE_DLL(INT_PTR) db_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
- if (currDb == NULL) return 1;
+ if (currDb == NULL)
+ return 1;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = dbv;
- return currDb->GetContactSetting(hContact, &cgs);
+ return currDb->GetContactSetting(hContact, szModule, szSetting, dbv);
}
MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType)
{
- if (currDb == NULL) return 1;
+ if (currDb == NULL)
+ return 1;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = dbv;
dbv->type = (BYTE)nType;
- return currDb->GetContactSettingStr(hContact, &cgs);
+ return currDb->GetContactSettingStr(hContact, szModule, szSetting, dbv);
}
MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char *szSetting)
@@ -137,6 +119,45 @@ MIR_CORE_DLL(wchar_t*) db_get_wsa(HANDLE hContact, const char *szModule, const c
}
/////////////////////////////////////////////////////////////////////////////////////////
+// getting static data
+
+MIR_CORE_DLL(int) db_get_static(HANDLE hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest)
+{
+ if (currDb == NULL)
+ return 1;
+
+ DBVARIANT dbv;
+ dbv.type = DBVT_ASCIIZ;
+ dbv.pszVal = pDest;
+ dbv.cchVal = cbDest;
+ return currDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv);
+}
+
+MIR_CORE_DLL(int) db_get_static_utf(HANDLE hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest)
+{
+ if (currDb == NULL)
+ return 1;
+
+ DBVARIANT dbv;
+ dbv.type = DBVT_UTF8;
+ dbv.pszVal = pDest;
+ dbv.cchVal = cbDest;
+ return currDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv);
+}
+
+MIR_CORE_DLL(int) db_get_wstatic(HANDLE hContact, const char *szModule, const char *szSetting, WCHAR *pDest, int cbDest)
+{
+ if (currDb == NULL)
+ return 1;
+
+ DBVARIANT dbv;
+ dbv.type = DBVT_WCHAR;
+ dbv.pwszVal = pDest;
+ dbv.cchVal = cbDest;
+ return currDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// setting data
MIR_CORE_DLL(INT_PTR) db_set(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
@@ -308,12 +329,10 @@ MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv)
MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, const char *szModule, const char *szSetting)
{
- if (currDb == NULL) return 1;
+ if (currDb == NULL)
+ return 1;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- return currDb->DeleteContactSetting(hContact, &cgs);
+ return currDb->DeleteContactSetting(hContact, szModule, szSetting);
}
MIR_CORE_DLL(HANDLE) db_find_first(const char *szProto)
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index e78ccb8ffa..6b0244e4db 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -245,3 +245,6 @@ IsWorkstationLocked @242
IsScreenSaverRunning @243
ProtoLogA @244
ProtoLogW @245
+db_get_static @246
+db_get_wstatic @247
+db_get_static_utf @248
diff --git a/src/modules/clist/contacts.cpp b/src/modules/clist/contacts.cpp
index 77e3145a0d..9385b2dc5e 100644
--- a/src/modules/clist/contacts.cpp
+++ b/src/modules/clist/contacts.cpp
@@ -47,7 +47,8 @@ static int GetDatabaseString(CONTACTINFO *ci, const char* setting, DBVARIANT* db
dbv->type = (ci->dwFlag & CNF_UNICODE) ? DBVT_WCHAR : DBVT_ASCIIZ;
int res = CallProtoService(ci->szProto, PS_GETINFOSETTING, (WPARAM)ci->hContact, (LPARAM)&cgs);
- if (res != CALLSERVICE_NOTFOUND) return res;
+ if (res != CALLSERVICE_NOTFOUND)
+ return res;
}
if (ci->dwFlag & CNF_UNICODE)
diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp
index 14e02c7430..a03ac5b97c 100644
--- a/src/modules/database/dbintf.cpp
+++ b/src/modules/database/dbintf.cpp
@@ -76,11 +76,6 @@ static INT_PTR srvEnumModuleNames(WPARAM wParam,LPARAM lParam)
///////////////////////////////////////////////////////////////////////////////
// Settings
-static INT_PTR srvGetContactSettingStatic(WPARAM wParam,LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->GetContactSettingStatic((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
-}
-
static INT_PTR srvEnumContactSettings(WPARAM wParam,LPARAM lParam)
{
return (currDb) ? (INT_PTR)currDb->EnumContactSettings((HANDLE)wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0;
@@ -152,7 +147,6 @@ int LoadDbintfModule()
CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames);
- CreateServiceFunction(MS_DB_CONTACT_GETSETTINGSTATIC, srvGetContactSettingStatic);
CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp
index 56080253dc..3841d1842f 100644
--- a/src/modules/protocols/protochains.cpp
+++ b/src/modules/protocols/protochains.cpp
@@ -44,12 +44,7 @@ static int GetProtocolP(HANDLE hContact, char *szBuf, int cbLen)
dbv.pszVal = szBuf;
dbv.cchVal = cbLen;
- DBCONTACTGETSETTING dbcgs;
- dbcgs.pValue = &dbv;
- dbcgs.szModule = "Protocol";
- dbcgs.szSetting = "p";
-
- int res = currDb->GetContactSettingStatic(hContact, &dbcgs);
+ int res = currDb->GetContactSettingStatic(hContact, "Protocol", "p", &dbv);
if (res == 0) {
if (cc == NULL)
cc = currDb->m_cache->AddContactToCache(hContact);