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 --- include/delphi/m_database.inc | 206 ------------------ include/m_core.h | 233 +++++++++++++++++---- include/m_database.h | 230 -------------------- include/m_protoint.h | 2 +- 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 +- protocols/GTalkExt/src/tipper_items.cpp | 15 +- protocols/IcqOscarJ/src/icqosc_svcs.cpp | 21 +- protocols/MRA/src/MraAntiSpam.cpp | 13 +- protocols/MRA/src/Mra_functions.cpp | 23 +- protocols/Skype/src/skype_contacts.cpp | 2 +- protocols/Twitter/src/connection.cpp | 7 +- src/modules/clist/clistmod.cpp | 5 - src/modules/database/dbintf.cpp | 112 ---------- 52 files changed, 393 insertions(+), 1314 deletions(-) diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 4876451e3a..210f4dc914 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -59,32 +59,6 @@ type end; const - { - wParam : Handle of a contact to get the setting for (see notes) - lParam : pointer to a TDBCONTACTGETSETTING structure to be filled with setting - this structure also has to be initalised (see notes) - affect : Queries the database module for a setting from a contact. - returns: 0 on success, non zero on failure (contact not found, setting doesn't exist) - notes : TDBCONTACTGETSETTING must be filled with the module name that created - /wrote the setting you want to get (e.g. your module name) - and the actual setting to read with TDBCONTACTGETSETTING.szModule and - TDBCONTACTGETSETTING.szSetting -- TDBCONTACTGETSETTING.pValue is - a pointer to a TDBVARIANT with the returned setting, this maybe nil - and MUST be freed after you're done with it with FreeVariant() - - There are helper functions for reading/writing/deleting common types to and - from the database -- see DBGetContactSetting - - the contact handle (hContact) can be returned by FindContact/AddContact - } - MS_DB_CONTACT_GETSETTING:PAnsiChar = 'DB/Contact/GetSetting'; - - { - DB/Contact/GetSettingString service 0.4.3+ - Same as DB/Contact/GetSetting, but also gets the required string type - inside the dbcgs->type parameter - } - MS_DB_CONTACT_GETSETTING_STR:PAnsiChar = 'DB/Contact/GetSettingStr'; { wParam : Handle for a contact to query a setting for @@ -103,15 +77,6 @@ const } MS_DB_CONTACT_GETSETTINGSTATIC:PAnsiChar = 'DB/Contact/GetSettingStatic'; - { - wParam : 0 - lParam : Pointer to a TDBVARIANT structure - affect : Free's the passed DBVARIANT's dynamic memory (if any) see notes - returns: 0 on success, non zero on failure - notes : use the helper function FreeVariant() - } - MS_DB_CONTACT_FREEVARIANT:PAnsiChar = 'DB/Contact/FreeVariant'; - { wParam : Handle to contact to write setting for lParam : Pointer to TDBCONTACTWRITESETTING which must be initalised @@ -124,19 +89,6 @@ const } MS_DB_CONTACT_WRITESETTING:PAnsiChar = 'DB/Contact/WriteSetting'; - { - wParam : hContact under which the setting should be deleted - lParam : Pointer to a TDBCONTACTGETSETTING structure - affects: Deletes the given setting for a contact, the TDBCONTACTGETSETTING.pValue - field is ignored -- only .szModule and .szSetting are needed, see notes - returns: 0 on success, non zero on failure - notes : triggers 'DB/Contact/SettingChanged' BEFORE it deletes the given - setting, when the service returns the TDBVARIANT structure .type_ is set - to 0 and no fields are valid, there is a helper function for this - service, see below. - } - MS_DB_CONTACT_DELETESETTING:PAnsiChar = 'DB/Contact/DeleteSetting'; - { wParam : Handle of a contact to enum settings for lParam : Pointer to a TDBCONTACTENUMSETTINGS structure, must be initalised @@ -182,25 +134,6 @@ const } MS_DB_CONTACT_GETCOUNT:PAnsiChar = 'DB/Contact/GetCount'; - { - wParam : 0 - lParam : 0 - returns: Returns a handle to the first contact in the database, - this handle does not need to be closed, if there are no users - NULL(0) is returned. - } - MS_DB_CONTACT_FINDFIRST:PAnsiChar = 'DB/Contact/FindFirst'; - - { - wParam : Contact handle - lParam : 0 - returns: Returns a handle to the next contact after the given contact in - wParam, this handle does not neeed to be closed -- may return NULL(0) - if the given contact in wParam was the last in the database, or the - given contact was invalid - } - MS_DB_CONTACT_FINDNEXT:PAnsiChar = 'DB/Contact/FindNext'; - { wParam : Handle of a contact to delete lParam : 0 @@ -288,71 +221,6 @@ const } MS_DB_EVENT_GETTYPE:PAnsiChar = 'DB/EventType/Get'; - { - wParam : contact handle for events count is needed - lParam : 0 - service: Gets the number of events in the chain belonging to a contact - in the databasee. - returns: the numbef of events owned by hContact or -1 if hContact - is invalid, they can be found with the event/find* servicees - } - MS_DB_EVENT_GETCOUNT:PAnsiChar = 'DB/Event/GetCount'; - - { - wParam : contact handle to add an event for - lParam : Pointer to TDBEVENTINFO initialised with data - affect : Add's an event to the contact's event list, the TDBEVENTINFO - structure should be filled with the event of message -- see notes - returns: a handle to a DB event (HANDLE), or NULL on error - notes : Triggers DB/Event/Added event just before it returns, - Events are sorted chronologically as they are entered, - so you cannot guarantee that the new hEvent is the last event in the chain, - however if a new event is added that has a timestamp less than - 90 seconds *before* the event that should be after it, - it will be added afterwards, to allow for protocols that only - store times to the nearest minute, and slight delays in transports. - There are a few predefined eventTypes below for easier compatibility, but - modules are free to define their own, beginning at 2000 - DBEVENTINFO.timestamp is in GMT, as returned by time() - } -const - MS_DB_EVENT_ADD:PAnsiChar = 'DB/Event/Add'; - - { - wParam : Handle to the contact - lParam : HANDLE handle to delete - affects: Removes a single event from the database for the given contact - returns: 0 on success, nonzero on failure - notes : Triggers DB/Event/Deleted just before the event *is* deleted - } - MS_DB_EVENT_DELETE:PAnsiChar = 'DB/Event/Delete'; - - { - wParam : Handle to DB event - lParam : 0 - returns: Returns the space in bytes requried to store the blob in HANDLE - given by HANDLE(wParam) -- or -1 on error - } - MS_DB_EVENT_GETBLOBSIZE:PAnsiChar = 'DB/Event/GetBlobSize'; - - { - wParam : Handle to a DB event - lParam : Pointer to a TDBEVENTINFO structure which must be initialised - affects: Returns all the information about an DB event handle to a TDBEVENTINFO - structure which must be initalised, DBEI.cbSize, DBEI.pBlob and DBEI.cbSize - before calling this service, the size can be assertained with - GetBlobSize() service, see notes - returns: Returns 0 on success, non zero on failure - notes : The correct value dbe.cbBlob can be got using db/event/getblobsize - If successful, all the fields of dbe are filled. dbe.cbBlob is set to the - actual number of bytes retrieved and put in dbe.pBlob - If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob - and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob - On return, dbe.szModule is a pointer to the database module's - own internal list of modules. Look but don't touch. - } - MS_DB_EVENT_GET:PAnsiChar = 'DB/Event/Get'; - { DB/Event/GetText (0.7.0+) Retrieves the event's text wParam=0 @@ -395,80 +263,6 @@ const MS_DB_EVENT_GETSTRINGT:PAnsiChar = 'DB/Event/GetStringT'; - { - wParam : HCONTACT - lParam : HANDLE - affect : Changes the flag for an event to mark it as read - Returns: Returns the entire flag DWORD for the event after the change, or -1 - if HANDLE is invalid, see notes - notes : This iss one of the database write operations that does not trigger - an event, modules should not save flagss states for any length of time. - } - MS_DB_EVENT_MARKREAD:PAnsiChar = 'DB/Event/MarkRead'; - - { - wParam : HANDLE - lParam : 0 - Affect : Returns a handle to a contact that owns the HANDLE, - see notes - Returns: Returns a handle if successful or HDBEEVENT(-1) on failure - notes : This service is very slow, only use wheen you have no other choice - at all. - } - MS_DB_EVENT_GETCONTACT:PAnsiChar = 'DB/Event/GetContact'; - - { - wParam : HCONTACT - lParam : 0 - Affect : Retrieves a handlee to the first event in the chain - for a HCONTACT - returns: Returns a handle, or NULL(0) if HCONTACT is invalid or has - no events, events in a chain are sorted chronologically automatically - } - MS_DB_EVENT_FINDFIRST:PAnsiChar = 'DB/Event/FindFirst'; - - { - wParam : HCONTACT - lParam : 0 - Affect : Retrieves a handle to the first unreead event in a chain for a HCONTACT - see notes - Returns: Returns a HANDLE handle or NULL(0) if the HCONTACT is invalid - or all it's events have beeen read. - Notes : Events in a chain are sorted chronologically automatically, - but this does not necessarily mean that all events after - the first unread are unread too. - They should be checked individually with event/findnext and event/get - This service is designed for startup, reloading all the events that remained - unread from last time - } - MS_DB_EVENT_FINDFIRSTUNREAD:PAnsiChar = 'DB/Event/FindFirstUnread'; - - { - wParam : HCONTACT - lParam : 0; - Affects: Retrieves a handle to the lasts event in the chain for a HCONTACT - Returns: Returns a handle or NULL(0) if HCONTACT is invalid or has no events - } - MS_DB_EVENT_FINDLAST:PAnsiChar = 'DB/Event/FindLast'; - - { - wParam : HANDLE - lParam : 0 - Affects: Retrieves a handle to the next event in a chain after HANDLE - Returns: A handle to the next DB event or NULL(0) if HANDLE is invalid - or the last event in the chain. - } - MS_DB_EVENT_FINDNEXT:PAnsiChar = 'DB/Event/FindNext'; - - { - wParam : HANDLE - lParam : 0 - Affects: Retrieves a handle to the previous event in a chain before HANDLE - Returns: A handle to the previous HANDLE or NULL(0) if HANDLE is invalid - or is the first event in the chain - } - MS_DB_EVENT_FINDPREV:PAnsiChar = 'DB/Event/FindPrev'; - //************************** Encryption **************************** { diff --git a/include/m_core.h b/include/m_core.h index 2b81f6e9bd..638666c0d7 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -107,28 +107,181 @@ typedef struct { } DBEVENTINFO; MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv); -MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, const char *szModule, const char *szSetting); + +/****************************************************************************** + * DATABASE CONTACTS + */ + +/* +Gets the handle of the first contact in the database. This handle can be used +with loads of functions. It does not need to be closed. +You can specify szProto to find only its contacts +Returns a handle to the first contact in the db on success, or NULL if there +are no contacts in the db. +*/ + +#if defined(__cplusplus) + MIR_CORE_DLL(HANDLE) db_find_first(const char *szProto = NULL); +#else + MIR_CORE_DLL(HANDLE) db_find_first(const char *szProto); +#endif + +/* +Gets the handle of the next contact after hContact in the database. This handle +can be used with loads of functions. It does not need to be closed. +You can specify szProto to find only its contacts +Returns a handle to the contact after hContact in the db on success or NULL if +hContact was the last contact in the db or hContact was invalid. +*/ #if defined(__cplusplus) - MIR_CORE_DLL(HANDLE) db_find_first(const char *szProto = NULL); - MIR_CORE_DLL(HANDLE) db_find_next(HANDLE hContact, const char *szProto = NULL); + MIR_CORE_DLL(HANDLE) db_find_next(HANDLE hContact, const char *szProto = NULL); #else - MIR_CORE_DLL(HANDLE) db_find_first(const char *szProto); - MIR_CORE_DLL(HANDLE) db_find_next(HANDLE hContact, const char *szProto); + MIR_CORE_DLL(HANDLE) db_find_next(HANDLE hContact, const char *szProto); #endif -MIR_CORE_DLL(HANDLE) db_event_add(HANDLE hContact, DBEVENTINFO *dbei); -MIR_CORE_DLL(int) db_event_count(HANDLE hContact); -MIR_CORE_DLL(int) db_event_delete(HANDLE hContact, HANDLE hDbEvent); -MIR_CORE_DLL(HANDLE) db_event_first(HANDLE hContact); -MIR_CORE_DLL(HANDLE) db_event_firstUnread(HANDLE hContact); -MIR_CORE_DLL(int) db_event_get(HANDLE hDbEvent, DBEVENTINFO *dbei); -MIR_CORE_DLL(int) db_event_getBlobSize(HANDLE hDbEvent); -MIR_CORE_DLL(HANDLE) db_event_getContact(HANDLE hDbEvent); -MIR_CORE_DLL(HANDLE) db_event_last(HANDLE hDbEvent); -MIR_CORE_DLL(int) db_event_markRead(HANDLE hContact, HANDLE hDbEvent); -MIR_CORE_DLL(HANDLE) db_event_next(HANDLE hDbEvent); -MIR_CORE_DLL(HANDLE) db_event_prev(HANDLE hDbEvent); +/****************************************************************************** + * DATABASE EVENTS + */ + +/* +Adds a new event to a contact's event list +Returns a handle to the newly added event, or NULL on failure +Triggers a db/event/added event just before it returns. +Events are sorted chronologically as they are entered, so you cannot guarantee +that the new hEvent is the last event in the chain, however if a new event is +added that has a timestamp less than 90 seconds *before* the event that should +be after it, it will be added afterwards, to allow for protocols that only +store times to the nearest minute, and slight delays in transports. +There are a few predefined eventTypes below for easier compatibility, but +modules are free to define their own, beginning at 2000 +DBEVENTINFO.timestamp is in GMT, as returned by time(). There are services +db/time/x below with useful stuff for dealing with it. +*/ + +#define EVENTTYPE_MESSAGE 0 +#define EVENTTYPE_URL 1 +#define EVENTTYPE_CONTACTS 2 //v0.1.2.2+ +#define EVENTTYPE_ADDED 1000 //v0.1.1.0+: these used to be module- +#define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module- +#define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000 + +MIR_CORE_DLL(HANDLE) db_event_add(HANDLE hContact, DBEVENTINFO *dbei); + +/* +Gets the number of events in the chain belonging to a contact in the database. +Returns the number of events in the chain owned by hContact or -1 if hContact +is invalid. They can be retrieved using the db_event_first/last() services. +*/ + +MIR_CORE_DLL(int) db_event_count(HANDLE hContact); + +/* +Removes a single event from the database +hDbEvent should have been returned by db_event_add/first/last/next/prev() +Returns 0 on success, or nonzero if hDbEvent was invalid +Triggers a db/event/deleted event just *before* the event is deleted +*/ + +MIR_CORE_DLL(int) db_event_delete(HANDLE hContact, HANDLE hDbEvent); + +/* +Retrieves a handle to the first event in the chain for hContact +Returns the handle, or NULL if hContact is invalid or has no events +Events in a chain are sorted chronologically automatically +*/ + +MIR_CORE_DLL(HANDLE) db_event_first(HANDLE hContact); + +/* +Retrieves a handle to the first unread event in the chain for hContact +Returns the handle, or NULL if hContact is invalid or all its events have been +read + +Events in a chain are sorted chronologically automatically, but this does not +necessarily mean that all events after the first unread are unread too. They +should be checked individually with db_event_next() and db_event_get() +This service is designed for startup, reloading all the events that remained +unread from last time +*/ + +MIR_CORE_DLL(HANDLE) db_event_firstUnread(HANDLE hContact); + +/* +Retrieves all the information stored in hDbEvent +hDbEvent should have been returned by db_event_add/first/last/next/prev() +Returns 0 on success or nonzero if hDbEvent is invalid +Don't forget to set dbe.cbSize, dbe.pBlob and dbe.cbBlob before calling this +service +The correct value dbe.cbBlob can be got using db/event/getblobsize +If successful, all the fields of dbe are filled. dbe.cbBlob is set to the +actual number of bytes retrieved and put in dbe.pBlob +If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob +and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob +On return, dbe.szModule is a pointer to the database module's own internal list +of modules. Look but don't touch. +*/ + +MIR_CORE_DLL(int) db_event_get(HANDLE hDbEvent, DBEVENTINFO *dbei); + +/* +Retrieves the space in bytes required to store the blob in hDbEvent +hDbEvent should have been returned by db_event_add/first/last/next/prev() +Returns the space required in bytes, or -1 if hDbEvent is invalid +*/ + +MIR_CORE_DLL(int) db_event_getBlobSize(HANDLE hDbEvent); + +/* +Retrieves a handle to the contact that owns hDbEvent. +hDbEvent should have been returned by db_event_add/first/last/next/prev() +NULL is a valid return value, meaning, as usual, the user. +Returns (HANDLE)(-1) if hDbEvent is invalid, or the handle to the contact on +success +This service is exceptionally slow. Use only when you have no other choice at +all. +*/ + +MIR_CORE_DLL(HANDLE) db_event_getContact(HANDLE hDbEvent); + +/* +Retrieves a handle to the last event in the chain for hContact +Returns the handle, or NULL if hContact is invalid or has no events +Events in a chain are sorted chronologically automatically +*/ + +MIR_CORE_DLL(HANDLE) db_event_last(HANDLE hDbEvent); + +/* +Changes the flags for an event to mark it as read. +hDbEvent should have been returned by db_event_add/first/last/next/prev() +Returns the entire flag DWORD for the event after the change, or -1 if hDbEvent +is invalid. +This is the one database write operation that does not trigger an event. +Modules should not save flags states for any length of time. +*/ + +MIR_CORE_DLL(int) db_event_markRead(HANDLE hContact, HANDLE hDbEvent); + +/* +Retrieves a handle to the next event in a chain after hDbEvent +Returns the handle, or NULL if hDbEvent is invalid or is the last event +Events in a chain are sorted chronologically automatically +*/ + +MIR_CORE_DLL(HANDLE) db_event_next(HANDLE hDbEvent); + +/* +Retrieves a handle to the previous event in a chain before hDbEvent +Returns the handle, or NULL if hDbEvent is invalid or is the first event +Events in a chain are sorted chronologically automatically +*/ + +MIR_CORE_DLL(HANDLE) db_event_prev(HANDLE hDbEvent); + +/****************************************************************************** + * DATABASE SETTINGS + */ 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); @@ -151,6 +304,8 @@ MIR_CORE_DLL(INT_PTR) db_set_ws(HANDLE hContact, const char *szModule, const cha 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_unset(HANDLE hContact, const char *szModule, const char *szSetting); + #if defined(__cplusplus) MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable=TRUE); #else @@ -191,28 +346,28 @@ typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM); #define CALLSERVICE_NOTFOUND ((int)0x80000000) #endif -MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name); -MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent); -MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook); -MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam); -MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam); -MIR_CORE_DLL(int) NotifyFastHook(HANDLE hEvent, WPARAM wParam, LPARAM lParam); - -MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc); -MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam); -MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object); -MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam); -MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message); -MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook); -MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject); -MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE pModule); - -MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc); -MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam); -MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object); -MIR_CORE_DLL(HANDLE) CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam); -MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService); -MIR_CORE_DLL(int) ServiceExists(const char *name); +MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name); +MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent); +MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook); +MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam); +MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam); +MIR_CORE_DLL(int) NotifyFastHook(HANDLE hEvent, WPARAM wParam, LPARAM lParam); + +MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc); +MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam); +MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object); +MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam); +MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message); +MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook); +MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject); +MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE pModule); + +MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc); +MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam); +MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object); +MIR_CORE_DLL(HANDLE) CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam); +MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService); +MIR_CORE_DLL(int) ServiceExists(const char *name); MIR_CORE_DLL(INT_PTR) CallService(const char *name, WPARAM wParam, LPARAM lParam); MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam); diff --git a/include/m_database.h b/include/m_database.h index a050bb2fb2..c5657b91b7 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -140,44 +140,12 @@ Implemented in the dbchecker plugins, thus it might not exist /************************* Contact ********************************/ -/* DB/Contact/GetSetting 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 -Caller is responsible for free()ing dbcgs.pValue->pszVal and pbVal if they are -returned. This should be done with db/contact/freevariant if you have your own -heap (like DLLs do). -Note that DBCONTACTGETSETTING takes a pointer to a DBVARIANT, whereas -DBCONTACTWRITESETTING contains a DBVARIANT. -Returns 0 on success or nonzero if the setting name was not found or hContact -was invalid -Because this is such a common function there are some short helper function at -the bottom of this header that use it. - -(Added during 0.3.3+ development!!) - -If a setting is queried under for contact and it is deleted it will -not be returned as a successful attempt, prior to 0.3.3 a *deleted* -setting would be successfully read (which was a bug because the pValue -was often garbage and maybe not even NULL terminated) - -To test for existing but 'deleted' settings, the return value will -be 2, and pValue->type == DBVT_DELETED, at this point pValue is undefined. -*/ typedef struct { const char *szModule; // pointer to name of the module that wrote the // setting to get const char *szSetting; // pointer to name of the setting to get DBVARIANT *pValue; // pointer to variant to receive the value } DBCONTACTGETSETTING; -#define MS_DB_CONTACT_GETSETTING "DB/Contact/GetSetting" - -/* DB/Contact/GetSettingString service 0.4.3+ -Same as DB/Contact/GetSetting, but also gets the required string type inside -the dbcgs->type parameter -*/ -#define MS_DB_CONTACT_GETSETTING_STR "DB/Contact/GetSettingStr" /* DB/Contact/GetSettingStatic service Look up the value of a named setting for a specific contact in the database @@ -206,24 +174,6 @@ was invalid. */ #define MS_DB_CONTACT_GETSETTINGSTATIC "DB/Contact/GetSettingStatic" -/* DB/Contact/FreeVariant service -Free the memory in a DBVARIANT that is allocated by a call to -db/contact/getsetting - wParam = 0 - lParam = (LPARAM)(DBVARIANT*)&dbv -Returns 0 on success, nonzero otherwise -This service is actually just a wrapper around a call to free() and a test to -check that it is a string or a blob in the variant. It exists because DLLs have -their own heap and cannot free the memory allocated in db/contact/getsetting. -Thus it need not be called if you know the variant contains some form of int, -and you will often see free() used instead in code written before I noticed -this problem. -Good style, of course, dictates that it should be present to match all calls to -db/contact/getsetting, but that's not going to happen of course. -There's a helper function for this at the bottom of this header too. -*/ -#define MS_DB_CONTACT_FREEVARIANT "DB/Contact/FreeVariant" - /* DB/Contact/WriteSetting service Change the value of, or create a new value with, a named setting for a specific contact in the database to the given value @@ -245,20 +195,6 @@ typedef struct { } DBCONTACTWRITESETTING; #define MS_DB_CONTACT_WRITESETTING "DB/Contact/WriteSetting" -/* DB/Contact/DeleteSetting service -Removes a named setting for a specific contact from the database - wParam = (WPARAM)(HANDLE)hContact - lParam = (LPARAM)(DBCONTACTGETSETTING*)&dbcgs -hContact should have been returned by find*contact or addcontact -pValue from dbcgs is not used. -Returns 0 on success or nonzero if the setting was not present or hContact was -invalid -Triggers a db/contact/settingchanged event before it deletes the setting. The -'new value' of the setting is set to type = 0 and all the other fields are -undefined. -*/ -#define MS_DB_CONTACT_DELETESETTING "DB/Contact/DeleteSetting" - /* db/contact/enumsettings v0.1.0.1+ Lists all the settings a specific modules has stored in the database for a specific contact. @@ -290,25 +226,6 @@ and contact/findnext */ #define MS_DB_CONTACT_GETCOUNT "DB/Contact/GetCount" -/* DB/Contact/FindFirst service -Gets the handle of the first contact in the database. This handle can be used -with loads of functions. It does not need to be closed. - wParam = lParam = 0 -Returns a handle to the first contact in the db on success, or NULL if there -are no contacts in the db. -*/ -#define MS_DB_CONTACT_FINDFIRST "DB/Contact/FindFirst" - -/* DB/Contact/FindNext service -Gets the handle of the next contact after hContact in the database. This handle -can be used with loads of functions. It does not need to be closed. - wParam = (WPARAM)(HANDLE)hContact - lParam = 0 -Returns a handle to the contact after hContact in the db on success or NULL if -hContact was the last contact in the db or hContact was invalid. -*/ -#define MS_DB_CONTACT_FINDNEXT "DB/Contact/FindNext" - /* DB/Contact/Delete Deletes the contact hContact from the database and all events and settings associated with it. @@ -376,7 +293,6 @@ typedef struct #define DETF_MSGWINDOW 2 // show event in message window #define DETF_NONOTIFY 4 // block event notify (e.g. Popups) - #define MS_DB_EVENT_REGISTERTYPE "DB/EventType/Register" /* DB/EventType/Get service (0.7+) @@ -388,81 +304,10 @@ Returns DBEVENTTYPEDESCR* or NULL, if an event isn't found. #define MS_DB_EVENT_GETTYPE "DB/EventType/Get" -/* DB/Event/GetCount service -Gets the number of events in the chain belonging to a contact in the database. - wParam = (WPARAM)(HANDLE)hContact - lParam = 0 -Returns the number of events in the chain owned by hContact or -1 if hContact -is invalid. They can be retrieved using the event/find* services. -*/ -#define MS_DB_EVENT_GETCOUNT "DB/Event/GetCount" - -/* DB/Event/Add -Adds a new event to a contact's event list - wParam = (WPARAM)(HANDLE)hContact - lParam = (LPARAM)(DBEVENTINFO*)&dbe -Returns a handle to the newly added event, or NULL on failure -Triggers a db/event/added event just before it returns. -Events are sorted chronologically as they are entered, so you cannot guarantee -that the new hEvent is the last event in the chain, however if a new event is -added that has a timestamp less than 90 seconds *before* the event that should -be after it, it will be added afterwards, to allow for protocols that only -store times to the nearest minute, and slight delays in transports. -There are a few predefined eventTypes below for easier compatibility, but -modules are free to define their own, beginning at 2000 -DBEVENTINFO.timestamp is in GMT, as returned by time(). There are services -db/time/x below with useful stuff for dealing with it. -*/ - -#define EVENTTYPE_MESSAGE 0 -#define EVENTTYPE_URL 1 -#define EVENTTYPE_CONTACTS 2 //v0.1.2.2+ -#define EVENTTYPE_ADDED 1000 //v0.1.1.0+: these used to be module- -#define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module- -#define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000 -#define MS_DB_EVENT_ADD "DB/Event/Add" - __forceinline HANDLE DbGetAuthEventContact(DBEVENTINFO* dbei) { return (HANDLE)(*(DWORD*)&dbei->pBlob[sizeof(DWORD)]); } -/* DB/Event/Delete -Removes a single event from the database - wParam = (WPARAM)(HANDLE)hContact - lParam = (LPARAM)(HANDLE)hDbEvent -hDbEvent should have been returned by db/event/add or db/event/find*event -Returns 0 on success, or nonzero if hDbEvent was invalid -Triggers a db/event/deleted event just *before* the event is deleted -*/ -#define MS_DB_EVENT_DELETE "DB/Event/Delete" - -/* DB/Event/GetBlobSize -Retrieves the space in bytes required to store the blob in hDbEvent - wParam = (WPARAM)(HANDLE)hDbEvent - lParam = 0 -hDbEvent should have been returned by db/event/add or db/event/find*event -Returns the space required in bytes, or -1 if hDbEvent is invalid -*/ -#define MS_DB_EVENT_GETBLOBSIZE "DB/Event/GetBlobSize" - -/* DB/Event/Get -Retrieves all the information stored in hDbEvent - wParam = (WPARAM)(HANDLE)hDbEvent - lParam = (LPARAM)(DBEVENTINFO*)&dbe -hDbEvent should have been returned by db/event/add or db/event/find*event -Returns 0 on success or nonzero if hDbEvent is invalid -Don't forget to set dbe.cbSize, dbe.pBlob and dbe.cbBlob before calling this -service -The correct value dbe.cbBlob can be got using db/event/getblobsize -If successful, all the fields of dbe are filled. dbe.cbBlob is set to the -actual number of bytes retrieved and put in dbe.pBlob -If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob -and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob -On return, dbe.szModule is a pointer to the database module's own internal list -of modules. Look but don't touch. -*/ -#define MS_DB_EVENT_GET "DB/Event/Get" - /* DB/Event/GetText (0.7.0+) Retrieves the event's text wParam = (WPARAM)0 (unused) @@ -532,81 +377,6 @@ __forceinline TCHAR* DbGetEventStringT(DBEVENTINFO* dbei, const char* str) return (TCHAR*)CallService(MS_DB_EVENT_GETSTRINGT, (WPARAM)dbei, (LPARAM)str); } -/* DB/Event/MarkRead -Changes the flags for an event to mark it as read. - wParam = (WPARAM)(HANDLE)hContact - lParam = (LPARAM)(HANDLE)hDbEvent -hDbEvent should have been returned by db/event/add or db/event/find*event -Returns the entire flag DWORD for the event after the change, or -1 if hDbEvent -is invalid. -This is the one database write operation that does not trigger an event. -Modules should not save flags states for any length of time. -*/ -#define MS_DB_EVENT_MARKREAD "DB/Event/MarkRead" - -/* DB/Event/GetContact -Retrieves a handle to the contact that owns hDbEvent. - wParam = (WPARAM)(HANDLE)hDbEvent - lParam = 0 -hDbEvent should have been returned by db/event/add or db/event/find*event -NULL is a valid return value, meaning, as usual, the user. -Returns (HANDLE)(-1) if hDbEvent is invalid, or the handle to the contact on -success -This service is exceptionally slow. Use only when you have no other choice at -all. -*/ -#define MS_DB_EVENT_GETCONTACT "DB/Event/GetContact" - -/* DB/Event/FindFirst -Retrieves a handle to the first event in the chain for hContact - wParam = (WPARAM)(HANDLE)hContact - lParam = 0 -Returns the handle, or NULL if hContact is invalid or has no events -Events in a chain are sorted chronologically automatically -*/ -#define MS_DB_EVENT_FINDFIRST "DB/Event/FindFirst" - -/* DB/Event/FindFirstUnread -Retrieves a handle to the first unread event in the chain for hContact - wParam = (WPARAM)(HANDLE)hContact - lParam = 0 -Returns the handle, or NULL if hContact is invalid or all its events have been -read -Events in a chain are sorted chronologically automatically, but this does not -necessarily mean that all events after the first unread are unread too. They -should be checked individually with event/findnext and event/get -This service is designed for startup, reloading all the events that remained -unread from last time -*/ -#define MS_DB_EVENT_FINDFIRSTUNREAD "DB/Event/FindFirstUnread" - -/* DB/Event/FindLast -Retrieves a handle to the last event in the chain for hContact - wParam = (WPARAM)(HANDLE)hContact - lParam = 0 -Returns the handle, or NULL if hContact is invalid or has no events -Events in a chain are sorted chronologically automatically -*/ -#define MS_DB_EVENT_FINDLAST "DB/Event/FindLast" - -/* DB/Event/FindNext -Retrieves a handle to the next event in a chain after hDbEvent - wParam = (WPARAM)(HANDLE)hDbEvent - lParam = 0 -Returns the handle, or NULL if hDbEvent is invalid or is the last event -Events in a chain are sorted chronologically automatically -*/ -#define MS_DB_EVENT_FINDNEXT "DB/Event/FindNext" - -/* DB/Event/FindPrev -Retrieves a handle to the previous event in a chain before hDbEvent - wParam = (WPARAM)(HANDLE)hDbEvent - lParam = 0 -Returns the handle, or NULL if hDbEvent is invalid or is the first event -Events in a chain are sorted chronologically automatically -*/ -#define MS_DB_EVENT_FINDPREV "DB/Event/FindPrev" - /************************** Encryption ****************************/ /* DB/Crypt/EncodeString diff --git a/include/m_protoint.h b/include/m_protoint.h index 0c457f03cc..9849bbe320 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -54,7 +54,7 @@ struct PROTO_INTERFACE : public MZeroedObject char* m_szModuleName; HANDLE m_hProtoIcon; - DWORD __forceinline ProtoBroadcastAck(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam) + INT_PTR __forceinline ProtoBroadcastAck(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam) { return ::ProtoBroadcastAck(m_szModuleName, hContact, type, hResult, hProcess, lParam); } 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); diff --git a/protocols/GTalkExt/src/tipper_items.cpp b/protocols/GTalkExt/src/tipper_items.cpp index 77c5e60e95..6dc8a3d6ae 100644 --- a/protocols/GTalkExt/src/tipper_items.cpp +++ b/protocols/GTalkExt/src/tipper_items.cpp @@ -48,21 +48,20 @@ void ShiftTipperSettings(LPSTR buff, int count, LPSTR format) { for (int i = count; i > 0; i--) { DBCONTACTWRITESETTING cws; - DBCONTACTGETSETTING cgs; - cgs.szModule = TIPPER_ITEMS_MOD_NAME; sprintf(buff, format, i - 1); - cgs.szSetting = buff; - cgs.pValue = &cws.value; - if (CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&cgs)) break; + if (db_get(0, TIPPER_ITEMS_MOD_NAME, buff, &cws.value)) + break; + __try { if (DBVT_ASCIIZ == cws.value.type) { db_free(&cws.value); - cws.value.type = DBVT_WCHAR; - if (CallService(MS_DB_CONTACT_GETSETTING_STR, 0, (LPARAM)&cgs)) break; + if (db_get_ws(0, TIPPER_ITEMS_MOD_NAME, buff, &cws.value)) + break; } - if (CallService(MS_DB_CONTACT_GETSETTING_STR, 0, (LPARAM)&cgs)) break; + if (db_get_s(0, TIPPER_ITEMS_MOD_NAME, buff, &cws.value)) + break; cws.szModule = TIPPER_ITEMS_MOD_NAME; sprintf(buff, format, i); diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index 2d140d8094..9442d860d6 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -89,15 +89,10 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM wParam, LPARAM lParam) DBCONTACTGETSETTING *cgs = (DBCONTACTGETSETTING*)lParam; BYTE type = cgs->pValue->type; - cgs->pValue->type = 0; // original type without conversion - INT_PTR rc = CallService(MS_DB_CONTACT_GETSETTING_STR, wParam, lParam); - + DBVARIANT dbv = { 0 }; + INT_PTR rc = db_get_s((HANDLE)wParam, cgs->szModule, cgs->szSetting, &dbv, 0); if (!rc) { // Success - DBVARIANT dbv; - - memcpy(&dbv, cgs->pValue, sizeof(DBVARIANT)); - if (dbv.type == DBVT_BLOB) { cgs->pValue->pbVal = (BYTE*)mir_alloc(dbv.cpbVal); @@ -742,23 +737,15 @@ INT_PTR __cdecl CIcqProto::IcqAddCapability(WPARAM wParam, LPARAM lParam) INT_PTR __cdecl CIcqProto::IcqCheckCapability(WPARAM wParam, LPARAM lParam) { int res = 0; - DBCONTACTGETSETTING dbcgs; DBVARIANT dbvariant; HANDLE hContact = (HANDLE)wParam; ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)lParam; - dbcgs.pValue = &dbvariant; - dbcgs.szModule = m_szModuleName; - dbcgs.szSetting = "CapBuf"; - - CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + db_get(hContact, m_szModuleName, "CapBuf", &dbvariant); if (dbvariant.type == DBVT_BLOB) - { res = MatchCapability(dbvariant.pbVal, dbvariant.cpbVal, (const capstr*)&icqCustomCap->caps, 0x10)?1:0; // FIXME: Why icqCustomCap->caps is not capstr? - } - - CallService(MS_DB_CONTACT_FREEVARIANT,0,(LPARAM)(DBVARIANT*)&dbvariant); + db_free(&dbvariant); return res; } diff --git a/protocols/MRA/src/MraAntiSpam.cpp b/protocols/MRA/src/MraAntiSpam.cpp index 2eaa64348e..e3bc5edd82 100644 --- a/protocols/MRA/src/MraAntiSpam.cpp +++ b/protocols/MRA/src/MraAntiSpam.cpp @@ -17,15 +17,8 @@ static size_t dwBadWordsCount = 0; size_t MraAntiSpamLoadBadWordsW() { - char szSettingName[MAX_PATH]; - size_t i = 0, dwValueSize, dwAllocatedItemsCount = MRA_ANTISPAM_PREALLOC_COUNT; DBVARIANT dbv = {0}; - DBCONTACTGETSETTING sVal = {0}; - - dbv.type = DBVT_WCHAR; - sVal.pValue = &dbv; - sVal.szModule = "MRA"; - sVal.szSetting = szSettingName; + size_t i = 0, dwValueSize, dwAllocatedItemsCount = MRA_ANTISPAM_PREALLOC_COUNT; if (pmabwBadWords || dwBadWordsCount) MraAntiSpamFreeBadWords(); @@ -33,9 +26,9 @@ size_t MraAntiSpamLoadBadWordsW() pmabwBadWords = (MRA_ANTISPAM_BAD_WORD*)mir_calloc((sizeof(MRA_ANTISPAM_BAD_WORD)*dwAllocatedItemsCount)); for (i = 0;TRUE;i++) { + char szSettingName[MAX_PATH]; mir_snprintf(szSettingName, SIZEOF(szSettingName), "AntiSpamBadWord %lu", i); - dbv.type = DBVT_WCHAR; - if (CallService(MS_DB_CONTACT_GETSETTING_STR, NULL, (LPARAM)&sVal)) + if (db_get_ws(NULL, "MRA", szSettingName, &dbv)) break; if (dwAllocatedItemsCount == i) { diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index d4a5f657ac..65ed85f6c1 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -207,13 +207,7 @@ BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam BOOL bRet = FALSE; size_t dwReadedStringLen, dwRetBuffSizeLocal; 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 (lpszRetBuff && (dwRetBuffSize>dwReadedStringLen)) @@ -241,13 +235,7 @@ BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam 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)) @@ -344,12 +332,7 @@ BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszVal { BOOL bRet = FALSE; DBVARIANT dbv; - DBCONTACTGETSETTING sVal = {0}; - - sVal.pValue = &dbv; - sVal.szModule = lpszModule; - sVal.szSetting = lpszValueName; - if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&sVal) == 0) + if (db_get(hContact, lpszModule, lpszValueName, &dbv) == 0) { if (dbv.type == DBVT_BLOB) { diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 932cc30c5f..176fe529f2 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -182,7 +182,7 @@ HANDLE CSkypeProto::GetContactFromAuthEvent(HANDLE hEvent) dbei.cbBlob = sizeof(DWORD) * 2; dbei.pBlob = (PBYTE)&body; - if (::CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei)) + if (::db_event_get(hEvent, &dbei)) return INVALID_HANDLE_VALUE; if (dbei.eventType != EVENTTYPE_AUTHREQUEST) diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 031d21fc36..5dac1643bf 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -28,12 +28,7 @@ template inline static T db_pod_get(HANDLE hContact,const char *module,const char *setting,T errorValue) { DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - - cgs.szModule = module; - cgs.szSetting = setting; - cgs.pValue = &dbv; - if(CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs)) + if(db_get(hContact, module, setting, &dbv)) return errorValue; // TODO: remove this, it's just a temporary workaround diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp index 6108a31fe2..9fa264df86 100644 --- a/src/modules/clist/clistmod.cpp +++ b/src/modules/clist/clistmod.cpp @@ -216,11 +216,6 @@ static void RemoveProtoIconIndex(PROTOACCOUNT* pa) static int ContactListModulesLoaded(WPARAM, LPARAM) { - if ( !ServiceExists(MS_DB_CONTACT_GETSETTING_STR)) { - MessageBox(NULL, TranslateT("This plugin requires db3x plugin version 0.5.1.0 or later"), _T("CList"), MB_ICONERROR | MB_OK); - return 1; - } - RebuildMenuOrder(); for (int i=0; i < accounts.getCount(); i++) AddProtoIconIndex(accounts[i]); diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp index c1c69cece8..78102a8e80 100644 --- a/src/modules/database/dbintf.cpp +++ b/src/modules/database/dbintf.cpp @@ -45,16 +45,6 @@ static INT_PTR srvGetContactCount(WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////// // Contacts -static INT_PTR srvFindFirstContact(WPARAM, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindFirstContact((LPCSTR)lParam) : 0; -} - -static INT_PTR srvFindNextContact(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindNextContact((HANDLE)wParam, (LPCSTR)lParam) : 0; -} - static INT_PTR srvDeleteContact(WPARAM wParam, LPARAM) { return (currDb) ? currDb->DeleteContact((HANDLE)wParam) : 0; @@ -70,69 +60,6 @@ static INT_PTR srvIsDbContact(WPARAM wParam, LPARAM) return (currDb) ? currDb->IsDbContact((HANDLE)wParam) : 0; } -/////////////////////////////////////////////////////////////////////////////// -// Events - -static INT_PTR srvGetEventCount(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? currDb->GetEventCount((HANDLE)wParam) : 0; -} - -static INT_PTR srvAddEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->AddEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0; -} - -static INT_PTR srvDeleteEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? currDb->DeleteEvent((HANDLE)wParam, (HANDLE)lParam) : 0; -} - -static INT_PTR srvGetBlobSize(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? currDb->GetBlobSize((HANDLE)wParam) : 0; -} - -static INT_PTR srvGetEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->GetEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0; -} - -static INT_PTR srvMarkEventRead(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? currDb->MarkEventRead((HANDLE)wParam, (HANDLE)lParam) : 0; -} - -static INT_PTR srvGetEventContact(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->GetEventContact((HANDLE)wParam) : 0; -} - -static INT_PTR srvFindFirstEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindFirstEvent((HANDLE)wParam) : 0; -} - -static INT_PTR srvFindFirstUnreadEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindFirstUnreadEvent((HANDLE)wParam) : 0; -} - -static INT_PTR srvFindLastEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindLastEvent((HANDLE)wParam) : 0; -} - -static INT_PTR srvFindNextEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindNextEvent((HANDLE)wParam) : 0; -} - -static INT_PTR srvFindPrevEvent(WPARAM wParam, LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FindPrevEvent((HANDLE)wParam) : 0; -} - /////////////////////////////////////////////////////////////////////////////// // Module chain @@ -144,36 +71,16 @@ static INT_PTR srvEnumModuleNames(WPARAM wParam,LPARAM lParam) /////////////////////////////////////////////////////////////////////////////// // Settings -static INT_PTR srvGetContactSetting(WPARAM wParam,LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->GetContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0; -} - -static INT_PTR srvGetContactSettingStr(WPARAM wParam,LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->GetContactSettingStr((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0; -} - static INT_PTR srvGetContactSettingStatic(WPARAM wParam,LPARAM lParam) { return (currDb) ? (INT_PTR)currDb->GetContactSettingStatic((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0; } -static INT_PTR srvFreeVariant(WPARAM wParam,LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->FreeVariant((DBVARIANT*)lParam) : 0; -} - static INT_PTR srvWriteContactSetting(WPARAM wParam,LPARAM lParam) { return (currDb) ? (INT_PTR)currDb->WriteContactSetting((HANDLE)wParam, (DBCONTACTWRITESETTING*)lParam) : 0; } -static INT_PTR srvDeleteContactSetting(WPARAM wParam,LPARAM lParam) -{ - return (currDb) ? (INT_PTR)currDb->DeleteContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0; -} - static INT_PTR srvEnumContactSettings(WPARAM wParam,LPARAM lParam) { return (currDb) ? (INT_PTR)currDb->EnumContactSettings((HANDLE)wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0; @@ -241,33 +148,14 @@ int LoadDbintfModule() CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode); CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount); - CreateServiceFunction(MS_DB_CONTACT_FINDFIRST, srvFindFirstContact); - CreateServiceFunction(MS_DB_CONTACT_FINDNEXT, srvFindNextContact); CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact); CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact); CreateServiceFunction(MS_DB_CONTACT_IS, srvIsDbContact); - CreateServiceFunction(MS_DB_EVENT_GETCOUNT, srvGetEventCount); - CreateServiceFunction(MS_DB_EVENT_ADD, srvAddEvent); - CreateServiceFunction(MS_DB_EVENT_DELETE, srvDeleteEvent); - CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE, srvGetBlobSize); - CreateServiceFunction(MS_DB_EVENT_GET, srvGetEvent); - CreateServiceFunction(MS_DB_EVENT_MARKREAD, srvMarkEventRead); - CreateServiceFunction(MS_DB_EVENT_GETCONTACT, srvGetEventContact); - CreateServiceFunction(MS_DB_EVENT_FINDFIRST, srvFindFirstEvent); - CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD, srvFindFirstUnreadEvent); - CreateServiceFunction(MS_DB_EVENT_FINDLAST, srvFindLastEvent); - CreateServiceFunction(MS_DB_EVENT_FINDNEXT, srvFindNextEvent); - CreateServiceFunction(MS_DB_EVENT_FINDPREV, srvFindPrevEvent); - CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames); - CreateServiceFunction(MS_DB_CONTACT_GETSETTING, srvGetContactSetting); - CreateServiceFunction(MS_DB_CONTACT_GETSETTING_STR, srvGetContactSettingStr); CreateServiceFunction(MS_DB_CONTACT_GETSETTINGSTATIC, srvGetContactSettingStatic); - CreateServiceFunction(MS_DB_CONTACT_FREEVARIANT, srvFreeVariant); CreateServiceFunction(MS_DB_CONTACT_WRITESETTING, srvWriteContactSetting); - CreateServiceFunction(MS_DB_CONTACT_DELETESETTING, srvDeleteContactSetting); CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings); CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings); -- cgit v1.2.3