diff options
174 files changed, 627 insertions, 1323 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex e2bbe89dbb..3e12883dd4 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex 0fe2c7b8da..afffb493c0 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib Binary files differindex e2bbe89dbb..3e12883dd4 100644 --- a/bin12/lib/mir_core.lib +++ b/bin12/lib/mir_core.lib diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib Binary files differindex 0fe2c7b8da..afffb493c0 100644 --- a/bin12/lib/mir_core64.lib +++ b/bin12/lib/mir_core64.lib diff --git a/bin14/lib/mir_core.lib b/bin14/lib/mir_core.lib Binary files differindex e2bbe89dbb..3e12883dd4 100644 --- a/bin14/lib/mir_core.lib +++ b/bin14/lib/mir_core.lib diff --git a/bin14/lib/mir_core64.lib b/bin14/lib/mir_core64.lib Binary files differindex 0fe2c7b8da..afffb493c0 100644 --- a/bin14/lib/mir_core64.lib +++ b/bin14/lib/mir_core64.lib diff --git a/include/delphi/m_api.pas b/include/delphi/m_api.pas index e7a5a82b91..c20865c82c 100644 --- a/include/delphi/m_api.pas +++ b/include/delphi/m_api.pas @@ -201,7 +201,6 @@ var {$include m_contacts.inc}
{$include m_crypto.inc}
{$include m_database.inc}
- {$include m_db_int.inc}
{$include m_descbutton.inc}
{$include m_email.inc}
{$include m_extraicons.inc}
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index b11c097a1e..8dd608b9c4 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -67,8 +67,7 @@ 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.
}
-function db_event_add(hContact:TMCONTACT; dbei:PDBEVENTINFO):TMEVENT; stdcall;
- external CoreDLL name 'db_event_add';
+function db_event_add(hContact:TMCONTACT; dbei:PDBEVENTINFO):TMEVENT; stdcall; external CoreDLL;
{
Gets the number of events in the chain belonging to a contact in the database.
@@ -76,8 +75,7 @@ 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.
Returns 0 for Subcontacts (use db_event_last to recognize empty history)
}
-function db_event_count(hContact:TMCONTACT):int; stdcall;
- external CoreDLL name 'db_event_count';
+function db_event_count(hContact:TMCONTACT):int; stdcall; external CoreDLL;
{
Removes a single event from the database
@@ -85,16 +83,14 @@ 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
}
-function db_event_delete(hContact:TMCONTACT; hDbEvent:TMEVENT):int; stdcall;
- external CoreDLL name 'db_event_delete';
+function db_event_delete(hContact:TMCONTACT; hDbEvent:TMEVENT):int; stdcall; external CoreDLL;
{
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
}
-function db_event_first(hContact:TMCONTACT):TMEVENT; stdcall;
- external CoreDLL name 'db_event_first';
+function db_event_first(hContact:TMCONTACT):TMEVENT; stdcall; external CoreDLL;
{
Retrieves a handle to the first unread event in the chain for hContact
@@ -107,8 +103,7 @@ 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
}
-function db_event_firstUnread(hContact:TMCONTACT):TMEVENT; stdcall;
- external CoreDLL name 'db_event_firstUnread';
+function db_event_firstUnread(hContact:TMCONTACT):TMEVENT; stdcall; external CoreDLL;
{
Retrieves all the information stored in hDbEvent
@@ -124,16 +119,14 @@ 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.
}
-function db_event_get(hDbEvent:TMEVENT; dbei:PDBEVENTINFO):int; stdcall;
- external CoreDLL name 'db_event_get';
+function db_event_get(hDbEvent:TMEVENT; dbei:PDBEVENTINFO):int; stdcall; external CoreDLL;
{
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
}
-function db_event_getBlobSize(hDbEvent:TMEVENT):int; stdcall;
- external CoreDLL name 'db_event_getBlobSize';
+function db_event_getBlobSize(hDbEvent:TMEVENT):int; stdcall; external CoreDLL;
{
Retrieves a handle to the contact that owns hDbEvent.
@@ -144,16 +137,14 @@ success This service is exceptionally slow. Use only when you have no other choice at
all.
}
-function db_event_getContact(hDbEvent:TMEVENT):TMCONTACT; stdcall;
- external CoreDLL name 'db_event_getContact';
+function db_event_getContact(hDbEvent:TMEVENT):TMCONTACT; stdcall; external CoreDLL;
{
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
}
-function db_event_last(hContact:TMCONTACT):TMEVENT; stdcall;
- external CoreDLL name 'db_event_last';
+function db_event_last(hContact:TMCONTACT):TMEVENT; stdcall; external CoreDLL;
{
Changes the flags for an event to mark it as read.
@@ -163,27 +154,23 @@ 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.
}
-function db_event_markRead(hContact:TMCONTACT; hDbEvent:TMEVENT):int; stdcall;
- external CoreDLL name 'db_event_markRead';
+function db_event_markRead(hContact:TMCONTACT; hDbEvent:TMEVENT):int; stdcall; external CoreDLL;
{
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
}
-function db_event_next(hContact:TMCONTACT; hDbEvent:TMEVENT):THANDLE; stdcall;
- external CoreDLL name 'db_event_next';
+function db_event_next(hContact:TMCONTACT; hDbEvent:TMEVENT):THANDLE; stdcall; external CoreDLL;
{
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
}
-function db_event_prev(hContact:TMCONTACT; hDbEvent:TMEVENT):THANDLE; stdcall;
- external CoreDLL name 'db_event_prev';
+function db_event_prev(hContact:TMCONTACT; hDbEvent:TMEVENT):THANDLE; stdcall; external CoreDLL;
-function db_free(dbv:PDBVARIANT):int_ptr; stdcall;
- external CoreDLL name 'db_free';
+function db_free(dbv:PDBVARIANT):int_ptr; stdcall; external CoreDLL;
(******************************************************************************
* DATABASE CONTACTS
@@ -196,8 +183,7 @@ 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.
}
-function db_find_first(const szModule:PAnsiChar=nil):TMCONTACT; stdcall;
- external CoreDLL name 'db_find_first';
+function db_find_first(const szModule:PAnsiChar=nil):TMCONTACT; stdcall; external CoreDLL;
{
Gets the handle of the next contact after hContact in the database. This handle
@@ -206,57 +192,45 @@ 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.
}
-function db_find_next(hContact:TMCONTACT; const szModule:PAnsiChar=nil):TMCONTACT; stdcall;
- external CoreDLL name 'db_find_next';
+function db_find_next(hContact:TMCONTACT; const szModule:PAnsiChar=nil):TMCONTACT; stdcall; external CoreDLL;
(******************************************************************************
* DATABASE SETTINGS
*)
-function db_get(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall;
- external CoreDLL name 'db_get';
-function db_get_b(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall;
- external CoreDLL name 'db_get_b';
-function db_get_w(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall;
- external CoreDLL name 'db_get_w';
-function db_get_dw(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:dword):dword; stdcall;
- external CoreDLL name 'db_get_dw';
-function db_get_s(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT; const nType:int=DBVT_ASCIIZ):int_ptr; stdcall;
- external CoreDLL name 'db_get_s';
-function db_get_sa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PAnsiChar; stdcall;
- external CoreDLL name 'db_get_sa';
-function db_get_wsa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PWideChar; stdcall;
- external CoreDLL name 'db_get_wsa';
-
-function db_get_static(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall;
- external CoreDLL name 'db_get_static';
-function db_get_static_utf(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall;
- external CoreDLL name 'db_get_static_utf';
-function db_get_wstatic(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PWideChar; destLen:int):int; stdcall;
- external CoreDLL name 'db_get_wstatic';
-
-function db_set(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall;
- external CoreDLL name 'db_set';
-function db_set_b(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:byte):int_ptr; stdcall;
- external CoreDLL name 'db_set_b';
-function db_set_w(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:word):int_ptr; stdcall;
- external CoreDLL name 'db_set_w';
-function db_set_dw(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:dword):int_ptr; stdcall;
- external CoreDLL name 'db_set_dw';
-function db_set_s(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall;
- external CoreDLL name 'db_set_s';
-function db_set_ws(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PWideChar):int_ptr; stdcall;
- external CoreDLL name 'db_set_ws';
-function db_set_utf(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall;
- external CoreDLL name 'db_set_utf';
-function db_set_blob(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:pointer; len:uint):int_ptr; stdcall;
- external CoreDLL name 'db_set_blob';
-
-function db_unset(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):int_ptr; stdcall;
- external CoreDLL name 'db_unset';
-
-function db_set_resident(const szModule:PAnsiChar; const szSetting:PAnsiChar; bEnable:int):int; stdcall;
- external CoreDLL name 'db_set_resident';
+function db_get(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall; external CoreDLL;
+function db_get_b(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall; external CoreDLL;
+function db_get_w(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall; external CoreDLL;
+function db_get_dw(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:dword):dword; stdcall; external CoreDLL;
+function db_get_s(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT; const nType:int=DBVT_ASCIIZ):int_ptr; stdcall; external CoreDLL;
+function db_get_sa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PAnsiChar; stdcall; external CoreDLL;
+function db_get_wsa(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PWideChar; stdcall; external CoreDLL;
+
+function db_get_static(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall; external CoreDLL;
+function db_get_static_utf(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PAnsiChar; destLen:int):int; stdcall; external CoreDLL;
+function db_get_wstatic(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; szDest:PWideChar; destLen:int):int; stdcall; external CoreDLL;
+
+function db_set(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall; external CoreDLL;
+function db_set_b(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:byte):int_ptr; stdcall; external CoreDLL;
+function db_set_w(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:word):int_ptr; stdcall; external CoreDLL;
+function db_set_dw(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:dword):int_ptr; stdcall; external CoreDLL;
+function db_set_s(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall; external CoreDLL;
+function db_set_ws(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PWideChar):int_ptr; stdcall; external CoreDLL;
+function db_set_utf(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall; external CoreDLL;
+function db_set_blob(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:pointer; len:uint):int_ptr; stdcall; external CoreDLL;
+
+function db_unset(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):int_ptr; stdcall; external CoreDLL;
+
+function db_set_resident(const szModule:PAnsiChar; const szSetting:PAnsiChar; bEnable:int):int; stdcall; external CoreDLL;
+
+///////////////////////////////////////////////////////////////////////////////
+
+function db_add_contact() : TMCONTACT; stdcall; external CoreDLL;
+function db_delete_contact(hContact:TMCONTACT) : int; stdcall; external CoreDLL;
+
+function db_is_contact(hContact:TMCONTACT) : int; stdcall; external CoreDLL;
+
+function db_get_contact_count() : int; stdcall; external CoreDLL;
///////////////////////////////////////////////////////////////////////////////
@@ -299,62 +273,7 @@ type type
TDBSETTINGENUMPROC = function(const szSetting: PAnsiChar; lParam: LPARAM): int; cdecl;
- PDBCONTACTENUMSETTINGS = ^TDBCONTACTENUMSETTINGS;
- TDBCONTACTENUMSETTINGS = record
- pfnEnumProc: TDBSETTINGENUMPROC; // function pointer to call to start the
- // enum via MS_DB_CONTACT_ENUMSETTINGS
- lParam : LPARAM; // passed to the above function
- szModule : PAnsiChar; // name of the module to get settings for
- ofsSettings: dword; // not used by us
- end;
-
-const
- MS_DB_CONTACT_ENUMSETTINGS:PAnsiChar = 'DB/Contact/EnumSettings';
-
- {
- wParam : 0
- lParam : 0
- affect : none
- returns: Returns the number of contacts in the database for the loaded profile
- not including the profile user, see notes.
- notes : the contacts in the database can be read with FindFirst/FindNext
- }
- MS_DB_CONTACT_GETCOUNT:PAnsiChar = 'DB/Contact/GetCount';
-
- {
- wParam : Handle of a contact to delete
- lParam : 0
- affect : the user by the given handle is deleted from the database, see notes
- returns: Returns 0 on success or nonzero if the handle was invalid
- notes : this triggers DB/Contact/Deleted BEFORE it actually deletes the contact
- all events are also deleted -- other modules may end up with invalid
- handles because of this, which they should be prepared for.
- }
- MS_DB_CONTACT_DELETE:PAnsiChar = 'DB/Contact/Delete';
-
- {
- wParam : 0
- lParam : 0
- affects: creates a new contact in the database, they have no settings,
- settings must be added with MS_DB_CONTACT_WRITESETTING or
- database helper functions for writing, see notes
- returns: A handle to a new contact or NULL(0) on failure.
- notes : triggers the ME_DB_CONTACT_ADDED event just before the service returns
- }
- MS_DB_CONTACT_ADD:PAnsiChar = 'DB/Contact/Add';
-
-
- {
- wParam : (HANDLE) hContact
- lParam : 0
- affects: Checks the given handle within the database for valid information, for
- a proper internal header.
- returns: Returns 1 if the contact handle is valid, 0 if it is not
- notes : Due to the nature of multiple threading a contact handle can be deleted
- soon after this service has returned a handle as valid, however it will never point
- to another contact.
- }
- MS_DB_CONTACT_IS:PAnsiChar = 'DB/Contact/Is';
+function db_enum_settings(hContact:TMCONTACT; pFunc:TDBSETTINGENUMPROC; szModule:PAnsiChar; param:pointer) : int; stdcall; external CoreDll;
//************************** Event *********************************
@@ -398,51 +317,13 @@ function DbEvent_GetTextW(dbei:PDBEVENTINFO; codepage:int) : PWideChar; stdcall; function DbEvent_GetIcon(dbei:PDBEVENTINFO; flags:int) : HICON; stdcall; external AppDll;
-//*************************** Random *******************************
-
- {
- wParam : newSetting (BOOLEAN)
- lParam : 0
- Affect : Miranda's database is normally protected against corruption by
- aggressively flushing data to the disk on writes, if you're doing
- alot of writes e.g. an import plugin, it can sometimes be desirable
- to switch this feature off to speed up the process, if you do switch
- it off, you must remember that crashes are far more likely to be
- catastrophic, so switch it back on at the earliest possible opportunity.
- if you're doing a lot of setting writes, the flush is already delayed
- so you need not use this service for that purpose, see notes.
- Returns: Always returns 0 (successful)
- notes : This is set to true initally
- }
-const
- MS_DB_SETSAFETYMODE:PAnsiChar = 'DB/SetSafetyMode';
-
//*************************** Modules ******************************
- {
- wParam : (caller defined data) will be passed to lParam of the call back
- lParam : function pointer to TDBMODULEENUMPROC
- Affects: Enumerates the names of all modules that have stored or
- requested information from the database,
- the modules are returned in no real order --
- Writing to the database while module names are being enumerated will cause
- unpredictable results in the enumeration, but the write will work.
-
- the enumeration will stop if the callback returns a non zero value.
-
- Returns: the last return value from the enumeration call back.
- Notes : This service is only useful for debugging or EnumSettings
- version: The service registered to enumerate all modules that have touched
- the database module uses wParam as the lParam cookie value and the lParam
- value given here is the function pointer -- this is not safe
- to use before v0.1.2.1 because I don't know if this was done in v0.1.2.1-
- }
-type
- TDBMODULEENUMPROC = function(const szModule: PAnsiChar; ofsModuleName: dword; lParam: LPARAM): int; cdecl;
-const
- MS_DB_MODULES_ENUM:PAnsiChar = 'DB/Modules/Enum';
+function db_delete_module(hContact:TMCONTACT; szModuleName:PAnsiChar) : int; stdcall; external CoreDll;
+
+//************************** RANDOM ********************************
-function DbModule_Delete(hContact:TMCONTACT; szModuleName:PAnsiChar) : int; stdcall; external AppDll;
+function db_set_safety_mode(bMode:int) : int; stdcall; external CoreDll;
//************************** EVENTS ********************************
diff --git a/include/delphi/m_db_int.inc b/include/delphi/m_db_int.inc deleted file mode 100644 index 9511534cae..0000000000 --- a/include/delphi/m_db_int.inc +++ /dev/null @@ -1,264 +0,0 @@ -{
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright 2012 Miranda NG project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-
-{$IFNDEF M_DB_INT}
-{$DEFINE M_DB_INT}
-
-///////////////////////////////////////////////////////////////////////////////
-// basic database interface
-type
- TDBCachedGlobalValue = record
- name : PAnsiChar;
- value:TDBVARIANT;
- end;
-type
- PDBCachedContactValue = ^TDBCachedContactValue;
- TDBCachedContactValue = record
- name:PAnsiChar;
- value:TDBVARIANT;
- next: PDBCachedContactValue;
- end;
-
- PDBCachedContact = ^TDBCachedContact;
- TDBCachedContact = record
- contactID:TMCONTACT;
- szProto:PAnsiChar;
- first :PDBCachedContactValue;
- last :PDBCachedContactValue;
- // metacontacts
- nSubs:int; // == -1 -> not a metacontact
- pSubs:PMCONTACT;
- parentID:TMCONTACT; // == 0 -> not a subcontact
- nDefault:int // default sub number
- end;
-
- PMIDatabaseCache = ^MIDatabaseCache;
- MIDatabaseCache = interface
- function AddContactToCache(contactID:TMCONTACT):PDBCachedContact; stdcall;
- function GetCachedContact(contactID:TMCONTACT):PDBCachedContact; stdcall;
- function GetFirstContact():PDBCachedContact; stdcall;
- function GetNextContact(contactID:TMCONTACT):PDBCachedContact; stdcall;
- procedure FreeCachedContact(contactID:TMCONTACT); stdcall;
-
- function InsertCachedSetting(szName:PAnsiChar; param:int):PAnsiChar; stdcall;
- function GetCachedSetting(szModuleName:PAnsiChar; szSettingName:PAnsiChar; param1:int; param2:int):PAnsiChar; stdcall;
- procedure SetCachedVariant(s:PDBVARIANT; d:PDBVARIANT); stdcall;
- function GetCachedValuePtr(contactID:TMCONTACT; szSetting:PAnsiChar; bAllocate:int):PDBVARIANT; stdcall;
- end;
-
-type
- PMIDatabase = ^TMIDatabase;
- TMIDatabase = record
- m_cache: PMIDatabaseCache;
-
- IsRelational:function():long; stdcall;
- SetCacheSafetyMode:procedure(val:bool); stdcall;
-
- GetContactCount:function():long; stdcall;
- FindFirstContact:function(const szProto:PAnsiChar = NIL):TMCONTACT; stdcall;
- FindNextContact:function(contactID:TMCONTACT; const szProto:PAnsiChar = NIL):TMCONTACT; stdcall;
-
- DeleteContact:function(contactID:TMCONTACT):long; stdcall;
- AddContact:function():TMCONTACT; stdcall;
- IsDbContact:function(contactID:TMCONTACT):bool; stdcall;
- GetContactSize:function():long; stdcall;
-
- GetEventCount:function(contactID:TMCONTACT):long; stdcall;
- AddEvent:function(contactID:TMCONTACT; dbe:PDBEVENTINFO):TMEVENT; stdcall;
- DeleteEvent:function(contactID:TMCONTACT; hDbEvent:TMEVENT):bool; stdcall;
- GetBlobSize:function(hDbEvent:TMEVENT):long; stdcall;
- GetEvent:function(hDbEvent:TMEVENT; dbe:PDBEVENTINFO):bool; stdcall;
- MarkEventRead:function(contactID:TMCONTACT; hDbEvent:TMEVENT):bool; stdcall;
- GetEventContact:function(hDbEvent:TMEVENT):TMCONTACT; stdcall;
- FindFirstEvent:function(contactID:TMCONTACT):TMEVENT; stdcall;
- FindFirstUnreadEvent:function(contactID:TMCONTACT):TMEVENT; stdcall;
- FindLastEvent:function(contactID:TMCONTACT):TMEVENT; stdcall;
- FindNextEvent:function(contactID:TMCONTACT;hDbEvent:TMEVENT):TMEVENT; stdcall;
- FindPrevEvent:function(contactID:TMCONTACT;hDbEvent:TMEVENT):TMEVENT; stdcall;
-
- EnumModuleNames:function(pFunc:TDBMODULEENUMPROC; pParam:pointer):bool; stdcall;
-
- GetContactSetting:function(contactID:TMCONTACT; szModule, szSetting:PAnsiChar; dbv:PDBVARIANT):bool; stdcall;
- GetContactSettingStr:function(contactID:TMCONTACT; szModule, szSetting:PAnsiChar; dbv:PDBVARIANT):bool; stdcall;
- GetContactSettingStatic:function(contactID:TMCONTACT; szModule, szSetting:PAnsiChar; dbv:PDBVARIANT):bool; stdcall;
- FreeVariant:function(dbv:PDBVARIANT):bool; stdcall;
- WriteContactSetting:function(contactID:TMCONTACT; dbcws:PDBCONTACTWRITESETTING):bool; stdcall;
- DeleteContactSetting:function(contactID:TMCONTACT; szModule, szSetting:PAnsiChar):bool; stdcall;
- EnumContactSettings:function(contactID:TMCONTACT; dbces:PDBCONTACTENUMSETTINGS):bool; stdcall;
- SetSettingResident:function(bIsResident:bool; const pszSettingName:PAnsiChar):bool; stdcall;
- EnumResidentSettings:function(pFunc:TDBMODULEENUMPROC; pParam:pointer):bool; stdcall;
- IsSettingEncrypted:function(szModule:PAnsiChar; szSetting:PAnsiChar):bool; stdcall;
-
- MetaDetouchSub:function(contact:PDBCachedContact; nSub:int):bool; stdcall;
- MetaSetDefault:function(contact:PDBCachedContact):bool; stdcall;
- MetaMergeHistory:function(ccMeta:PDBCachedContact; ccSub:PDBCachedContact):bool; stdcall;
- MetaSplitHistory:function(ccMeta:PDBCachedContact; ccSub:PDBCachedContact):bool; stdcall;
- end;
-
-///////////////////////////////////////////////////////////////////////////////
-// basic database checker interface
-
-const
- STATUS_MESSAGE = 0;
- STATUS_WARNING = 1;
- STATUS_ERROR = 2;
- STATUS_FATAL = 3;
- STATUS_SUCCESS = 4;
-
-type
- pDBCHeckCallback = ^tDBCHeckCallback;
- tDBCHeckCallback = record
- cbSize:int;
- spaceProcessed,
- spaceUsed: dword;
- hOutFile:THANDLE;
- bCheckOnly,
- bBackup,
- bAggressive,
- bEraseHistory,
- bMarkRead,
- bConvertUtf:int;
- pfnAddLogMessage: procedure(_type:int; const szFormat:PWideChar{;...}); cdecl;
- end;
-
-type
- PMIDatabaseChecker = ^MIDatabaseChecker;
- MIDatabaseChecker = interface
- function Start(callback:PDBCHeckCallback):bool;stdcall;
- function CheckDb(phase:int; firstTime:int):bool; stdcall;
- procedure Destroy(); stdcall;
- end;
-
-///////////////////////////////////////////////////////////////////////////////
-// Each database plugin should register itself using this structure
-
-
-{
- Codes for DATABASELINK functions
-}
-const
-// grokHeader() error codes
- EGROKPRF_NOERROR = 0;
- EGROKPRF_CANTREAD = 1; // can't open the profile for reading
- EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
- EGROKPRF_VERNEWER = 3; // header correct, version in profile newer than reader/writer
- EGROKPRF_DAMAGED = 4; // header/version fine, other internal data missing, damaged.
- EGROKPRF_OBSOLETE = 5; // obsolete database version detected, requiring conversion
-
-// makeDatabase() error codes
- EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
-
-type
- PDATABASELINK = ^TDATABASELINK;
- TDATABASELINK = record
- cbSize : int;
- szShortName:PAnsiChar; // uniqie short database name
- szFullName:TChar; // in English, auto-translated by the core
- {
- profile: pointer to a string which contains full path + name
- Affect: The database plugin should create the profile, the filepath will not exist at
- the time of this call, profile will be C:\..\<name>.dat
- Returns: 0 on success, non zero on failure - error contains extended error information, see EMKPRF_
- }
- makeDatabase : function (const profile:TChar):int; cdecl;
- {
- profile: [in] a null terminated string to file path of selected profile
- error: [in/out] pointer to an int to set with error if any
- Affect: Ask the database plugin if it supports the given profile, if it does it will
- return 0, if it doesnt return 1, with the error set in error -- EGROKPRF_ can be valid error
- condition, most common error would be [EGROKPRF_UNKHEADER]
- Note: Just because 1 is returned, doesnt mean the profile is not supported, the profile might be damaged
- etc.
- Returns: 0 on success, non zero on failure
- }
- grokHeader : function (const profile:TChar):int; cdecl;
- {
- Affect: Tell the database to create all services/hooks that a 3.xx legacy database might support into link,
- which is a DATABASELINK structure
- Returns: 0 on success, nonzero on failure
- }
- Load : function (const profile:TChar; bReadOnly:bool):PMIDatabase; cdecl;
- {
- Affect: The database plugin should shutdown, unloading things from the core and freeing internal structures
- Returns: 0 on success, nonzero on failure
- Note: Unload() might be called even if Load() was never called, wasLoaded is set to 1 if Load() was ever called.
- }
- Unload : function (db:PMIDatabase):int; cdecl;
- {
- Returns a pointer to the database checker or NULL if a database doesn't support checking
- When you don't need this object aanymore, call its Destroy() method
- }
- CheckDB : function (const profile:PWideChar; error:pint):PMIDatabaseChecker;cdecl;
- end;
-
-///////////////////////////////////////////////////////////////////////////////
-// cache access functions
-
-function db_get_contact(hContact:TMCONTACT):PDBCachedContact; stdcall;
- external CoreDLL name 'db_get_contact';
-
-///////////////////////////////////////////////////////////////////////////////
-// Database list's services
-
-const
-{
- MS_DB_REGISTER_PLUGIN : registers a database plugin
- wParam : 0 (unused)
- lParam : DATABASELINK* = database link description
-}
- MS_DB_REGISTER_PLUGIN:PAnsiChar = 'DB/RegisterPlugin';
-
-{
- MS_DB_FIND_PLUGIN : looks for a database plugin suitable to open this file
- wParam : 0 (unused)
- lParam : const TCHAR* = name of the database file
- returns DATABASELINK* of the required plugin or NULL on error
-}
- MS_DB_FIND_PLUGIN:PAnsiChar = 'DB/FindPlugin';
-
-{
- MS_DB_GET_CURRENT : returns the database pointer for the current profile
- wParam : 0 (unused)
- lParam : 0 (unused)
- returns MIDatabase* of the current profile or NULL on error
-}
- MS_DB_GET_CURRENT:PAnsiChar = 'DB/GetCurrentDb';
-
-{
- MS_DB_INIT_INSTANCE : initializes a database instance
- wParam : 0 (unused)
- lParam : MIDatabase* = pointer to a database instance
- returns 0
-}
- MS_DB_INIT_INSTANCE:PAnsiChar = 'DB/InitDbInstance';
-
-
-{
- MS_DB_DESTROY_INSTANCE : destroys a database instance
- wParam : 0 (unused)
- lParam : MIDatabase* = pointer to a database instance
- returns 0
-}
- MS_DB_DESTROY_INSTANCE:PAnsiChar = 'DB/DestroyDbInstance';
-
-{$ENDIF}
diff --git a/include/m_database.h b/include/m_database.h index 999b451d54..5a2b678032 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -43,6 +43,91 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
// database functions
+// Switches safety settings on or off
+// newSetting is TRUE initially.
+// Miranda's database is normally protected against corruption by agressively
+// flushing data to the disk on writes. If you're doing a lot of writes (eg in
+// an import plugin) it can sometimes be desirable to switch this feature off to
+// speed up the process. If you do switch it off, you must remember that crashes
+// are far more likely to be catastrophic, so switch it back on at the earliest
+// possible opportunity.
+// Note that if you're doing a lot of setting writes, the flush is already delayed
+// so you need not use this service for that purpose.
+
+EXTERN_C MIR_CORE_DLL(void) db_set_safety_mode(BOOL bNewMode);
+
+// Gets the number of contacts in the database, which does not count the user
+// Returns the number of contacts. They can be retrieved using contact/findfirst and contact/findnext
+
+EXTERN_C MIR_CORE_DLL(int) db_get_contact_count(void);
+
+// Removes all settings for the specified module.
+// hContact is 0 for global settings or matches the concrete contact
+
+EXTERN_C MIR_CORE_DLL(int) db_delete_module(MCONTACT hContact, const char *szModuleName);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// contact functions
+
+// Adds a new contact to the database. New contacts initially have no settings
+// whatsoever, they must all be added with db/contacts/writesetting.
+// Returns a handle to the newly created contact on success, or NULL otherwise.
+// Triggers a db/contact/added event just before it returns.
+
+EXTERN_C MIR_CORE_DLL(MCONTACT) db_add_contact(void);
+
+// Deletes the contact hContact from the database and all events and settings associated with it.
+// Returns 0 on success or nonzero if hContact was invalid
+// Please don't try to delete the user contact (hContact = NULL)
+// Triggers a db/contact/deleted event just *before* it removes anything
+// Because all events are deleted, lots of people may end up with invalid event
+// handles from this operation, which they should be prepared for.
+
+EXTERN_C MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact);
+
+// Checks if a given value is a valid contact handle, note that due
+// to the nature of multiple threading, a valid contact can still become
+// invalid after a call to this service.
+// Returns 1 if the contact is a contact, or 0 if the contact is not valid.
+
+EXTERN_C MIR_CORE_DLL(int) db_is_contact(MCONTACT hContact);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// enumerators
+
+// Enumerates the names of all modules that have stored or requested information from the database.
+// Returns the value returned by the last call to dbmep
+// This service is only really useful for debugging, in conjunction with db/contact/enumsettings
+// dbmep should return 0 to continue enumeration, or nonzero to stop.
+// ofsModuleName is the offset of the module name from the start of the profile
+// database, and is only useful for really heavyweight debugging
+// Modules names will be enumerated in no particular order
+// Writing to the database while module names are being enumerated will cause
+// unpredictable results in the enumeration, but the write will work.
+// szModuleName is only guaranteed to be valid for the duration of the callback.
+// If you want to keep it for longer you must allocation your own storage.
+
+typedef int(*DBMODULEENUMPROC)(const char *szModuleName, DWORD ofsModuleName, LPARAM lParam);
+
+EXTERN_C MIR_CORE_DLL(int) db_enum_modules(DBMODULEENUMPROC dbmep, const void *param = NULL);
+
+// Lists all resident settings
+
+EXTERN_C MIR_CORE_DLL(int) db_enum_residents(DBMODULEENUMPROC pFunc, const void *param = NULL);
+
+// Lists all the settings a specific modules has stored in the database for a specific contact.
+// Returns the return value of the last call to pfnEnumProc, or -1 if there are
+// no settings for that module/contact pair
+// Writing to or deleting from the database while enumerating will have
+// unpredictable results for the enumeration, but the write will succeed.
+// Use db/modules/enum to get a complete list of module names
+// szSetting is only guaranteed to be valid for the duration of the callback. If
+// you want to keep it for longer you must allocation your own storage.
+
+typedef int (*DBSETTINGENUMPROC)(const char *szSetting, LPARAM lParam);
+
+EXTERN_C MIR_CORE_DLL(int) db_enum_settings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param = NULL);
+
/////////////////////////////////////////////////////////////////////////////////////////
// DBVARIANT: used by db/contact/getsetting and db/contact/writesetting
@@ -362,69 +447,6 @@ typedef struct { DBVARIANT value; // variant containing the value to set
} DBCONTACTWRITESETTING;
-/* db/contact/enumsettings v0.1.0.1+
-Lists all the settings a specific modules has stored in the database for a
-specific contact.
-wParam = (MCONTACT)hContact
-lParam = (LPARAM)(DBCONTACTENUMSETTINGS*)&dbces
-Returns the return value of the last call to pfnEnumProc, or -1 if there are
-no settings for that module/contact pair
-Writing to or deleting from the database while enumerating will have
-unpredictable results for the enumeration, but the write will succeed.
-Use db/modules/enum to get a complete list of module names
-szSetting is only guaranteed to be valid for the duration of the callback. If
-you want to keep it for longer you must allocation your own storage.
-*/
-typedef int (*DBSETTINGENUMPROC)(const char *szSetting, LPARAM lParam);
-typedef struct {
- DBSETTINGENUMPROC pfnEnumProc;
- LPARAM lParam; // passed direct to pfnEnumProc
- const char *szModule; // name of the module to get settings for
- DWORD ofsSettings; // filled by the function to contain the offset from
- // the start of the database of the requested settings group.
-} DBCONTACTENUMSETTINGS;
-#define MS_DB_CONTACT_ENUMSETTINGS "DB/Contact/EnumSettings"
-
-/* DB/Contact/GetCount service
-Gets the number of contacts in the database, which does not count the user
- wParam = lParam = 0
-Returns the number of contacts. They can be retrieved using contact/findfirst
-and contact/findnext
-*/
-#define MS_DB_CONTACT_GETCOUNT "DB/Contact/GetCount"
-
-/* DB/Contact/Delete
-Deletes the contact hContact from the database and all events and settings
-associated with it.
- wParam = (MCONTACT)hContact
- lParam = 0
-Returns 0 on success or nonzero if hContact was invalid
-Please don't try to delete the user contact (hContact = NULL)
-Triggers a db/contact/deleted event just *before* it removes anything
-Because all events are deleted, lots of people may end up with invalid event
-handles from this operation, which they should be prepared for.
-*/
-#define MS_DB_CONTACT_DELETE "DB/Contact/Delete"
-
-/* DB/Contact/Add
-Adds a new contact to the database. New contacts initially have no settings
-whatsoever, they must all be added with db/contacts/writesetting.
- wParam = lParam = 0
-Returns a handle to the newly created contact on success, or NULL otherwise.
-Triggers a db/contact/added event just before it returns.
-*/
-#define MS_DB_CONTACT_ADD "DB/Contact/Add"
-
-/* DB/Contact/Is
-Checks if a given value is a valid contact handle, note that due
-to the nature of multiple threading, a valid contact can still become
-invalid after a call to this service.
- wParam = (WPARAM)hContact
- lParam = 0
-Returns 1 if the contact is a contact, or 0 if the contact is not valid.
-*/
-#define MS_DB_CONTACT_IS "DB/Contact/Is"
-
/////////////////////////////////////////////////////////////////////////////////////////
// Event services
@@ -505,56 +527,6 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags); EXTERN_C MIR_APP_DLL(wchar_t*) DbEvent_GetString(DBEVENTINFO *dbei, const char *str);
/////////////////////////////////////////////////////////////////////////////////////////
-// Random services
-
-/*
-Switches safety settings on or off
-wParam = (WPARAM)(BOOL)newSetting
-lParam = 0
-returns 0 always
-newSetting is TRUE initially.
-Miranda's database is normally protected against corruption by agressively
-flushing data to the disk on writes. If you're doing a lot of writes (eg in
-an import plugin) it can sometimes be desirable to switch this feature off to
-speed up the process. If you do switch it off, you must remember that crashes
-are far more likely to be catastrophic, so switch it back on at the earliest
-possible opportunity.
-Note that if you're doing a lot of setting writes, the flush is already delayed
-so you need not use this service for that purpose.
-*/
-#define MS_DB_SETSAFETYMODE "DB/SetSafetyMode"
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Module services
-
-/* db/modules/enum v0.1.0.1+
-Enumerates the names of all modules that have stored or requested information
-from the database.
-wParam = lParam
-lParam = (WPARAM)(DBMODULEENUMPROC)dbmep
-Returns the value returned by the last call to dbmep
-This service is only really useful for debugging, in conjunction with
-db/contact/enumsettings
-lParam is passed directly to dbmep
-dbmep should return 0 to continue enumeration, or nonzero to stop.
-ofsModuleName is the offset of the module name from the start of the profile
-database, and is only useful for really heavyweight debugging
-Modules names will be enumerated in no particular order
-Writing to the database while module names are being enumerated will cause
-unpredictable results in the enumeration, but the write will work.
-szModuleName is only guaranteed to be valid for the duration of the callback.
-If you want to keep it for longer you must allocation your own storage.
-*/
-typedef int (*DBMODULEENUMPROC)(const char *szModuleName, DWORD ofsModuleName, LPARAM lParam);
-#define MS_DB_MODULES_ENUM "DB/Modules/Enum"
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Removes all settings for the specified module.
-// hContact is 0 for global settings or matches the concrete contact
-
-EXTERN_C MIR_APP_DLL(int) DbModule_Delete(MCONTACT hContact, const char *szModuleName);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Database events
/* DB/Event/Added event
diff --git a/include/m_db_int.h b/include/m_db_int.h index d33b465ccb..81ce096276 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -109,7 +109,7 @@ interface MIDatabase STDMETHOD_(MEVENT, FindNextEvent)(MCONTACT contactID, MEVENT hDbEvent) PURE;
STDMETHOD_(MEVENT, FindPrevEvent)(MCONTACT contactID, MEVENT hDbEvent) PURE;
- STDMETHOD_(BOOL, EnumModuleNames)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
+ STDMETHOD_(BOOL, EnumModuleNames)(DBMODULEENUMPROC pFunc, const void *pParam) PURE;
STDMETHOD_(BOOL, GetContactSetting)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE;
STDMETHOD_(BOOL, GetContactSettingStr)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) PURE;
@@ -117,9 +117,9 @@ interface MIDatabase STDMETHOD_(BOOL, FreeVariant)(DBVARIANT *dbv) PURE;
STDMETHOD_(BOOL, WriteContactSetting)(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws) PURE;
STDMETHOD_(BOOL, DeleteContactSetting)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting) PURE;
- STDMETHOD_(BOOL, EnumContactSettings)(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces) PURE;
+ STDMETHOD_(BOOL, EnumContactSettings)(MCONTACT contactID, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param) PURE;
STDMETHOD_(BOOL, SetSettingResident)(BOOL bIsResident, const char *pszSettingName) PURE;
- STDMETHOD_(BOOL, EnumResidentSettings)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
+ STDMETHOD_(BOOL, EnumResidentSettings)(DBMODULEENUMPROC pFunc, const void *pParam) PURE;
STDMETHOD_(BOOL, IsSettingEncrypted)(LPCSTR szModule, LPCSTR szSetting) PURE;
STDMETHOD_(BOOL, MetaDetouchSub)(DBCachedContact*, int nSub) PURE;
diff --git a/plugins/Actman/iac_dbrw.pas b/plugins/Actman/iac_dbrw.pas index 416827c598..f03e5048a7 100644 --- a/plugins/Actman/iac_dbrw.pas +++ b/plugins/Actman/iac_dbrw.pas @@ -213,7 +213,7 @@ begin if (asbuf[0]='*') or (asbuf[StrLen(asbuf)-1]='*') then
DBDeleteGroup(hContact,ambuf,asbuf)
else if asbuf[0]=#0 then
- DbModule_Delete(hContact,ambuf)
+ db_delete_module(hContact,ambuf)
else
db_unset(hContact,ambuf,asbuf);
end
diff --git a/plugins/Actman/iac_inout.pas b/plugins/Actman/iac_inout.pas index 0626de08f2..e83e62ad8f 100644 --- a/plugins/Actman/iac_inout.pas +++ b/plugins/Actman/iac_inout.pas @@ -129,7 +129,7 @@ begin begin
if (flags and ACF_FILE_PATH)<>0 then
begin
- if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then
+ if db_is_contact(WorkData.Parameter)<>0 then
hContact:=WorkData.Parameter
else
hContact:=0;
@@ -263,7 +263,7 @@ begin if hContact=0 then
begin
- if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then
+ if db_is_contact(WorkData.Parameter)<>0 then
hContact:=WorkData.Parameter;
end;
diff --git a/plugins/Actman/iac_program.pas b/plugins/Actman/iac_program.pas index d16c356019..b62e774da2 100644 --- a/plugins/Actman/iac_program.pas +++ b/plugins/Actman/iac_program.pas @@ -136,7 +136,7 @@ begin if ((flags and ACF_PRG_PRG)<>0) or
((flags and ACF_PRG_ARG)<>0) then
begin
- if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)<>0 then
+ if db_is_contact(WorkData.Parameter)<>0 then
pd:=WorkData.Parameter
else
pd:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus});
diff --git a/plugins/AssocMgr/src/test.cpp b/plugins/AssocMgr/src/test.cpp index 2722545302..1175e20807 100644 --- a/plugins/AssocMgr/src/test.cpp +++ b/plugins/AssocMgr/src/test.cpp @@ -759,7 +759,7 @@ static int ServiceParseXmppURI(WPARAM wParam, LPARAM lParam) MCONTACT hContact;
hContact = JabberHContactFromJID(jid);
if (hContact == NULL) /* not yet implemented: show standard miranda dialog here */
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
return 0;
}
/* add user subscription */
diff --git a/plugins/AssocMgr/src/utils.cpp b/plugins/AssocMgr/src/utils.cpp index 6028343440..6f2a90b8d1 100644 --- a/plugins/AssocMgr/src/utils.cpp +++ b/plugins/AssocMgr/src/utils.cpp @@ -110,16 +110,12 @@ static int EnumPrefixSettingsProc(const char *pszSetting,LPARAM lParam) // mir_free() the returned pSettings after use
BOOL EnumDbPrefixSettings(const char *pszModule,const char *pszSettingPrefix,char ***pSettings,int *pnSettingsCount)
{
- DBCONTACTENUMSETTINGS dbces;
struct EnumPrefixSettingsParams param;
- dbces.szModule = pszModule;
- dbces.pfnEnumProc = EnumPrefixSettingsProc;
- dbces.lParam = (LPARAM)¶m;
param.settings = NULL;
param.nSettingsCount = 0;
param.pszPrefix = pszSettingPrefix;
param.nPrefixLen = (int)mir_strlen(pszSettingPrefix);
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, EnumPrefixSettingsProc, pszModule, ¶m);
*pnSettingsCount = param.nSettingsCount;
*pSettings = param.settings;
return param.nSettingsCount != 0;
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index a2a73665e4..457b5e57dc 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -504,7 +504,7 @@ void HistoryEventList::MargeMessages(const std::vector<IImport::ExternalMessage> DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(m_hContact);
- CallService(MS_DB_SETSAFETYMODE, FALSE, 0);
+ db_set_safety_mode(FALSE);
for (std::list<EventTempIndex>::iterator it = tempList.begin(); it != tempList.end(); ++it) {
if (it->isExternal) {
IImport::ExternalMessage& msg = m_importedMessages[it->exIdx];
@@ -522,7 +522,7 @@ void HistoryEventList::MargeMessages(const std::vector<IImport::ExternalMessage> }
}
- CallService(MS_DB_SETSAFETYMODE, TRUE, 0);
+ db_set_safety_mode(TRUE);
std::vector<IImport::ExternalMessage> emessages;
ImportMessages(emessages);
}
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 6d5017ce14..8f8c856e9f 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -392,13 +392,13 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM hContact, LPARAM) if (MessageBox(hWnd, message, TranslateT("Are You sure?"), MB_OKCANCEL | MB_ICONERROR) != IDOK)
return FALSE;
- CallService(MS_DB_SETSAFETYMODE, FALSE, 0);
+ db_set_safety_mode(FALSE);
MEVENT hDbEvent = db_event_last(hContact);
while (hDbEvent != NULL) {
MEVENT hPrevEvent = db_event_prev(hContact, hDbEvent);
hDbEvent = (db_event_delete(hContact, hDbEvent) == 0) ? hPrevEvent : NULL;
}
- CallService(MS_DB_SETSAFETYMODE, TRUE, 0);
+ db_set_safety_mode(TRUE);
if (HistoryEventList::IsImportedHistory(hContact)) {
message = TranslateT("Do you want to delete all imported messages for this contact?\nNote that next scheduler task import this messages again.");
diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index de682600e7..93d215e2ff 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -384,7 +384,7 @@ INT_PTR ContactStillAbsentAction(WPARAM hContact, LPARAM lParam) switch (options.action2) {
case GCA_DELETE:
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
break;
case GCA_UDETAILS:
CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
diff --git a/plugins/ClientChangeNotify/src/Options.cpp b/plugins/ClientChangeNotify/src/Options.cpp index 0a81d2f701..d5647554f3 100644 --- a/plugins/ClientChangeNotify/src/Options.cpp +++ b/plugins/ClientChangeNotify/src/Options.cpp @@ -300,12 +300,7 @@ void COptItem_TreeCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi m_value.RemoveAll();
sTreeReadEnumData pData(this, sModule, *sDBSettingPrefix);
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&pData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = TreeReadEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, TreeReadEnum, sModule, &pData);
if (!m_value.GetSize()) {
m_value = m_defValue;
}
@@ -481,12 +476,7 @@ void COptItem_TreeCtrl::CleanDBSettings(const CString &sModule, CString *sDBSett sTreeDeleteEnumData TreeDeleteEnumData;
TreeDeleteEnumData.TreeCtrl = this;
TreeDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&TreeDeleteEnumData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = TreeDeleteEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, TreeDeleteEnum, sModule, &TreeDeleteEnumData);
for (int i = 0; i < TreeDeleteEnumData.TreeSettings.GetSize(); i++)
db_unset(NULL, sModule, TreeDeleteEnumData.TreeSettings[i]);
@@ -672,12 +662,8 @@ void COptItem_ListCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi m_value.RemoveAll();
sListReadEnumData pData(this, sModule, *sDBSettingPrefix);
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&pData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = ListReadEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, ListReadEnum, sModule, &pData);
+
if (!m_value.GetSize())
m_value = m_defValue;
else {
@@ -752,12 +738,7 @@ void COptItem_ListCtrl::CleanDBSettings(const CString &sModule, CString *sDBSett sListDeleteEnumData ListDeleteEnumData;
ListDeleteEnumData.ListCtrl = this;
ListDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&ListDeleteEnumData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = ListDeleteEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, ListDeleteEnum, sModule, &ListDeleteEnumData);
for (int i = 0; i < ListDeleteEnumData.ListSettings.GetSize(); i++)
db_unset(NULL, sModule, ListDeleteEnumData.ListSettings[i]);
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 683f0bd7d4..6d5f29ad3f 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1345,7 +1345,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam ClcGroup *group = NULL;
ClcContact *contact = NULL;
if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) {
- if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
+ if (shouldShow && db_is_contact(wParam)) {
if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
pcli->pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0);
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 5131e493ca..efe7ff5ba1 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -1923,12 +1923,8 @@ static int ske_GetSkinFromDB(char *, SKINOBJECTSLIST *Skin) } // Load objects - DBCONTACTENUMSETTINGS dbces; pCurrentSkin = Skin; - dbces.pfnEnumProc = ske_enumdb_SkinObjectsProc; - dbces.szModule = SKIN; - dbces.ofsSettings = 0; - CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces); + db_enum_settings(NULL, ske_enumdb_SkinObjectsProc, SKIN); SortMaskList(pCurrentSkin->pMaskList); ske_LinkSkinObjects(pCurrentSkin); @@ -1948,7 +1944,7 @@ static int ske_LoadSkinFromResource(BOOL bOnlyObjects) { IniParser parser(g_hInst, MAKEINTRESOURCEA(IDR_MSF_DEFAULT_SKIN), "MSF", bOnlyObjects ? IniParser::FLAG_ONLY_OBJECTS : IniParser::FLAG_WITH_SETTINGS); if (parser.CheckOK()) { - DbModule_Delete(0, "ModernSkin"); + db_delete_module(0, "ModernSkin"); db_set_s(NULL, SKIN, "SkinFolder", "%Default%"); db_set_s(NULL, SKIN, "SkinFile", "%Default%"); parser.Parse(IniParser::WriteStrToDb, 0); @@ -1966,7 +1962,7 @@ int ske_LoadSkinFromIniFile(wchar_t *szFileName, BOOL bOnlyObjects) if (!parser.CheckOK()) return 0; - DbModule_Delete(0, "ModernSkin"); + db_delete_module(0, "ModernSkin"); wchar_t skinFolder[MAX_PATH], skinFile[MAX_PATH]; IniParser::GetSkinFolder(szFileName, skinFolder); diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index efced1370b..c4f96d36b8 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -338,7 +338,7 @@ static int Toolbar_ModulesLoaded(WPARAM, LPARAM) db_unset(NULL, "CLUI", "ShowButtonBar");
- DbModule_Delete(0, "ModernToolBar");
+ db_delete_module(0, "ModernToolBar");
}
db_set_b(NULL, "Compatibility", "TTB_Upgrade", 1);
}
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 0858bcbe5f..c298d85e96 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -101,12 +101,7 @@ int CLVM_EnumProc(const char *szSetting, LPARAM lParam) void CLVM_EnumModes(pfnEnumCallback EnumCallback)
{
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = CLVM_EnumProc;
- dbces.szModule = CLVM_MODULE;
- dbces.ofsSettings = 0;
- dbces.lParam = (LPARAM)EnumCallback;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, CLVM_EnumProc, CLVM_MODULE, EnumCallback);
}
int FillModes(char *szsetting)
diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 189717d6c6..c3adacca29 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -323,7 +323,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown
if (!pcli->pfnFindItem(hwnd, dat, hContact, &contact, &group, NULL)) {
- if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
+ if (shouldShow && db_is_contact(wParam)) {
if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0);
diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp index 9abe3553d9..7a87c93264 100644 --- a/plugins/Clist_nicer/src/init.cpp +++ b/plugins/Clist_nicer/src/init.cpp @@ -130,7 +130,7 @@ extern "C" int __declspec(dllexport) CListInitialise() memset(&cfg::dat, 0, sizeof(cfg::dat));
- int iCount = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
+ int iCount = db_get_contact_count();
iCount += 20;
if (iCount < 300)
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 313c8065d2..39da94436f 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -67,12 +67,7 @@ int CLVM_EnumProc(const char *szSetting, LPARAM lParam) void CLVM_EnumModes(pfnEnumCallback EnumCallback)
{
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = CLVM_EnumProc;
- dbces.szModule = CLVM_MODULE;
- dbces.ofsSettings = 0;
- dbces.lParam = (LPARAM)EnumCallback;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, CLVM_EnumProc, CLVM_MODULE, EnumCallback);
}
int FillModes(char *szsetting)
diff --git a/plugins/CyrTranslit/src/MirandaContact.cpp b/plugins/CyrTranslit/src/MirandaContact.cpp index e9f8eda164..7eedca1ce1 100644 --- a/plugins/CyrTranslit/src/MirandaContact.cpp +++ b/plugins/CyrTranslit/src/MirandaContact.cpp @@ -76,7 +76,7 @@ void MirandaContact::addMenuItem() INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM)
{
MCONTACT hContact = MCONTACT(wParam);
- if (!CallService(MS_DB_CONTACT_IS, wParam, 0))
+ if (!db_is_contact(wParam))
return 0;
save(hContact, !bIsActive(hContact));
@@ -89,7 +89,7 @@ int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM) {
if (!hTransliterateCmdMenuItem) return 0;
MCONTACT hContact = MCONTACT(wParam);
- if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0;
+ if (!db_is_contact(wParam)) return 0;
Menu_ModifyItem(hTransliterateCmdMenuItem, NULL, INVALID_HANDLE_VALUE, bIsActive(hContact) ? CMIF_CHECKED : 0);
return 0;
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 710b5324c1..e672a7ce7b 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -207,7 +207,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID) BOOL CDb3Mmap::MetaDetouchSub(DBCachedContact *cc, int nSub)
{
- DbModule_Delete(cc->pSubs[nSub], META_PROTO);
+ db_delete_module(cc->pSubs[nSub], META_PROTO);
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 006821fc9a..755dcbf717 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -89,12 +89,7 @@ void sttContactEnum(MCONTACT contactID, const char *szModule, CDb3Mmap *db) {
OBJLIST<VarDescr> arSettings(1);
SettingUgraderParam param = { db, szModule, contactID, &arSettings };
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttSettingUgrader;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)¶m;
- db->EnumContactSettings(NULL, &dbces);
+ db->EnumContactSettings(NULL, sttSettingUgrader, szModule, ¶m);
for (int i = 0; i < arSettings.getCount(); i++) {
VarDescr &p = arSettings[i];
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 5a11c25259..e31d023454 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -141,17 +141,15 @@ int CDb3Mmap::Load(bool bSkipInit) if (m_dbHeader.version < DB_095_1_VERSION)
return EGROKPRF_CANTREAD;
- // we don't need events in the service mode
- if (ServiceExists(MS_DB_SETSAFETYMODE)) {
- hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
- hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
- hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
- hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
-
- hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
- hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
- hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
- }
+ // retrieve the event handles
+ hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+ hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
+
+ hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
+ hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
+ hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
}
FillContacts();
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index dc21944426..6f9a173b39 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -232,7 +232,7 @@ public: STDMETHODIMP_(MEVENT) FindNextEvent(MCONTACT contactID, MEVENT hDbEvent);
STDMETHODIMP_(MEVENT) FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent);
- STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, const void *pParam);
STDMETHODIMP_(BOOL) GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
@@ -240,9 +240,9 @@ public: STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws);
STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS *dbces);
+ STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
- STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, const void *pParam);
STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
STDMETHODIMP_(BOOL) MetaDetouchSub(DBCachedContact *cc, int nSub);
diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp index 995d681a69..034a7a6a12 100644 --- a/plugins/Db3x_mmap/src/dbmodulechain.cpp +++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp @@ -127,7 +127,7 @@ char* CDb3Mmap::GetModuleNameByOfs(DWORD ofs) return NULL;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDb3Mmap::EnumModuleNames(DBMODULEENUMPROC pFunc, const void *pParam)
{
for (int i = 0; i < m_lMods.getCount(); i++) {
ModuleName *pmn = m_lMods[i];
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index c12a0e0d3e..a99d5b64ef 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -811,9 +811,9 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces)
+STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param)
{
- if (!dbces->szModule)
+ if (!szModule)
return -1;
mir_cslock lck(m_csDbAccess);
@@ -826,12 +826,12 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTE if (dbc->signature != DBCONTACT_SIGNATURE)
return -1;
- DWORD ofsModuleName = GetModuleNameOfs(dbces->szModule);
- dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
- if (!dbces->ofsSettings)
+ DWORD ofsModuleName = GetModuleNameOfs(szModule);
+ DWORD ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
+ if (!ofsSettings)
return -1;
- DWORD ofsBlobPtr = dbces->ofsSettings + offsetof(DBContactSettings, blob);
+ DWORD ofsBlobPtr = ofsSettings + offsetof(DBContactSettings, blob);
int bytesRemaining;
PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
if (pBlob[0] == 0)
@@ -843,7 +843,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTE NeedBytes(1 + pBlob[0]);
char szSetting[256];
memcpy(szSetting, pBlob + 1, pBlob[0]); szSetting[pBlob[0]] = 0;
- result = (dbces->pfnEnumProc)(szSetting, dbces->lParam);
+ result = pfnEnumProc(szSetting, LPARAM(param));
MoveAlong(1 + pBlob[0]);
NeedBytes(3);
MoveAlong(1 + GetSettingValueLength(pBlob));
@@ -852,7 +852,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTE return result;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDb3Mmap::EnumResidentSettings(DBMODULEENUMPROC pFunc, const void *pParam)
{
for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam);
diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index faa42d29ea..ae2430bb68 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -91,7 +91,7 @@ void copyModuleMenuItem(MCONTACT hContact, const char *module) int CloneContact(MCONTACT hContact)
{
- MCONTACT newContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT newContact = db_add_contact();
if (!newContact)
return 0;
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index f87b9af57a..6f33002d52 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -330,7 +330,7 @@ void importSettings(MCONTACT hContact, char *utf8) }
if (hContact == INVALID_CONTACT_ID) {
- MCONTACT temp = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT temp = db_add_contact();
if (temp)
hContact = temp;
}
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index ba44c3fa20..da31dd2eb1 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -134,7 +134,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR if (dlg(str, MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
break;
}
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
freeTree(mtis->hContact);
TreeView_DeleteItem(hwnd, tvi.hItem);
}
diff --git a/plugins/DbEditorPP/src/modsettingenum.cpp b/plugins/DbEditorPP/src/modsettingenum.cpp index dc30d2f473..e1e7de6e33 100644 --- a/plugins/DbEditorPP/src/modsettingenum.cpp +++ b/plugins/DbEditorPP/src/modsettingenum.cpp @@ -51,7 +51,7 @@ int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail {
msll->first = 0;
msll->last = 0;
- if (CallService(MS_DB_MODULES_ENUM, (WPARAM)msll, (WPARAM)enumModulesSettingsProc)) {
+ if (db_enum_modules(enumModulesSettingsProc, msll)) {
msg(TranslateT("Error loading module list"));
return 0;
}
@@ -67,14 +67,10 @@ int enumSettingsProc(const char *setting, LPARAM lParam) int EnumSettings(MCONTACT hContact, const char *module, ModuleSettingLL *msll)
{
- DBCONTACTENUMSETTINGS dbces;
// enum all setting the contact has for the module
- dbces.pfnEnumProc = enumSettingsProc;
- dbces.szModule = module;
- dbces.lParam = (LPARAM)msll;
msll->first = 0;
msll->last = 0;
- if (CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces)) {
+ if (db_enum_settings(hContact, enumSettingsProc, module, msll)) {
msg(TranslateT("Error loading setting list"));
return 0;
}
@@ -90,10 +86,7 @@ int CheckIfModuleIsEmptyProc(const char *, LPARAM) int IsModuleEmpty(MCONTACT hContact, const char *module)
{
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = CheckIfModuleIsEmptyProc;
- dbces.szModule = module;
- return 0 > CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ return 0 > db_enum_settings(hContact, CheckIfModuleIsEmptyProc, module);
}
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 2853c4a57c..34c43fb7e8 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -723,7 +723,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t if (dlg(str, MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
break;
}
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
freeTree(hContact);
TreeView_DeleteItem(hwnd2Tree, tvi.hItem);
break;
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index 921d116c24..7014dfd6c7 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -165,7 +165,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::IsDbContact(MCONTACT contactID) BOOL CDbxMdb::MetaDetouchSub(DBCachedContact *cc, int nSub)
{
- DbModule_Delete(cc->pSubs[nSub], META_PROTO);
+ db_delete_module(cc->pSubs[nSub], META_PROTO);
return 0;
}
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp index c1f7500ccf..13a3b78e62 100644 --- a/plugins/Dbx_mdb/src/dbintf.cpp +++ b/plugins/Dbx_mdb/src/dbintf.cpp @@ -142,17 +142,15 @@ int CDbxMdb::Load(bool bSkipInit) // everything is ok, go on
if (!m_bReadOnly) {
- // we don't need events in the service mode
- if (ServiceExists(MS_DB_SETSAFETYMODE)) {
- hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
- hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
- hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
- hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
-
- hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
- hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
- hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
- }
+ // retrieve the event handles
+ hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+ hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
+
+ hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
+ hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
+ hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
}
FillContacts();
diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h index 496a315589..05d80d71cb 100644 --- a/plugins/Dbx_mdb/src/dbintf.h +++ b/plugins/Dbx_mdb/src/dbintf.h @@ -174,7 +174,7 @@ public: STDMETHODIMP_(MEVENT) FindNextEvent(MCONTACT contactID, MEVENT hDbEvent);
STDMETHODIMP_(MEVENT) FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent);
- STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, const void *pParam);
STDMETHODIMP_(BOOL) GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
@@ -182,9 +182,9 @@ public: STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws);
STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS *dbces);
+ STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
- STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, const void *pParam);
STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
STDMETHODIMP_(BOOL) MetaDetouchSub(DBCachedContact *cc, int nSub);
diff --git a/plugins/Dbx_mdb/src/dbmodulechain.cpp b/plugins/Dbx_mdb/src/dbmodulechain.cpp index 2b821023d6..e45c2e2f69 100644 --- a/plugins/Dbx_mdb/src/dbmodulechain.cpp +++ b/plugins/Dbx_mdb/src/dbmodulechain.cpp @@ -64,7 +64,7 @@ char* CDbxMdb::GetModuleName(uint32_t dwId) return it != m_Modules.end() ? const_cast<char*>(it->second.c_str()) : nullptr;
}
-STDMETHODIMP_(BOOL) CDbxMdb::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDbxMdb::EnumModuleNames(DBMODULEENUMPROC pFunc, const void *pParam)
{
for (auto it = m_Modules.begin(); it != m_Modules.end(); ++it)
if (int ret = pFunc(it->second.c_str(), it->first, (LPARAM)pParam))
diff --git a/plugins/Dbx_mdb/src/dbsettings.cpp b/plugins/Dbx_mdb/src/dbsettings.cpp index 9c48880618..2887675cec 100644 --- a/plugins/Dbx_mdb/src/dbsettings.cpp +++ b/plugins/Dbx_mdb/src/dbsettings.cpp @@ -549,11 +549,11 @@ STDMETHODIMP_(BOOL) CDbxMdb::DeleteContactSetting(MCONTACT contactID, LPCSTR szM return 0;
}
-STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces)
+STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, const void *param)
{
int result = -1;
- DBSettingKey keyVal = { contactID, GetModuleID(dbces->szModule) };
+ DBSettingKey keyVal = { hContact, GetModuleID(szModule) };
txn_ptr_ro txn(m_txn);
cursor_ptr_ro cursor(m_curSettings);
@@ -562,15 +562,15 @@ STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT contactID, DBCONTACTEN for (int res = mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE); res == MDB_SUCCESS; res = mdb_cursor_get(cursor, &key, &data, MDB_NEXT))
{
const DBSettingKey *pKey = (const DBSettingKey*)key.mv_data;
- if (pKey->hContact != contactID || pKey->dwModuleId != keyVal.dwModuleId)
+ if (pKey->hContact != hContact || pKey->dwModuleId != keyVal.dwModuleId)
break;
- result = (dbces->pfnEnumProc)(pKey->szSettingName, dbces->lParam);
+ result = pfnEnumProc(pKey->szSettingName, LPARAM(param));
}
return result;
}
-STDMETHODIMP_(BOOL) CDbxMdb::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDbxMdb::EnumResidentSettings(DBMODULEENUMPROC pFunc, const void *pParam)
{
for (int i = 0; i < m_lResidentSettings.getCount(); i++)
if (int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam))
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index 6ec01a5354..de21e2613c 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -48,7 +48,7 @@ MCONTACT CDropbox::GetDefaultContact() hDefaultContact = db_find_first(MODULE);
if (!hDefaultContact) {
- hDefaultContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hDefaultContact = db_add_contact();
if (!Proto_AddToContact(hDefaultContact, MODULE)) {
db_set_s(NULL, MODULE, "Nick", MODULE);
db_set_s(hDefaultContact, MODULE, "Nick", MODULE);
diff --git a/plugins/FavContacts/src/http_api.cpp b/plugins/FavContacts/src/http_api.cpp index cc84b08adc..d71e1c536d 100644 --- a/plugins/FavContacts/src/http_api.cpp +++ b/plugins/FavContacts/src/http_api.cpp @@ -52,7 +52,7 @@ public: int hContact;
sscanf(s, "/fav/open/%d", &hContact);
- if (CallService(MS_DB_CONTACT_IS, hContact, 0))
+ if (db_is_contact(hContact))
CallServiceSync(MS_FAVCONTACTS_OPEN_CONTACT, hContact, 0);
}
diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp index 92775dee70..176f645120 100644 --- a/plugins/FavContacts/src/menu.cpp +++ b/plugins/FavContacts/src/menu.cpp @@ -128,7 +128,7 @@ BOOL MenuMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options) BOOL res = FALSE;
if (INT_PTR(lpmis->itemData) < 0)
res = sttMeasureItem_Group(lpmis, options);
- else if (CallService(MS_DB_CONTACT_IS, lpmis->itemData, 0))
+ else if (db_is_contact(lpmis->itemData))
res = sttMeasureItem_Contact(lpmis, options);
if (res && (lpmis->itemWidth > g_maxItemWidth)) lpmis->itemWidth = g_maxItemWidth;
@@ -350,7 +350,7 @@ BOOL MenuDrawItem(LPDRAWITEMSTRUCT lpdis, Options *options) if (INT_PTR(lpdis->itemData) < 0)
return sttDrawItem_Group(lpdis, options);
- if (CallService(MS_DB_CONTACT_IS, lpdis->itemData, 0))
+ if (db_is_contact(lpdis->itemData))
return sttDrawItem_Contact(lpdis, options);
return FALSE;
@@ -419,7 +419,7 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, GetMenuItemInfo((HMENU)lParam, wParam, TRUE, &mii);
MCONTACT cc = (MCONTACT)mii.dwItemData;
- if (!CallService(MS_DB_CONTACT_IS, cc, 0))
+ if (!db_is_contact(cc))
return FALSE;
HMENU hMenu = Menu_BuildContactMenu(cc);
diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index 7be689df09..02be23fd17 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -149,7 +149,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendMessage(hwndCombo, CB_SETCURSEL, curIndex, 0);
SetDlgItemTextA(hwndDlg, IDC_PASS, "");
SetFocus(hwndCombo);
- acc[curIndex].hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
+ acc[curIndex].hContact = db_add_contact();
Proto_AddToContact(acc[curIndex].hContact, MODULE_NAME);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -164,7 +164,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendMessage(hwndCombo, CB_DELETESTRING, curIndex, 0);
DeleteResults(acc[curIndex].results.next);
acc[curIndex].results.next = NULL;
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)acc[curIndex].hContact, 0);
+ db_delete_contact(acc[curIndex].hContact);
for (int i = curIndex; i < acc_num; i++)
acc[i] = acc[i + 1];
curIndex = 0;
diff --git a/plugins/HistoryPlusPlus/hpp_database.pas b/plugins/HistoryPlusPlus/hpp_database.pas index ead338fb9c..dc7d36b13c 100644 --- a/plugins/HistoryPlusPlus/hpp_database.pas +++ b/plugins/HistoryPlusPlus/hpp_database.pas @@ -104,7 +104,7 @@ uses procedure SetSafetyMode(Safe: Boolean);
begin
- CallService(MS_DB_SETSAFETYMODE,WPARAM(Safe),0);
+ db_set_safety_mode(int(Safe));
end;
function DBExists(const Module, Param: AnsiString): Boolean;
diff --git a/plugins/HistoryPlusPlus/hpp_searchthread.pas b/plugins/HistoryPlusPlus/hpp_searchthread.pas index 6d850ddf5e..daceee6684 100644 --- a/plugins/HistoryPlusPlus/hpp_searchthread.pas +++ b/plugins/HistoryPlusPlus/hpp_searchthread.pas @@ -401,7 +401,7 @@ end; function TSearchThread.GetContactsCount: Integer;
begin
- Result := CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
+ Result := db_get_contact_count();
end;
function TSearchThread.GetItemsCount(hContact: THandle): Integer;
diff --git a/plugins/HistoryStats/src/mirandasettings.cpp b/plugins/HistoryStats/src/mirandasettings.cpp index 9840e1ae0a..a05b843a65 100644 --- a/plugins/HistoryStats/src/mirandasettings.cpp +++ b/plugins/HistoryStats/src/mirandasettings.cpp @@ -139,5 +139,5 @@ int MirandaSettings::enumSettingsProc(const char* szSetting, LPARAM lParam) void MirandaSettings::enumSettings(const SetInserter& insertIterator)
{
- mu::db_contact::enumSettings(m_hContact, m_strModule.c_str(), enumSettingsProc, LPARAM(&insertIterator));
+ db_enum_settings(m_hContact, enumSettingsProc, m_strModule.c_str(), &insertIterator);
}
diff --git a/plugins/HistoryStats/src/mu_common.cpp b/plugins/HistoryStats/src/mu_common.cpp index d941c7c1c1..598537b135 100644 --- a/plugins/HistoryStats/src/mu_common.cpp +++ b/plugins/HistoryStats/src/mu_common.cpp @@ -44,25 +44,6 @@ namespace mu }
/*
- * db_time
- */
-
- namespace db_contact
- {
- int enumSettings(MCONTACT hContact, const char* szModule, DBSETTINGENUMPROC pEnumProc, LPARAM lProcParam)
- {
- DBCONTACTENUMSETTINGS dbces;
-
- dbces.pfnEnumProc = pEnumProc;
- dbces.lParam = lProcParam;
- dbces.szModule = szModule;
- dbces.ofsSettings = 0;
-
- return CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, reinterpret_cast<LPARAM>(&dbces));
- }
- }
-
- /*
* icolib
*/
diff --git a/plugins/HistoryStats/src/mu_common.h b/plugins/HistoryStats/src/mu_common.h index e8d407e928..f2afb7c9df 100644 --- a/plugins/HistoryStats/src/mu_common.h +++ b/plugins/HistoryStats/src/mu_common.h @@ -18,15 +18,6 @@ namespace mu }
/*
- * db_contact
- */
-
- namespace db_contact
- {
- int enumSettings(MCONTACT hContact, const char* szModule, DBSETTINGENUMPROC pEnumProc, LPARAM lProcParam);
- }
-
- /*
* icolib
*/
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 57e54e5f89..48a0f50b23 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -147,7 +147,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke // switch off SAFETYMODE if necessary
if (unsafe)
- CallService(MS_DB_SETSAFETYMODE, 0, 0);
+ db_set_safety_mode(FALSE);
GetBookmarks(hContact, &books, &bookcnt);
@@ -187,7 +187,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke // switch ON safety mode as fast as we can to avoid DB corruption
if (unsafe)
- CallService(MS_DB_SETSAFETYMODE, 1, 0);
+ db_set_safety_mode(TRUE);
SetCursor(LoadCursor(0, IDC_ARROW));
}
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index b163428edb..62b4260e8a 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -163,12 +163,7 @@ static int CopySettingsEnum(const char *szSetting, LPARAM lParam) void CopySettings(MCONTACT srcID, const char *szSrcModule, MCONTACT dstID, const char *szDstModule)
{
LIST<char> arSettings(50);
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.szModule = szSrcModule;
- dbces.pfnEnumProc = CopySettingsEnum;
- dbces.lParam = (LPARAM)&arSettings;
- srcDb->EnumContactSettings(srcID, &dbces);
+ srcDb->EnumContactSettings(srcID, CopySettingsEnum, szSrcModule, &arSettings);
for (int i = arSettings.getCount() - 1; i >= 0; i--) {
DBVARIANT dbv = { 0 };
@@ -527,9 +522,9 @@ static MCONTACT MapContact(MCONTACT hSrc) static MCONTACT AddContact(char *szProto, char *pszUniqueSetting, DBVARIANT *id, const wchar_t *pszUserID, wchar_t *nick, wchar_t *group)
{
- MCONTACT hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
if (Proto_AddToContact(hContact, szProto) != 0) {
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
AddMessage(LPGENW("Failed to add %S contact %s"), szProto, pszUserID);
return INVALID_CONTACT_ID;
}
@@ -572,8 +567,7 @@ void ImportContactSettings(AccountMap *pda, MCONTACT hSrc, MCONTACT hDst) return;
ImportContactData icd = { hSrc, hDst, pda->szSrcAcc, pda->pa->szModuleName };
-
- CallService(MS_DB_MODULES_ENUM, (WPARAM)&icd, (LPARAM)ModulesEnumProc);
+ db_enum_modules(ModulesEnumProc, &icd);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -594,12 +588,7 @@ static int ImportGroup(const char* szSettingName, LPARAM lParam) static int ImportGroups()
{
int nGroups = 0;
-
- DBCONTACTENUMSETTINGS param = { 0 };
- param.szModule = "CListGroups";
- param.pfnEnumProc = ImportGroup;
- param.lParam = (LPARAM)&nGroups;
- srcDb->EnumContactSettings(NULL, ¶m);
+ db_enum_settings(NULL, ImportGroup, "CListGroups", &nGroups);
return nGroups;
}
@@ -669,7 +658,7 @@ void ImportMeta(DBCachedContact *ccSrc) // do we need to add a new metacontact?
if (hDest == INVALID_CONTACT_ID) {
- hDest = CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hDest = db_add_contact();
Proto_AddToContact(hDest, META_PROTO);
CopySettings(ccSrc->contactID, META_PROTO, hDest, META_PROTO);
diff --git a/plugins/ImportTXT/ImportThrd.pas b/plugins/ImportTXT/ImportThrd.pas index 24a92156a8..4c4468d5e7 100644 --- a/plugins/ImportTXT/ImportThrd.pas +++ b/plugins/ImportTXT/ImportThrd.pas @@ -624,14 +624,14 @@ begin // [preMultiLine] ìîäèôèêàòîð äëÿ âîñïðèÿòèÿ ìíîãîñòðî÷íîãî òåêñòà
if DoMapFile then // Çàãðóæàåì ôàéë
begin
- CallService(MS_DB_SETSAFETYMODE, wParam(FALSE), 0);
+ db_set_safety_mode(0);
case WorkPattern.IType of
1: TextImportProcedure;
2: BinImportProcedure;
end; // case
end; // DoMapFile
finally
- CallService(MS_DB_SETSAFETYMODE, wParam(true), 0);
+ db_set_safety_mode(1);
DoMessage(ITXT_THREAD_FINISH, AddedMessages, Duplicates);
DoUnMapFile;
RegExpr.Free;
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 7f40aa30fb..522b590739 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -159,17 +159,11 @@ void FreeModuleSettingLL(ModuleSettingLL* msll) void RenameDbProto(MCONTACT hContact, MCONTACT hContactNew, char* oldName, char* newName, int delOld)
{
DBVARIANT dbv;
- ModuleSettingLL settinglist;
struct ModSetLinkLinkItem *setting;
- DBCONTACTENUMSETTINGS dbces;
// enum all setting the contact has for the module
- dbces.pfnEnumProc = enumModulesSettingsProc;
- dbces.szModule = oldName;
- dbces.lParam = (LPARAM)&settinglist;
- settinglist.first = 0;
- settinglist.last = 0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ ModuleSettingLL settinglist = { NULL, NULL };
+ db_enum_settings(hContact, enumModulesSettingsProc, oldName, &settinglist);
setting = settinglist.first;
while (setting) {
@@ -694,7 +688,7 @@ INT_PTR onChangeProto(WPARAM wparam, LPARAM lparam) Proto_AddToContact(hContactNew, (char*)lparam);
}
else {
- hContactNew = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContactNew = db_add_contact();
if (hContactNew) {
Proto_AddToContact(hContactNew, (char*)lparam);
RenameDbProto(hContact, hContactNew, GetContactProto(hContact), (char*)lparam, 0);
diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp index c19a436e84..f5d64b0450 100644 --- a/plugins/MirFox/src/MirfoxMiranda.cpp +++ b/plugins/MirFox/src/MirfoxMiranda.cpp @@ -125,7 +125,7 @@ void CMirfoxMiranda::onContactAdded_async(void* threadArg) canAdd = false;
// check if hContact still exist
- if (canAdd && !CallService(MS_DB_CONTACT_IS, onContactAsyncThreadArgStruct->hContact, 0))
+ if (canAdd && !db_is_contact(onContactAsyncThreadArgStruct->hContact))
canAdd = false;
// execute
@@ -186,7 +186,7 @@ void CMirfoxMiranda::onContactSettingChanged_async(void* threadArg){ canAdd = false;
// check if hContact still exist
- if (canAdd && !CallService(MS_DB_CONTACT_IS, onContactAsyncThreadArgStruct->hContact, 0))
+ if (canAdd && !db_is_contact(onContactAsyncThreadArgStruct->hContact))
canAdd = false;
// edit
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 3a747f45aa..64715f01cf 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -331,7 +331,7 @@ static int db_Modules(lua_State *L) {
LIST<char> *param = new LIST<char>(5, PtrKeySortT);
- CallService(MS_DB_MODULES_ENUM, (WPARAM)param, (LPARAM)ModulesEnumProc);
+ db_enum_modules(ModulesEnumProc, param);
lua_pushinteger(L, 0);
lua_pushlightuserdata(L, param);
@@ -388,13 +388,7 @@ static int db_Settings(lua_State *L) const char* szModule = luaL_checkstring(L, 2);
LIST<char> *param = new LIST<char>(5, PtrKeySortT);
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = SettingsEnumProc;
- dbces.szModule = szModule;
- dbces.ofsSettings = 0;
- dbces.lParam = (LPARAM)param;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ db_enum_settings(hContact, SettingsEnumProc, szModule, param);
lua_pushinteger(L, 0);
lua_pushlightuserdata(L, param);
diff --git a/plugins/NewAwaySysMod/src/Options.cpp b/plugins/NewAwaySysMod/src/Options.cpp index 0a81d2f701..dd33eb8d02 100644 --- a/plugins/NewAwaySysMod/src/Options.cpp +++ b/plugins/NewAwaySysMod/src/Options.cpp @@ -299,13 +299,8 @@ void COptItem_TreeCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi m_value.RemoveAll();
sTreeReadEnumData pData(this, sModule, *sDBSettingPrefix);
+ db_enum_settings(NULL, TreeReadEnum, sModule, &pData);
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&pData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = TreeReadEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
if (!m_value.GetSize()) {
m_value = m_defValue;
}
@@ -481,12 +476,7 @@ void COptItem_TreeCtrl::CleanDBSettings(const CString &sModule, CString *sDBSett sTreeDeleteEnumData TreeDeleteEnumData;
TreeDeleteEnumData.TreeCtrl = this;
TreeDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&TreeDeleteEnumData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = TreeDeleteEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, TreeDeleteEnum, sModule, &TreeDeleteEnumData);
for (int i = 0; i < TreeDeleteEnumData.TreeSettings.GetSize(); i++)
db_unset(NULL, sModule, TreeDeleteEnumData.TreeSettings[i]);
@@ -672,12 +662,8 @@ void COptItem_ListCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi m_value.RemoveAll();
sListReadEnumData pData(this, sModule, *sDBSettingPrefix);
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&pData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = ListReadEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, ListReadEnum, sModule, &pData);
+
if (!m_value.GetSize())
m_value = m_defValue;
else {
@@ -752,12 +738,7 @@ void COptItem_ListCtrl::CleanDBSettings(const CString &sModule, CString *sDBSett sListDeleteEnumData ListDeleteEnumData;
ListDeleteEnumData.ListCtrl = this;
ListDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
- DBCONTACTENUMSETTINGS dbEnum;
- dbEnum.lParam = (LPARAM)&ListDeleteEnumData;
- dbEnum.ofsSettings = 0;
- dbEnum.pfnEnumProc = ListDeleteEnum;
- dbEnum.szModule = sModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ db_enum_settings(NULL, ListDeleteEnum, sModule, &ListDeleteEnumData);
for (int i = 0; i < ListDeleteEnumData.ListSettings.GetSize(); i++)
db_unset(NULL, sModule, ListDeleteEnumData.ListSettings[i]);
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 466c7f6a14..afa1d8a579 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -1235,12 +1235,8 @@ int handleEnum(const char *szSetting, LPARAM lParam) bool isTabsrmmUsed() { - DBCONTACTENUMSETTINGS enm = { 0 }; bool found = false; - enm.lParam = (LPARAM)&found; - enm.pfnEnumProc = handleEnum; - enm.szModule = "PluginDisable"; - if (CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&enm) == -1) + if (db_enum_settings(NULL, handleEnum, "PluginDisable", &found) == -1) return false; return found; diff --git a/plugins/NewsAggregator/Src/ExportImport.cpp b/plugins/NewsAggregator/Src/ExportImport.cpp index 03a553b9d9..e959797d1b 100644 --- a/plugins/NewsAggregator/Src/ExportImport.cpp +++ b/plugins/NewsAggregator/Src/ExportImport.cpp @@ -149,7 +149,7 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM isGroupUTF = 1;
}
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, MODULE);
db_set_ws(hContact, MODULE, "Nick", text);
db_set_ws(hContact, MODULE, "URL", url);
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 5079444792..9c0b9e3a28 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -53,7 +53,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break;
}
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, MODULE);
GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, _countof(str));
db_set_ws(hContact, MODULE, "Nick", str);
@@ -510,7 +510,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA if (mir_wstrcmp(dbURL, url))
continue;
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ db_delete_contact(hContact);
ListView_DeleteItem(hwndList, sel);
break;
}
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp index 0dc717daef..11ac955a3a 100644 --- a/plugins/Non-IM Contact/src/contactinfo.cpp +++ b/plugins/Non-IM Contact/src/contactinfo.cpp @@ -338,7 +338,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) i++;
}
free(replace);
- MCONTACT hContact2 = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact2 = db_add_contact();
Proto_AddToContact(hContact2, MODNAME);
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact2, IGNOREEVENT_USERONLINE);
db_set_s(hContact2, MODNAME, "Nick", Translate("New Non-IM Contact"));
@@ -394,7 +394,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) char dbVar1[2000];
MCONTACT hContact1 = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!db_get_static(hContact1, MODNAME, "Name", dbVar1, _countof(dbVar1))) {
- MCONTACT hContact2 = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact2 = db_add_contact();
if (!hContact2) {
msg("contact did not get created", "");
return 0;
@@ -632,7 +632,7 @@ INT_PTR ImportContacts(WPARAM, LPARAM) }
if (MessageBoxA(0, msg, modFullname, MB_YESNO) == IDYES) {
- if (!(hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0))) {
+ if (!(hContact = db_add_contact())) {
msg("contact did get created", "");
continue;
}
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 8ead40caf2..482bd9674f 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -303,13 +303,13 @@ void DoPropertySheet(MCONTACT hContact) INT_PTR addContact(WPARAM, LPARAM)
{
char tmp[256];
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_ws(hContact, MODNAME, "Nick", TranslateT("New Non-IM Contact"));
DoPropertySheet(hContact);
if (db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
replaceAllStrings(hContact);
return 0;
}
@@ -319,14 +319,14 @@ INT_PTR editContact(WPARAM wParam, LPARAM) MCONTACT hContact = wParam;
char tmp[256];
if (!hContact) {
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
}
DoPropertySheet(hContact);
if (db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
replaceAllStrings(hContact);
return 0;
}
diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp index 05e81a89b7..f375336afe 100644 --- a/plugins/Popup/src/config.cpp +++ b/plugins/Popup/src/config.cpp @@ -151,14 +151,9 @@ static int EnumProc(const char *szSetting, LPARAM lParam) static void CopyModule(const char *szModule, const char *szNewModule)
{
EnumProcParam param = { szModule, szNewModule };
+ db_enum_settings(NULL, EnumProc, szModule, ¶m);
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = EnumProc;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)¶m;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
-
- DbModule_Delete(0, szModule);
+ db_delete_module(0, szModule);
}
void UpgradeDb()
diff --git a/plugins/QuickSearch/i_ok.inc b/plugins/QuickSearch/i_ok.inc index fb2c41e137..a464d30e7b 100644 --- a/plugins/QuickSearch/i_ok.inc +++ b/plugins/QuickSearch/i_ok.inc @@ -455,7 +455,7 @@ begin if qsopt.numcolumns=0 then
exit;
// calculating contacts
- cnt:=CallService(MS_DB_CONTACT_GETCOUNT,0,0);
+ cnt:=db_get_contact_count();
if cnt=0 then
exit;
diff --git a/plugins/QuickSearch/sr_global.pas b/plugins/QuickSearch/sr_global.pas index d6b60ebed8..1412e8142a 100644 --- a/plugins/QuickSearch/sr_global.pas +++ b/plugins/QuickSearch/sr_global.pas @@ -696,7 +696,7 @@ var begin
if DBGetSettingType(0,qs_module,so_flags)=DBVT_DELETED then
begin
- DbModule_Delete(0,qs_module);
+ db_delete_module(0,qs_module);
qsopt.flags:=
QSO_SORTBYSTATUS or QSO_DRAWGRID or
QSO_CLIENTICONS or QSO_COLORIZE or
diff --git a/plugins/QuickSearch/sr_window.pas b/plugins/QuickSearch/sr_window.pas index de7b108950..bdefa5f51b 100644 --- a/plugins/QuickSearch/sr_window.pas +++ b/plugins/QuickSearch/sr_window.pas @@ -362,7 +362,7 @@ begin if ServiceExists(strCListDel)>0 then
CallService(strCListDel,hContact,0)
else
- CallService(MS_DB_CONTACT_DELETE,hContact,0);
+ db_delete_contact(hContact);
end;
procedure DeleteByList;
@@ -380,7 +380,7 @@ begin for i:=j downto 0 do
begin
if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then
- CallService(MS_DB_CONTACT_DELETE,FlagBuf[LV_GetLParam(grid,i)].contact,0);
+ db_delete_contact(FlagBuf[LV_GetLParam(grid,i)].contact);
end;
SendMessage(grid,WM_SETREDRAW,1,0);
end;
diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index 6818c5c879..468558b7be 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -106,13 +106,8 @@ int EnumDbModules(const char *szModuleName, DWORD, LPARAM lp) if (pModule) {
ctx->m_pszModule = szModuleName;
ctx->m_pNode = pModule;
+ db_enum_settings(ctx->m_hContact, &enum_contact_settings, szModuleName, ctx);
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = &enum_contact_settings;
- dbces.szModule = szModuleName;
- dbces.lParam = reinterpret_cast<LPARAM>(ctx);
-
- CallService(MS_DB_CONTACT_ENUMSETTINGS, WPARAM(ctx->m_hContact), reinterpret_cast<LPARAM>(&dbces));
if (pModule->GetChildCount() > 0)
pXml->AddChild(pModule);
@@ -131,7 +126,7 @@ IXMLNode::TXMLNodePtr export_contact(MCONTACT hContact, const CModuleInfo::TXMLE ctx.m_pNode = pNode;
ctx.m_hContact = hContact;
- CallService(MS_DB_MODULES_ENUM, (WPARAM)&ctx, (LPARAM)EnumDbModules);
+ db_enum_modules(EnumDbModules, &ctx);
}
return pNode;
}
@@ -557,7 +552,7 @@ bool import_contact(const IXMLNode::TXMLNodePtr& pXmlContact, CImportContext& im bool bResult = get_contact_state(pXmlContact, cst);
if (bResult) {
if (NULL == cst.m_hContact) {
- cst.m_hContact = MCONTACT(CallService(MS_DB_CONTACT_ADD, 0, 0));
+ cst.m_hContact = db_add_contact();
cst.m_bNewContact = true;
}
else if (impctx.m_nFlags & QUOTES_IMPORT_SKIP_EXISTING_CONTACTS)
diff --git a/plugins/Quotes/src/QuotesProviderBase.cpp b/plugins/Quotes/src/QuotesProviderBase.cpp index 73937e2cf5..7697ba6d6a 100644 --- a/plugins/Quotes/src/QuotesProviderBase.cpp +++ b/plugins/Quotes/src/QuotesProviderBase.cpp @@ -662,7 +662,7 @@ void CQuotesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, cons MCONTACT CQuotesProviderBase::CreateNewContact(const tstring& rsName)
{
- MCONTACT hContact = MCONTACT(CallService(MS_DB_CONTACT_ADD, 0, 0));
+ MCONTACT hContact = db_add_contact();
if (hContact) {
if (0 == Proto_AddToContact(hContact, QUOTES_PROTOCOL_NAME)) {
tstring sProvName = GetInfo().m_sName;
@@ -674,7 +674,7 @@ MCONTACT CQuotesProviderBase::CreateNewContact(const tstring& rsName) m_aContacts.push_back(hContact);
}
else {
- CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
+ db_delete_contact(hContact);
hContact = NULL;
}
}
diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp index 8119521bd1..c86049c521 100644 --- a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp +++ b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp @@ -38,7 +38,7 @@ bool CQuotesProviderDukasCopy::WatchForQuote(const CQuote& rQuote, bool bWatch) m_aContacts.erase(i);
}
- CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
+ db_delete_contact(hContact);
return true;
}
else if ((true == bWatch) && (i == m_aContacts.end())) {
diff --git a/plugins/Quotes/src/QuotesProviderFinance.cpp b/plugins/Quotes/src/QuotesProviderFinance.cpp index ada9936e77..d17a1c39ea 100644 --- a/plugins/Quotes/src/QuotesProviderFinance.cpp +++ b/plugins/Quotes/src/QuotesProviderFinance.cpp @@ -37,7 +37,7 @@ bool CQuotesProviderFinance::WatchForQuote(const CQuote& rQuote, bool bWatch) m_aContacts.erase(i);
}
- CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
+ db_delete_contact(hContact);
return true;
}
diff --git a/plugins/Quotes/src/QuotesProviderGoogle.cpp b/plugins/Quotes/src/QuotesProviderGoogle.cpp index 555081c72c..fb530adb06 100644 --- a/plugins/Quotes/src/QuotesProviderGoogle.cpp +++ b/plugins/Quotes/src/QuotesProviderGoogle.cpp @@ -53,7 +53,7 @@ bool CQuotesProviderGoogle::WatchForRate(const CRateInfo& ri, m_aContacts.erase(i);
}
- CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
+ db_delete_contact(hContact);
return true;
}
diff --git a/plugins/RemovePersonalSettings/src/rps.cpp b/plugins/RemovePersonalSettings/src/rps.cpp index 5df0d124b5..7da24ba134 100644 --- a/plugins/RemovePersonalSettings/src/rps.cpp +++ b/plugins/RemovePersonalSettings/src/rps.cpp @@ -195,14 +195,14 @@ void RemoveUsers() MCONTACT hContactOld = hContact;
hContact = db_find_next(hContact);
- if (isMetaContact(hContactOld) )
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContactOld, 0);
+ if (isMetaContact(hContactOld))
+ db_delete_contact(hContactOld);
}
// Now delete all left-overs
hContact = db_find_first();
while(hContact != NULL) {
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = db_find_first();
}
@@ -632,7 +632,7 @@ void DeleteSettingEx(const char *szModule, const char *szSetting) dms.filter = szModule;
dms.lenFilterMinusOne = lenModule-1;
- CallService(MS_DB_MODULES_ENUM, (WPARAM) &dms, (LPARAM) &ModuleEnumProc);
+ db_enum_modules(ModuleEnumProc, &dms);
// Delete then
szModule = dms.buffer;
@@ -647,19 +647,10 @@ void DeleteSettingEx(const char *szModule, const char *szSetting) size_t lenSetting = szSetting == NULL ? 0 : mir_strlen(szSetting);
if (szSetting == NULL || szSetting[0] == '*' || szSetting[lenSetting-1] == '*') {
DeleteModuleStruct dms;
- DBCONTACTENUMSETTINGS dbces;
-
memset(&dms, 0, sizeof(dms));
-
dms.filter = szSetting;
dms.lenFilterMinusOne = lenSetting-1;
-
- dbces.pfnEnumProc = EnumProc;
- dbces.lParam = (LPARAM) &dms;
- dbces.szModule = szModule;
- dbces.ofsSettings = 0;
-
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM) &dbces);
+ db_enum_settings(NULL, EnumProc, szModule, &dms);
// Delete then
szSetting = dms.buffer;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8962d354fe..70156a8b2b 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1835,7 +1835,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP db_set_b(dat->hContact, SRMMMOD, "UseRTL", (BYTE)((dat->flags & SMF_RTL) ? 1 : 0));
if (dat->hContact && (g_dat.flags & SMF_DELTEMP))
if (db_get_b(dat->hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, dat->hContact, 0);
+ db_delete_contact(dat->hContact);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
SendMessage(dat->hwndParent, CM_REMOVECHILD, 0, (LPARAM)hwndDlg);
diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 6f9475c6e8..1cd20ad1ba 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -243,7 +243,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) bHideOffline = true;
// get the number of contacts
- int dwContacts = (int)CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
+ int dwContacts = db_get_contact_count();
if (dwContacts == 0)
return false;
diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index c53573bbf4..212e04ff37 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -911,21 +911,15 @@ int OptionsInit(WPARAM wparam,LPARAM lparam) static int ClearDatabase(char* filter)
{
- DBCONTACTENUMSETTINGS dbces;
- char** settings;
- int i, settingCount = 0;
-
settingIndex = 0;
- dbces.szModule = MODULENAME;
- dbces.lParam = (LPARAM)&settingCount;
- dbces.pfnEnumProc = CountSettings;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
-
- settings = (char**)malloc(settingCount*sizeof(char*));
- dbces.lParam = (LPARAM)&settings;
- dbces.pfnEnumProc = DeleteSetting;
- CallService(MS_DB_CONTACT_ENUMSETTINGS,0,(LPARAM)&dbces);
- for (i=0; i < settingCount; i++) {
+
+ int settingCount = 0;
+ db_enum_settings(NULL, CountSettings, MODULENAME, &settingCount);
+
+ char **settings = (char**)malloc(settingCount*sizeof(char*));
+ db_enum_settings(NULL, DeleteSetting, MODULENAME, &settings);
+
+ for (int i=0; i < settingCount; i++) {
if ((filter == NULL) || (!strncmp(filter, settings[i], mir_strlen(filter))))
db_unset(NULL, MODULENAME, settings[i]);
free(settings[i]);
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 5f3a810b60..4a42cb136c 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -261,7 +261,7 @@ void CleanProtocolTmpThread(std::string proto) for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
LogSpamToFile(*i, L"Deleted");
HistoryLogFunc(*i, "Deleted");
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
+ db_delete_contact(*i);
}
clean_mutex.unlock();
}
@@ -286,7 +286,7 @@ void CleanProtocolExclThread(std::string proto) for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
LogSpamToFile(*i, L"Deleted");
HistoryLogFunc(*i, "Deleted");
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
+ db_delete_contact(*i);
}
clean_mutex.unlock();
}
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 54c0019486..d0d4021ea4 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -38,7 +38,7 @@ INT_PTR RemoveTempContacts(WPARAM, LPARAM lParam) // Set a flag so we remember to delete the contact when the protocol goes online the next time
db_set_b(hContact, "CList", "Delete", 1);
else
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
}
}
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index 36124651a1..18b2aa5846 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -611,7 +611,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l switch (LOWORD(wParam)) { case IDC_BBRESET: - DbModule_Delete(NULL, "TabSRMM_Toolbar"); + db_delete_module(NULL, "TabSRMM_Toolbar"); CB_HardReInit(); BuildMenuObjectsTree(hToolBarTree); break; diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index aa1d32a4fd..d1f8cb16e0 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -226,12 +226,7 @@ static void CheckUpdate() if (compat == 0) {
LIST<char> szSettings(120);
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.szModule = CHAT_OLDFONTMODULE;
- dbces.pfnEnumProc = CopyChatSetting;
- dbces.lParam = (LPARAM)&szSettings;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, CopyChatSetting, CHAT_OLDFONTMODULE, &szSettings);
DBVARIANT dbv;
for (int i = szSettings.getCount() - 1; i >= 0; i--) {
@@ -242,7 +237,7 @@ static void CheckUpdate() mir_free(p);
}
- DbModule_Delete(NULL, CHAT_OLDFONTMODULE);
+ db_delete_module(NULL, CHAT_OLDFONTMODULE);
compat++;
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 87e0e8c979..afc2c235f6 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -3295,7 +3295,7 @@ quote_from_last: dat->cache->setWindowData();
if (dat->cache->isValid() && !dat->fIsReattach && dat->hContact && M.GetByte("deletetemp", 0))
if (db_get_b(dat->hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, dat->hContact, 0);
+ db_delete_contact(dat->hContact);
delete dat->Panel;
mir_free(dat);
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 97c12d1764..7415e54513 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -244,15 +244,8 @@ int _cdecl CSendLater::addStub(const char *szSetting, LPARAM lParam) void CSendLater::processSingleContact(const MCONTACT hContact)
{
int iCount = db_get_dw(hContact, "SendLater", "count", 0);
-
- if (iCount) {
- DBCONTACTENUMSETTINGS ces = { 0 };
- ces.pfnEnumProc = CSendLater::addStub;
- ces.szModule = "SendLater";
- ces.lParam = hContact;
-
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&ces);
- }
+ if (iCount)
+ db_enum_settings(hContact, CSendLater::addStub, "SendLater", (void*)hContact);
}
// called periodically from a timer, check if new contacts were added
diff --git a/plugins/TooltipNotify/src/DbHelpers.cpp b/plugins/TooltipNotify/src/DbHelpers.cpp index 4393e44b5a..8fe93249a6 100644 --- a/plugins/TooltipNotify/src/DbHelpers.cpp +++ b/plugins/TooltipNotify/src/DbHelpers.cpp @@ -13,12 +13,7 @@ static int EnumSettingsProc1(const char*, LPARAM) bool ModuleSettingsExists(MCONTACT hContact, const char* pszModuleName)
{
- DBCONTACTENUMSETTINGS dbces = {0};
- dbces.szModule = pszModuleName;
- dbces.pfnEnumProc = EnumSettingsProc1;
-
- int nResult = ::CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
- return (nResult != -1);
+ return db_enum_settings(hContact, EnumSettingsProc1, pszModuleName) != -1;
}
static int EnumSettingsProc2(const char *pszSetting, LPARAM lParam)
@@ -31,12 +26,7 @@ static int EnumSettingsProc2(const char *pszSetting, LPARAM lParam) void DeleteModuleSettings(MCONTACT hContact, const char* pszModuleName)
{
SettingsList settingsList;
- DBCONTACTENUMSETTINGS dbces = {0};
- dbces.szModule = pszModuleName;
- dbces.lParam = (LPARAM)&settingsList;
- dbces.pfnEnumProc = EnumSettingsProc2;
-
- int nResult = ::CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ int nResult = db_enum_settings(hContact, EnumSettingsProc2, pszModuleName, &settingsList);
if (nResult != -1)
{
for(unsigned i=0; i<settingsList.size(); i++)
@@ -60,12 +50,7 @@ static int GetSetting(MCONTACT hContact, const char *szModule, const char *szSet void RenameModule(MCONTACT hContact, const char* pszOldName, const char* pszNewName)
{
SettingsList settingsList;
- DBCONTACTENUMSETTINGS dbces = {0};
- dbces.szModule = pszOldName;
- dbces.lParam = (LPARAM)&settingsList;
- dbces.pfnEnumProc = EnumSettingsProc2;
-
- int nResult = ::CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ int nResult = db_enum_settings(hContact, EnumSettingsProc2, pszOldName, &settingsList);
if (nResult != -1)
{
DBVARIANT dbv;
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp index b8d878b188..34eb007d36 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp @@ -236,18 +236,18 @@ MCONTACT CExImContactBase::toDB() } // create new contact - _hContact = DB::Contact::Add(); + _hContact = db_add_contact(); if (!_hContact) { return _hContact = INVALID_CONTACT_ID; } // Add the protocol to the new contact if (Proto_AddToContact(_hContact, _pszProto)) { - DB::Contact::Delete(_hContact); + db_delete_contact(_hContact); return _hContact = INVALID_CONTACT_ID; } // write uid to protocol module if (db_set(_hContact, _pszProto, _pszUIDKey, &_dbvUID)) { - DB::Contact::Delete(_hContact); + db_delete_contact(_hContact); return _hContact = INVALID_CONTACT_ID; } // write nick and display name diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index 4a9b06f82e..c3b8f48f8e 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -607,7 +607,7 @@ int CExImContactXML::ImportContact() LPGENW("Importing a new contact was aborted!"),
LPGENW("You aborted import of a new contact.\nSome information may be missing for this contact.\n\nDo you want to delete the incomplete contact?"));
if (result == IDYES) {
- DB::Contact::Delete(_hContact);
+ db_delete_contact(_hContact);
_hContact = INVALID_CONTACT_ID;
}
}
@@ -749,7 +749,7 @@ int CExImContactXML::ImportMetaSubContact(CExImContactXML * pMetaContact) MIR_FREE(ptszNick);
MIR_FREE(ptszMetaNick);
if (result == IDYES) {
- DB::Contact::Delete(_hContact);
+ db_delete_contact(_hContact);
_hContact = INVALID_CONTACT_ID;
}
}
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 2ac2aaa37d..aee6a83b5f 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -366,11 +366,11 @@ int CFileXml::Import(MCONTACT hContact, LPCSTR pszFileName) int ret;
// disable database safty mode to speed up the operation
- CallService(MS_DB_SETSAFETYMODE, 0, 0);
+ db_set_safety_mode(0);
// import owner contact
ret = ImportOwner(xmlCard->FirstChildElement(XKEY_OWNER));
// as soon as possible enable safty mode again!
- CallService(MS_DB_SETSAFETYMODE, 1, 0);
+ db_set_safety_mode(1);
if (!ret) {
MsgBox(NULL, MB_ICONINFORMATION,
@@ -395,11 +395,11 @@ int CFileXml::Import(MCONTACT hContact, LPCSTR pszFileName) if (_numContactsTodo > 0) {
_progress.SetContactCount(_numContactsTodo);
// disable database safty mode to speed up the operation
- CallService(MS_DB_SETSAFETYMODE, 0, 0);
+ db_set_safety_mode(0);
// import the contacts
ImportContacts(xmlCard);
// as soon as possible enable safty mode again!
- CallService(MS_DB_SETSAFETYMODE, 1, 0);
+ db_set_safety_mode(1);
}
// finally hide the progress dialog
_progress.Hide();
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 6bf79fc8e7..f1b8feaf83 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -28,36 +28,6 @@ namespace DB { **/
namespace Contact {
-
-/**
- * Gets the number of contacts in the database, which does not count the user
- * @param hContact - handle to the contact
- * @return Returns the number of contacts. They can be retrieved using
- * contact/findfirst and contact/findnext
- **/
-INT_PTR GetCount()
-{
- return CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
-}
-
-/**
- * Simply adds a new contact without setting up any protocol or something else
- * @return HANDLE The function returns the HANDLE of the new contact
- **/
-MCONTACT Add()
-{
- return (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
-}
-
-/**
- * This function deletes a contact from the database.
- * @param hContact - handle to the contact
- **/
-BYTE Delete(MCONTACT hContact)
-{
- return CallService(MS_DB_CONTACT_DELETE, hContact, 0) != 0;
-}
-
/**
* This function trys to guess, when an ICQ contact was added to database.
**/
@@ -121,10 +91,7 @@ static int IsEmptyEnumProc(LPCSTR, LPARAM) bool IsEmpty(MCONTACT hContact, LPCSTR pszModule)
{
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = IsEmptyEnumProc;
- dbces.szModule = pszModule;
- return (0 > CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces));
+ return 0 > db_enum_settings(hContact, IsEmptyEnumProc, pszModule);
}
/**
@@ -755,7 +722,7 @@ LPSTR CEnumList::Insert(LPCSTR str) INT_PTR CEnumList::EnumModules()
{
- return CallService(MS_DB_MODULES_ENUM, (WPARAM)this, (LPARAM)CEnumList::EnumProc);
+ return db_enum_modules(CEnumList::EnumProc, this);
}
/**
@@ -765,11 +732,7 @@ INT_PTR CEnumList::EnumModules() INT_PTR CEnumList::EnumSettings(MCONTACT hContact, LPCSTR pszModule)
{
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = (DBSETTINGENUMPROC)CEnumList::EnumSettingsProc;
- dbces.szModule = pszModule;
- dbces.lParam = (LPARAM)this;
- return CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ return db_enum_settings(hContact, &CEnumList::EnumSettingsProc, pszModule, this);
}
} /* namespace DB */
\ No newline at end of file diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index 6b83a4e3a5..a9897306b5 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -32,13 +32,7 @@ namespace Contact { { return pcli->pfnGetContactDisplayName(hContact, 0);
}
- INT_PTR GetCount();
-
- MCONTACT Add();
- BYTE Delete(MCONTACT hContact);
-
DWORD WhenAdded(DWORD dwUIN, LPCSTR szBaseProto);
-
} /* namespace Contact */
namespace Module {
diff --git a/plugins/Utils.pas/dbsettings.pas b/plugins/Utils.pas/dbsettings.pas index c60220e3a2..32ba169808 100644 --- a/plugins/Utils.pas/dbsettings.pas +++ b/plugins/Utils.pas/dbsettings.pas @@ -217,7 +217,6 @@ end; function DBDeleteGroup(hContact:TMCONTACT;szModule:PAnsiChar;prefix:PAnsiChar=nil):int_ptr;
var
- ces:TDBCONTACTENUMSETTINGS;
p:PAnsiChar;
code,num:integer;
ptr:PAnsiChar;
@@ -227,26 +226,19 @@ var begin
if (prefix=nil) or (prefix^=#0) then
begin
- DbModule_Delete(hContact,szModule);
+ db_delete_module(hContact,szModule);
result:=0;
exit;
end;
- ces.szModule:=szModule;
- num:=0;
//calculate size for setting names buffer
- ces.pfnEnumProc:=@EnumSettingsProcCalc;
- ces.lParam :=lParam(@num);
- ces.ofsSettings:=0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS,hContact,lparam(@ces));
+ num:=0;
+ db_enum_settings(hContact,@EnumSettingsProcCalc,szModule,@num);
//get setting names list
GetMem(p,num+1);
ptr:=p;
- ces.pfnEnumProc:=@EnumSettingsProc;
- ces.lParam :=lparam(@ptr);
- ces.ofsSettings:=0;
- result:=CallService(MS_DB_CONTACT_ENUMSETTINGS,hContact,lparam(@ces));
+ result:=db_enum_settings(hContact,@EnumSettingsProc,szModule,@ptr);
ptr^:=#0;
ptr:=p;
diff --git a/plugins/Utils.pas/mircontacts.pas b/plugins/Utils.pas/mircontacts.pas index cb87d93b5a..d9e2e2bf7e 100644 --- a/plugins/Utils.pas/mircontacts.pas +++ b/plugins/Utils.pas/mircontacts.pas @@ -459,7 +459,7 @@ begin {
CallService(MS_CLIST_CONTACTDOUBLECLICKED,hContact,0);
}
- if (hContact<>0) and (CallService(MS_DB_CONTACT_IS,hContact,0)<>0) then
+ if (hContact<>0) and (db_is_contact(hContact)<>0) then
begin
if StrCopy(pc,GetContactProto(hContact))<>nil then
if DblClk or (DBReadByte(hContact,pc,'ChatRoom',0)=1) then // chat room
diff --git a/plugins/Utils.pas/srvblock.pas b/plugins/Utils.pas/srvblock.pas index cf7b4125eb..6a0e0adfe0 100644 --- a/plugins/Utils.pas/srvblock.pas +++ b/plugins/Utils.pas/srvblock.pas @@ -561,7 +561,7 @@ begin mFreeMem(lservice);
if StrPos(buf,protostr)<>nil then
- if CallService(MS_DB_CONTACT_IS,data.Parameter,0)<>0 then
+ if db_is_contact(data.Parameter)<>0 then
StrReplace(buf,protostr,Proto_GetBaseAccountName(data.Parameter))
else
Exit;
diff --git a/plugins/Watrack/status/i_opt_tmpl.inc b/plugins/Watrack/status/i_opt_tmpl.inc index 9d717198da..285e61a9e8 100644 --- a/plugins/Watrack/status/i_opt_tmpl.inc +++ b/plugins/Watrack/status/i_opt_tmpl.inc @@ -134,17 +134,12 @@ end; function EnumTemplates:PAnsiChar;
var
- ces:TDBCONTACTENUMSETTINGS;
p:PAnsiChar;
begin
mGetMem(result,16384);
result^:=#0;
p:=result;
- ces.pfnEnumProc:=@EnumSettingsProc;
- ces.lParam :=lparam(@p);
- ces.szModule :=PluginShort;
- ces.ofsSettings:=0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS,0,lparam(@ces));
+ db_enum_settings(0, @EnumSettingsProc, PluginShort, @p);
end;
procedure LoadTemplates;
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index 8cdd7c98ed..58379ec9c4 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -63,7 +63,7 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam) // if contact with the same ID was not found, add it
if (psr->cbSize < sizeof(PROTOSEARCHRESULT)) return 0;
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, WEATHERPROTONAME);
// suppress online notification for the new contact
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index eea3edf81b..498d9db482 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -403,14 +403,9 @@ int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam) //
void DBDataManage(MCONTACT hContact, WORD Mode, WPARAM wParam, LPARAM)
{
+ // get all the settings and store them in a temporary list
LIST<char> arSettings(10);
-
- // get all the settings and stored them in a temporary list
- DBCONTACTENUMSETTINGS dbces;
- dbces.lParam = (LPARAM)&arSettings;
- dbces.pfnEnumProc = GetWeatherDataFromDB;
- dbces.szModule = WEATHERCONDITION;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
+ db_enum_settings(hContact, GetWeatherDataFromDB, WEATHERCONDITION, &arSettings);
// begin deleting settings
for (int i = arSettings.getCount() - 1; i >= 0; i--) {
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp index 9958e98629..fc3fccb510 100644 --- a/plugins/WebView/src/webview_services.cpp +++ b/plugins/WebView/src/webview_services.cpp @@ -368,7 +368,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam) db_free(&dbv); } - hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); + hContact = db_add_contact(); Proto_AddToContact(hContact, MODULENAME); /////////write to db diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index edf298d3e6..8984a4dfbb 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -302,7 +302,7 @@ int RegisterPOP3Plugin(WPARAM, LPARAM) if (!Finder->hContact && (Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) {
//No account contact found, have to create one
- Finder->hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
+ Finder->hContact = db_add_contact();
Proto_AddToContact(Finder->hContact, YAMN_DBMODULE);
db_set_s(Finder->hContact, YAMN_DBMODULE, "Id", Finder->Name);
db_set_s(Finder->hContact, YAMN_DBMODULE, "Nick", Finder->Name);
diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp index 3148158989..14d242106f 100644 --- a/plugins/YAMN/src/proto/pop3/pop3opt.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -869,7 +869,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP DlgSetItemTextT(hDlg, IDC_STTIMELEFT, TranslateT("Please wait while no account is in use."));
if (ActualAccount->hContact != NULL)
- CallService(MS_DB_CONTACT_DELETE, ActualAccount->hContact, 0);
+ db_delete_contact(ActualAccount->hContact);
CallService(MS_YAMN_DELETEACCOUNT, (WPARAM)POP3Plugin, (LPARAM)ActualAccount);
diff --git a/plugins/YAMN/src/services.cpp b/plugins/YAMN/src/services.cpp index 6bb3c1c21f..ba0f805c4e 100644 --- a/plugins/YAMN/src/services.cpp +++ b/plugins/YAMN/src/services.cpp @@ -443,7 +443,7 @@ void RefreshContact(void) db_set_b(Finder->hContact, "CList", "Hidden", 1);
}
else if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) {
- Finder->hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ Finder->hContact = db_add_contact();
Proto_AddToContact(Finder->hContact, YAMN_DBMODULE);
db_set_s(Finder->hContact, YAMN_DBMODULE, "Id", Finder->Name);
db_set_s(Finder->hContact, YAMN_DBMODULE, "Nick", Finder->Name);
diff --git a/plugins/mRadio/i_myservice.inc b/plugins/mRadio/i_myservice.inc index d55ab469e9..303aef72c1 100644 --- a/plugins/mRadio/i_myservice.inc +++ b/plugins/mRadio/i_myservice.inc @@ -149,7 +149,7 @@ begin pc:=GetParamSectionStr(section,'URL');
if pc<>nil then
begin
- result:=CallService(MS_DB_CONTACT_ADD,0,0);
+ result:=db_add_contact();
if result<>0 then
begin
Proto_AddToContact(result,PluginName);
@@ -259,7 +259,7 @@ begin StrCopy(dst,PAnsiChar(lParam));
if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
begin
- if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
+ if (wParam<>0) and (db_is_contact(wParam)<>0) then
begin
result:=1;
ExportRadioContact(result,dst,wParam)
@@ -285,7 +285,7 @@ begin filter:=ConstructFilter;
if ShowDlgW(@buf,nil,filter) then
begin
- result:=CallService(MS_DB_CONTACT_ADD,0,0);
+ result:=db_add_contact();
if result<>0 then
begin
Proto_AddToContact(result,PluginName);
diff --git a/plugins/mRadio/i_search.inc b/plugins/mRadio/i_search.inc index 355d91f833..4073d82d97 100644 --- a/plugins/mRadio/i_search.inc +++ b/plugins/mRadio/i_search.inc @@ -397,7 +397,7 @@ begin end;
// if not found
}
- hContact:=CallService(MS_DB_CONTACT_ADD,0,0);
+ hContact:=db_add_contact();
if hContact<>0 then
begin
Proto_AddToContact(hContact,PluginName);
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index f4c9580841..f3dbb61265 100644 --- a/protocols/AimOscar/src/proto.cpp +++ b/protocols/AimOscar/src/proto.cpp @@ -673,7 +673,7 @@ int __cdecl CAimProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l case EV_PROTO_ONERASE:
char szDbsettings[64];
mir_snprintf(szDbsettings, "%sP2P", m_szModuleName);
- DbModule_Delete(0, szDbsettings);
+ db_delete_module(0, szDbsettings);
break;
case EV_PROTO_ONCONTACTDELETED:
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp index a41ea0d5ce..50bddbceb9 100644 --- a/protocols/AimOscar/src/server.cpp +++ b/protocols/AimOscar/src/server.cpp @@ -889,7 +889,7 @@ void CAimProto::delete_ssi_list(SNAC &snac, int &offset) }
}
if (i == 1)
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
break;
case 0x0001: //group record
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp index 69c60f9cfc..6ac3457ed4 100755 --- a/protocols/AimOscar/src/utility.cpp +++ b/protocols/AimOscar/src/utility.cpp @@ -197,7 +197,7 @@ MCONTACT CAimProto::contact_from_sn(const char* sn, bool addIfNeeded, bool tempo }
if (addIfNeeded) {
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
if (hContact) {
if (Proto_AddToContact(hContact, m_szModuleName) == 0) {
setString(hContact, AIM_KEY_SN, norm_sn);
@@ -207,7 +207,7 @@ MCONTACT CAimProto::contact_from_sn(const char* sn, bool addIfNeeded, bool tempo db_set_b(hContact, "CList", "NotOnList", 1);
return hContact;
}
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
}
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 801d977a8e..56a4d3b8b8 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -157,10 +157,9 @@ MCONTACT CDummyProto::AddToList(int flags, PROTOSEARCHRESULT* psr) if (psr->id.w == NULL) return NULL; - MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD); - + MCONTACT hContact = db_add_contact(); if (hContact && Proto_AddToContact(hContact, m_szModuleName) != 0) { - CallService(MS_DB_CONTACT_DELETE, hContact); + db_delete_contact(hContact); hContact = NULL; } diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index 8b502d2fb9..60b126ff56 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -218,7 +218,7 @@ MCONTACT CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, bo } if (add_to_list) { - MCONTACT res = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); + MCONTACT res = db_add_contact(); Proto_AddToContact(res, PROTONAME); db_set_dw(res, PROTONAME, "ipaddr", addr.S_un.S_addr); db_set_s(res, PROTONAME, "Nick", nick); diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 36d2536f92..f0b8852938 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -97,7 +97,7 @@ MCONTACT FacebookProto::ChatIDToHContact(const std::string &chat_id) auto it = facy.chat_id_to_hcontact.find(chat_id); if (it != facy.chat_id_to_hcontact.end()) { // Check if contact is still valid - if (CallService(MS_DB_CONTACT_IS, (WPARAM)it->second) == 1) + if (db_is_contact((WPARAM)it->second) == 1) return it->second; else facy.chat_id_to_hcontact.erase(it); @@ -129,7 +129,7 @@ MCONTACT FacebookProto::ContactIDToHContact(const std::string &user_id) std::map<std::string, MCONTACT>::iterator it = facy.user_id_to_hcontact.find(user_id); if (it != facy.user_id_to_hcontact.end()) { // Check if contact is still valid - if (CallService(MS_DB_CONTACT_IS, (WPARAM)it->second) == 1) + if (db_is_contact((WPARAM)it->second) == 1) return it->second; else facy.user_id_to_hcontact.erase(it); @@ -401,10 +401,10 @@ MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, bool force_add, boo } // Try to make a new contact - MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD); + MCONTACT hContact = db_add_contact(); if (hContact && Proto_AddToContact(hContact, m_szModuleName) != 0) { - CallService(MS_DB_CONTACT_DELETE, hContact); + db_delete_contact(hContact); hContact = NULL; } @@ -625,7 +625,7 @@ void FacebookProto::IgnoreFriendshipRequest(void *data) // Delete this contact, if he's temporary if (db_get_b(hContact, "CList", "NotOnList", 0)) - CallService(MS_DB_CONTACT_DELETE, hContact); + db_delete_contact(hContact); } else facy.client_notify(TranslateT("Error occurred when ignoring friendship request.")); diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp index e80e573742..eecfe8abd8 100644 --- a/protocols/GTalkExt/src/notifications.cpp +++ b/protocols/GTalkExt/src/notifications.cpp @@ -168,7 +168,7 @@ MCONTACT SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTST {
MCONTACT hContact = db_get_dw(NULL, acc, PSEUDOCONTACT_LINK, 0);
if (!hContact || !db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
db_set_dw(0, acc, PSEUDOCONTACT_LINK, hContact);
db_set_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 1);
Proto_AddToContact(hContact, acc);
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 8440ab94ab..ffce72b6b5 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1536,7 +1536,7 @@ MCONTACT GGPROTO::getcontact(uin_t uin, int create, int inlist, wchar_t *szNick) if (!create)
return NULL;
- MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hContact = db_add_contact();
if (!hContact) {
debugLogW(L"getcontact(): Failed to create Gadu-Gadu contact %s", szNick);
return NULL;
@@ -1544,7 +1544,7 @@ MCONTACT GGPROTO::getcontact(uin_t uin, int create, int inlist, wchar_t *szNick) if (Proto_AddToContact(hContact, m_szModuleName) != 0) {
// For some reason we failed to register the protocol for this contact
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
debugLogA("getcontact(): Failed to register GG contact %d", uin);
return NULL;
}
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 29f3e39abc..65db400791 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -139,7 +139,7 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) DBVARIANT dbv;
if (!getWString(hContact, "ChatRoomID", &dbv)) {
if (dbv.ptszVal && !mir_wstrcmp(gch->pDest->ptszID, dbv.ptszVal))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
db_free(&dbv);
}
hContact = hNext;
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index fbb314a22c..78542d1802 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -380,7 +380,7 @@ INT_PTR GGPROTO::get_acc_mgr_gui(WPARAM, LPARAM lParam) INT_PTR GGPROTO::leavechat(WPARAM hContact, LPARAM)
{
if (hContact)
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
return 0;
}
diff --git a/protocols/ICQCorp/src/protocol.cpp b/protocols/ICQCorp/src/protocol.cpp index 19b51ca642..5b112d6e83 100644 --- a/protocols/ICQCorp/src/protocol.cpp +++ b/protocols/ICQCorp/src/protocol.cpp @@ -1317,7 +1317,7 @@ ICQUser *ICQ::addUser(unsigned int uin, bool persistent) u = new ICQUser();
u->uin = uin;
- u->hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ u->hContact = db_add_contact();
icqUsers.push_back(u);
Proto_AddToContact(u->hContact, protoName);
diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index 8ef7cab404..a0406973c6 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -97,7 +97,7 @@ MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline) }
// here we create a new one since no one is to be found
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
if (hContact) {
Proto_AddToContact(hContact, m_szModuleName);
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index 50ac719935..a7befd3419 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -246,11 +246,7 @@ int CIrcProto::OnModulesLoaded(WPARAM, LPARAM) if (!getByte("PerformConversionDone", 0)) {
OBJLIST<CMStringA> performToConvert(10);
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttCheckPerform;
- dbces.lParam = (LPARAM)&performToConvert;
- dbces.szModule = m_szModuleName;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbces);
+ db_enum_settings(NULL, sttCheckPerform, m_szModuleName, &performToConvert);
for (int i = 0; i < performToConvert.getCount(); i++) {
CMStringA s = performToConvert[i];
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 1a249a3fc3..20a7899faf 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -165,10 +165,7 @@ void RereadServers() {
g_servers.destroy();
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttServerEnum;
- dbces.szModule = SERVERSMODULE;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbces);
+ db_enum_settings(NULL, sttServerEnum, SERVERSMODULE);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -747,7 +744,7 @@ void CConnectPrefsDlg::OnApply() if (m_serverlistModified) {
m_serverlistModified = false;
- DbModule_Delete(0, SERVERSMODULE);
+ db_delete_module(0, SERVERSMODULE);
int j = m_serverCombo.GetCount();
if (j != CB_ERR && j != 0) {
diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp index faec561278..412dec2b39 100644 --- a/protocols/IcqOscarJ/src/fam_01service.cpp +++ b/protocols/IcqOscarJ/src/fam_01service.cpp @@ -470,7 +470,7 @@ char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactRes WORD wCurrentLen = 0;
int add;
- char *szList = (char*)SAFE_MALLOC(CallService(MS_DB_CONTACT_GETCOUNT, 0, 0) * UINMAXLEN);
+ char *szList = (char*)SAFE_MALLOC(db_get_contact_count() * UINMAXLEN);
char szLen[2];
szLen[1] = '\0';
diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp index f78ba6541c..21978f1886 100644 --- a/protocols/IcqOscarJ/src/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp @@ -520,7 +520,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info*) AddToSpammerList(dwUIN);
if (getByte("PopupsSpamEnabled", DEFAULT_SPAM_POPUPS_ENABLED))
ShowPopupMsg(hContact, LPGEN("Spambot Detected"), LPGEN("Contact deleted & further events blocked."), POPTYPE_SPAM);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
debugLogA("Contact %u deleted", dwUIN);
}
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 91d2014802..d9ed1b32dd 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -415,7 +415,7 @@ int CIcqProto::AuthDeny(MEVENT hDbEvent, const wchar_t* szReason) icq_sendAuthResponseServ(uin, uid, 0, szReason);
if (db_get_b(hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
return 0; // Success
}
@@ -1862,11 +1862,11 @@ int __cdecl CIcqProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l {
char szDbSetting[MAX_PATH];
mir_snprintf(szDbSetting, "%sP2P", m_szModuleName);
- DbModule_Delete(0, szDbSetting);
+ db_delete_module(0, szDbSetting);
mir_snprintf(szDbSetting, "%sSrvGroups", m_szModuleName);
- DbModule_Delete(0, szDbSetting);
+ db_delete_module(0, szDbSetting);
mir_snprintf(szDbSetting, "%sGroups", m_szModuleName);
- DbModule_Delete(0, szDbSetting);
+ db_delete_module(0, szDbSetting);
}
break;
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 9c9ae7a703..2a031977e5 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -854,11 +854,7 @@ void CIcqProto::LoadServerIDs() mir_snprintf(szModule, "%sSrvGroups", m_szModuleName);
GroupReserveIdsEnumParam param = { this, szModule };
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = &GroupReserveIdsEnumProc;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)¶m;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, &GroupReserveIdsEnumProc, szModule, ¶m);
nGroups = nServerIDListCount - nStart;
@@ -1180,7 +1176,7 @@ int CIcqProto::IsServerGroupsDefined() // flush obsolete linking data
mir_snprintf(szModule, "%sGroups", m_szModuleName);
- DbModule_Delete(0, szModule);
+ db_delete_module(0, szModule);
iRes = 0; // no groups defined, or older version
}
@@ -1194,7 +1190,7 @@ void CIcqProto::FlushSrvGroupsCache() {
char szModule[MAX_PATH];
mir_snprintf(szModule, "%sSrvGroups", m_szModuleName);
- DbModule_Delete(0, szModule);
+ db_delete_module(0, szModule);
}
// Look thru DB and collect all ContactIDs from a group
@@ -1279,12 +1275,7 @@ void CIcqProto::removeGroupPathLinks(WORD wGroupID) pars[1] = (char*)wGroupID;
pars[2] = szModule;
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = &GroupLinksEnumProc;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)pars;
-
- if (!CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces)) { // we found some links, remove them
+ if (!db_enum_settings(NULL, &GroupLinksEnumProc, szModule, pars)) { // we found some links, remove them
char** list = (char**)pars[0];
while (list) {
void* bet;
@@ -1515,7 +1506,6 @@ static int SrvGroupNamesEnumProc(const char *szSetting, LPARAM lParam) char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloced)
{
// enum ICQSrvGroups and create unique name if neccessary
- DBCONTACTENUMSETTINGS dbces;
char szModule[MAX_PATH];
char *pars[4];
int uniqueID = 1;
@@ -1533,11 +1523,7 @@ char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloce pars[1] = NULL;
pars[2] = szNewGroupName ? szNewGroupName : szGroupNameBase;
pars[3] = szModule;
-
- dbces.pfnEnumProc = &SrvGroupNamesEnumProc;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)pars;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, &SrvGroupNamesEnumProc, szModule, pars);
if (pars[1]) { // the groupname already exists, create another
SAFE_FREE((void**)&szNewGroupName);
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index b99b17b95e..021331a978 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -150,12 +150,7 @@ static void enumServerGroups(CIcqProto* ppro) {
char szModule[MAX_PATH + 9];
mir_snprintf(szModule, "%s%s", ppro->m_szModuleName, "SrvGroups");
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = &GroupEnumIdsEnumProc;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)szModule;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, &GroupEnumIdsEnumProc, szModule, szModule);
}
static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char* szItemName)
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 3ecc78a9df..d15779ae08 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -442,7 +442,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) if (Added) {
debugLogA("Attempt to create ICQ contact %u", dwUin);
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
if (!hContact) {
debugLogA("Failed to create ICQ contact %u", dwUin);
return INVALID_CONTACT_ID;
@@ -450,7 +450,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) if (Proto_AddToContact(hContact, m_szModuleName) != 0) {
// For some reason we failed to register the protocol to this contact
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
debugLogA("Failed to register ICQ contact %u", dwUin);
return INVALID_CONTACT_ID;
}
@@ -515,7 +515,7 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) if (Added) {
debugLogA("Attempt to create ICQ contact by string <%s>", szUid);
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, UNIQUEIDSETTING, szUid);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 186d2da1a9..d2c836869d 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -496,7 +496,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
if (item && item->hContact && !item->bRealContact) {
debugLogW(L"Syncing roster: preparing to delete %s (hContact=0x%x)", item->jid, item->hContact);
- CallService(MS_DB_CONTACT_DELETE, item->hContact, 0);
+ db_delete_contact(item->hContact);
}
}
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 0a4600cecb..c6e995a074 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -101,7 +101,7 @@ MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, else
wcsncpy_s(szJid, jid, _TRUNCATE);
- MCONTACT hNewContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
setWString(hNewContact, "jid", szJid);
if (nick != NULL && *nick != '\0')
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index f869c96f1c..6c193d8618 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1326,7 +1326,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) else if (!mir_wstrcmp(action, L"delete")) {
MCONTACT cc = HContactFromJID(jid);
if (cc)
- CallService(MS_DB_CONTACT_DELETE, cc, 0);
+ db_delete_contact(cc);
}
}
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 92a44be899..ea2913deba 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -547,7 +547,7 @@ MCONTACT CMraProto::MraHContactFromEmail(const CMStringA &szEmail, BOOL bAddIfNe }
}
else {
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index 190fb1e704..93ac87ce7c 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -1590,7 +1590,7 @@ void CMsnProto::MSN_ProcessRemove(char* buf, size_t len) MsnContact* msc = Lists_Get(szEmail);
if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) {
if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail)) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)msc->hContact, 0);
+ db_delete_contact(msc->hContact);
msc->hContact = NULL;
}
}
diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index fd3dde5643..921415024d 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -36,7 +36,7 @@ MCONTACT CMsnProto::MSN_HContactFromEmail(const char* wlid, const char* msnNick, if (hContact == NULL && addIfNeeded) {
int netId = (msc && msc->netId)?msc->netId:(szNet?atoi(szNet):NETID_MSN);
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
if (netId != NETID_SKYPE) setString(hContact, "e-mail", szEmail);
setStringUtf(hContact, "Nick", msnNick ? msnNick : szEmail);
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index acd43695cb..fdbaeb732e 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -222,7 +222,7 @@ void CMsnProto::Lists_Populate(void) else
Lists_Add(0, netId, szEmail, hContact);
}
- else if (!isChatRoom(hContact)) CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ else if (!isChatRoom(hContact)) db_delete_contact(hContact);
hContact = hNext;
}
}
@@ -260,7 +260,7 @@ void CMsnProto::MSN_CleanupLists(void) }
if (!(p.list & (LIST_LL | LIST_FL))) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)p.hContact, 0);
+ db_delete_contact(p.hContact);
p.hContact = NULL;
}
}
@@ -483,7 +483,7 @@ static void SaveSettings(MCONTACT hItem, HWND hwndList, CMsnProto* proto) if (xorMask & (LIST_FL | LIST_LL) && !(newMask & (LIST_FL | LIST_LL))) {
if (!IsHContactInfo(hItem)) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hItem, 0);
+ db_delete_contact(hItem);
MsnContact* msc = proto->Lists_Get(szEmail);
if (msc) msc->hContact = NULL;
}
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index f66e293edd..745505288c 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -385,10 +385,10 @@ int CMsnProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) MSN_AddUser(NULL, email, msc->netId, LIST_RL);
if (!(msc->list & (LIST_FL | LIST_LL))) {
- if (msc->hContact) CallService(MS_DB_CONTACT_DELETE, (WPARAM)msc->hContact, 0);
+ if (msc->hContact) db_delete_contact(msc->hContact);
msc->hContact = NULL;
MCONTACT hContact = MSN_HContactFromEmail(email);
- if (hContact) CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ if (hContact) db_delete_contact(hContact);
}
return 0;
@@ -1199,7 +1199,7 @@ int __cdecl CMsnProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l case EV_PROTO_ONERASE:
char szDbsettings[64];
mir_snprintf(szDbsettings, "%s_HTTPS", m_szModuleName);
- DbModule_Delete(0, szDbsettings);
+ db_delete_module(0, szDbsettings);
break;
case EV_PROTO_ONCONTACTDELETED:
diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index 9217b49663..bcac4f2532 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -227,7 +227,7 @@ void CSametimeProto::SetAllOffline() for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ db_delete_contact(hContact);
continue;
}
diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index cb91800016..11c8591827 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -64,13 +64,13 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) MCONTACT hContact = FindContactByUserId(id);
bool new_contact = false;
if (!hContact) {
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
if (!hContact) {
debugLogW(L"AddContact(): Failed to create Sametime contact");
return NULL; ///TODO error handling
}
if (Proto_AddToContact(hContact, m_szModuleName) != 0) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ db_delete_contact(hContact);
debugLogW(L"AddContact(): Failed to register Sametime contact");
return NULL; ///TODO error handling
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 71c924d51c..3f1ce32b1d 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -293,7 +293,7 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM) SendRequest(new KickUserRequest(_T2A(idT), li.szSkypename, li));
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ db_delete_contact(hContact);
}
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 38bc23ecc5..acabbd7b7a 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -89,7 +89,7 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) if (!hContact)
{
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, SKYPE_SETTINGS_ID, skypename);
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index a6a8c0668e..39bd619363 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -357,7 +357,7 @@ MCONTACT CSteamProto::AddContact(const char *steamId, bool isTemporary) if (!hContact) { // create contact - hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); + hContact = db_add_contact(); Proto_AddToContact(hContact, this->m_szModuleName); setString(hContact, "SteamID", steamId); diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index 4e04784de1..dd749424be 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -217,7 +217,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) if (szJid != NULL) {
if (!TlenListExist(proto, LIST_ROSTER, szJid)) {
proto->debugLogA("Syncing roster: deleting 0x%x", hContact);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
}
hContact = hNext;
diff --git a/protocols/Tlen/src/tlen_misc.cpp b/protocols/Tlen/src/tlen_misc.cpp index 732af24769..48f2bf617a 100644 --- a/protocols/Tlen/src/tlen_misc.cpp +++ b/protocols/Tlen/src/tlen_misc.cpp @@ -45,7 +45,7 @@ void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) MCONTACT hContact;
if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) {
- hContact = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, proto->m_szModuleName);
// strip resource if present
s = TlenLoginFromJID(jid);
@@ -113,7 +113,7 @@ MCONTACT TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL te return NULL;
if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) {
- hContact = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, proto->m_szModuleName);
db_set_s(hContact, proto->m_szModuleName, "jid", jid);
if (nick != NULL && nick[0] != '\0')
diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index dcc6395496..be6431cfc3 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -183,7 +183,7 @@ static MCONTACT AddToListByJID(TlenProtocol *proto, const char *newJid, DWORD fl if (hContact == NULL) {
// not already there: add
char *jid = mir_strdup(newJid); _strlwr(jid);
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, proto->m_szModuleName);
db_set_s(hContact, proto->m_szModuleName, "jid", jid);
char *nick = TlenNickFromJID(newJid);
diff --git a/protocols/Tox/src/tox_chatrooms.cpp b/protocols/Tox/src/tox_chatrooms.cpp index e44b337a18..82805ab96e 100644 --- a/protocols/Tox/src/tox_chatrooms.cpp +++ b/protocols/Tox/src/tox_chatrooms.cpp @@ -23,7 +23,7 @@ MCONTACT CToxProto::AddChatRoom(int groupNumber) MCONTACT hContact = GetChatRoom(groupNumber);
if (!hContact)
{
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setWord(hContact, TOX_SETTINGS_CHAT_ID, groupNumber);
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 63091d2408..fa6b05a7c2 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -85,7 +85,7 @@ MCONTACT CToxProto::AddContact(const char *address, const char *nick, const char if (hContact)
return hContact;
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, TOX_SETTINGS_ID, address);
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index d5d56f9d85..2e28000c1f 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -240,7 +240,7 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status) AddChatContact(name);
// If not, make a new contact!
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = db_add_contact();
if (hContact) {
if (Proto_AddToContact(hContact, m_szModuleName) == 0) {
setString(hContact, TWITTER_KEY_UN, name);
@@ -258,7 +258,7 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status) return hContact;
}
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
return 0;
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 763d269344..f44f1ce6b4 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -446,7 +446,7 @@ void TwitterProto::UpdateSettings() for (MCONTACT hContact = db_find_first(m_szModuleName); hContact;) {
MCONTACT hNext = db_find_next(hContact, m_szModuleName);
if (isChatRoom(hContact))
- CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
}
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp index f2bad47bed..f66d051a8c 100644 --- a/protocols/Twitter/src/ui.cpp +++ b/protocols/Twitter/src/ui.cpp @@ -318,8 +318,7 @@ namespace popup_options // Pick a random contact
MCONTACT hContact = 0;
- int n_contacts = (int)CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
-
+ int n_contacts = db_get_contact_count();
if (n_contacts != 0) {
int contact = rand() % n_contacts;
hContact = db_find_first();
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 4857b38430..3691ae82ff 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -190,7 +190,7 @@ MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate) if (!bCreate)
return NULL;
- MCONTACT hNewContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD);
+ MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
setDword(hNewContact, "ID", dwUserid);
db_set_ws(hNewContact, "CList", "Group", m_vkOptions.pwszDefaultGroup);
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index f26d1ae631..fa0a1d8b09 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -676,7 +676,7 @@ void CVkProto::LeaveChat(int chat_id, bool close_window, bool delete_chat) gcd.iType = GC_EVENT_CONTROL;
CallServiceSync(MS_GC_EVENT, close_window? SESSION_TERMINATE:SESSION_OFFLINE, (LPARAM)&gce);
if (delete_chat)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)cc->m_hContact);
+ db_delete_contact(cc->m_hContact);
else
setByte(cc->m_hContact, "off", (int)true);
m_chats.remove(cc);
@@ -746,7 +746,7 @@ INT_PTR __cdecl CVkProto::SvcDestroyKickChat(WPARAM hContact, LPARAM) Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
<< CHAR_PARAM("code", code));
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
+ db_delete_contact(hContact);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 64c020b12a..85e4fe73a8 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -24,7 +24,7 @@ void CVkProto::AddFeedSpecialUser() MCONTACT hContact = FindUser(VK_FEED_USER);
if (!bSpecialContact) {
if (hContact)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
+ db_delete_contact(hContact);
return;
}
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 5b47e4de2c..b546761193 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -756,7 +756,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq bool bIsFriendGroup = IsGroupUser(hContact) && getBool(hContact, "friend");
if (userID == m_myUserId || userID == VK_FEED_USER || bIsFriendGroup)
continue;
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
+ db_delete_contact(hContact);
}
arContacts.destroy();
@@ -898,7 +898,7 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM) << CHAR_PARAM("code", code));
if (m_vkOptions.bRemoveFromCList)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
+ db_delete_contact(hContact);
return 0;
}
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index eded520031..bc2d6c9fb0 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -489,7 +489,7 @@ void WhatsAppProto::onLeaveGroup(const std::string &gjid) gce.ptszUID = pInfo->tszJid;
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
- CallService(MS_DB_CONTACT_DELETE, pInfo->hContact, 0);
+ db_delete_contact(pInfo->hContact);
m_chats.erase((char*)_T2A(pInfo->tszJid));
}
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp index e4f0d50330..f35fc5c565 100644 --- a/protocols/WhatsApp/src/contacts.cpp +++ b/protocols/WhatsApp/src/contacts.cpp @@ -33,7 +33,7 @@ MCONTACT WhatsAppProto::AddToContactList(const std::string &jid, const char *new }
// If not, make a new contact!
- if ((hContact = CallService(MS_DB_CONTACT_ADD, 0, 0)) == 0)
+ if ((hContact = db_add_contact()) == 0)
return INVALID_CONTACT_ID;
Proto_AddToContact(hContact, m_szModuleName);
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index ed7e110a8d..353baf3c16 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -255,7 +255,7 @@ int CYahooProto::AuthDeny(MEVENT hdbe, const wchar_t *reason) debugLogA("Rejecting buddy:%s msg: %s", who, u_reason);
reject(myid, who, getWord(hContact, "yprotoid", 0), u_reason);
- CallService(MS_DB_CONTACT_DELETE, hContact);
+ db_delete_contact(hContact);
}
}
return 0;
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index 499528b520..5baf2caf4c 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -263,7 +263,7 @@ MCONTACT CYahooProto::add_buddy(const char *yahoo_id, const char *yahoo_name, in //not already there: add
LOG(("[add_buddy] Adding buddy id: %s (Nick: %s), flags: %lu", yid, yahoo_name, flags));
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD);
+ hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, YAHOO_LOGINID, yid);
Set_Protocol(hContact, protocol);
@@ -668,7 +668,7 @@ void CYahooProto::ext_rejected(const char *who, const char *msg) * Make sure the contact is temporary so we could delete it w/o extra traffic
*/
db_set_b(hContact, "CList", "NotOnList", 1);
- CallService(MS_DB_CONTACT_DELETE, hContact);
+ db_delete_contact(hContact);
}
else LOG(("[ext_rejected] Buddy not on our buddy list"));
@@ -700,7 +700,7 @@ void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status ShowPopup(TranslateT("Invalid Contact"), TranslateT("The ID you tried to add is invalid."), NULL);
/* Make it TEMP first, we don't want to send any extra packets for FALSE ids */
db_set_b(hContact, "CList", "NotOnList", 1);
- CallService(MS_DB_CONTACT_DELETE, hContact);
+ db_delete_contact(hContact);
}
break;
@@ -710,7 +710,7 @@ void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status ShowPopup(TranslateT("Invalid Contact"), TranslateT("Unknown Error."), NULL);
/* Make it TEMP first, we don't want to send any extra packets for FALSE ids */
db_set_b(hContact, "CList", "NotOnList", 1);
- CallService(MS_DB_CONTACT_DELETE, hContact);
+ db_delete_contact(hContact);
}
break;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index e5309b928b..ad192efb95 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1628,7 +1628,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
if (dat->hContact && db_get_b(NULL, SRMMMOD, SRMSGSET_DELTEMP, SRMSGDEFSET_DELTEMP))
if (db_get_b(dat->hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)dat->hContact, 0);
+ db_delete_contact(dat->hContact);
Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 859c93e59a..d371083f5f 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -54,7 +54,7 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p }
// here we create a new one since no one is to be found
- if ((hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
+ if ((hContact = db_add_contact()) == NULL)
return NULL;
Proto_AddToContact(hContact, pszModule);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 83044f9d79..3ec71e4886 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -137,7 +137,7 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re // contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (pTemp->hContact && removeContact)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->hContact, 0);
+ db_delete_contact(pTemp->hContact);
SM_FreeSession(pTemp);
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index f0f947ad0f..0af50af530 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -495,7 +495,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam contact = NULL;
group = NULL;
if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) {
- if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
+ if (shouldShow && db_is_contact(wParam)) {
if (dat->selection >= 0 && cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
cli.pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0);
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index b74a591854..2255ed5ff7 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -125,7 +125,7 @@ static int ProtocolAck(WPARAM, LPARAM lParam) for (MCONTACT hContact = db_find_first(ack->szModule); hContact; ) {
MCONTACT hNext = db_find_next(hContact, ack->szModule);
if (db_get_b(hContact, "CList", "Delete", 0))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
}
@@ -453,7 +453,7 @@ void UnloadContactListModule() for (MCONTACT hContact = db_find_first(); hContact != NULL; ) {
MCONTACT hNext = db_find_next(hContact);
if (db_get_b(hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
ImageList_Destroy(hCListImages);
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index c679c6a15f..873caf139f 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -195,7 +195,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam) }
}
- CallService(MS_DB_CONTACT_DELETE, wParam, 0);
+ db_delete_contact(wParam);
break;
}
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 420e442f15..70db2791ef 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -25,14 +25,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "profilemanager.h"
+MIDatabase *currDb = NULL;
+DATABASELINK *currDblink = NULL;
+
// contains the location of mirandaboot.ini
bool g_bDbCreated;
wchar_t g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PATH];
wchar_t* g_defaultProfile;
void EnsureCheckerLoaded(bool);
-void LoadDatabaseServices();
-
bool fileExist(const wchar_t *fname)
{
if (*fname == 0)
@@ -486,8 +487,6 @@ int LoadDatabaseModule(void) _tchdir(szProfile);
szProfile[0] = 0;
- LoadDatabaseServices();
-
// find out which profile to load
if (!getProfile(szProfile, _countof(szProfile)))
return 1;
diff --git a/src/mir_app/src/dbutils.cpp b/src/mir_app/src/db_events.cpp index 155851a2e5..bc3fb4d470 100644 --- a/src/mir_app/src/dbutils.cpp +++ b/src/mir_app/src/db_events.cpp @@ -268,32 +268,6 @@ MIR_APP_DLL(wchar_t*) DbEvent_GetString(DBEVENTINFO *dbei, const char *str) /////////////////////////////////////////////////////////////////////////////////////////
-static int sttEnumVars(const char *szVarName, LPARAM lParam)
-{
- LIST<char>* vars = (LIST<char>*)lParam;
- vars->insert(mir_strdup(szVarName));
- return 0;
-}
-
-MIR_APP_DLL(int) DbModule_Delete(MCONTACT hContact, const char *szModuleName)
-{
- LIST<char> vars(20);
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttEnumVars;
- dbces.lParam = (LPARAM)&vars;
- dbces.szModule = (char*)szModuleName;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
-
- for (int i = vars.getCount()-1; i >= 0; i--) {
- db_unset(hContact, szModuleName, vars[i]);
- mir_free(vars[i]);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MIR_APP_DLL(int) Profile_GetPathA(size_t cbLen, char *pszDest)
{
if (!pszDest || !cbLen)
diff --git a/src/mir_app/src/dbini.cpp b/src/mir_app/src/db_ini.cpp index 8239b448e2..b33095de6c 100644 --- a/src/mir_app/src/dbini.cpp +++ b/src/mir_app/src/db_ini.cpp @@ -361,12 +361,8 @@ LBL_NewLine: if (secFN) warnThisSection = 0;
}
if (szLine[1] == '?') {
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = SettingsEnumProc;
mir_strncpy(szSection, szLine + 2, min(sizeof(szSection), (int)(szEnd - szLine - 1)));
- dbces.szModule = szSection;
- dbces.ofsSettings = 0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, SettingsEnumProc, szSection);
while (setting_items) {
SettingsList *next = setting_items->next;
@@ -428,11 +424,8 @@ LBL_NewLine: if (szValue[1] == '*') {
LIST<char> arSettings(1);
ESFDParam param = { &arSettings, szName };
- DBCONTACTENUMSETTINGS dbep = {};
- dbep.pfnEnumProc = EnumSettingsForDeletion;
- dbep.szModule = szSection;
- dbep.lParam = (LPARAM)¶m;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, LPARAM(&dbep));
+ db_enum_settings(NULL, EnumSettingsForDeletion, szSection, ¶m);
+
while (arSettings.getCount()) {
db_unset(NULL, szSection, arSettings[0]);
mir_free(arSettings[0]);
diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp new file mode 100644 index 0000000000..eaab4d9e9b --- /dev/null +++ b/src/mir_app/src/db_intf.cpp @@ -0,0 +1,98 @@ +/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-16 Miranda NG project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+#include "database.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// Database list
+
+LIST<DATABASELINK> arDbPlugins(5);
+
+static INT_PTR srvRegisterPlugin(WPARAM, LPARAM lParam)
+{
+ DATABASELINK* pPlug = (DATABASELINK*)lParam;
+ if (pPlug == NULL)
+ return 1;
+
+ arDbPlugins.insert(pPlug);
+ return 0;
+}
+
+static INT_PTR srvFindPlugin(WPARAM, LPARAM lParam)
+{
+ for (int i = arDbPlugins.getCount() - 1; i >= 0; i--) {
+ int error = arDbPlugins[i]->grokHeader((wchar_t*)lParam);
+ if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE)
+ return (INT_PTR)arDbPlugins[i];
+ }
+
+ return NULL;
+}
+
+static INT_PTR srvGetCurrentDb(WPARAM, LPARAM)
+{
+ return (INT_PTR)currDb;
+}
+
+static INT_PTR srvInitInstance(WPARAM, LPARAM lParam)
+{
+ MIDatabase *pDb = (MIDatabase*)lParam;
+ if (pDb != NULL)
+ pDb->m_cache = new MDatabaseCache(pDb->GetContactSize());
+ return 0;
+}
+
+static INT_PTR srvDestroyInstance(WPARAM, LPARAM lParam)
+{
+ MIDatabase *pDb = (MIDatabase*)lParam;
+ if (pDb != NULL) {
+ MDatabaseCache *pCache = (MDatabaseCache*)pDb->m_cache;
+ pDb->m_cache = NULL;
+ delete pCache;
+ }
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int LoadDbintfModule()
+{
+ CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
+ CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
+ CreateServiceFunction(MS_DB_GET_CURRENT, srvGetCurrentDb);
+
+ CreateServiceFunction(MS_DB_INIT_INSTANCE, srvInitInstance);
+ CreateServiceFunction(MS_DB_DESTROY_INSTANCE, srvDestroyInstance);
+
+ // create events once, they will be inherited by all database plugins
+ CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+ CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
+
+ CreateHookableEvent(ME_DB_EVENT_ADDED);
+ CreateHookableEvent(ME_DB_EVENT_DELETED);
+ CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ return 0;
+}
diff --git a/src/mir_app/src/dbintf.cpp b/src/mir_app/src/dbintf.cpp deleted file mode 100644 index ffa510f9e9..0000000000 --- a/src/mir_app/src/dbintf.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (C) 2012-16 Miranda NG project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "stdafx.h"
-#include "database.h"
-
-MIDatabase *currDb = NULL;
-DATABASELINK *currDblink = NULL;
-
-MIR_CORE_DLL(void) db_setCurrent(MIDatabase*);
-
-static INT_PTR srvSetSafetyMode(WPARAM wParam, LPARAM)
-{
- if (!currDb) return 1;
-
- currDb->SetCacheSafetyMode(wParam != 0);
- return 0;
-}
-
-static INT_PTR srvGetContactCount(WPARAM, LPARAM)
-{
- return (currDb) ? currDb->GetContactCount() : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Contacts
-
-static INT_PTR srvDeleteContact(WPARAM wParam, LPARAM)
-{
- DBVARIANT dbv = { 0 };
- if (!db_get_ws(wParam, "ContactPhoto", "File", &dbv)) {
- DeleteFile(dbv.ptszVal);
- db_free(&dbv);
- }
- return (currDb) ? currDb->DeleteContact(wParam) : 0;
-}
-
-static INT_PTR srvAddContact(WPARAM, LPARAM)
-{
- MCONTACT hNew = (currDb) ? currDb->AddContact() : 0;
- Netlib_Logf(NULL, "New contact created: %d", hNew);
- return hNew;
-}
-
-static INT_PTR srvIsDbContact(WPARAM wParam, LPARAM)
-{
- return (currDb) ? currDb->IsDbContact(wParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Module chain
-
-static INT_PTR srvEnumModuleNames(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumModuleNames((DBMODULEENUMPROC)lParam, (void*)wParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Settings
-
-static INT_PTR srvEnumContactSettings(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumContactSettings(wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0;
-}
-
-static INT_PTR srvEnumResidentSettings(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumResidentSettings((DBMODULEENUMPROC)wParam, (void*)lParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Database list
-
-LIST<DATABASELINK> arDbPlugins(5);
-
-static INT_PTR srvRegisterPlugin(WPARAM, LPARAM lParam)
-{
- DATABASELINK* pPlug = (DATABASELINK*)lParam;
- if (pPlug == NULL)
- return 1;
-
- arDbPlugins.insert(pPlug);
- return 0;
-}
-
-static INT_PTR srvFindPlugin(WPARAM, LPARAM lParam)
-{
- for (int i = arDbPlugins.getCount() - 1; i >= 0; i--) {
- int error = arDbPlugins[i]->grokHeader((wchar_t*)lParam);
- if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE)
- return (INT_PTR)arDbPlugins[i];
- }
-
- return NULL;
-}
-
-static INT_PTR srvGetCurrentDb(WPARAM, LPARAM)
-{
- return (INT_PTR)currDb;
-}
-
-static INT_PTR srvInitInstance(WPARAM, LPARAM lParam)
-{
- MIDatabase* pDb = (MIDatabase*)lParam;
- if (pDb != NULL)
- pDb->m_cache = new MDatabaseCache(pDb->GetContactSize());
- return 0;
-}
-
-static INT_PTR srvDestroyInstance(WPARAM, LPARAM lParam)
-{
- MIDatabase* pDb = (MIDatabase*)lParam;
- if (pDb != NULL) {
- MDatabaseCache *pCache = (MDatabaseCache*)pDb->m_cache;
- pDb->m_cache = NULL;
- delete pCache;
- }
- return 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-int LoadDbintfModule()
-{
- CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount);
- CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact);
- CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact);
- CreateServiceFunction(MS_DB_CONTACT_IS, srvIsDbContact);
-
- CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames);
-
- CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
- CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
-
- CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
- CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
- CreateServiceFunction(MS_DB_GET_CURRENT, srvGetCurrentDb);
-
- CreateServiceFunction(MS_DB_INIT_INSTANCE, srvInitInstance);
- CreateServiceFunction(MS_DB_DESTROY_INSTANCE, srvDestroyInstance);
- return 0;
-}
-
-void LoadDatabaseServices()
-{
- CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
-}
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 4ea32d150c..3a5baf7905 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -409,7 +409,7 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam) DBEVENTINFO *dbei = (DBEVENTINFO*)lParam;
if (dbei && dbei->eventType == EVENTTYPE_ADDED && dbei->pBlob != NULL) {
MCONTACT hContact = DbGetAuthEventContact(dbei);
- if (CallService(MS_DB_CONTACT_IS, hContact, 0) && IsIgnored(hContact, IGNOREEVENT_YOUWEREADDED))
+ if (db_is_contact(hContact) && IsIgnored(hContact, IGNOREEVENT_YOUWEREADDED))
return 1;
}
return 0;
diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index 5a9a88b60c..7863b338c0 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -130,7 +130,7 @@ class CGenMenuOptionsPage : public CDlgBase char szModule[256]; mir_snprintf(szModule, "%s_Items", pmo->pszName); - DbModule_Delete(NULL, szModule); + db_delete_module(NULL, szModule); SaveTreeInternal(NULL, m_menuItems.GetRoot(), szModule); db_set_b(NULL, szModule, "MenuFormat", 1); } diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index c714f06418..2b2f07e35d 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -935,7 +935,7 @@ static INT_PTR sttUpdateMenuService(WPARAM wParam, LPARAM) MO_RecursiveWalkMenu(pmo->m_items.first, sttReadOldItem, szModule);
// wipe out old trash, write new data & compatibility flag
- DbModule_Delete(NULL, szModule);
+ db_delete_module(NULL, szModule);
db_set_b(NULL, szModule, "MenuFormat", true);
MO_RecursiveWalkMenu(pmo->m_items.first, sttDumpItem, szModule);
}
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index cac1b4bdb2..674b55a9cd 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -52,7 +52,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM) ptrW tszGroup(db_get_wsa(wParam, "CList", "Group"));
// Create a new metacontact
- MCONTACT hMetaContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hMetaContact = db_add_contact();
if (hMetaContact == NULL)
return NULL;
@@ -73,7 +73,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM) // Assign the contact to the MetaContact just created (and make default).
if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
MessageBox(0, TranslateT("There was a problem in assigning the contact to the metacontact"), TranslateT("Error"), MB_ICONEXCLAMATION);
- CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0);
+ db_delete_contact(hMetaContact);
return 0;
}
@@ -200,7 +200,7 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion) Meta_RemoveContactNumber(cc, i, false);
NotifyEventHooks(hSubcontactsChanged, hContact, 0);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
else if (cc->IsSub()) {
if ((cc = currDb->m_cache->GetCachedContact(cc->parentID)) == NULL)
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 7a862f79df..37b23f355c 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -473,7 +473,7 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM) // no more subs? remove the meta itself
if (ccMeta->nSubs == 0)
- CallService(MS_DB_CONTACT_DELETE, ccMeta->contactID, 0);
+ db_delete_contact(ccMeta->contactID);
}
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index dfc1f380b4..d4755280f1 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -286,9 +286,9 @@ DbEvent_GetTextA @285 DbEvent_GetTextW @286
DbEvent_GetType @287
DbEvent_RegisterType @288
-DbModule_Delete @289
Profile_GetNameA @290
Profile_GetNameW @291
Profile_GetPathA @292
Profile_GetPathW @293
Profile_SetDefault @294
+DbModule_Delete @295 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 309b40d02d..db6e5def22 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -286,7 +286,6 @@ DbEvent_GetTextA @285 DbEvent_GetTextW @286
DbEvent_GetType @287
DbEvent_RegisterType @288
-DbModule_Delete @289
Profile_GetNameA @290
Profile_GetNameW @291
Profile_GetPathA @292
diff --git a/src/mir_app/src/options_ei.cpp b/src/mir_app/src/options_ei.cpp index d38dc19f6a..f9e11d7268 100644 --- a/src/mir_app/src/options_ei.cpp +++ b/src/mir_app/src/options_ei.cpp @@ -372,7 +372,7 @@ public: db_set_w(NULL, MODULE_NAME, setting, extra->getSlot());
}
- DbModule_Delete(NULL, MODULE_NAME "Groups");
+ db_delete_module(NULL, MODULE_NAME "Groups");
db_set_w(NULL, MODULE_NAME "Groups", "Count", groups.getCount());
for (int k = 0; k < groups.getCount(); k++) {
ExtraIconGroup *group = groups[k];
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 5c8edc3d13..d6d5e7ec68 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -114,7 +114,7 @@ void LoadDbAccounts(void) WriteDbAccounts();
int anum = accounts.getCount();
- CallService(MS_DB_MODULES_ENUM, 0, (LPARAM)EnumDbModules);
+ db_enum_modules(EnumDbModules);
if (anum != accounts.getCount())
WriteDbAccounts();
}
@@ -144,13 +144,7 @@ void WriteDbAccounts() {
// enum all old settings to delete
enumDB_ProtoProcParam param = { 0, NULL };
-
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = enumDB_ProtoProc;
- dbces.szModule = "Protocols";
- dbces.ofsSettings = 0;
- dbces.lParam = (LPARAM)¶m;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, enumDB_ProtoProc, "Protocols", ¶m);
// delete all settings
if (param.arrlen) {
@@ -383,12 +377,12 @@ void EraseAccount(const char *pszModuleName) // remove protocol contacts first
for (MCONTACT hContact = db_find_first(pszModuleName); hContact != NULL;) {
MCONTACT hNext = db_find_next(hContact, pszModuleName);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
// remove all protocol settings
- DbModule_Delete(NULL, pszModuleName);
+ db_delete_module(NULL, pszModuleName);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 8bac3b89bb..051ce6a32e 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -27,6 +27,82 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. MIDatabase *currDb = NULL;
/////////////////////////////////////////////////////////////////////////////////////////
+// database functions
+
+MIR_CORE_DLL(void) db_set_safety_mode(BOOL bNewMode)
+{
+ if (currDb)
+ currDb->SetCacheSafetyMode(bNewMode != 0);
+}
+
+MIR_CORE_DLL(int) db_get_contact_count(void)
+{
+ return (currDb) ? currDb->GetContactCount() : 0;
+}
+
+static int sttEnumVars(const char *szVarName, LPARAM lParam)
+{
+ LIST<char>* vars = (LIST<char>*)lParam;
+ vars->insert(mir_strdup(szVarName));
+ return 0;
+}
+
+MIR_CORE_DLL(int) db_delete_module(MCONTACT hContact, const char *szModuleName)
+{
+ LIST<char> vars(20);
+ db_enum_settings(hContact, sttEnumVars, szModuleName, &vars);
+
+ for (int i = vars.getCount() - 1; i >= 0; i--) {
+ db_unset(hContact, szModuleName, vars[i]);
+ mir_free(vars[i]);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// contact functions
+
+MIR_CORE_DLL(MCONTACT) db_add_contact(void)
+{
+ MCONTACT hNew = (currDb) ? currDb->AddContact() : 0;
+ Netlib_Logf(NULL, "New contact created: %d", hNew);
+ return hNew;
+}
+
+MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact)
+{
+ ptrW wszPhoto(db_get_wsa(hContact, "ContactPhoto", "File"));
+ if (wszPhoto != NULL)
+ DeleteFile(wszPhoto);
+
+ Netlib_Logf(NULL, "Contact deleted: %d", hContact);
+ return (currDb) ? currDb->DeleteContact(hContact) : 0;
+}
+
+MIR_CORE_DLL(int) db_is_contact(MCONTACT hContact)
+{
+ return (currDb) ? currDb->IsDbContact(hContact) : 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// enumerators
+
+MIR_CORE_DLL(int) db_enum_modules(DBMODULEENUMPROC pFunc, const void *param)
+{
+ return (currDb) ? currDb->EnumModuleNames(pFunc, param) : 0;
+}
+
+MIR_CORE_DLL(int) db_enum_residents(DBMODULEENUMPROC pFunc, const void *param)
+{
+ return (currDb) ? currDb->EnumResidentSettings(pFunc, param) : 0;
+}
+
+EXTERN_C MIR_CORE_DLL(int) db_enum_settings(MCONTACT hContact, DBSETTINGENUMPROC pFunc, const char *szModule, const void *param)
+{
+ return (currDb) ? currDb->EnumContactSettings(hContact, pFunc, szModule, param) : 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// getting data
MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue)
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 3c214307b8..6e1e032d92 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -993,3 +993,12 @@ hex2bin @1149 hex2binW @1150
mir_hmac_sha256 @1151
Utf8toUcs2 @1152
+db_add_contact @1153
+db_delete_contact @1154
+db_enum_modules @1155
+db_enum_residents @1156
+db_enum_settings @1157
+db_get_contact_count @1158
+db_is_contact @1159
+db_set_safety_mode @1160
+db_delete_module @1161
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index e988dcc60b..6e493bb0e9 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -993,3 +993,12 @@ hex2bin @1149 hex2binW @1150
mir_hmac_sha256 @1151
Utf8toUcs2 @1152
+db_add_contact @1153
+db_delete_contact @1154
+db_enum_modules @1155
+db_enum_residents @1156
+db_enum_settings @1157
+db_get_contact_count @1158
+db_is_contact @1159
+db_set_safety_mode @1160
+db_delete_module @1161
|