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 | |
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
49 files changed, 423 insertions, 598 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex 9d15f8b00a..10ac7e7513 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex fc0b9ba1e0..8f763d9797 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib Binary files differindex a03b92218a..d8c36ebb3d 100644 --- a/bin11/lib/mir_core.lib +++ b/bin11/lib/mir_core.lib diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib Binary files differindex 2751256dba..acf4e7cf28 100644 --- a/bin11/lib/mir_core64.lib +++ b/bin11/lib/mir_core64.lib diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib Binary files differindex a4f2061c84..2f6340a72c 100644 --- a/bin12/lib/mir_core.lib +++ b/bin12/lib/mir_core.lib diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib Binary files differindex cbe6abab7f..fa777946e7 100644 --- a/bin12/lib/mir_core64.lib +++ b/bin12/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index b02b09e61d..79bbe29b3f 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -280,6 +280,13 @@ function db_get_sa(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:p function db_get_wsa(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar):pWideChar; stdcall;
external CoreDLL name 'db_get_wsa';
+function db_get_static(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar; szDest:pAnsiChar; destLen:int):int; stdcall;
+ external CoreDLL name 'db_get_static';
+function db_get_static_utf(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar; szDest:pAnsiChar; destLen:int):int; stdcall;
+ external CoreDLL name 'db_get_static_utf';
+function db_get_wstatic(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar; szDest:pWideChar; destLen:int):int; stdcall;
+ external CoreDLL name 'db_get_wstatic';
+
function db_set(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall;
external CoreDLL name 'db_set';
function db_set_b(hContact:THANDLE; const szModule:pAnsiChar; const szSetting:pAnsiChar; val:byte):int_ptr; stdcall;
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index ce6b56ac6e..f02c506806 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -58,44 +58,25 @@ type value : TDBVARIANT; // variant containing value to set
end;
-const
-
{
- wParam : Handle for a contact to query a setting for
- lParam : Pointer to a TDBCONTACTGETSETTING structure
- affects: This service is almost the same as the one above, but it does
- not return a dynamic copy (with malloc()) -- the caller
- must do this for datatypes which require it, e.g. a string.
-
- This means the TDBCONTACTGETSETTING.pValue *has* to exist and be
- allocated by the caller (doesn't have to be allocated from the heap)
- the DBVARIANT structure has to be initalised with the type wanted
- and enough buffer space around to return the info, do not
- expect this service to be as fast as the one above.
-
- returns: 0 on success, non zero on failure.
+ wParam : Handle of a contact to enum settings for
+ lParam : Pointer to a TDBCONTACTENUMSETTINGS structure, must be initalised
+ affect : Enumerates all settings for a given contact under a module,
+ TDBCONTACTENUMSETTINGS must be filled with the function pointer to call
+ the TDBCONTACTENUMSETTINGS.lParam value to pass to it each time,
+ as well as the .szModule under which the contact is valid
+ returns: returns the value of the last call to the enum function, or -1
+ if no settings could be enumerated
+ notes : the szSetting argument passed to the enumeration function is only
+ valid for the duration of that enumeration call,
+ it must be allocated dynamically if it is required after that call frame
+ has returned.
+ Also, deleting settings as they are enumerated has unpredictable results!
+ but writing a new value for a setting is okay.
+ it is unclear how you stop the enumeration once it is started, maybe
+ possible to return -1 to stop it.
+ vesion : only valid for 0.1.0.1+
}
- MS_DB_CONTACT_GETSETTINGSTATIC:PAnsiChar = 'DB/Contact/GetSettingStatic';
-
- {
- wParam : Handle of a contact to enum settings for
- lParam : Pointer to a TDBCONTACTENUMSETTINGS structure, must be initalised
- affect : Enumerates all settings for a given contact under a module,
- TDBCONTACTENUMSETTINGS must be filled with the function pointer to call
- the TDBCONTACTENUMSETTINGS.lParam value to pass to it each time,
- as well as the .szModule under which the contact is valid
- returns: returns the value of the last call to the enum function, or -1
- if no settings could be enumerated
- notes : the szSetting argument passed to the enumeration function is only
- valid for the duration of that enumeration call,
- it must be allocated dynamically if it is required after that call frame
- has returned.
- Also, deleting settings as they are enumerated has unpredictable results!
- but writing a new value for a setting is okay.
- it is unclear how you stop the enumeration once it is started, maybe
- possible to return -1 to stop it.
- vesion : only valid for 0.1.0.1+
- }
type
TDBSETTINGENUMPROC = function(const szSetting: PAnsiChar; lParam: LPARAM): int; cdecl;
diff --git a/include/m_core.h b/include/m_core.h index c6c4368cb6..b6ef9ffb1d 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -284,47 +284,53 @@ MIR_CORE_DLL(HANDLE) db_event_prev(HANDLE hDbEvent); * DATABASE SETTINGS
*/
-MIR_CORE_DLL(INT_PTR) db_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
-MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue);
-MIR_CORE_DLL(int) db_get_w(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue);
-MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD errorValue);
-MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char *szSetting);
-MIR_CORE_DLL(WCHAR*) db_get_wsa(HANDLE hContact, const char *szModule, const char *szSetting);
+MIR_CORE_DLL(INT_PTR) db_get(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+MIR_CORE_DLL(int) db_get_b(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue);
+MIR_CORE_DLL(int) db_get_w(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue);
+MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue);
+MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
+MIR_CORE_DLL(WCHAR*) db_get_wsa(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
+
+MIR_CORE_DLL(int) db_get_static(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest);
+MIR_CORE_DLL(int) db_get_static_utf(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest);
+MIR_CORE_DLL(int) db_get_wstatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, WCHAR *pDest, int cbDest);
#if defined(__cplusplus)
- MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType=DBVT_ASCIIZ);
+ MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType=DBVT_ASCIIZ);
#else
- MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType);
+ MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType);
#endif
-MIR_CORE_DLL(INT_PTR) db_set(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
-MIR_CORE_DLL(INT_PTR) db_set_b(HANDLE hContact, const char *szModule, const char *szSetting, BYTE val);
-MIR_CORE_DLL(INT_PTR) db_set_w(HANDLE hContact, const char *szModule, const char *szSetting, WORD val);
-MIR_CORE_DLL(INT_PTR) db_set_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD val);
-MIR_CORE_DLL(INT_PTR) db_set_s(HANDLE hContact, const char *szModule, const char *szSetting, const char *val);
-MIR_CORE_DLL(INT_PTR) db_set_ws(HANDLE hContact, const char *szModule, const char *szSetting, const WCHAR *val);
-MIR_CORE_DLL(INT_PTR) db_set_utf(HANDLE hContact, const char *szModule, const char *szSetting, const char *val);
-MIR_CORE_DLL(INT_PTR) db_set_blob(HANDLE hContact, const char *szModule, const char *szSetting, void *val, unsigned len);
+MIR_CORE_DLL(INT_PTR) db_set(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+MIR_CORE_DLL(INT_PTR) db_set_b(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, BYTE val);
+MIR_CORE_DLL(INT_PTR) db_set_w(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, WORD val);
+MIR_CORE_DLL(INT_PTR) db_set_dw(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DWORD val);
+MIR_CORE_DLL(INT_PTR) db_set_s(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val);
+MIR_CORE_DLL(INT_PTR) db_set_ws(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, LPCWSTR val);
+MIR_CORE_DLL(INT_PTR) db_set_utf(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val);
+MIR_CORE_DLL(INT_PTR) db_set_blob(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, void *val, unsigned len);
-MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, const char *szModule, const char *szSetting);
+MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
#if defined(__cplusplus)
- MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable=TRUE);
+ MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable=TRUE);
#else
- MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable);
+ MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable);
#endif
-#define db_get_ws(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
-#define db_get_utf(a,b,c,d) db_get_s(a,b,c,d,DBVT_UTF8)
+#define db_get_ws(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
+#define db_get_utf(a,b,c,d) db_get_s(a,b,c,d,DBVT_UTF8)
#ifdef _UNICODE
- #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
- #define db_get_tsa db_get_wsa
- #define db_set_ts db_set_ws
+ #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
+ #define db_get_tsa db_get_wsa
+ #define db_set_ts db_set_ws
+ #define db_get_tstatic db_get_wstatic
#else
- #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_ASCIIZ)
- #define db_get_tsa db_get_sa
- #define db_set_ts db_set_s
+ #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_ASCIIZ)
+ #define db_get_tsa db_get_sa
+ #define db_set_ts db_set_s
+ #define db_get_tstatic db_get_static
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -380,10 +386,10 @@ MIR_CORE_DLL(void) KillObjectServices(void* pObject); #if defined(_STATIC)
__declspec(dllexport) INT_PTR CallContactService(HANDLE, const char *, WPARAM, LPARAM);
-__declspec(dllexport) INT_PTR CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+__declspec(dllexport) INT_PTR CallProtoService(LPCSTR szModule, const char *szService, WPARAM wParam, LPARAM lParam);
#else
MIR_C_CORE_DLL(INT_PTR) CallContactService(HANDLE, const char *, WPARAM, LPARAM);
-MIR_C_CORE_DLL(INT_PTR) CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+MIR_C_CORE_DLL(INT_PTR) CallProtoService(LPCSTR szModule, const char *szService, WPARAM wParam, LPARAM lParam);
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -603,9 +609,9 @@ MIR_CORE_DLL(int) mir_vsnwprintf(WCHAR *buffer, size_t count, const WCHAR* fm ///////////////////////////////////////////////////////////////////////////////
// protocol functions
-MIR_CORE_DLL(INT_PTR) ProtoCallService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
-MIR_CORE_DLL(int) ProtoServiceExists(const char *szModule, const char *szService);
-MIR_CORE_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+MIR_CORE_DLL(INT_PTR) ProtoCallService(LPCSTR szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(int) ProtoServiceExists(LPCSTR szModule, const char *szService);
+MIR_CORE_DLL(INT_PTR) ProtoBroadcastAck(LPCSTR szModule, HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
// Call it in the very beginning of your proto's constructor
MIR_CORE_DLL(void) ProtoConstructor(struct PROTO_INTERFACE *pThis, const char *pszModuleName, const TCHAR *ptszUserName);
diff --git a/include/m_database.h b/include/m_database.h index d017bd1cd4..b69663387e 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -155,33 +155,6 @@ typedef struct { DBVARIANT value; // variant containing the value to set
} DBCONTACTWRITESETTING;
-/* DB/Contact/GetSettingStatic service
-Look up the value of a named setting for a specific contact in the database
- wParam = (WPARAM)(HANDLE)hContact
- lParam = (LPARAM)(DBCONTACTGETSETTING*)&dbcgs
-hContact should have been returned by find*contact or addcontact
-This service differs from db/contact/getsetting in that it won't malloc()
-memory for the return value if it needs to do so. This introduces some extra
-constraints:
-Upon calling dbcgs.pValue->type should be initialised to the expected type of
-the setting. If the setting is of an integral type it won't matter if it's
-wrong and the service will correct it before returning, however if the setting
-is a string or a blob the service needs to know where to put the data and will
-fail if type is set wrongly.
-If dbcgs.pValue->type is DBVT_ASCIIZ or DBVT_BLOB upon calling, the
-corresponding data field (pszVal or pbVal) must point to a buffer allocated by
-the caller and the length field (cchVal or cpbVal) must contain the size of
-that buffer in bytes.
-If the setting type is variable length (DBVT_ASCIIZ or DBVT_BLOB), on exit the
-length field (cchVal or cpbVal) will be filled with the full length of the
-setting's value (excluding the terminating nul if it's DBVT_ASCIIZ).
-This service exists as well as db/contact/getsetting because malloc()/free()
-can be too slow for frequently queried settings.
-Returns 0 on success or nonzero if the setting name was not found or hContact
-was invalid.
-*/
-#define MS_DB_CONTACT_GETSETTINGSTATIC "DB/Contact/GetSettingStatic"
-
/* db/contact/enumsettings v0.1.0.1+
Lists all the settings a specific modules has stored in the database for a
specific contact.
diff --git a/include/m_db_int.h b/include/m_db_int.h index dbaaa77076..8d7adfa9b6 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -94,12 +94,12 @@ interface MIDatabase STDMETHOD_(BOOL,EnumModuleNames)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
- STDMETHOD_(BOOL,GetContactSetting)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
- STDMETHOD_(BOOL,GetContactSettingStr)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
- STDMETHOD_(BOOL,GetContactSettingStatic)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,GetContactSetting)(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE;
+ STDMETHOD_(BOOL,GetContactSettingStr)(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE;
+ STDMETHOD_(BOOL,GetContactSettingStatic)(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE;
STDMETHOD_(BOOL,FreeVariant)(DBVARIANT *dbv) PURE;
STDMETHOD_(BOOL,WriteContactSetting)(HANDLE hContact, DBCONTACTWRITESETTING *dbcws) PURE;
- STDMETHOD_(BOOL,DeleteContactSetting)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,DeleteContactSetting)(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting) PURE;
STDMETHOD_(BOOL,EnumContactSettings)(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces) PURE;
STDMETHOD_(BOOL,SetSettingResident)(BOOL bIsResident, const char *pszSettingName) PURE;
STDMETHOD_(BOOL,EnumResidentSettings)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
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
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp index 1cb4a3aa88..51a0cf5ddd 100644 --- a/protocols/GTalkExt/src/inbox.cpp +++ b/protocols/GTalkExt/src/inbox.cpp @@ -158,19 +158,10 @@ void OpenUrlThread(void *param) int GetMailboxPwd(LPCSTR acc, LPCTSTR mailbox, LPSTR *pwd, int buffSize)
{
char buff[256];
-
- DBCONTACTGETSETTING cgs;
- DBVARIANT dbv;
- cgs.szModule = acc;
- cgs.szSetting = LOGIN_PASS_SETTING_NAME;
- cgs.pValue = &dbv;
- dbv.type = DBVT_ASCIIZ;
- dbv.pszVal = &buff[0];
- dbv.cchVal = sizeof(buff);
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, 0, (LPARAM)&cgs))
+ if (db_get_static(NULL, acc, LOGIN_PASS_SETTING_NAME, buff, sizeof(buff)))
return 0;
- int result = dbv.cchVal;
+ int result = (int)strlen(buff);
if (pwd) {
if (buffSize < result + 1)
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp index ecf76ebfc4..8841ce24fc 100644 --- a/protocols/IcqOscarJ/src/icq_db.cpp +++ b/protocols/IcqOscarJ/src/icq_db.cpp @@ -107,27 +107,10 @@ WORD CIcqProto::getContactStatus(HANDLE hContact) int CIcqProto::getSettingStringStatic(HANDLE hContact, const char *szSetting, char *dest, int dest_len)
{
- DBVARIANT dbv = {DBVT_DELETED};
- DBCONTACTGETSETTING sVal = {0};
-
- dbv.pszVal = dest;
- dbv.cchVal = dest_len;
- dbv.type = DBVT_ASCIIZ;
-
- sVal.pValue = &dbv;
- sVal.szModule = m_szModuleName;
- sVal.szSetting = szSetting;
-
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&sVal) != 0) {
- dbv.pszVal = dest;
- dbv.cchVal = dest_len;
- dbv.type = DBVT_UTF8;
-
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&sVal) != 0)
- return 1; // nothing found
- }
+ if (!db_get_static(hContact, m_szModuleName, szSetting, dest, dest_len))
+ return 0;
- return (dbv.type != DBVT_ASCIIZ);
+ return db_get_static_utf(hContact, m_szModuleName, szSetting, dest, dest_len);
}
int CIcqProto::setSettingDouble(HANDLE hContact, const char *szSetting, double dValue)
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 44e6ef480e..5eac04a78b 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -930,28 +930,10 @@ static int GroupReserveIdsEnumProc(const char *szSetting,LPARAM lParam) // it is probably server group
GroupReserveIdsEnumParam *param = (GroupReserveIdsEnumParam*)lParam;
char val[MAX_PATH+2]; // dummy
-
- DBVARIANT dbv = {DBVT_DELETED};
- dbv.type = DBVT_ASCIIZ;
- dbv.pszVal = val;
- dbv.cchVal = MAX_PATH;
-
- DBCONTACTGETSETTING cgs;
- cgs.szModule = param->szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC,0,(LPARAM)&cgs))
- { // we failed to read setting, try also utf8 - DB bug
- dbv.type = DBVT_UTF8;
- dbv.pszVal = val;
- dbv.cchVal = MAX_PATH;
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC,0,(LPARAM)&cgs))
+ if (db_get_static(0, param->szModule, szSetting, val, MAX_PATH))
+ if (db_get_static_utf(0, param->szModule, szSetting, val, MAX_PATH))
return 0; // we failed also, invalid setting
- }
- if (dbv.type != DBVT_ASCIIZ)
- { // it is not a cached server-group name
- return 0;
- }
+
param->ppro->ReserveServerID((WORD)strtoul(szSetting, NULL, 0x10), SSIT_GROUP, 0);
#ifdef _DEBUG
param->ppro->debugLogA("Loaded group %u:'%s'", strtoul(szSetting, NULL, 0x10), val);
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index 01e7b14f6b..7b4aa7d4ba 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -148,25 +148,12 @@ static void GetLastUploadLogLine(HWND hwndDlg, char *szBuf, size_t cbBuf) static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam)
{
- if (szSetting && strlennull(szSetting)<5)
- { // it is probably server group
+ // it is probably server group
+ if (szSetting && strlennull(szSetting) < 5) {
char val[MAX_PATH+2]; // dummy
- DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
-
- dbv.type = DBVT_ASCIIZ;
- dbv.pszVal = val;
- dbv.cchVal = MAX_PATH;
-
- cgs.szModule=(char*)lParam;
- cgs.szSetting=szSetting;
- cgs.pValue=&dbv;
- if(CallService(MS_DB_CONTACT_GETSETTINGSTATIC,0,(LPARAM)&cgs))
+ if (db_get_static(NULL, (char*)lParam, szSetting, val, MAX_PATH))
return 0; // this converts all string types to DBVT_ASCIIZ
- if(dbv.type!=DBVT_ASCIIZ)
- { // it is not a cached server-group name
- return 0;
- }
+
pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds+1)*sizeof(WORD));
pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, NULL, 0x10);
cbGroupIds++;
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 50fa33305d..9474b71dfc 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -134,7 +134,7 @@ int CMsnProto::MSN_GetPassportAuth(void) int retVal = -1;
char szPassword[100];
- getStaticString(NULL, "Password", szPassword, sizeof(szPassword));
+ db_get_static(NULL, m_szModuleName, "Password", szPassword, sizeof(szPassword));
szPassword[16] = 0;
char* szEncPassword = HtmlEncode(szPassword);
@@ -156,7 +156,7 @@ int CMsnProto::MSN_GetPassportAuth(void) mir_free(szEncPassword);
char* szPassportHost = (char*)mir_alloc(256);
- if (getStaticString(NULL, "MsnPassportHost", szPassportHost, 256))
+ if (db_get_static(NULL, m_szModuleName, "MsnPassportHost", szPassportHost, 256))
strcpy(szPassportHost, defaultPassportUrl);
bool defaultUrlAllow = strcmp(szPassportHost, defaultPassportUrl) != 0;
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index bd5ce999d9..9701adc096 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -1250,12 +1250,12 @@ LBL_InvalidCommand: if (hContact != NULL) {
char szSavedHash[64] = "";
- getStaticString(hContact, "AvatarSavedHash", szSavedHash, sizeof(szSavedHash));
+ db_get_static(hContact, m_szModuleName, "AvatarSavedHash", szSavedHash, sizeof(szSavedHash));
if (stricmp(szSavedHash, pszAvatarHash))
pushAvatarRequest(hContact, pszUrl);
else {
char szSavedContext[64];
- int result = getStaticString(hContact, "PictSavedContext", szSavedContext, sizeof(szSavedContext));
+ int result = db_get_static(hContact, m_szModuleName, "PictSavedContext", szSavedContext, sizeof(szSavedContext));
if (result || strcmp(szSavedContext, data.cmdstring))
pushAvatarRequest(hContact, pszUrl);
}
diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index 132b73c8ae..3412165ef1 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -142,7 +142,7 @@ bool CMsnProto::MSN_AddUser(HANDLE hContact, const char* email, int netId, int f }
char id[MSN_GUID_LEN];
- if (!getStaticString(hContact, "ID", id, sizeof(id)))
+ if (!db_get_static(hContact, m_szModuleName, "ID", id, sizeof(id)))
{
int netId = Lists_GetNetId(email);
if (leaveHotmail)
@@ -172,7 +172,7 @@ bool CMsnProto::MSN_AddUser(HANDLE hContact, const char* email, int netId, int f {
char szContactID[100];
hContact = MSN_HContactFromEmail(email);
- if (getStaticString(hContact, "ID", szContactID, sizeof(szContactID)) == 0)
+ if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0)
{
MSN_ABAddRemoveContact(szContactID, netId, true);
res = true;
@@ -192,10 +192,8 @@ bool CMsnProto::MSN_AddUser(HANDLE hContact, const char* email, int netId, int f }
char szContactID[100];
- if (getStaticString(hContact, "ID", szContactID, sizeof(szContactID)) == 0)
- {
+ if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0)
MSN_ABFind("ABFindByContacts", szContactID);
- }
MSN_SharingFindMembership(true);
AddDelUserContList(email, flags, netId, false);
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index ad4098edd6..1a5d372fce 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -242,8 +242,8 @@ void CMsnProto::Lists_Populate(void) while (hContact) {
HANDLE hNext = db_find_next(hContact, m_szModuleName);
char szEmail[MSN_MAX_EMAIL_LEN] = "";
- if (getStaticString(hContact, "wlid", szEmail, sizeof(szEmail)))
- getStaticString(hContact, "e-mail", szEmail, sizeof(szEmail));
+ if (db_get_static(hContact, m_szModuleName, "wlid", szEmail, sizeof(szEmail)))
+ db_get_static(hContact, m_szModuleName, "e-mail", szEmail, sizeof(szEmail));
if (szEmail[0]) {
bool localList = getByte(hContact, "LocalList", 0) != 0;
if (localList)
@@ -447,7 +447,7 @@ static void SetContactIcons(HANDLE hItem, HWND hwndList, CMsnProto* proto) }
char szEmail[MSN_MAX_EMAIL_LEN];
- if (proto->getStaticString(hItem, "e-mail", szEmail, sizeof(szEmail))) {
+ if (db_get_static(hItem, proto->m_szModuleName, "e-mail", szEmail, sizeof(szEmail))) {
SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
return;
}
@@ -521,7 +521,7 @@ static void SaveSettings(HANDLE hItem, HWND hwndList, CMsnProto* proto) if (IsHContactContact(hItem))
{
- if (proto->getStaticString(hItem, "e-mail", szEmail, sizeof(szEmail))) continue;
+ if (db_get_static(hItem, proto->m_szModuleName, "e-mail", szEmail, sizeof(szEmail))) continue;
}
else if (IsHContactInfo(hItem))
{
diff --git a/protocols/MSN/src/msn_mail.cpp b/protocols/MSN/src/msn_mail.cpp index e095eb8856..180d3e77a3 100644 --- a/protocols/MSN/src/msn_mail.cpp +++ b/protocols/MSN/src/msn_mail.cpp @@ -345,7 +345,7 @@ void CMsnProto::sttNotificationMessage(char* msgBody, bool isInitial) return;
char mailerpath[MAX_PATH];
- if (!getStaticString(NULL, "MailerPath", mailerpath, sizeof(mailerpath)))
+ if (!db_get_static(NULL, m_szModuleName, "MailerPath", mailerpath, sizeof(mailerpath)))
{
if (mailerpath[0])
{
diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index 3bff6fdec8..76e2e9f784 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -37,7 +37,7 @@ INT_PTR CMsnProto::MsnBlockCommand(WPARAM wParam, LPARAM) const HANDLE hContact = (HANDLE)wParam;
char tEmail[MSN_MAX_EMAIL_LEN];
- getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail));
+ db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail));
if (Lists_IsInList(LIST_BL, tEmail))
delSetting(hContact, "ApparentMode");
@@ -94,7 +94,7 @@ INT_PTR CMsnProto::MsnViewProfile(WPARAM wParam, LPARAM) else
{
cid = buf;
- if (getStaticString(hContact, "CID", buf, 30))
+ if (db_get_static(hContact, m_szModuleName, "CID", buf, 30))
return 0;
}
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 0d568107f6..f774da7cde 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -305,7 +305,7 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen) _close(fileId);
char szAvatarHashdOld[41] = "";
- getStaticString(NULL, "AvatarHash", szAvatarHashdOld, sizeof(szAvatarHashdOld));
+ db_get_static(NULL, m_szModuleName, "AvatarHash", szAvatarHashdOld, sizeof(szAvatarHashdOld));
char *szAvatarHash = arrayToHex(sha1d, sizeof(sha1d));
if (strcmp(szAvatarHashdOld, szAvatarHash)) {
setString("PictObject", szEncodedBuffer);
@@ -786,7 +786,7 @@ void CMsnProto::MsnInvokeMyURL(bool ismail, const char* url) const char *postdata = ismail ? postdataM : postdataS;
char passport[256];
- if (getStaticString(NULL, "MsnPassportHost", passport, 256))
+ if (db_get_static(NULL, m_szModuleName, "MsnPassportHost", passport, 256))
strcpy(passport, "https://login.live.com/");
char *p = strchr(passport, '/');
@@ -1206,7 +1206,7 @@ bool CMsnProto::MSN_IsMeByContact(HANDLE hContact, char* szEmail) char *emailPtr = szEmail ? szEmail : tEmail;
*emailPtr = 0;
- if (getStaticString(hContact, "e-mail", emailPtr, sizeof(tEmail)))
+ if (db_get_static(hContact, m_szModuleName, "e-mail", emailPtr, sizeof(tEmail)))
return false;
return _stricmp(emailPtr, MyOptions.szEmail) == 0;
diff --git a/protocols/MSN/src/msn_natdetect.cpp b/protocols/MSN/src/msn_natdetect.cpp index 60a47a0895..c6569ff817 100644 --- a/protocols/MSN/src/msn_natdetect.cpp +++ b/protocols/MSN/src/msn_natdetect.cpp @@ -385,7 +385,7 @@ void CMsnProto::MSNConnDetectThread( void* ) // User specified host by himself so check if it matches MSN information
// if it does, move to connection type autodetection,
// if it does not, guess connection type from available info
- getStaticString(NULL, "YourHost", parBuf, sizeof(parBuf));
+ db_get_static(NULL, m_szModuleName, "YourHost", parBuf, sizeof(parBuf));
if (msnExternalIP == NULL || strcmp(msnExternalIP, parBuf) != 0)
{
MyConnection.extIP = inet_addr(parBuf);
diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 79139c3b23..26aa551c2d 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -90,7 +90,7 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);
char tBuffer[MAX_PATH];
- if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer))) {
+ if (!db_get_static(NULL, proto->m_szModuleName, "Password", tBuffer, sizeof(tBuffer))) {
tBuffer[16] = 0;
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
}
@@ -115,7 +115,7 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tValue);
EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tValue);
- if (!proto->getStaticString(NULL, "MailerPath", tBuffer, sizeof(tBuffer)))
+ if (!db_get_static(NULL, proto->m_szModuleName, "MailerPath", tBuffer, sizeof(tBuffer)))
SetDlgItemTextA(hwndDlg, IDC_MAILER_APP, tBuffer);
if (!proto->msnLoggedIn) {
@@ -328,7 +328,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam char ipaddr[256] = "";
if (gethst == 1)
- if (proto->getStaticString(NULL, "YourHost", ipaddr, sizeof(ipaddr)))
+ if (db_get_static(NULL, proto->m_szModuleName, "YourHost", ipaddr, sizeof(ipaddr)))
gethst = 0;
if (gethst == 0)
@@ -516,7 +516,7 @@ static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, L SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);
char tBuffer[MAX_PATH];
- if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer))) {
+ if (!db_get_static(NULL, proto->m_szModuleName, "Password", tBuffer, sizeof(tBuffer))) {
tBuffer[16] = 0;
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
}
@@ -601,7 +601,7 @@ INT_PTR CALLBACK DlgDeleteContactUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA DeleteParam *param = (DeleteParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
char szEmail[MSN_MAX_EMAIL_LEN];
- if (!param->proto->getStaticString(param->hContact, "e-mail", szEmail, sizeof(szEmail))) {
+ if (!db_get_static(param->hContact, param->proto->m_szModuleName, "e-mail", szEmail, sizeof(szEmail))) {
param->proto->MSN_AddUser(param->hContact, szEmail, 0, LIST_FL | (isHot ? LIST_REMOVE : LIST_REMOVENH));
if (isBlock) {
param->proto->MSN_AddUser(param->hContact, szEmail, 0, LIST_AL | LIST_REMOVE);
@@ -669,11 +669,11 @@ void CMsnProto::LoadOptions(void) MyOptions.ManageServer = getByte("ManageServer", TRUE) != 0;
MyOptions.ShowErrorsAsPopups = getByte("ShowErrorsAsPopups", TRUE) != 0;
MyOptions.SlowSend = getByte("SlowSend", FALSE) != 0;
- if (getStaticString(NULL, "e-mail", MyOptions.szEmail, sizeof(MyOptions.szEmail)))
+ if (db_get_static(NULL, m_szModuleName, "e-mail", MyOptions.szEmail, sizeof(MyOptions.szEmail)))
MyOptions.szEmail[0] = 0;
_strlwr(MyOptions.szEmail);
- if (getStaticString(NULL, "MachineGuid", MyOptions.szMachineGuid, sizeof(MyOptions.szMachineGuid))) {
+ if (db_get_static(NULL, m_szModuleName, "MachineGuid", MyOptions.szMachineGuid, sizeof(MyOptions.szMachineGuid))) {
char* uuid = getNewUuid();
strcpy(MyOptions.szMachineGuid, uuid);
setString("MachineGuid", MyOptions.szMachineGuid);
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 46e40adbef..d6f7fbef5c 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -90,7 +90,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : delSetting("MobileAllowed");
char path[MAX_PATH];
- if (getStaticString(NULL, "LoginServer", path, sizeof(path)) == 0 &&
+ if (db_get_static(NULL, m_szModuleName, "LoginServer", path, sizeof(path)) == 0 &&
(strcmp(path, MSN_DEFAULT_LOGIN_SERVER) == 0 ||
strcmp(path, MSN_DEFAULT_GATEWAY) == 0))
delSetting("LoginServer");
@@ -291,7 +291,7 @@ int __cdecl CMsnProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) if (msnLoggedIn)
{
char email[MSN_MAX_EMAIL_LEN];
- if (getStaticString(hContact, "e-mail", email, sizeof(email)))
+ if (db_get_static(hContact, m_szModuleName, "e-mail", email, sizeof(email)))
return 1;
char* szMsg = mir_utf8encodeT(szMessage);
@@ -746,7 +746,7 @@ int __cdecl CMsnProto::RecvFile(HANDLE hContact, PROTOFILEEVENT* evt) int __cdecl CMsnProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre)
{
char tEmail[MSN_MAX_EMAIL_LEN];
- getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail));
+ db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail));
if (Lists_IsInList(LIST_FL, tEmail))
db_unset(hContact, "CList", "Hidden");
@@ -1025,7 +1025,7 @@ int __cdecl CMsnProto::SetStatus(int iNewStatus) else if (!msnLoggedIn && m_iStatus == ID_STATUS_OFFLINE)
{
char szPassword[100];
- int ps = getStaticString(NULL, "Password", szPassword, sizeof(szPassword));
+ int ps = db_get_static(NULL, m_szModuleName, "Password", szPassword, sizeof(szPassword));
if (ps != 0 || *szPassword == 0)
{
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index d738dca64c..8d95a7e76d 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -562,7 +562,6 @@ struct CMsnProto : public PROTO<CMsnProto> TCHAR* GetContactNameT(HANDLE hContact);
- int getStaticString(HANDLE hContact, const char* valueName, char* dest, unsigned dest_len);
int getStringUtf(HANDLE hContact, const char* name, DBVARIANT* result);
int getStringUtf(const char* name, DBVARIANT* result);
void setStringUtf(HANDLE hContact, const char* name, const char* value);
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp index d602d6d96d..10f22e1df1 100644 --- a/protocols/MSN/src/msn_soapab.cpp +++ b/protocols/MSN/src/msn_soapab.cpp @@ -123,7 +123,7 @@ char* CMsnProto::GetABHost(const char* service, bool isSharing) mir_snprintf(hostname, sizeof(hostname), "ABHost-%s", service);
char* host = (char*)mir_alloc(256);
- if (getStaticString(NULL, hostname, host, 256))
+ if (db_get_static(NULL, m_szModuleName, hostname, host, 256))
{
mir_snprintf(host, 256, "https://byrdr.omega.contacts.msn.com/abservice/%s.asmx",
isSharing ? "SharingService" : "abservice");
diff --git a/protocols/MSN/src/msn_soapstore.cpp b/protocols/MSN/src/msn_soapstore.cpp index bc947a30ca..0edbe6b9b0 100644 --- a/protocols/MSN/src/msn_soapstore.cpp +++ b/protocols/MSN/src/msn_soapstore.cpp @@ -75,7 +75,7 @@ char* CMsnProto::GetStoreHost(const char* service) mir_snprintf(hostname, sizeof(hostname), "StoreHost-%s", service);
char* host = (char*)mir_alloc(256);
- if (getStaticString(NULL, hostname, host, 256))
+ if (db_get_static(NULL, m_szModuleName, hostname, host, 256))
strcpy(host, "https://tkrdr.storage.msn.com/storageservice/SchematizedStore.asmx");
return host;
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp index c77d2e8997..bf86fc1706 100644 --- a/protocols/MSN/src/msn_srv.cpp +++ b/protocols/MSN/src/msn_srv.cpp @@ -74,7 +74,7 @@ void CMsnProto::MSN_DeleteServerGroup(LPCSTR szId) if (msc == NULL) break;
char szGroupID[100];
- if (!getStaticString(msc->hContact, "GroupID", szGroupID, sizeof(szGroupID)))
+ if (!db_get_static(msc->hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID)))
{
if (strcmp(szGroupID, szId) == 0)
delSetting(msc->hContact, "GroupID");
@@ -139,10 +139,10 @@ void CMsnProto::MSN_MoveContactToGroup(HANDLE hContact, const char* grpName) LPCSTR szId = NULL;
char szContactID[100], szGroupID[100];
- if (getStaticString(hContact, "ID", szContactID, sizeof(szContactID)))
+ if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)))
return;
- if (getStaticString(hContact, "GroupID", szGroupID, sizeof(szGroupID)))
+ if (db_get_static(hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID)))
szGroupID[0] = 0;
bool bInsert = false, bDelete = szGroupID[0] != 0;
@@ -194,7 +194,7 @@ void CMsnProto::MSN_RemoveEmptyGroups(void) if (msc == NULL) break;
char szGroupID[100];
- if (!getStaticString(msc->hContact, "GroupID", szGroupID, sizeof(szGroupID)))
+ if (!db_get_static(msc->hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID)))
{
const char *pId = szGroupID;
int i = grpList.getIndex((ServerGroupItem*)&pId);
@@ -237,7 +237,7 @@ void CMsnProto::MSN_UploadServerGroups(char* group) {
char szGroupID[100];
if (group == NULL || (strcmp(group, dbv.pszVal) == 0 &&
- getStaticString(msc->hContact, "GroupID", szGroupID, sizeof(szGroupID)) != 0))
+ db_get_static(msc->hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID)) != 0))
{
MSN_MoveContactToGroup(msc->hContact, dbv.pszVal);
}
diff --git a/protocols/MSN/src/msn_std.cpp b/protocols/MSN/src/msn_std.cpp index 2917b8e05b..3816e2035e 100644 --- a/protocols/MSN/src/msn_std.cpp +++ b/protocols/MSN/src/msn_std.cpp @@ -34,23 +34,6 @@ int CMsnProto::getStringUtf(const char* name, DBVARIANT* result) { return db_get_utf(NULL, m_szModuleName, name, result);
}
-int CMsnProto::getStaticString(HANDLE hContact, const char* valueName, char* dest, unsigned dest_len)
-{
- DBVARIANT dbv;
- dbv.pszVal = dest;
- dbv.cchVal = (WORD)dest_len;
- dbv.type = DBVT_ASCIIZ;
-
- DBCONTACTGETSETTING sVal;
- sVal.pValue = &dbv;
- sVal.szModule = m_szModuleName;
- sVal.szSetting = valueName;
- if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&sVal) != 0)
- return 1;
-
- return (dbv.type != DBVT_ASCIIZ);
-}
-
void CMsnProto::setStringUtf(HANDLE hContact, const char* name, const char* value)
{ db_set_utf(hContact, m_szModuleName, name, value);
}
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 518fd045a3..5ed7d2f7b3 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -480,7 +480,7 @@ int CMsnProto::OnDbSettingChanged(WPARAM wParam,LPARAM lParam) if (!strcmp(cws->szSetting, "ApparentMode"))
{
char tEmail[MSN_MAX_EMAIL_LEN];
- if (!getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)))
+ if (!db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail)))
{
bool isBlocked = Lists_IsInList(LIST_BL, tEmail);
@@ -503,7 +503,7 @@ int CMsnProto::OnDbSettingChanged(WPARAM wParam,LPARAM lParam) if (!isMe || !nickChg)
{
char szContactID[100];
- if (!getStaticString(hContact, "ID", szContactID, sizeof(szContactID)))
+ if (!db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)))
{
if (cws->value.type != DBVT_DELETED)
{
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index 41c67ad031..a7f3027cbe 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -100,13 +100,13 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) strcpy(info->mGatewayIP, info->mServer);
else
{
- if (info->mGatewayIP[0] == 0 && getStaticString(NULL, "GatewayServer", info->mGatewayIP, sizeof(info->mGatewayIP)))
+ if (info->mGatewayIP[0] == 0 && db_get_static(NULL, m_szModuleName, "GatewayServer", info->mGatewayIP, sizeof(info->mGatewayIP)))
strcpy(info->mGatewayIP, MSN_DEFAULT_GATEWAY);
}
}
else
{
- if (info->mServer[0] == 0 && getStaticString(NULL, "DirectServer", info->mServer, sizeof(info->mServer)))
+ if (info->mServer[0] == 0 && db_get_static(NULL, m_szModuleName, "DirectServer", info->mServer, sizeof(info->mServer)))
strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
}
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);
|