From de5dce707cc60ace5b92d2ac61914c590cb9680b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 29 Jun 2013 18:16:23 +0000 Subject: rest of unused databases services removed git-svn-id: http://svn.miranda-ng.org/main/trunk@5181 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Actman/i_contact.inc | 4 +- plugins/Alarms/src/alarmlist.cpp | 10 +- plugins/AssocMgr/src/reg.cpp | 8 +- .../ClientChangeNotify/src/CommonLibs/CString.cpp | 75 ++------ .../ClientChangeNotify/src/CommonLibs/Options.cpp | 11 +- plugins/DbEditorPP/src/main.cpp | 7 +- plugins/ExternalAPI/m_userinfoex.h | 8 +- plugins/HistoryPlusPlus/PassForm.pas | 4 +- plugins/HistoryPlusPlus/hpp_contacts.pas | 6 +- plugins/HistoryPlusPlus/hpp_database.pas | 31 +--- plugins/HistoryPlusPlus/hpp_searchthread.pas | 12 +- .../src/historysweeperlight.cpp | 9 +- plugins/ImportTXT/General.pas | 28 +-- plugins/MenuItemEx/src/main.cpp | 9 +- plugins/MetaContacts/src/meta_utils.cpp | 9 +- plugins/MirFox/src/MirandaUtils.cpp | 2 +- plugins/MirandaNGHistoryToDB/Contacts.pas | 6 +- plugins/MirandaNGHistoryToDB/Database.pas | 31 +--- plugins/MirandaNGHistoryToDB/Menu.pas | 4 +- plugins/MirandaNGHistoryToDB/MsgExport.pas | 4 +- plugins/New_GPG/src/utilities.cpp | 109 +++++------ plugins/NotesAndReminders/src/miscutils.cpp | 8 +- plugins/Popup/src/common.h | 47 ++--- plugins/Quotes/src/DBUtils.cpp | 10 +- plugins/Quotes/src/ImportExport.cpp | 10 +- plugins/Quotes/src/QuoteInfoDlg.cpp | 10 +- .../Quotes/src/QuotesProviderVisitorFormater.cpp | 10 +- plugins/SMS/src/functions.cpp | 8 +- plugins/ShlExt/shlcom.pas | 16 +- plugins/ShlExt/shlext.dpr | 30 +--- plugins/SpellChecker/src/utils.cpp | 2 +- plugins/TooltipNotify/src/DbHelpers.cpp | 12 +- plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp | 18 +- plugins/UserInfoEx/src/mir_db.cpp | 10 +- plugins/Utils.pas/contact.pas | 6 +- plugins/Utils.pas/dbsettings.pas | 199 +-------------------- plugins/Utils.pas/mirutils.pas | 41 ++--- plugins/Utils.pas/protocols.pas | 6 +- plugins/XSoundNotify/src/xsn_main.cpp | 6 +- plugins/YARelay/src/main.cpp | 2 +- 40 files changed, 179 insertions(+), 659 deletions(-) (limited to 'plugins') diff --git a/plugins/Actman/i_contact.inc b/plugins/Actman/i_contact.inc index f73325121e..c73df31435 100644 --- a/plugins/Actman/i_contact.inc +++ b/plugins/Actman/i_contact.inc @@ -19,7 +19,7 @@ begin if format=nil then format:=defformat; SendMessage(list,CB_RESETCONTENT,0,0); - hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact:=db_find_first(); lName :=StrPosW(format,'%name%')<>nil; lGroup :=StrPosW(format,'%group%')<>nil; @@ -92,7 +92,7 @@ begin SendMessageW(list,CB_ADDSTRING,0,tlparam(@buf)), hContact); end; - hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0); + hContact:=db_find_next(hContact); end; end; diff --git a/plugins/Alarms/src/alarmlist.cpp b/plugins/Alarms/src/alarmlist.cpp index 73fa940a61..ffd15809ee 100644 --- a/plugins/Alarms/src/alarmlist.cpp +++ b/plugins/Alarms/src/alarmlist.cpp @@ -681,20 +681,14 @@ void InitList() SkinAddNewSoundEx("Triggered3", LPGEN("Alarms"), LPGEN("Alert 3")); // load last checked time - DBCONTACTGETSETTING dbcgs; DBVARIANT dbv; - dbcgs.szModule = MODULE; - dbcgs.szSetting = "LastCheck"; - dbcgs.pValue = &dbv; dbv.type = DBVT_BLOB; dbv.cpbVal = sizeof(SYSTEMTIME); - - if (!CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs)) { + if (!db_get(NULL, MODULE, "LastCheck", &dbv)) { memcpy(&last_check, dbv.pbVal, sizeof(SYSTEMTIME)); db_free(&dbv); - } else { - GetLocalTime(&last_check); } + else GetLocalTime(&last_check); last_saved_check = last_check; diff --git a/plugins/AssocMgr/src/reg.cpp b/plugins/AssocMgr/src/reg.cpp index a34b02918a..143b262533 100644 --- a/plugins/AssocMgr/src/reg.cpp +++ b/plugins/AssocMgr/src/reg.cpp @@ -357,12 +357,8 @@ static void WriteDbBackupData(const char *pszSetting,DWORD dwType,BYTE *pData,DW // mir_free() the value returned in ppData static BOOL ReadDbBackupData(const char *pszSetting,DWORD *pdwType,BYTE **ppData,DWORD *pcbData) { - DBCONTACTGETSETTING dbcgs; DBVARIANT dbv; - dbcgs.szModule="AssocMgr"; - dbcgs.szSetting=pszSetting; - dbcgs.pValue=&dbv; - if (!CallService(MS_DB_CONTACT_GETSETTING,0,(LPARAM)&dbcgs)) { + if (!db_get(0, "AssocMgr", pszSetting, &dbv)) { if (dbv.type==DBVT_BLOB && dbv.cpbVal>=sizeof(DWORD)) { *pdwType=*(DWORD*)dbv.pbVal; *ppData=dbv.pbVal; @@ -370,7 +366,7 @@ static BOOL ReadDbBackupData(const char *pszSetting,DWORD *pdwType,BYTE **ppData MoveMemory(*ppData,*ppData+sizeof(DWORD),*pcbData); return TRUE; } - CallService(MS_DB_CONTACT_FREEVARIANT,0,(LPARAM)&dbv); + db_free(&dbv); } return FALSE; } diff --git a/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp b/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp index fde5e4dc2a..b36076eec8 100644 --- a/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp +++ b/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp @@ -288,89 +288,36 @@ template class TString; CString db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, const char *szDefaultValue) { - DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs; - dbcgs.szModule = szModule; - dbcgs.pValue = &dbv; - dbcgs.szSetting = szSetting; - int iRes = CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); - CString Result; - if (!iRes && dbv.type == DBVT_ASCIIZ) - { - Result = dbv.pszVal; - } else - { - Result = szDefaultValue; - } - if (!iRes) - { - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); - } - return Result; + ptrA p( db_get_sa(hContact, szModule, szSetting)); + return CString(p == NULL ? szDefaultValue : p); } - - TCString db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue) { - DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs; - dbcgs.szModule = szModule; - dbcgs.pValue = &dbv; - dbcgs.szSetting = szSetting; - dbv.type = DBVT_WCHAR; - int iRes = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&dbcgs); - TCString Result; - if (!iRes && dbv.type == DBVT_WCHAR) - { - Result = dbv.ptszVal; - } else - { - Result = szDefaultValue; - } - if (!iRes) - { - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); - } - return Result; + ptrT p( db_get_tsa(hContact, szModule, szSetting)); + return TCString(p == NULL ? szDefaultValue : p); } - - -int db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) -{ - return db_get_s(hContact, szModule, szSetting, dbv, DBVT_ASCIIZ); -} - - - TCString DBGetContactSettingAsString(HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue) { // also converts numeric values to a string DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs; - dbcgs.szModule = szModule; - dbcgs.pValue = &dbv; - dbcgs.szSetting = szSetting; - - dbv.type = DBVT_WCHAR; - int iRes = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&dbcgs); + int iRes = db_get_ws(hContact, szModule, szSetting, &dbv); TCString Result; if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR)) { Result = dbv.ptszVal; - } else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) + } + else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) { long value = (dbv.type == DBVT_DWORD) ? dbv.dVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.bVal); _ultot(value, Result.GetBuffer(64), 10); Result.ReleaseBuffer(); - } else - { - Result = szDefaultValue; } + else Result = szDefaultValue; + if (!iRes) - { - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); - } + db_free(&dbv); + return Result; } diff --git a/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp b/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp index 36226b0f11..0c62967232 100644 --- a/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp +++ b/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp @@ -153,16 +153,9 @@ int COptItem::GetIntDBVal(CString &sModule, int bSigned, CString *sDBSettingPref { _ASSERT(nValueSize == DBVT_BYTE || nValueSize == DBVT_WORD || nValueSize == DBVT_DWORD); DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - cgs.szModule = sModule; - //NightFox: WTF is this shit - //cgs.szSetting = sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting; - cgs.szSetting = sDBSetting; - cgs.pValue = &dbv; - if (CallService(MS_DB_CONTACT_GETSETTING, NULL, (LPARAM)&cgs)) - { + if (db_get(NULL, sModule, sDBSetting, &dbv)) return GetDefValue(); - } + return (nValueSize == DBVT_BYTE) ? (bSigned ? (signed char)dbv.bVal : (unsigned char)dbv.bVal) : ((nValueSize == DBVT_WORD) ? (bSigned ? (signed short)dbv.wVal : (unsigned short)dbv.wVal) : dbv.dVal); } return GetDefValue(); diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index d69e9e7c54..f1f5c81b30 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -371,12 +371,7 @@ int WriteBlobFromString(HANDLE hContact,const char *szModule,const char *szSetti int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) { - DBCONTACTGETSETTING cgs; - cgs.szModule = szModule; - cgs.szSetting = szSetting; - cgs.pValue = dbv; - dbv->type = 0; - return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); + return db_get_s(hContact, szModule, szSetting, dbv, 0); } int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length) diff --git a/plugins/ExternalAPI/m_userinfoex.h b/plugins/ExternalAPI/m_userinfoex.h index 76be0cd8d3..a4d31bf5c7 100644 --- a/plugins/ExternalAPI/m_userinfoex.h +++ b/plugins/ExternalAPI/m_userinfoex.h @@ -337,8 +337,7 @@ static FORCEINLINE INT_PTR const char* pszProto, const char* pszSetting, DBVARIANT *dbv, - BYTE nType - ) + BYTE nType) { INT_PTR rc; DBCONTACTGETSETTING cgs; @@ -350,9 +349,8 @@ static FORCEINLINE INT_PTR rc = CallService(MS_DB_CONTACT_GETSETTING_STR_EX, (WPARAM)hContact, (LPARAM)&cgs); if (rc == CALLSERVICE_NOTFOUND) - { - rc = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&cgs); - } + rc = db_get_s(hContact, pszProto, pszSetting, dbv, nType); + return rc; } diff --git a/plugins/HistoryPlusPlus/PassForm.pas b/plugins/HistoryPlusPlus/PassForm.pas index 9de9e6ef63..6b923b3b68 100644 --- a/plugins/HistoryPlusPlus/PassForm.pas +++ b/plugins/HistoryPlusPlus/PassForm.pas @@ -185,11 +185,11 @@ begin lvCList.Items.BeginUpdate; try lvCList.Items.Clear; - hCont := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hCont := db_find_first(); while hCont <> 0 do begin AddContact(lvCList,hCont); - hCont := CallService(MS_DB_CONTACT_FINDNEXT, hCont, 0); + hCont := db_find_next(hCont); end; AddContact(lvCList,0); lvCList.SortType := stNone; diff --git a/plugins/HistoryPlusPlus/hpp_contacts.pas b/plugins/HistoryPlusPlus/hpp_contacts.pas index b78c4db72e..a9a4cd5e93 100644 --- a/plugins/HistoryPlusPlus/hpp_contacts.pas +++ b/plugins/HistoryPlusPlus/hpp_contacts.pas @@ -126,7 +126,6 @@ function GetContactID(hContact: THandle; Proto: AnsiString = ''; Contact: boolea var uid: PAnsiChar; dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tmp: String; begin Result := ''; @@ -137,10 +136,7 @@ begin uid := PAnsiChar(CallProtoService(PAnsiChar(Proto), PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0)); if (uid <> pAnsiChar(CALLSERVICE_NOTFOUND)) and (uid <> nil) then begin - cgs.szModule := PAnsiChar(Proto); - cgs.szSetting := uid; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, LPARAM(@cgs)) = 0 then + if db_get(hContact, PAnsiChar(Proto), uid, @dbv) = 0 then begin case dbv._type of DBVT_BYTE: diff --git a/plugins/HistoryPlusPlus/hpp_database.pas b/plugins/HistoryPlusPlus/hpp_database.pas index 483e5c553d..4341fa64e2 100644 --- a/plugins/HistoryPlusPlus/hpp_database.pas +++ b/plugins/HistoryPlusPlus/hpp_database.pas @@ -115,12 +115,8 @@ end; function DBExists(const hContact: THandle; const Module, Param: AnsiString): Boolean; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; begin - cgs.szModule := PAnsiChar(Module); - cgs.szSetting := PAnsiChar(Param); - cgs.pValue := @dbv; - Result := (CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0); + Result := (db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv) = 0); if Result then DBFreeVariant(@dbv); end; @@ -262,15 +258,10 @@ end; function GetDBBlob(const hContact: THandle; const Module,Param: AnsiString; var Value: Pointer; var Size: Integer): Boolean; var - cgs: TDBContactGetSetting; dbv: TDBVARIANT; begin Result := False; - ZeroMemory(@cgs,SizeOf(cgs)); - cgs.szModule := PAnsiChar(Module); - cgs.szSetting := PAnsiChar(Param); - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then exit; + if db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv) <> 0 then exit; Size := dbv.cpbVal; Value := nil; if dbv.cpbVal = 0 then exit; @@ -327,15 +318,11 @@ end; function GetDBInt(const hContact: THandle; const Module,Param: AnsiString; Default: Integer): Integer; var - cws:TDBCONTACTGETSETTING; dbv:TDBVariant; begin dbv._type := DBVT_DWORD; dbv.dVal:=Default; - cws.szModule:=PAnsiChar(Module); - cws.szSetting:=PAnsiChar(Param); - cws.pValue:=@dbv; - if CallService(MS_DB_CONTACT_GETSETTING,hContact,LPARAM(@cws))<>0 then + if db_get(hContact,PAnsiChar(Module),PAnsiChar(Param),@dbv)<>0 then Result:=default else Result:=dbv.dval; @@ -354,13 +341,9 @@ end; function DBGetContactSettingString(hContact: THandle; const szModule: PAnsiChar; const szSetting: PAnsiChar; ErrorValue: PAnsiChar): AnsiString; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tmp: WideString; begin - cgs.szModule := szModule; - cgs.szSetting := szSetting; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then + if db_get(hContact, szModule, szSetting, @dbv) <> 0 then Result := ErrorValue else begin case dbv._type of @@ -391,12 +374,8 @@ end; function DBGetContactSettingWideString(hContact: THandle; const szModule: PAnsiChar; const szSetting: PAnsiChar; ErrorValue: PWideChar): WideString; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; begin - cgs.szModule := szModule; - cgs.szSetting := szSetting; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then + if db_get(hContact, szModule, szSetting, @dbv) <> 0 then Result := ErrorValue else begin case dbv._type of diff --git a/plugins/HistoryPlusPlus/hpp_searchthread.pas b/plugins/HistoryPlusPlus/hpp_searchthread.pas index 30effa8ae4..d3bd22d361 100644 --- a/plugins/HistoryPlusPlus/hpp_searchthread.pas +++ b/plugins/HistoryPlusPlus/hpp_searchthread.pas @@ -251,7 +251,7 @@ procedure TSearchThread.BuildContactsList; var hCont: THandle; begin - hCont := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hCont := db_find_first(); while hCont <> 0 do begin @@ -261,7 +261,7 @@ begin if SearchProtectedContacts or (not SearchProtectedContacts and (not IsUserProtected(hCont))) then AddContact(hCont); - hCont := CallService(MS_DB_CONTACT_FINDNEXT, hCont, 0); + hCont := db_find_next(hCont); end; AddContact(hCont); @@ -274,7 +274,7 @@ var hCont: THandle; begin MaxProgress := 0; - hCont := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hCont := db_find_first(); while hCont <> 0 do begin // I hope I haven't messed this up by @@ -282,7 +282,7 @@ begin if SearchProtectedContacts or (not SearchProtectedContacts and (not IsUserProtected(hCont))) then MaxProgress := MaxProgress + GetItemsCount(hCont); - hCont := CallService(MS_DB_CONTACT_FINDNEXT, hCont, 0); + hCont := db_find_next(hCont); end; // add sysem history MaxProgress := MaxProgress + GetItemsCount(hCont); @@ -338,7 +338,7 @@ begin end; {$IFNDEF SMARTSEARCH} - hCont := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hCont := db_find_first(); while (hCont <> 0) and not Terminated do begin Inc(AllContacts); @@ -352,7 +352,7 @@ begin else SearchContact(hCont); end; - hCont := CallService(MS_DB_CONTACT_FINDNEXT, hCont, 0); + hCont := db_find_next(hCont); end; if BookmarksMode then SearchBookmarks(hCont) diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 2adbec5872..d39293a87a 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -95,16 +95,11 @@ static int CompareBookmarks( const void* p1, const void* p2 ) static void GetBookmarks(HANDLE hContact, BEventData** books, size_t* bookcnt ) { - DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - *books = NULL; *bookcnt = 0; - cgs.szModule = "HistoryPlusPlus"; - cgs.szSetting = "Bookmarks"; - cgs.pValue = &dbv; - if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs) == 0) + DBVARIANT dbv; + if (db_get(hContact, "HistoryPlusPlus", "Bookmarks", &dbv) == 0) { if (dbv.cpbVal > 2 && *(WORD*)dbv.pbVal >= sizeof(BEventData)) { diff --git a/plugins/ImportTXT/General.pas b/plugins/ImportTXT/General.pas index 709f6c27f6..a57e497b0f 100644 --- a/plugins/ImportTXT/General.pas +++ b/plugins/ImportTXT/General.pas @@ -266,7 +266,7 @@ begin tempwstr := UTF8ToWide(PAnsiChar(id), tempwstr); ws := tempwstr; FreeMem(tempwstr); - Contact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + Contact := db_find_first(); while (Contact <> 0) do begin otherproto := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, Contact, 0)); @@ -286,7 +286,7 @@ begin end; // case end; // if end; // if - Contact := CallService(MS_DB_CONTACT_FINDNEXT, Contact, 0); + Contact := db_find_next(Contact); end; // while if Contact=0 then result := INVALID_HANDLE_VALUE @@ -301,7 +301,7 @@ var ci: TCONTACTINFO; begin result := INVALID_HANDLE_VALUE; - Contact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + Contact := db_find_first(); while (Contact <> 0) do begin otherproto := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, Contact, 0)); @@ -321,7 +321,7 @@ begin end; end; // if end; // if - Contact := CallService(MS_DB_CONTACT_FINDNEXT, Contact, 0); + Contact := db_find_next(Contact); end; // while end; @@ -356,7 +356,7 @@ end; function DBFreeVariant(dbv: PDBVARIANT): integer; begin - result := CallService(MS_DB_CONTACT_FREEVARIANT, 0, lParam(dbv)); + result := db_free(dbv); end; function GetContactID(hContact: THandle; proto: AnsiString = ''; @@ -364,7 +364,6 @@ function GetContactID(hContact: THandle; proto: AnsiString = ''; var uid: PAnsiChar; dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tempstr: PWideChar; begin result := ''; @@ -375,10 +374,7 @@ begin uid := PAnsiChar(CallProtoService(PAnsiChar(proto), PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0)); if (uid <> pAnsiChar(CALLSERVICE_NOTFOUND)) and (uid <> nil) then begin - cgs.szModule := PAnsiChar(proto); - cgs.szSetting := uid; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0 then + if db_get(hContact, PAnsiChar(proto), uid, @dbv) = 0 then begin case dbv._type of DBVT_BYTE: @@ -413,7 +409,6 @@ function GetContactNick(hContact: THandle; proto: AnsiString = ''; Contact: boolean = false): WideString; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tempstr: PWideChar; begin result := ''; @@ -421,10 +416,7 @@ begin begin if proto = '' then proto := GetContactProto(hContact); - cgs.szModule := PAnsiChar(proto); - cgs.szSetting := 'Nick'; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0 then + if db_get(hContact, PAnsiChar(proto), 'Nick', @dbv) = 0 then begin case dbv._type of DBVT_BYTE: @@ -458,12 +450,8 @@ function DBReadByte(hContact: THandle; szModule: PAnsiChar; szSetting: PAnsiChar; default: byte = 0): byte; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; begin - cgs.szModule := szModule; - cgs.szSetting := szSetting; - cgs.pValue := @dbv; - If CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then + If db_get(hContact, szModule, szSetting, @dbv) <> 0 then result := default else result := dbv.bVal; diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 7021bdabc9..30168a3466 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -102,14 +102,7 @@ typedef struct { int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) { - DBCONTACTGETSETTING cgs; - - cgs.szModule = szModule; - cgs.szSetting = szSetting; - cgs.pValue = dbv; - dbv->type = 0; - - return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); + return db_get_s(hContact, szModule, szSetting, dbv, 0); } int enumModulesSettingsProc( const char *szName, LPARAM lParam) diff --git a/plugins/MetaContacts/src/meta_utils.cpp b/plugins/MetaContacts/src/meta_utils.cpp index 56d15dad88..088417e473 100644 --- a/plugins/MetaContacts/src/meta_utils.cpp +++ b/plugins/MetaContacts/src/meta_utils.cpp @@ -37,15 +37,8 @@ INT_PTR MyDBWriteContactSetting(HANDLE hContact, const char *szModule, const cha } INT_PTR Mydb_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) { - static BOOL strsvc, strsvcset = FALSE; memset(dbv, 0, sizeof(DBVARIANT)); - - if ( !strsvcset) {strsvc = ServiceExists(MS_DB_CONTACT_GETSETTING_STR); strsvcset = TRUE;} - - // preserve unicode strings - this service should return other data types unchanged - if (strsvc) return db_get_s(hContact, szModule, szSetting, dbv, 0); - - return db_get(hContact, szModule, szSetting, dbv); + return db_get_s(hContact, szModule, szSetting, dbv, 0); } int Meta_EqualDBV(DBVARIANT *dbv, DBVARIANT *id) { diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 28ba5c4294..146db14619 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -418,7 +418,7 @@ MirandaUtils::addMessageToDB(HANDLE hContact, int mirandaSendModeFlag, char* msg dbei.timestamp = (DWORD)time(NULL); dbei.cbBlob = (DWORD)bufSize; dbei.pBlob = (PBYTE)msgBuffer; - CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei); + db_event_add(hContact, &dbei); } diff --git a/plugins/MirandaNGHistoryToDB/Contacts.pas b/plugins/MirandaNGHistoryToDB/Contacts.pas index 8d95b5f3bc..6ecb7f7eec 100644 --- a/plugins/MirandaNGHistoryToDB/Contacts.pas +++ b/plugins/MirandaNGHistoryToDB/Contacts.pas @@ -110,7 +110,6 @@ function GetContactID(hContact: THandle; Proto: AnsiString = ''; Contact: Boolea var uid: PAnsiChar; dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tmp: String; begin Result := ''; @@ -121,11 +120,8 @@ begin uid := PAnsiChar(CallProtoService(PAnsiChar(Proto), PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0)); if (Cardinal(uid) <> CALLSERVICE_NOTFOUND) and (uid <> nil) then begin - cgs.szModule := PAnsiChar(Proto); - cgs.szSetting := uid; - cgs.pValue := @dbv; try - if CallService(MS_DB_CONTACT_GETSETTING, hContact, LPARAM(@cgs)) = 0 then + if db_get(hContact, PAnsiChar(Proto), uid, @dbv) = 0 then begin case dbv._type of DBVT_BYTE: diff --git a/plugins/MirandaNGHistoryToDB/Database.pas b/plugins/MirandaNGHistoryToDB/Database.pas index ba58a7295a..2b5e03b647 100644 --- a/plugins/MirandaNGHistoryToDB/Database.pas +++ b/plugins/MirandaNGHistoryToDB/Database.pas @@ -101,12 +101,8 @@ end; function DBExists(const hContact: THandle; const Module, Param: AnsiString): Boolean; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; begin - cgs.szModule := PAnsiChar(Module); - cgs.szSetting := PAnsiChar(Param); - cgs.pValue := @dbv; - Result := (CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0); + Result := (db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv) = 0); if Result then DBFreeVariant(@dbv); end; @@ -118,15 +114,10 @@ end; function GetDBBlob(const hContact: THandle; const Module,Param: AnsiString; var Value: Pointer; var Size: Integer): Boolean; var - cgs: TDBContactGetSetting; dbv: TDBVARIANT; begin Result := False; - ZeroMemory(@cgs,SizeOf(cgs)); - cgs.szModule := PAnsiChar(Module); - cgs.szSetting := PAnsiChar(Param); - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then exit; + if db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv) <> 0 then exit; Size := dbv.cpbVal; Value := nil; if dbv.cpbVal = 0 then exit; @@ -183,15 +174,11 @@ end; function GetDBInt(const hContact: THandle; const Module,Param: AnsiString; Default: Integer): Integer; var - cws:TDBCONTACTGETSETTING; dbv:TDBVariant; begin dbv._type := DBVT_DWORD; dbv.dVal:=Default; - cws.szModule:=PAnsiChar(Module); - cws.szSetting:=PAnsiChar(Param); - cws.pValue:=@dbv; - if CallService(MS_DB_CONTACT_GETSETTING,hContact,LPARAM(@cws))<>0 then + if db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv)<>0 then Result:=default else Result:=dbv.dval; @@ -210,13 +197,9 @@ end; function DBGetContactSettingString(hContact: THandle; const szModule: PAnsiChar; const szSetting: PAnsiChar; ErrorValue: PAnsiChar): AnsiString; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; tmp: WideString; begin - cgs.szModule := szModule; - cgs.szSetting := szSetting; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then + if db_get(hContact, szModule, szSetting, @dbv) <> 0 then Result := ErrorValue else begin case dbv._type of @@ -247,12 +230,8 @@ end; function DBGetContactSettingWideString(hContact: THandle; const szModule: PAnsiChar; const szSetting: PAnsiChar; ErrorValue: PWideChar): WideString; var dbv: TDBVARIANT; - cgs: TDBCONTACTGETSETTING; begin - cgs.szModule := szModule; - cgs.szSetting := szSetting; - cgs.pValue := @dbv; - if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then + if db_get(hContact, szModule, szSetting, @dbv) <> 0 then Result := ErrorValue else begin case dbv._type of diff --git a/plugins/MirandaNGHistoryToDB/Menu.pas b/plugins/MirandaNGHistoryToDB/Menu.pas index 15d51a11b7..b2218747b5 100644 --- a/plugins/MirandaNGHistoryToDB/Menu.pas +++ b/plugins/MirandaNGHistoryToDB/Menu.pas @@ -170,7 +170,7 @@ var AccountName: ^PPROTOACCOUNT; begin // Получаем список контактов - hContact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact := db_find_first(); while hContact <> 0 do begin ContactProto := GetContactProto(hContact); @@ -183,7 +183,7 @@ begin ContactID := TranslateW('Unknown Contact'); if not ((MatchStrings(LowerCase(ContactProto), 'skype*')) or (ContactID = TranslateW('Unknown Contact')) or MatchStrings(LowerCase(ContactProto), 'metacontacts*')) then WriteInLog(ProfilePath, Format('%s;%s;%s;%d', [ContactID, ContactName, GroupName, StrContactProtoToInt(ContactProto)]), 3); - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); end; AccountCount := 0; // Выгружаем список протоколов в файл ProtoList.csv diff --git a/plugins/MirandaNGHistoryToDB/MsgExport.pas b/plugins/MirandaNGHistoryToDB/MsgExport.pas index e36e3b1c8a..a409a01091 100644 --- a/plugins/MirandaNGHistoryToDB/MsgExport.pas +++ b/plugins/MirandaNGHistoryToDB/MsgExport.pas @@ -93,7 +93,7 @@ begin IMExportWizard.ActivePage := Page1; StartExport := False; // Получаем список контактов - hContact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact := db_find_first(); ContactList.Columns[0].MaxWidth := 190; ContactList.Columns[1].MaxWidth := 90; ContactList.Columns[2].MaxWidth := 140; @@ -126,7 +126,7 @@ begin ListItem.Checked := False else ListItem.Checked := True;} - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); end; ContactList.Items.EndUpdate; end; diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index a7aee1a7cf..faabdf07b4 100644 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -1393,116 +1393,105 @@ void ExportGpGKeysFunc(int type) std::string id = "Comment: login "; const char * uid = (const char*)CallProtoService(proto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs = {0}; - dbcgs.pValue = &dbv; - dbcgs.szModule = proto; - dbcgs.szSetting = uid; - CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs); - switch(dbcgs.pValue->type) - { + db_get(0, proto, uid, &dbv); + switch(dbv.type) { case DBVT_DELETED: continue; - break; + case DBVT_BYTE: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + mir_snprintf(_id, 63, "%d", dbv.bVal); id += _id; } break; case DBVT_WORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + mir_snprintf(_id, 63, "%d", dbv.wVal); id += _id; } break; case DBVT_DWORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + mir_snprintf(_id, 63, "%d", dbv.dVal); id += _id; } break; case DBVT_ASCIIZ: { - id += dbcgs.pValue->pszVal; - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + id += dbv.pszVal; + db_free(&dbv); } break; case DBVT_UTF8: { - char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + char *tmp = mir_utf8decodeA(dbv.pszVal); if(tmp[0]) id += tmp; mir_free(tmp); - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); } break; case DBVT_BLOB: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; case DBVT_WCHAR: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; } id += " contact_id "; ZeroMemory(&dbv, sizeof(dbv)); - ZeroMemory(&dbcgs, sizeof(dbcgs)); - dbcgs.pValue = &dbv; - dbcgs.szModule = proto; - dbcgs.szSetting = uid; - CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); - switch(dbcgs.pValue->type) - { + db_get(hContact, proto, uid, &dbv); + switch(dbv.type) { case DBVT_DELETED: continue; - break; case DBVT_BYTE: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + mir_snprintf(_id, 63, "%d", dbv.bVal); id += _id; } break; case DBVT_WORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + mir_snprintf(_id, 63, "%d", dbv.wVal); id += _id; } break; case DBVT_DWORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + mir_snprintf(_id, 63, "%d", dbv.dVal); id += _id; } break; case DBVT_ASCIIZ: { - id += dbcgs.pValue->pszVal; - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + id += dbv.pszVal; + db_free(&dbv); } break; case DBVT_UTF8: { - char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + char *tmp = mir_utf8decodeA(dbv.pszVal); if(tmp[0]) id += tmp; mir_free(tmp); - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); } break; case DBVT_BLOB: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; case DBVT_WCHAR: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; } std::string::size_type p1 = key.find("-----BEGIN PGP PUBLIC KEY BLOCK-----"); @@ -1607,13 +1596,9 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) break; const char * uid = (const char*)CallProtoService(accs[i]->szModuleName, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs = {0}; - dbcgs.pValue = &dbv; - dbcgs.szModule = accs[i]->szModuleName; - dbcgs.szSetting = uid; - CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs); + db_get(0, accs[i]->szModuleName, uid, &dbv); std::string id; - switch(dbcgs.pValue->type) + switch(dbv.type) { case DBVT_DELETED: continue; @@ -1621,7 +1606,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_BYTE: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + mir_snprintf(_id, 63, "%d", dbv.bVal); id += _id; if(id == login) acc = accs[i]->szModuleName; @@ -1630,7 +1615,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_WORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + mir_snprintf(_id, 63, "%d", dbv.wVal); id += _id; if(id == login) acc = accs[i]->szModuleName; @@ -1639,7 +1624,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_DWORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + mir_snprintf(_id, 63, "%d", dbv.dVal); id += _id; if(id == login) acc = accs[i]->szModuleName; @@ -1647,30 +1632,30 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) break; case DBVT_ASCIIZ: { - id += dbcgs.pValue->pszVal; - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + id += dbv.pszVal; + db_free(&dbv); if(id == login) acc = accs[i]->szModuleName; } break; case DBVT_UTF8: { - char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + char *tmp = mir_utf8decodeA(dbv.pszVal); if(tmp[0]) id += tmp; mir_free(tmp); - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); if(id == login) acc = accs[i]->szModuleName; } break; case DBVT_BLOB: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; case DBVT_WCHAR: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; } } @@ -1679,14 +1664,10 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) const char * uid = (const char*)CallProtoService(acc.c_str(), PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); for(HANDLE hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str())) { DBVARIANT dbv = {0}; - DBCONTACTGETSETTING dbcgs = {0}; - dbcgs.pValue = &dbv; - dbcgs.szModule = acc.c_str(); - dbcgs.szSetting = uid; - CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + db_get(hContact, acc.c_str(), uid, &dbv); std::string id; bool found = false; - switch(dbcgs.pValue->type) + switch(dbv.type) { case DBVT_DELETED: continue; @@ -1694,7 +1675,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_BYTE: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + mir_snprintf(_id, 63, "%d", dbv.bVal); id += _id; if(id == contact_id) found = true; @@ -1703,7 +1684,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_WORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + mir_snprintf(_id, 63, "%d", dbv.wVal); id += _id; if(id == contact_id) found = true; @@ -1712,7 +1693,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) case DBVT_DWORD: { char _id[64]; - mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + mir_snprintf(_id, 63, "%d", dbv.dVal); id += _id; if(id == contact_id) found = true; @@ -1720,30 +1701,30 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) break; case DBVT_ASCIIZ: { - id += dbcgs.pValue->pszVal; - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + id += dbv.pszVal; + db_free(&dbv); if(id == contact_id) found = true; } break; case DBVT_UTF8: { - char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + char *tmp = mir_utf8decodeA(dbv.pszVal); if(tmp[0]) id += tmp; mir_free(tmp); - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); if(id == contact_id) found = true; } break; case DBVT_BLOB: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; case DBVT_WCHAR: //TODO - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); break; } if(found) diff --git a/plugins/NotesAndReminders/src/miscutils.cpp b/plugins/NotesAndReminders/src/miscutils.cpp index 8ce1ca8655..3031922af6 100644 --- a/plugins/NotesAndReminders/src/miscutils.cpp +++ b/plugins/NotesAndReminders/src/miscutils.cpp @@ -29,7 +29,7 @@ void FreeSettingBlob(WORD pSize,void *pbBlob) dbv.type = DBVT_BLOB; dbv.cpbVal = pSize; dbv.pbVal = (BYTE*)pbBlob; - CallService(MS_DB_CONTACT_FREEVARIANT,0,(DWORD)&dbv); + db_free(&dbv); } void WriteSettingBlob(HANDLE hContact,char *ModuleName,char *SettingName,WORD pSize,void *pbBlob) @@ -47,13 +47,9 @@ void WriteSettingBlob(HANDLE hContact,char *ModuleName,char *SettingName,WORD pS void ReadSettingBlob(HANDLE hContact, char *ModuleName, char *SettingName, WORD *pSize, void **pbBlob) { - DBCONTACTGETSETTING cgs = {0}; DBVARIANT dbv = {0}; dbv.type = DBVT_BLOB; - cgs.szModule = ModuleName; - cgs.szSetting = SettingName; - cgs.pValue = &dbv; - if ( CallService(MS_DB_CONTACT_GETSETTING,(DWORD)hContact,(DWORD)&cgs)) { + if ( db_get(hContact, ModuleName, SettingName, &dbv)) { *pSize = 0; *pbBlob = NULL; } diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h index 8b587b6559..5700f7f55f 100644 --- a/plugins/Popup/src/common.h +++ b/plugins/Popup/src/common.h @@ -54,57 +54,38 @@ inline int Percentile2Byte(int vPerc) { return (vPerc*255)/100; } inline char *db_get_s(HANDLE hContact, const char *ModuleName, const char *SettingName, const char *Default) { DBVARIANT dbv; - DBCONTACTGETSETTING dbcgs; - dbcgs.szModule = ModuleName; - dbcgs.pValue = &dbv; - dbcgs.szSetting = SettingName; - - CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + db_get(hContact, ModuleName, SettingName, &dbv); char *result = 0; if (dbv.type == DBVT_ASCIIZ) - { result = mir_strdup(dbv.pszVal); - } else if (Default) - { result = mir_strdup(Default); - } - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); return result; } inline INT_PTR DBGetContactSettingStringX(HANDLE hContact, const char *ModuleName, const char *SettingName, const char *Default, const int retType) { INT_PTR ret = NULL; - BOOL result = 0; - DBVARIANT dbv; - DBCONTACTGETSETTING dbcgs; - dbcgs.szModule = ModuleName; - dbcgs.szSetting = SettingName; - dbcgs.pValue = &dbv; - dbv.type=(BYTE)retType; - result = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&dbcgs); + DBVARIANT dbv; + BOOL result = db_get_s(hContact, ModuleName, SettingName, &dbv, retType); switch(retType) { - case DBVT_ASCIIZ: - ret = (INT_PTR)mir_strdup(result ? Default : dbv.pszVal); - break; - case DBVT_WCHAR: - if (!result) { - ret = (INT_PTR)mir_wstrdup(dbv.pwszVal); - } - else { - ret = (INT_PTR)mir_a2u(Default); - } - break; - default: - break; + case DBVT_ASCIIZ: + ret = (INT_PTR)mir_strdup(result ? Default : dbv.pszVal); + break; + case DBVT_WCHAR: + if (!result) + ret = (INT_PTR)mir_wstrdup(dbv.pwszVal); + else + ret = (INT_PTR)mir_a2u(Default); + break; } if (!result) - CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + db_free(&dbv); return ret; } diff --git a/plugins/Quotes/src/DBUtils.cpp b/plugins/Quotes/src/DBUtils.cpp index 4ef1f1dd3a..583cedcf85 100644 --- a/plugins/Quotes/src/DBUtils.cpp +++ b/plugins/Quotes/src/DBUtils.cpp @@ -49,19 +49,11 @@ bool Quotes_DBWriteDouble(HANDLE hContact,const char* szModule,const char* szSet bool Quotes_DBReadDouble(HANDLE hContact,const char* szModule,const char* szSetting,double& rdValue) { DBVARIANT dbv = {0}; - DBCONTACTGETSETTING cgs; - cgs.szModule=szModule; - cgs.szSetting=szSetting; - cgs.pValue = &dbv; dbv.type = DBVT_BLOB; - bool bResult = ((0 == CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs)) - && (DBVT_BLOB == dbv.type)); - + bool bResult = ((0 == db_get(hContact, szModule, szSetting, &dbv)) && (DBVT_BLOB == dbv.type)); if(bResult) - { rdValue = *reinterpret_cast(dbv.pbVal); - } db_free(&dbv); return bResult; diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index 6ffaef1594..00153d79dd 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -34,18 +34,10 @@ namespace static int enum_contact_settings(const char* szSetting,LPARAM lp) { -// USES_CONVERSION; CEnumContext* ctx = reinterpret_cast(lp); DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - - cgs.szModule = ctx->m_pszModule; - cgs.szSetting = szSetting; - cgs.pValue = &dbv; - if(0 == CallService(MS_DB_CONTACT_GETSETTING, - reinterpret_cast(ctx->m_hContact), - reinterpret_cast(&cgs))) + if(0 == db_get(ctx->m_hContact, ctx->m_pszModule, szSetting, &dbv)) { mir_safety_dbvar sdbvar(&dbv); diff --git a/plugins/Quotes/src/QuoteInfoDlg.cpp b/plugins/Quotes/src/QuoteInfoDlg.cpp index c04f6d8ec9..756a17ad8f 100644 --- a/plugins/Quotes/src/QuoteInfoDlg.cpp +++ b/plugins/Quotes/src/QuoteInfoDlg.cpp @@ -31,16 +31,8 @@ namespace bool get_fetch_time(time_t& rTime,HANDLE hContact) { DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - - cgs.szModule=QUOTES_PROTOCOL_NAME; - cgs.szSetting=DB_STR_QUOTE_FETCH_TIME; - cgs.pValue=&dbv; - if(CallService(MS_DB_CONTACT_GETSETTING,reinterpret_cast(hContact),reinterpret_cast(&cgs)) - || (DBVT_DWORD != dbv.type)) - { + if (db_get(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type)) return false; - } rTime = dbv.dVal; return true; diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp index d95b4ed342..0c95f3846f 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp +++ b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp @@ -48,16 +48,8 @@ namespace bool get_fetch_time(HANDLE hContact,time_t& rTime) { DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - - cgs.szModule=QUOTES_MODULE_NAME; - cgs.szSetting=DB_STR_QUOTE_FETCH_TIME; - cgs.pValue=&dbv; - if(CallService(MS_DB_CONTACT_GETSETTING,reinterpret_cast(hContact),reinterpret_cast(&cgs)) - || (DBVT_DWORD != dbv.type)) - { + if (db_get(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type)) return false; - } rTime = dbv.dVal; return true; diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp index 5597ec2a9b..7eca077e23 100644 --- a/plugins/SMS/src/functions.cpp +++ b/plugins/SMS/src/functions.cpp @@ -5,13 +5,7 @@ BOOL DB_GetStaticStringW(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LP BOOL bRet=FALSE; SIZE_T dwReadedStringLen; DBVARIANT dbv={0}; - DBCONTACTGETSETTING sVal={0}; - - dbv.type=DBVT_WCHAR; - sVal.pValue=&dbv; - sVal.szModule=lpszModule; - sVal.szSetting=lpszValueName; - if (CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&sVal)==0) + if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv)==0) { dwReadedStringLen=lstrlenW(dbv.pwszVal); if (lpwszRetBuff && (dwRetBuffSize>dwReadedStringLen)) diff --git a/plugins/ShlExt/shlcom.pas b/plugins/ShlExt/shlcom.pas index 8aeb14c62b..97fef24660 100644 --- a/plugins/ShlExt/shlcom.pas +++ b/plugins/ShlExt/shlcom.pas @@ -1938,7 +1938,7 @@ begin GetMem(pContacts, (dwContacts + 2) * sizeof(TSlotInfo)); i := 0; dwOnline := 0; - hContact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact := db_find_first(); while (hContact <> 0) do begin if i >= dwContacts then @@ -1953,7 +1953,7 @@ begin dwCaps := CallService(szTmp, PFLAGNUM_1, 0); if (dwCaps and PF1_FILESEND) = 0 then begin - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); continue; end; dwStatus := DBGetContactSettingWord(hContact, szProto, 'Status', ID_STATUS_OFFLINE); @@ -1961,7 +1961,7 @@ begin inc(dwOnline) else if bHideOffline then begin - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); continue; end; // if // is HIT on? @@ -1974,7 +1974,7 @@ begin (CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_MESSAGE or IGNOREEVENT_URL or IGNOREEVENT_FILE) <> 0) then begin - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); continue; end; // if end; // if @@ -1985,7 +1985,7 @@ begin if DBGetContactSettingWord(hContact, szProto, 'ApparentMode', 0) = ID_STATUS_OFFLINE then begin - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); continue; end; // if end; // if @@ -1999,7 +1999,7 @@ begin begin // contact has no protocol! end; // if - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); end; // while // if no one is online and the CList isn't showing offliners, quit if (dwOnline = 0) and (bHideOffline) then @@ -2077,14 +2077,14 @@ var hContact: THandle; begin begin - hContact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact := db_find_first(); while hContact <> 0 do begin if DBGetContactSettingByte(hContact, SHLExt_Name, SHLExt_MRU, 0) > 0 then begin DBWriteContactSettingByte(hContact, SHLExt_Name, SHLExt_MRU, 0); end; - hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0); + hContact := db_find_next(hContact); end; end; end; diff --git a/plugins/ShlExt/shlext.dpr b/plugins/ShlExt/shlext.dpr index 32d1eab0c7..c23ee75f93 100644 --- a/plugins/ShlExt/shlext.dpr +++ b/plugins/ShlExt/shlext.dpr @@ -198,7 +198,6 @@ var comReg: Integer; iCheck: Integer; szBuf: array [0 .. MAX_PATH] of Char; - cgs: TDBCONTACTGETSETTING; begin Result := wMsg = WM_INITDIALOG; case wMsg of @@ -281,28 +280,13 @@ begin 'Are you sure? this will remove all the settings stored in your database and all registry entries created for shlext to work with Explorer'), TranslateW('Disable/Remove shlext'), MB_YESNO or MB_ICONQUESTION) then begin - cgs.szModule := SHLExt_Name; - - cgs.szSetting := SHLExt_UseGroups; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_UseCListSetting; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_UseHITContacts; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_UseHIT2Contacts; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_ShowNoProfile; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_ShowNoIcons; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); - - cgs.szSetting := SHLExt_ShowNoOffline; - CallService(MS_DB_CONTACT_DELETESETTING, 0, TLPARAM(@cgs)); + db_unset(0, SHLExt_Name, SHLExt_UseGroups); + db_unset(0, SHLExt_Name, SHLExt_UseCListSetting); + db_unset(0, SHLExt_Name, SHLExt_UseHITContacts); + db_unset(0, SHLExt_Name, SHLExt_UseHIT2Contacts); + db_unset(0, SHLExt_Name, SHLExt_ShowNoProfile); + db_unset(0, SHLExt_Name, SHLExt_ShowNoIcons); + db_unset(0, SHLExt_Name, SHLExt_ShowNoOffline); (* remove from Explorer *) // DllUnregisterServer(); diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 9d956eaa65..cdcdd31c27 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -731,7 +731,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, HANDLE hContact, char *group, char else { rc = CallService(MS_DB_CONTACT_GETSETTING_STR_EX, (WPARAM)hContact, (LPARAM)&cgs); if (rc == CALLSERVICE_NOTFOUND) - rc = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&cgs); + rc = db_get_ts(hContact, group, setting, &dbv); } if (!rc && dbv.type == DBVT_TCHAR && dbv.ptszVal != NULL) { diff --git a/plugins/TooltipNotify/src/DbHelpers.cpp b/plugins/TooltipNotify/src/DbHelpers.cpp index 017e01451c..19de8c826f 100644 --- a/plugins/TooltipNotify/src/DbHelpers.cpp +++ b/plugins/TooltipNotify/src/DbHelpers.cpp @@ -50,16 +50,8 @@ void DeleteModuleSettings(HANDLE hContact, const char* pszModuleName) static int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) { - DBCONTACTGETSETTING cgs; - - cgs.szModule=szModule; - cgs.szSetting=szSetting; - cgs.pValue=dbv; - dbv->type = 0; - - int rr = CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs); - - if (dbv->type != DBVT_UTF8) + int rr = db_get(hContact, szModule, szSetting, dbv); + if (dbv->type != DBVT_UTF8) return rr; else return 1; diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp index b57f2835ce..5e5c25e482 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp @@ -693,22 +693,12 @@ size_t CVCardFileVCF::packList(LPIDSTRLIST pList, UINT nList, int iID, size_t *c **/ BYTE CVCardFileVCF::GetSetting(const CHAR *pszModule, const CHAR *pszSetting, DBVARIANT *dbv) { - DBCONTACTGETSETTING cgs; - - cgs.szModule = pszModule; - cgs.szSetting = pszSetting; - cgs.pValue = dbv; - dbv->type = _useUtf8 ? DBVT_UTF8 : DBVT_ASCIIZ; + int type = _useUtf8 ? DBVT_UTF8 : DBVT_ASCIIZ; dbv->pszVal = NULL; - if (!pszModule || CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)_hContact, (LPARAM)&cgs) || (dbv->type == DBVT_ASCIIZ && !dbv->pszVal && !*dbv->pszVal)) { - cgs.szModule = _pszBaseProto; - cgs.szSetting = pszSetting; - cgs.pValue = dbv; - dbv->type = DBVT_ASCIIZ; - if (!_pszBaseProto || CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)_hContact, (LPARAM)&cgs) || (dbv->type == DBVT_ASCIIZ && !dbv->pszVal && !*dbv->pszVal)) { + if (!pszModule || db_get_s(_hContact, pszModule, pszSetting, dbv, type) || (dbv->type == DBVT_ASCIIZ && !dbv->pszVal && !*dbv->pszVal)) + if (!_pszBaseProto || db_get_s(_hContact, _pszBaseProto, pszSetting, dbv) || (dbv->type == DBVT_ASCIIZ && !dbv->pszVal && !*dbv->pszVal)) return DBVT_DELETED; - } - } + _hasUtf8 += _useUtf8 && !IsUSASCII(dbv->pszVal, NULL); return dbv->type; } diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index dc31be814a..e40855b24b 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -262,16 +262,8 @@ namespace Setting { **/ BYTE Get(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv, const BYTE destType) { - BYTE result; - DBCONTACTGETSETTING dgs; - - dgs.szModule = pszModule; - dgs.szSetting = pszSetting; - dgs.pValue = dbv; - dbv->type = 0; - // read value without translation to specific type - result = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM) hContact, (LPARAM) &dgs) != 0; + BYTE result = db_get_s(hContact, pszModule, pszSetting, dbv, 0) != 0; // Is value read successfully and destination type set? if (!result && destType) { diff --git a/plugins/Utils.pas/contact.pas b/plugins/Utils.pas/contact.pas index 93bd4f7f73..9dc959c91f 100644 --- a/plugins/Utils.pas/contact.pas +++ b/plugins/Utils.pas/contact.pas @@ -32,13 +32,13 @@ begin if format=nil then format:=defformat; SendMessage(list,CB_RESETCONTENT,0,0); - hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact:=db_find_first(); lName :=StrPosW(format,'%name%')<>nil; lGroup :=StrPosW(format,'%group%')<>nil; lAccount:=StrPosW(format,'%account%')<>nil; lUID :=StrPosW(format,'%uid%')<>nil; - + while hContact<>0 do begin if ((not filter) and ((IsContactActive(hContact)+1)>=0)) or // + disabled (not deleted) @@ -105,7 +105,7 @@ begin SendMessageW(list,CB_ADDSTRING,0,tlparam(@buf)), hContact); end; - hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0); + hContact:=db_find_next(hContact); end; end; diff --git a/plugins/Utils.pas/dbsettings.pas b/plugins/Utils.pas/dbsettings.pas index 9c8578b225..5e2b5b08fd 100644 --- a/plugins/Utils.pas/dbsettings.pas +++ b/plugins/Utils.pas/dbsettings.pas @@ -1,4 +1,3 @@ -{$DEFINE UseCore} {$INCLUDE compilers.inc} unit dbsettings; interface @@ -47,127 +46,57 @@ implementation uses common; function DBReadByte(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;default:byte=0):byte; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_get_b(hContact, szModule, szSetting, default); end; -{$ELSE} -var - dbv:TDBVARIANT; - cgs:TDBCONTACTGETSETTING; -begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; - If CallService(MS_DB_CONTACT_GETSETTING,hContact,lParam(@cgs))<>0 then - Result:=default - else - Result:=dbv.bVal; -end; -{$ENDIF} function DBReadWord(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;default:word=0):word; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_get_w(hContact, szModule, szSetting, default); end; -{$ELSE} -var - dbv:TDBVARIANT; - cgs:TDBCONTACTGETSETTING; -begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; - If CallService(MS_DB_CONTACT_GETSETTING,hContact,lParam(@cgs))<>0 then - Result:=default - else - Result:=dbv.wVal; -end; -{$ENDIF} function DBReadDWord(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;default:dword=0):dword; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_get_dw(hContact, szModule, szSetting, default); end; -{$ELSE} -var - dbv:TDBVARIANT; - cgs:TDBCONTACTGETSETTING; -begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; - If CallService(MS_DB_CONTACT_GETSETTING,hContact,lParam(@cgs))<>0 then - Result:=default - else - Result:=dbv.dVal; -end; -{$ENDIF} function DBReadSetting(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;dbv:PDBVARIANT):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_get(hContact, szModule, szSetting, dbv); end; -{$ELSE} -var - cgs:TDBCONTACTGETSETTING; -begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=dbv; - Result:=CallService(MS_DB_CONTACT_GETSETTING,hContact,lParam(@cgs)); -end; -{$ENDIF} function DBReadSettingStr(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;dbv:PDBVARIANT):int_ptr; -var - cgs:TDBCONTACTGETSETTING; begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=dbv; - Result:=CallService(MS_DB_CONTACT_GETSETTING_STR,hContact,lParam(@cgs)); + Result:=db_get_s(hContact,szModule,szSetting,dbv,DBVT_ASCIIZ); end; function DBReadStringLength(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar):integer; var - cgs:TDBCONTACTGETSETTING; dbv:TDBVARIANT; i:int_ptr; begin FillChar(dbv,SizeOf(dbv),0); - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; - i:=CallService(MS_DB_CONTACT_GETSETTING_STR,hContact,lParam(@cgs)); + i:=db_get_s(hContact,szModule,szSetting,@dbv,DBVT_ASCIIZ); if (i<>0) or (dbv.szVal.a=nil) or (dbv.szVal.a^=#0) then result:=0 else result:=lstrlena(dbv.szVal.a); -//!! if i=0 then - DBFreeVariant(@dbv); + DBFreeVariant(@dbv); end; function DBReadString(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar; default:PAnsiChar=nil;enc:integer=DBVT_ASCIIZ):PAnsiChar; var - cgs:TDBCONTACTGETSETTING; dbv:TDBVARIANT; i:int_ptr; begin FillChar(dbv,SizeOf(dbv),0); - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; dbv._type :=enc; - i:=CallService(MS_DB_CONTACT_GETSETTING_STR,hContact,lParam(@cgs)); + i:=db_get_s(hContact,szModule,szSetting,@dbv,DBVT_ASCIIZ); if i=0 then default:=dbv.szVal.a; @@ -187,16 +116,11 @@ end; function DBReadUnicode(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;default:PWideChar=nil):PWideChar; var - cgs:TDBCONTACTGETSETTING; dbv:TDBVARIANT; i:int_ptr; begin FillChar(dbv,SizeOf(dbv),0); - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - cgs.pValue :=@dbv; - dbv._type :=DBVT_WCHAR; - i:=CallService(MS_DB_CONTACT_GETSETTING_STR,hContact,lParam(@cgs)); + i:=db_get_s(hContact,szModule,szSetting,@dbv,DBVT_WCHAR); if i=0 then default:=dbv.szVal.w; @@ -205,8 +129,7 @@ begin else StrDupW(result,default); -//!! if i=0 then - DBFreeVariant(@dbv); + DBFreeVariant(@dbv); end; function DBReadStruct(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar; @@ -230,23 +153,10 @@ end; function DBWriteStruct(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar; ptr:pointer;size:dword):Integer; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_blob(hContact, szModule, szSetting, ptr, size); end; -{$ELSE} -var - cws:TDBCONTACTWRITESETTING; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type :=DBVT_BLOB; - cws.value.pbVal :=ptr; - cws.value.cpbVal:=size; - result:=CallService(MS_DB_CONTACT_WRITESETTING,0,lParam(@cws)); -end; -{$ENDIF} function DBWriteSetting(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;dbv:PDBVARIANT):int_ptr; var @@ -259,145 +169,53 @@ begin end; function DBWriteByte(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;val:Byte):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_b(hContact, szModule, szSetting, val); end; -{$ELSE} -var - cws:TDBCONTACTWRITESETTING; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type:=DBVT_BYTE; - cws.value.bVal :=val; - Result:=CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws)); -end; -{$ENDIF} function DBWriteWord(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;val:Word):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_w(hContact, szModule, szSetting, val); end; -{$ELSE} -var - cws:TDBCONTACTWRITESETTING; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type:=DBVT_WORD; - cws.value.wVal :=val; - Result:=CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws)); -end; -{$ENDIF} function DBWriteDWord(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;val:dword):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_dw(hContact, szModule, szSetting, val); end; -{$ELSE} -var - cws:TDBCONTACTWRITESETTING; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type:=DBVT_DWORD; - cws.value.dVal :=val; - Result:=CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws)); -end; -{$ENDIF} function DBWriteString(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar; val:PAnsiChar;enc:integer=DBVT_ASCIIZ):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_s(hContact, szModule, szSetting, val); end; -{$ELSE} -var - cws:TDBCONTACTWRITESETTING; - p:dword; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type :=enc; - if val=nil then - begin - p:=0; - val:=@p; - end; - cws.value.szVal.a:=val; - Result:=CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws)); -end; -{$ENDIF} function DBWriteUTF8(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;val:PAnsiChar):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_utf(hContact, szModule, szSetting, val); end; -{$ELSE} -begin - result:=DBWriteString(hContact,szModule,szSetting,val,DBVT_UTF8); -end; -{$ENDIF} function DBWriteUnicode(hContact:THANDLE;szModule:PAnsiChar;szSetting:PAnsiChar;val:PWideChar):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_set_ws(hContact, szModule, szSetting, val); end; -{$ELSE} -begin - result:=DBWriteString(hContact,szModule,szSetting,PAnsiChar(val),DBVT_WCHAR); -{ -var - cws:TDBCONTACTWRITESETTING; -begin - cws.szModule :=szModule; - cws.szSetting :=szSetting; - cws.value._type :=DBVT_WCHAR; - cws.value.szVal.w:=Val; - Result:=CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws)); -} -end; -{$ENDIF} function DBFreeVariant(dbv:PDBVARIANT):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_free(dbv); end; -{$ELSE} -begin - Result:=CallService(MS_DB_CONTACT_FREEVARIANT,0,lParam(dbv)); -end; -{$ENDIF} function DBDeleteSetting(hContact:THandle;szModule:PAnsiChar;szSetting:PAnsiChar):int_ptr; -{$IFDEF UseCore} {$IFDEF AllowInline}inline;{$ENDIF} begin result:=db_unset(hContact, szModule, szSetting); end; -{$ELSE} -var - cgs:TDBCONTACTGETSETTING; -begin - cgs.szModule :=szModule; - cgs.szSetting:=szSetting; - Result:=CallService(MS_DB_CONTACT_DELETESETTING,hContact,lParam(@cgs)); -end; -{$ENDIF} type ppchar = ^pAnsiChar; @@ -418,7 +236,6 @@ end; function DBDeleteGroup(hContact:THANDLE;szModule:PAnsiChar;prefix:pAnsiChar=nil):int_ptr; var ces:TDBCONTACTENUMSETTINGS; - cgs:TDBCONTACTGETSETTING; p:PAnsiChar; num,len:integer; ptr:pAnsiChar; @@ -439,7 +256,6 @@ begin result:=CallService(MS_DB_CONTACT_ENUMSETTINGS,hContact,lparam(@ces)); ptr^:=#0; - cgs.szModule:=szModule; ptr:=p; if (prefix<>nil) and (prefix^<>#0) then len:=StrLen(prefix) @@ -449,8 +265,7 @@ begin begin if (len=0) or (StrCmp(prefix,ptr,len)=0) then begin - cgs.szSetting:=ptr; - CallService(MS_DB_CONTACT_DELETESETTING,hContact,lParam(@cgs)); + db_unset(hContact,szModule,ptr); end; while ptr^<>#0 do inc(ptr); inc(ptr); diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 1b06920810..97717ea1cd 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -83,7 +83,7 @@ uses const clGroup = 'Group'; -// Save / Load contact +// Save / Load contact const opt_cproto = 'cproto'; opt_cuid = 'cuid'; @@ -424,7 +424,7 @@ var mwod:TMessageWindowOutputData; begin wnd:=GetParent(wnd); //!! - hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact:=db_find_first(); with mwid do begin cbSize:=SizeOf(mwid); @@ -442,7 +442,7 @@ begin exit; end end; - hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0); + hContact:=db_find_next(hContact); end; result:=0; end; @@ -645,7 +645,7 @@ begin if uid=pAnsiChar(CALLSERVICE_NOTFOUND) then exit; end; - hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact:=db_find_first(); while hContact<>0 do begin if is_chat then @@ -685,7 +685,7 @@ begin end; // added 2011.04.20 if result<>0 then break; - hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0); + hContact:=db_find_next(hContact); end; end; @@ -752,10 +752,8 @@ function CreateGroupW(name:pWideChar;hContact:THANDLE):integer; var groupId:integer; groupIdStr:array [0..10] of AnsiChar; - dbv:TDBVARIANT; - cgs:TDBCONTACTGETSETTING; grbuf:array [0..127] of WideChar; - p:pWideChar; + p, pw:pWideChar; begin if (name=nil) or (name^=#0) then begin @@ -768,25 +766,20 @@ begin // Check for duplicate & find unused id groupId:=0; - cgs.szModule:='CListGroups'; - cgs.pValue :=@dbv; repeat - dbv._type:=DBVT_WCHAR; - cgs.szSetting:=IntToStr(groupIdStr,groupId); - if CallService(MS_DB_CONTACT_GETSETTING_STR,0,lParam(@cgs))<>0 then + pw:=DBReadUnicode(0,'CListGroups',IntToStr(groupIdStr,groupId)); + if pw<>nil then break; - if StrCmpW(dbv.szVal.w+1,@grbuf[1])=0 then + if StrCmpW(pw+1,@grbuf[1])=0 then begin if hContact<>0 then DBWriteUnicode(hContact,strCList,clGroup,@grbuf[1]); - DBFreeVariant(@dbv); result:=0; exit; end; - DBFreeVariant(@dbv); inc(groupId); until false; @@ -809,10 +802,8 @@ function CreateGroup(name:pAnsiChar;hContact:THANDLE):integer; var groupId:integer; groupIdStr:array [0..10] of AnsiChar; - dbv:TDBVARIANT; - cgs:TDBCONTACTGETSETTING; grbuf:array [0..127] of AnsiChar; - p:pAnsiChar; + p, pa:pAnsiChar; begin if (name=nil) or (name^=#0) then begin @@ -825,25 +816,19 @@ begin // Check for duplicate & find unused id groupId:=0; - cgs.szModule:='CListGroups'; - cgs.pValue :=@dbv; repeat - dbv._type:=DBVT_ASCIIZ; - cgs.szSetting:=IntToStr(groupIdStr,groupId); - if CallService(MS_DB_CONTACT_GETSETTING_STR,0,lParam(@cgs))<>0 then + pa:=DBReadString(0,'CListGroups',IntToStr(groupIdStr,groupId)); + if pa=nil then break; - if StrCmp(dbv.szVal.a+1,@grbuf[1])=0 then + if StrCmp(pa+1,@grbuf[1])=0 then begin if hContact<>0 then DBWriteString(hContact,strCList,clGroup,@grbuf[1]); - - DBFreeVariant(@dbv); result:=0; exit; end; - DBFreeVariant(@dbv); inc(groupId); until false; diff --git a/plugins/Utils.pas/protocols.pas b/plugins/Utils.pas/protocols.pas index 101c1e4282..5b4c611e47 100644 --- a/plugins/Utils.pas/protocols.pas +++ b/plugins/Utils.pas/protocols.pas @@ -460,7 +460,7 @@ begin StrCopy(p,PS_SET_LISTENINGTO); if ServiceExists(buf)<>0 then status:=status or psf_tunes; - + end; inc(proto); end; @@ -468,7 +468,7 @@ begin { if deepscan then begin - hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact:=db_find_first(); while hContact<>0 do begin i:=NumProto; @@ -479,7 +479,7 @@ begin dec(i); end; - hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0); + hContact:=db_find_next(hContact); end; end; } diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 838705e82f..f70d61c3be 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -41,10 +41,10 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfo; } -bool isReceiveMessage(LPARAM event) +bool isReceiveMessage(HANDLE hDbEvent) { DBEVENTINFO info = { sizeof(info) }; - CallService(MS_DB_EVENT_GET, event, (LPARAM)&info); + db_event_get(hDbEvent, &info); // i don't understand why it works and how it works, but it works correctly - practice way (методом тыка) // so, i think correct condition would be : eventType == EVENTTYPE_MESSAGE && info.flags & DBEF_READ, but it really isn't return !(((info.eventType != EVENTTYPE_MESSAGE) && !(info.flags & DBEF_READ)) || (info.flags & DBEF_SENT)); @@ -52,7 +52,7 @@ bool isReceiveMessage(LPARAM event) INT ProcessEvent(WPARAM wParam, LPARAM lParam) { - if (!isReceiveMessage(lParam)) + if (!isReceiveMessage(HANDLE(lParam))) return 0; isIgnoreSound = db_get_b((HANDLE)wParam, SETTINGSNAME, SETTINGSIGNOREKEY, 0); diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index c4506df141..34cf80857a 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -75,7 +75,7 @@ int ProtoAck(WPARAM wparam,LPARAM lparam) dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (DWORD)strlen(p->msgText) + 1; dbei.pBlob = (PBYTE)p->msgText; - CallService(MS_DB_EVENT_ADD, (WPARAM)hForwardTo, (LPARAM)&dbei); + db_event_add(hForwardTo, &dbei); } mir_free(p->msgText); -- cgit v1.2.3