From f51995e13679a37851baef8e7f52f2d993cbc7c1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Sep 2016 17:11:58 +0000 Subject: mode old database junk to die git-svn-id: http://svn.miranda-ng.org/main/trunk@17291 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_app.lib | Bin 75230 -> 77942 bytes bin10/lib/mir_app64.lib | Bin 72434 -> 74922 bytes bin12/lib/mir_app.lib | Bin 75230 -> 77942 bytes bin12/lib/mir_app64.lib | Bin 72434 -> 74922 bytes bin14/lib/mir_app.lib | Bin 75230 -> 77942 bytes bin14/lib/mir_app64.lib | Bin 72434 -> 74922 bytes include/delphi/m_database.inc | 80 +----- include/m_database.h | 280 ++++++++------------- plugins/Actman/iac_contact.pas | 2 +- plugins/AssocMgr/src/reg.cpp | 2 +- plugins/AutoRun/src/main.cpp | 2 +- plugins/AvatarHistory/src/AvatarHistory.cpp | 3 +- plugins/BasicHistory/src/EventList.cpp | 6 +- plugins/Boltun/src/boltun.cpp | 7 +- plugins/Clist_modern/src/modern_clui.cpp | 4 +- plugins/Clist_modern/src/modern_skinengine.cpp | 6 +- plugins/Clist_modern/src/modern_toolbar.cpp | 2 +- plugins/Clist_nicer/src/init.cpp | 2 +- plugins/CmdLine/src/mimcmd_handlers.cpp | 2 +- plugins/Console/src/Console.cpp | 5 +- plugins/Db3x_mmap/src/dbcontacts.cpp | 2 +- plugins/DbChecker/src/finished.cpp | 2 +- plugins/DbChecker/src/progress.cpp | 2 +- plugins/Db_autobackups/src/backup.cpp | 2 +- plugins/Db_autobackups/src/main.cpp | 4 +- plugins/Dbx_mdb/src/dbcontacts.cpp | 2 +- plugins/Folders/src/services.cpp | 4 +- plugins/HTTPServer/src/main.cpp | 2 +- plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 6 +- plugins/HistoryPlusPlus/CustomizeToolbar.pas | 4 +- plugins/HistoryPlusPlus/HistoryForm.pas | 2 +- plugins/HistoryPlusPlus/hpp_contacts.pas | 4 +- plugins/HistoryPlusPlus/hpp_database.pas | 24 +- plugins/HistoryPlusPlus/hpp_itemprocess.pas | 2 +- plugins/HistoryStats/src/mu_common.cpp | 22 -- plugins/HistoryStats/src/mu_common.h | 12 - plugins/HistoryStats/src/utils.cpp | 4 +- plugins/IEView/src/HTMLBuilder.cpp | 12 +- plugins/IEView/src/Utils.cpp | 4 +- plugins/ImportTXT/General.pas | 9 +- plugins/KeyboardNotify/src/utils.cpp | 6 +- plugins/MirFox/src/MirandaUtils.cpp | 4 +- plugins/MirLua/src/m_database.cpp | 2 +- plugins/Msg_Export/src/utils.cpp | 6 +- plugins/NewEventNotify/src/main.cpp | 10 +- plugins/NewEventNotify/src/popup.cpp | 23 +- plugins/NewXstatusNotify/src/main.cpp | 2 +- plugins/NotifyAnything/src/options.cpp | 2 +- plugins/Nudge/src/main.cpp | 2 +- plugins/Ping/src/log.cpp | 2 +- plugins/Popup/src/config.cpp | 2 +- plugins/Scriver/src/msgdialog.cpp | 2 +- plugins/Scriver/src/msglog.cpp | 8 +- plugins/ShellExt/src/shlcom.cpp | 2 +- plugins/TabSRMM/src/buttonsbar.cpp | 2 +- plugins/TabSRMM/src/chat/main.cpp | 2 +- plugins/TabSRMM/src/eventpopups.cpp | 8 +- plugins/TabSRMM/src/msglog.cpp | 10 +- plugins/TabSRMM/src/srmm.cpp | 2 +- plugins/TipperYM/src/subst.cpp | 2 +- .../src/ex_import/dlg_ExImOpenSaveFile.cpp | 2 +- plugins/UserInfoEx/src/svc_avatar.cpp | 2 +- plugins/Utils.pas/dbsettings.pas | 12 +- plugins/Utils.pas/mircontacts.pas | 14 +- plugins/Utils.pas/mirutils.pas | 4 +- plugins/Variables/src/parse_miranda.cpp | 8 +- plugins/YAMN/src/main.cpp | 4 +- plugins/mRadio/mradio.dpr | 2 +- plugins/wbOSD/src/events.cpp | 4 +- protocols/AimOscar/src/proto.cpp | 2 +- protocols/FacebookRM/src/proto.cpp | 2 +- protocols/GTalkExt/src/avatar.cpp | 5 +- protocols/IRCG/src/options.cpp | 2 +- protocols/IcqOscarJ/src/icq_avatar.cpp | 2 +- protocols/IcqOscarJ/src/icq_proto.cpp | 8 +- protocols/IcqOscarJ/src/icq_servlist.cpp | 5 +- protocols/IcqOscarJ/src/icqosc_svcs.cpp | 15 +- protocols/JabberG/src/jabber_proto.cpp | 4 +- protocols/JabberG/src/jabber_rc.cpp | 4 +- protocols/JabberG/src/jabber_svc.cpp | 58 ++--- protocols/MSN/src/msn_proto.cpp | 2 +- protocols/SkypeWeb/src/skype_db.cpp | 2 +- protocols/SkypeWeb/src/skype_events.cpp | 60 ++--- protocols/Steam/src/steam_events.cpp | 3 +- protocols/Steam/src/steam_utils.cpp | 13 +- protocols/Tox/src/tox_events.cpp | 4 +- protocols/Twitter/src/proto.cpp | 2 +- src/core/stdfile/src/filerecvdlg.cpp | 4 +- src/core/stdmsg/src/msglog.cpp | 10 +- src/core/stduihist/src/history.cpp | 6 +- src/mir_app/src/dbini.cpp | 23 +- src/mir_app/src/dbutils.cpp | 176 ++++++------- src/mir_app/src/menu_options.cpp | 2 +- src/mir_app/src/menu_utils.cpp | 2 +- src/mir_app/src/mir_app.def | 12 + src/mir_app/src/mir_app64.def | 12 + src/mir_app/src/modules.cpp | 11 +- src/mir_app/src/options_ei.cpp | 2 +- src/mir_app/src/proto_accs.cpp | 4 +- utils/mir_options.cpp | 4 +- 100 files changed, 452 insertions(+), 688 deletions(-) diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib index d100581bd1..5a9eaff3bd 100644 Binary files a/bin10/lib/mir_app.lib and b/bin10/lib/mir_app.lib differ diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib index 17403e14c9..fbf49e2bc9 100644 Binary files a/bin10/lib/mir_app64.lib and b/bin10/lib/mir_app64.lib differ diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib index d100581bd1..5a9eaff3bd 100644 Binary files a/bin12/lib/mir_app.lib and b/bin12/lib/mir_app.lib differ diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib index 17403e14c9..fbf49e2bc9 100644 Binary files a/bin12/lib/mir_app64.lib and b/bin12/lib/mir_app64.lib differ diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib index d100581bd1..5a9eaff3bd 100644 Binary files a/bin14/lib/mir_app.lib and b/bin14/lib/mir_app.lib differ diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib index 17403e14c9..fbf49e2bc9 100644 Binary files a/bin14/lib/mir_app64.lib and b/bin14/lib/mir_app64.lib differ diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 24eedfa197..15b8755073 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -258,83 +258,15 @@ function db_unset(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting: function db_set_resident(const szModule:PAnsiChar; const szSetting:PAnsiChar; bEnable:int):int; stdcall; external CoreDLL name 'db_set_resident'; -// deprecated Aliases -function DBFreeVariant(dbv:PDBVARIANT):int_ptr; stdcall; - external CoreDLL name 'db_free'; -function DBDeleteContactSetting(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):int_ptr; stdcall; - external CoreDLL name 'db_unset'; -function DBGetContactSettingByte(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall; - external CoreDLL name 'db_get_b'; -function DBGetContactSettingWord(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:int):int; stdcall; - external CoreDLL name 'db_get_w'; -function DBGetContactSettingDWord(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; errorValue:dword):dword; stdcall; - external CoreDLL name 'db_get_dw'; -function DBGetContactSetting(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; dbv:PDBVARIANT):int_ptr; stdcall; - external CoreDLL name 'db_get'; -function DBGetContactSettingStr(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 DBGetContactSettingString(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PAnsiChar; stdcall; - external CoreDLL name 'db_get_sa'; -function DBGetContactSettingWString(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar):PWideChar; stdcall; - external CoreDLL name 'db_get_wsa'; - -function DBWriteContactSettingByte(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:byte):int_ptr; stdcall; - external CoreDLL name 'db_set_b'; -function DBWriteContactSettingWord(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:word):int_ptr; stdcall; - external CoreDLL name 'db_set_w'; -function DBWriteContactSettingDWord(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:dword):int_ptr; stdcall; - external CoreDLL name 'db_set_dw'; -function DBWriteContactSettingString(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall; - external CoreDLL name 'db_set_s'; -function DBWriteContactSettingWString(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PWideChar):int_ptr; stdcall; - external CoreDLL name 'db_set_ws'; -function DBWriteContactSettingUTF8String(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; const val:PAnsiChar):int_ptr; stdcall; - external CoreDLL name 'db_set_utf'; -function DBWriteContactSettingBlob(hContact:TMCONTACT; const szModule:PAnsiChar; const szSetting:PAnsiChar; val:pointer; len:uint):int_ptr; stdcall; - external CoreDLL name 'db_set_blob'; - - -const - { - wParam : size of the buffer to be filled - lParam : pointer to the buffer to be filled - affect : Get's the name of the current profile being used by the database - module -- this is the same as the filename of the profile without - the .ext - return : 0 on success, non zero on failure - } - MS_DB_GETPROFILENAME :PAnsiChar = 'DB/GetProfileName'; - MS_DB_GETPROFILENAMEW:PAnsiChar = 'DB/GetProfileNameW'; +/////////////////////////////////////////////////////////////////////////////// - { - wParam : size of buffer pointed to by lParam - lParam : pointer to a buffer to be filled - affect : Get the path of the base folder where Miranda will store all individual profiles - The returned path does NOT include a trailing backslash. - Essentially this is what has been set in mirandaboot.ini as ProfileDir. - For more options to retrieve profile paths check MS_UTILS_REPLACEVARS - return : 0 on success, non zero on failure - version: 0.3a only - } - MS_DB_GETPROFILEPATH :PAnsiChar = 'DB/GetProfilePath'; - MS_DB_GETPROFILEPATHW:PAnsiChar = 'DB/GetProfilePathW'; +function Profile_GetNameA(cbLen:cardinal; pDest:PAnsiChar) : int; stdcall; external AppDll; +function Profile_GetNameW(cbLen:cardinal; pDest:PWideChar) : int; stdcall; external AppDll; - { - Sets the default profile name programmatically - Analog of Database/DefaultProfile in mirandaboot.ini - wParam = (WPARAM)(TCHAR*)ptszProfileName - lParam = 0 (unused) - } - MS_DB_SETDEFAULTPROFILE:PAnsiChar = 'DB/SetDefaultProfile'; - - { - Checks the specified profile like dbtool did. - Implemented in the dbchecker plugins, thus it might not exist - wParam = (WPARAM)(TCHAR*)ptszProfileName - lParam = (BOOL)bConversionMode - } +function Profile_GetPathA(cbLen:cardinal; pDest:PAnsiChar) : int; stdcall; external AppDll; +function Profile_GetPathW(cbLen:cardinal; pDest:PWideChar) : int; stdcall; external AppDll; - MS_DB_CHECKPROFILE:PAnsiChar = 'DB/CheckProfile'; +/////////////////////////////////////////////////////////////////////////////// type PDBCONTACTWRITESETTING = ^TDBCONTACTWRITESETTING; diff --git a/include/m_database.h b/include/m_database.h index 99762e4e92..999b451d54 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -43,11 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// // database functions -#if defined(__cplusplus) -extern "C" -{ -#endif - ///////////////////////////////////////////////////////////////////////////////////////// // DBVARIANT: used by db/contact/getsetting and db/contact/writesetting @@ -111,7 +106,7 @@ typedef struct #endif } DBEVENTINFO; -MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv); ///////////////////////////////////////////////////////////////////////////////////////// // Database contacts @@ -125,9 +120,9 @@ are no contacts in the db. */ #if defined(__cplusplus) -MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = NULL); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = NULL); #else -MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto); #endif /* @@ -139,9 +134,9 @@ hContact was the last contact in the db or hContact was invalid. */ #if defined(__cplusplus) -MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = NULL); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = NULL); #else -MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto); #endif ///////////////////////////////////////////////////////////////////////////////////////// @@ -169,7 +164,7 @@ db/time/x below with useful stuff for dealing with it. #define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module- #define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000 -MIR_CORE_DLL(MEVENT) db_event_add(MCONTACT hContact, DBEVENTINFO *dbei); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_add(MCONTACT hContact, DBEVENTINFO *dbei); /* Gets the number of events in the chain belonging to a contact in the database. @@ -177,7 +172,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. */ -MIR_CORE_DLL(int) db_event_count(MCONTACT hContact); +EXTERN_C MIR_CORE_DLL(int) db_event_count(MCONTACT hContact); /* Removes a single event from the database @@ -186,7 +181,7 @@ Returns 0 on success, or nonzero if hDbEvent was invalid Triggers a db/event/deleted event just *before* the event is deleted */ -MIR_CORE_DLL(int) db_event_delete(MCONTACT hContact, MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(int) db_event_delete(MCONTACT hContact, MEVENT hDbEvent); /* Retrieves a handle to the first event in the chain for hContact @@ -194,7 +189,7 @@ Returns the handle, or NULL if hContact is invalid or has no events Events in a chain are sorted chronologically automatically */ -MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact); /* Retrieves a handle to the first unread event in the chain for hContact @@ -208,7 +203,7 @@ This service is designed for startup, reloading all the events that remained unread from last time */ -MIR_CORE_DLL(MEVENT) db_event_firstUnread(MCONTACT hContact); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_firstUnread(MCONTACT hContact); /* Retrieves all the information stored in hDbEvent @@ -225,7 +220,7 @@ On return, dbe.szModule is a pointer to the database module's own internal list of modules. Look but don't touch. */ -MIR_CORE_DLL(int) db_event_get(MEVENT hDbEvent, DBEVENTINFO *dbei); +EXTERN_C MIR_CORE_DLL(int) db_event_get(MEVENT hDbEvent, DBEVENTINFO *dbei); /* Retrieves the space in bytes required to store the blob in hDbEvent @@ -233,7 +228,7 @@ hDbEvent should have been returned by db_event_add/first/last/next/prev() Returns the space required in bytes, or -1 if hDbEvent is invalid */ -MIR_CORE_DLL(int) db_event_getBlobSize(MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(int) db_event_getBlobSize(MEVENT hDbEvent); /* Retrieves a handle to the contact that owns hDbEvent. @@ -242,7 +237,7 @@ NULL is a valid return value, meaning, as usual, the user. Returns INVALID_CONTACT_ID if hDbEvent is invalid, or the handle to the contact on success */ -MIR_CORE_DLL(MCONTACT) db_event_getContact(MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_event_getContact(MEVENT hDbEvent); /* Retrieves a handle to the last event in the chain for hContact @@ -250,7 +245,7 @@ Returns the handle, or NULL if hContact is invalid or has no events Events in a chain are sorted chronologically automatically */ -MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact); /* Changes the flags for an event to mark it as read. @@ -261,7 +256,7 @@ This is the one database write operation that does not trigger an event. Modules should not save flags states for any length of time. */ -MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent); /* Retrieves a handle to the next event in a chain after hDbEvent @@ -269,7 +264,7 @@ Returns the handle, or NULL if hDbEvent is invalid or is the last event Events in a chain are sorted chronologically automatically */ -MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent); /* Retrieves a handle to the previous event in a chain before hDbEvent @@ -277,97 +272,76 @@ Returns the handle, or NULL if hDbEvent is invalid or is the first event Events in a chain are sorted chronologically automatically */ -MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent); +EXTERN_C MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent); ///////////////////////////////////////////////////////////////////////////////////////// // Database settings -MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv); -MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0); -MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0); -MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue = 0); -MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); -MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv); +EXTERN_C MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0); +EXTERN_C MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue = 0); +EXTERN_C MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue = 0); +EXTERN_C MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); +EXTERN_C MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); -MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest); -MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest); -MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, wchar_t *pDest, int cbDest); +EXTERN_C MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest); +EXTERN_C MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, char *pDest, int cbDest); +EXTERN_C MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, wchar_t *pDest, int cbDest); #if defined(__cplusplus) -MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType = DBVT_ASCIIZ); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType = DBVT_ASCIIZ); #else -MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, const int nType); #endif -MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv); -MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, BYTE val); -MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, WORD val); -MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD val); -MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val); -MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCWSTR val); -MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val); -MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, void *val, unsigned len); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, BYTE val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, WORD val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCWSTR val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, LPCSTR val); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, void *val, unsigned len); -MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); +EXTERN_C MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting); #if defined(__cplusplus) -MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable = TRUE); +EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable = TRUE); #else -MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable); +EXTERN_C MIR_CORE_DLL(BOOL) db_set_resident(LPCSTR szModule, const char *szService, BOOL bEnable); #endif #define db_get_ws(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR) #define db_get_utf(a,b,c,d) db_get_s(a,b,c,d,DBVT_UTF8) -#if defined(__cplusplus) -} -#endif - ///////////////////////////////////////////////////////////////////////////////////////// // Profile services -/* DB/GetProfileName service -Gets the name of the profile currently being used by the database module. This -is the same as the filename of the database - wParam = (WPARAM)(UINT)cbSize - lParam = (LPARAM)(char*)pszName -pszName is a pointer to the buffer that receives the name of the profile -cbSize is the size in characters of the pszName buffer -Returns 0 on success or nonzero otherwise -*/ -#define MS_DB_GETPROFILENAME "DB/GetProfileName" -#define MS_DB_GETPROFILENAMEW "DB/GetProfileNameW" - -/* DB/GetProfilePath service -Get the path of the base folder where Miranda will store all individual profiles -The returned path does NOT include a trailing backslash. -Essentially this is what has been set in mirandaboot.ini as ProfileDir. -For more options to retrieve profile paths check MS_UTILS_REPLACEVARS - wParam = (WPARAM)(UINT)cbSize - lParam = (LPARAM)(char*)pszName -pszName is a pointer to the buffer that receives the path of the profile -cbSize is the size in characters of the pszName buffer -Returns 0 on success or nonzero otherwise -*/ +// Gets the name of the profile currently being used by the database module. +// This is the same as the filename of the database +// Returns 0 on success or nonzero otherwise -#define MS_DB_GETPROFILEPATH "DB/GetProfilePath" -#define MS_DB_GETPROFILEPATHW "DB/GetProfilePathW" +EXTERN_C MIR_APP_DLL(int) Profile_GetNameA(size_t cbLen, char *pszDest); +EXTERN_C MIR_APP_DLL(int) Profile_GetNameW(size_t cbLen, wchar_t *pwszDest); -/* DB/SetDefaultProfile service -Sets the default profile name programmatically -Analog of Database/DefaultProfile in mirandaboot.ini - wParam = (WPARAM)(wchar_t*)ptszProfileName - lParam = 0 (unused) -*/ +// Get the path of the base folder where Miranda will store all individual profiles +// The returned path does NOT include a trailing backslash. +// Essentially this is what has been set in mirandaboot.ini as ProfileDir. +// For more options to retrieve profile paths check MS_UTILS_REPLACEVARS +// Returns 0 on success or nonzero otherwise -#define MS_DB_SETDEFAULTPROFILE "DB/SetDefaultProfile" +EXTERN_C MIR_APP_DLL(int) Profile_GetPathA(size_t cbLen, char *pszDest); +EXTERN_C MIR_APP_DLL(int) Profile_GetPathW(size_t cbLen, wchar_t *pwszDest); -/* DB/CheckProfile service -Checks the specified profile like dbtool did. -Implemented in the dbchecker plugins, thus it might not exist - wParam = (WPARAM)(wchar_t*)ptszProfileName - lParam = (BOOL)bConversionMode -*/ +// Sets the default profile name programmatically +// Analog of Database/DefaultProfile in mirandaboot.ini + +EXTERN_C MIR_APP_DLL(void) Profile_SetDefault(const wchar_t *pwszPath); + +// Checks the specified profile like dbtool did. +// Implemented in the dbchecker plugins, thus it might not exist +// wParam = (WPARAM)(wchar_t*)ptszProfileName +// lParam = (BOOL)bConversionMode #define MS_DB_CHECKPROFILE "DB/CheckProfile" @@ -454,17 +428,14 @@ Returns 1 if the contact is a contact, or 0 if the contact is not valid. ///////////////////////////////////////////////////////////////////////////////////////// // Event services -/* DB/EventType/Register service (0.7+) -Registers the specified database event type, with module, id & description. -When someone needs to retrieve an event's text, a service named Module/GetEventText -will be called. For example, for module named 'foo' and event id 2000 a service -foo/GetEventText2000 should be defined to process this request. That handler should -decode a blob and return the event text in the required format, its prototype is identical -to a call of MS_DB_EVENT_GETTEXT (see below) - wParam = 0 - lParam = (LPARAM)(DBEVENTTYPEDESCR*) -Returns -1 on error (e.g., event type already registred), 0 on success -*/ +// Registers the specified database event type, with module, id & description. +// When someone needs to retrieve an event's text, a service named Module/GetEventText +// will be called. For example, for module named 'foo' and event id 2000 a service +// foo/GetEventText2000 should be defined to process this request. That handler should +// decode a blob and return the event text in the required format, its prototype is identical +// to a call of DbEvent_GetText (see below) +// +// Returns -1 on error (e.g., event type already registred), 0 on success typedef struct { @@ -484,84 +455,54 @@ typedef struct #define DETF_MSGWINDOW 2 // show event in message window #define DETF_NONOTIFY 4 // block event notify (e.g. Popups) -#define MS_DB_EVENT_REGISTERTYPE "DB/EventType/Register" - -/* DB/EventType/Get service (0.7+) -Retrieves the previously registered database event type, by module & id. - wParam = (WPARAM)(char*)szModule - lParam = (LPARAM)(int)eventType -Returns DBEVENTTYPEDESCR* or NULL, if an event isn't found. -*/ - -#define MS_DB_EVENT_GETTYPE "DB/EventType/Get" +EXTERN_C MIR_APP_DLL(int) DbEvent_RegisterType(DBEVENTTYPEDESCR*); -__forceinline MCONTACT DbGetAuthEventContact(DBEVENTINFO* dbei) -{ - return (MCONTACT)(*(DWORD*)&dbei->pBlob[sizeof(DWORD)]); -} - -/* DB/Event/GetText (0.7.0+) -Retrieves the event's text - wParam = 0 (unused) - lParam = (LPARAM)(DBEVENTGETTEXT*)egt - pointer to structure with parameters - egt->dbei should be the valid database event read via db_event_get() - egt->datatype = DBVT_WCHAR or DBVT_ASCIIZ or DBVT_TCHAR. - egt->codepage is any valid codepage, CP_ACP by default. - -Function returns a pointer to a string in the required format. -This string should be freed by a call of mir_free -*/ - -typedef struct { - DBEVENTINFO* dbei; - int datatype; - int codepage; -} DBEVENTGETTEXT; +///////////////////////////////////////////////////////////////////////////////////////// +// Retrieves the previously registered database event type, by module & id. +// Returns DBEVENTTYPEDESCR* or NULL, if an event isn't found. -#define MS_DB_EVENT_GETTEXT "DB/Event/GetText" +EXTERN_C MIR_APP_DLL(DBEVENTTYPEDESCR*) DbEvent_GetType(const char *szModule, int eventType); -__forceinline char* DbGetEventTextA(DBEVENTINFO* dbei, int codepage) -{ - DBEVENTGETTEXT temp = { dbei, DBVT_ASCIIZ, codepage }; - return (char*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&temp); -} +///////////////////////////////////////////////////////////////////////////////////////// +// macro to extract MCONTACT from the auth blob -__forceinline wchar_t* DbGetEventTextW(DBEVENTINFO* dbei, int codepage) +__forceinline MCONTACT DbGetAuthEventContact(DBEVENTINFO *dbei) { - DBEVENTGETTEXT temp = { dbei, DBVT_WCHAR, codepage }; - return (wchar_t*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&temp); + return (MCONTACT)(*(DWORD*)&dbei->pBlob[sizeof(DWORD)]); } -/* DB/Event/GetIcon (0.7.0.1+) -Retrieves the event's icon - wParam = (WPARAM)(int)flags - use LR_SHARED for shared HICON - lParam = (LPARAM)(DBEVENTINFO*)dbei -dbei should be a valid database event read via db_event_get() +///////////////////////////////////////////////////////////////////////////////////////// +// Retrieves the event's text +// * dbei should be the valid database event read via db_event_get() +// * codepage is any valid codepage, CP_ACP by default. +// +// Function returns a pointer to a string in the required format. +// This string should be freed by a call of mir_free -Function returns HICON (use DestroyIcon to release resources if not LR_SHARED) +EXTERN_C MIR_APP_DLL(char*) DbEvent_GetTextA(DBEVENTINFO *dbei, int codepage); +EXTERN_C MIR_APP_DLL(wchar_t*) DbEvent_GetTextW(DBEVENTINFO *dbei, int codepage); -A plugin can register the standard event icon in IcoLib named -'eventicon_'+Module+EvtID, like eventicon_ICQ2001. Otherwise, to declare an icon -with the non-standard name, you can declare the special service, Module/GetEventIcon, -which will retrieve the custom icon handle (HICON). This service function has the -same parameters MS_DB_EVENT_GETICON does. -*/ -#define MS_DB_EVENT_GETICON "DB/Event/GetIcon" - -/* DB/Event/GetString (0.9.0+) -Converts the event's string to wchar_t* depending on the event's format - wParam = (LPARAM)(DBEVENTINFO*)dbei - lParam = (WPARAM)(char*)str - string to be converted - returns wchar_t* - the converted string -Caller must free the result using mir_free -*/ +///////////////////////////////////////////////////////////////////////////////////////// +// Retrieves the event's icon +// * use LR_SHARED in flags for shared HICON +// dbei should be a valid database event read via db_event_get() +// +// Function returns HICON (use DestroyIcon to release resources if not LR_SHARED) +// +// A plugin can register the standard event icon in IcoLib named +// 'eventicon_'+Module+EvtID, like eventicon_ICQ2001. Otherwise, to declare an icon +// with the non-standard name, you can declare the special service, Module/GetEventIcon, +// which will retrieve the custom icon handle (HICON). This service function has the +// same parameters MS_DB_EVENT_GETICON does. + +EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags); -#define MS_DB_EVENT_GETSTRINGT "DB/Event/GetStringT" +///////////////////////////////////////////////////////////////////////////////////////// +// Converts the event's string to wchar_t* depending on the event's format +// returns wchar_t* - the converted string +// Caller must free the result using mir_free -__forceinline wchar_t* DbGetEventStringT(DBEVENTINFO* dbei, const char* str) -{ - return (wchar_t*)CallService(MS_DB_EVENT_GETSTRINGT, (WPARAM)dbei, (LPARAM)str); -} +EXTERN_C MIR_APP_DLL(wchar_t*) DbEvent_GetString(DBEVENTINFO *dbei, const char *str); ///////////////////////////////////////////////////////////////////////////////////////// // Random services @@ -607,14 +548,11 @@ 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" -/* DB/Module/Delete 0.8.0+ - -Removes all settings for the specified module. -wParam = (WPARAM)(MCONTACT)hContact or 0 for global settings -lParam = (LPARAM)(char*)szModuleName - the module name to be deleted -*/ +///////////////////////////////////////////////////////////////////////////////////////// +// Removes all settings for the specified module. +// hContact is 0 for global settings or matches the concrete contact -#define MS_DB_MODULE_DELETE "DB/Module/Delete" +EXTERN_C MIR_APP_DLL(int) DbModule_Delete(MCONTACT hContact, const char *szModuleName); ///////////////////////////////////////////////////////////////////////////////////////// // Database events diff --git a/plugins/Actman/iac_contact.pas b/plugins/Actman/iac_contact.pas index 561c8840fa..02931f7ae9 100644 --- a/plugins/Actman/iac_contact.pas +++ b/plugins/Actman/iac_contact.pas @@ -138,7 +138,7 @@ begin end; end; end; - DBFreeVariant(@cws); + db_free(@cws); end; if result<>0 then begin diff --git a/plugins/AssocMgr/src/reg.cpp b/plugins/AssocMgr/src/reg.cpp index 2c7789bb60..7a717a0766 100644 --- a/plugins/AssocMgr/src/reg.cpp +++ b/plugins/AssocMgr/src/reg.cpp @@ -127,7 +127,7 @@ wchar_t* MakeRunCommand(BOOL fMirExe, BOOL fFixedDbProfile) { wchar_t szDbFile[MAX_PATH], szExe[MAX_PATH], *pszFmt; if (fFixedDbProfile) { - if (CallService(MS_DB_GETPROFILENAMEW, _countof(szDbFile), (LPARAM)szDbFile)) + if (Profile_GetNameW(_countof(szDbFile), szDbFile)) return NULL; wchar_t *p = wcsrchr(szDbFile, '.'); if (p) diff --git a/plugins/AutoRun/src/main.cpp b/plugins/AutoRun/src/main.cpp index 0ec952d756..dbd17855b0 100644 --- a/plugins/AutoRun/src/main.cpp +++ b/plugins/AutoRun/src/main.cpp @@ -27,7 +27,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) void GetProfilePath(wchar_t *res, size_t resLen) { wchar_t dbname[MAX_PATH], exename[MAX_PATH]; - CallService(MS_DB_GETPROFILENAMEW, _countof(dbname), (LPARAM)dbname); + Profile_GetNameW(_countof(dbname), dbname); GetModuleFileName(NULL, exename, _countof(exename)); wchar_t *p = wcsrchr(dbname, '.'); diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 8ff71a8b5d..fd70eff119 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -343,8 +343,7 @@ extern "C" __declspec(dllexport) int Load(void) CreateServiceFunction(MS_AVATARHISTORY_ENABLED, IsEnabled); CreateServiceFunction(MS_AVATARHISTORY_GET_CACHED_AVATAR, GetCachedAvatar); - if (CallService(MS_DB_GETPROFILEPATHW, MAX_PATH, (LPARAM)profilePath) != 0) - mir_wstrcpy(profilePath, L"."); // Failed, use current dir + Profile_GetPathW(MAX_PATH, profilePath); SkinAddNewSoundExW("avatar_changed",LPGENW("Avatar History"),LPGENW("Contact changed avatar")); SkinAddNewSoundExW("avatar_removed",LPGENW("Avatar History"),LPGENW("Contact removed avatar")); diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index bc459bfd95..a2a73665e4 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -86,7 +86,7 @@ bool HistoryEventList::CanShowHistory(DBEVENTINFO* dbei) return true; default: - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); if (et && (et->flags & DETF_HISTORY)) return true; } @@ -448,7 +448,7 @@ std::wstring HistoryEventList::GetContactId() static void GetMessageDescription(DBEVENTINFO *dbei, wchar_t* buf, int cbBuf) { - wchar_t *msg = DbGetEventTextW(dbei, CP_ACP); + wchar_t *msg = DbEvent_GetTextW(dbei, CP_ACP); wcsncpy_s(buf, cbBuf, msg ? msg : TranslateT("Invalid Message"), _TRUNCATE); buf[cbBuf - 1] = 0; mir_free(msg); @@ -568,7 +568,7 @@ HICON HistoryEventList::GetEventCoreIcon(const EventIndex& ev) if (ev.isExternal) return NULL; - HICON ico = (HICON)CallService(MS_DB_EVENT_GETICON, LR_SHARED, (LPARAM)&m_dbei); + HICON ico = DbEvent_GetIcon(&m_dbei, LR_SHARED); HICON icoMsg = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); if (icoMsg == ico) return NULL; diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index 42278611c0..ca63fc71c5 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -216,11 +216,8 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) db_event_get(hDbEvent, &dbei); if (dbei.flags & DBEF_SENT || dbei.flags & DBEF_READ || dbei.eventType != EVENTTYPE_MESSAGE) return 0; - DBEVENTGETTEXT egt; - egt.codepage = CP_ACP; - egt.datatype = DBVT_WCHAR; - egt.dbei = &dbei; - wchar_t* s = (wchar_t*)(void*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&egt); + + wchar_t *s = DbEvent_GetTextW(&dbei, CP_ACP); free(dbei.pBlob); if (Config.MarkAsRead) db_event_markRead(hContact, hDbEvent); diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 58903af561..6c0e1af226 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -1560,8 +1560,8 @@ LRESULT CLUI::PreProcessWndProc(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bH hView = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH); if (hView) { char szFilePath[MAX_PATH], szProfile[MAX_PATH]; - CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)&szFilePath); - CallService(MS_DB_GETPROFILENAME, MAX_PATH, (LPARAM)&szProfile); + Profile_GetPathA(MAX_PATH, szFilePath); + Profile_GetNameA(MAX_PATH, szProfile); mir_snprintf((char*)hView, MAX_PATH, "%s\\%s", szFilePath, szProfile); UnmapViewOfFile(hView); rc = 1; diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 167a0a8d07..5131e493ca 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -1948,7 +1948,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()) { - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernSkin"); + DbModule_Delete(0, "ModernSkin"); db_set_s(NULL, SKIN, "SkinFolder", "%Default%"); db_set_s(NULL, SKIN, "SkinFile", "%Default%"); parser.Parse(IniParser::WriteStrToDb, 0); @@ -1966,7 +1966,7 @@ int ske_LoadSkinFromIniFile(wchar_t *szFileName, BOOL bOnlyObjects) if (!parser.CheckOK()) return 0; - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernSkin"); + DbModule_Delete(0, "ModernSkin"); wchar_t skinFolder[MAX_PATH], skinFile[MAX_PATH]; IniParser::GetSkinFolder(szFileName, skinFolder); @@ -3314,7 +3314,7 @@ wchar_t* ske_ReplaceVar(wchar_t *var) if (!var) return mir_wstrdup(L""); if (!mir_wstrcmpi(var, L"Profile")) { char buf[MAX_PATH] = { 0 }; - CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)buf); + Profile_GetNameA(MAX_PATH, buf); char *p = strrchr(buf, '.'); if (p) *p = 0; diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index b31609f534..efced1370b 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"); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernToolBar"); + DbModule_Delete(0, "ModernToolBar"); } db_set_b(NULL, "Compatibility", "TTB_Upgrade", 1); } diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp index adb599e45c..9abe3553d9 100644 --- a/plugins/Clist_nicer/src/init.cpp +++ b/plugins/Clist_nicer/src/init.cpp @@ -182,7 +182,7 @@ extern "C" int __declspec(dllexport) CListInitialise() cfg::dat.dwFlags |= (db_get_b(NULL, "CLUI", "ShowSBar", 1) ? CLUI_FRAME_SBARSHOW : 0); cfg::dat.soundsOff = db_get_b(NULL, "Skin", "UseSound", 1) ? 0 : 1; - CallService(MS_DB_GETPROFILEPATHW, MAX_PATH, (LPARAM)cfg::dat.tszProfilePath); + Profile_GetPathW(MAX_PATH, cfg::dat.tszProfilePath); wcslwr(cfg::dat.tszProfilePath); // get the clist interface diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 1d18f4bc8b..6d4323338e 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1373,7 +1373,7 @@ void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply) TimeZone_ToString(dbEvent->timestamp, "D, s", timestamp, sizeof(timestamp)); char *sender = (dbEvent->flags & DBEF_SENT) ? Translate("[me]") : contact; - char *message = DbGetEventTextA(dbEvent, CP_ACP); + char *message = DbEvent_GetTextA(dbEvent, CP_ACP); static char buffer[8192]; mir_snprintf(buffer, "[%s] %15s: %s", timestamp, sender, message); diff --git a/plugins/Console/src/Console.cpp b/plugins/Console/src/Console.cpp index c3bc12a83c..3a2c58b4e8 100644 --- a/plugins/Console/src/Console.cpp +++ b/plugins/Console/src/Console.cpp @@ -617,9 +617,8 @@ static INT_PTR CALLBACK ConsoleDlgProc(HWND hwndDlg, UINT message, WPARAM wParam // restore position Utils_RestoreWindowPosition(hwndDlg, NULL, "Console", "Console", RWPF_HIDDEN); - CallService(MS_DB_GETPROFILENAMEW, (WPARAM)_countof(name), (LPARAM)name); - - CallService(MS_DB_GETPROFILEPATHW, (WPARAM)_countof(path), (LPARAM)path); + Profile_GetNameW(_countof(name), name); + Profile_GetPathW(_countof(path), path); mir_snwprintf(title, L"%s - %s\\%s", TranslateT("Miranda Console"), path, name); diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 5935ac0685..710b5324c1 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) { - CallService(MS_DB_MODULE_DELETE, cc->pSubs[nSub], (LPARAM)META_PROTO); + DbModule_Delete(cc->pSubs[nSub], META_PROTO); return 0; } diff --git a/plugins/DbChecker/src/finished.cpp b/plugins/DbChecker/src/finished.cpp index 8984215d03..2609a763bd 100644 --- a/plugins/DbChecker/src/finished.cpp +++ b/plugins/DbChecker/src/finished.cpp @@ -43,7 +43,7 @@ INT_PTR CALLBACK FinishedDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case WZN_CANCELCLICKED: bLaunchMiranda = IsDlgButtonChecked(hdlg, IDC_LAUNCHMIRANDA) == BST_CHECKED; - CallService(MS_DB_SETDEFAULTPROFILE, (WPARAM)opts.filename, 0); + Profile_SetDefault(opts.filename); wizardResult = 1; return TRUE; } diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp index 5c123b86e0..ffac34c610 100644 --- a/plugins/DbChecker/src/progress.cpp +++ b/plugins/DbChecker/src/progress.cpp @@ -185,7 +185,7 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM if (bShortModeDone) { if (!errorCount) { if (bLaunchMiranda) - CallService(MS_DB_SETDEFAULTPROFILE, (WPARAM)opts.filename, 0); + Profile_SetDefault(opts.filename); wizardResult = 1; } return TRUE; diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index d95b9e59f1..ee9383fdff 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -186,7 +186,7 @@ int Backup(wchar_t *backup_filename) HWND progress_dialog = NULL; SYSTEMTIME st; - CallService(MS_DB_GETPROFILENAMEW, _countof(dbname), (LPARAM)dbname); + Profile_GetNameW(_countof(dbname), dbname); if (backup_filename == NULL) { int err; diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 448e15fab4..13bf958c21 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -35,14 +35,14 @@ static INT_PTR ABService(WPARAM, LPARAM) static INT_PTR DBSaveAs(WPARAM, LPARAM) { wchar_t fname_buff[MAX_PATH], tszFilter[200]; - OPENFILENAME ofn = { 0 }; - CallService(MS_DB_GETPROFILENAMEW, _countof(fname_buff), (LPARAM)fname_buff); + Profile_GetNameW(_countof(fname_buff), fname_buff); mir_snwprintf(tszFilter, L"%s (*.dat)%c*.dat%c%s (*.zip)%c*.zip%c%s (*.*)%c*%c", TranslateT("Miranda NG databases"), 0, 0, TranslateT("Compressed Miranda NG databases"), 0, 0, TranslateT("All files"), 0, 0); + OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = fname_buff; ofn.nMaxFile = _countof(fname_buff); diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index 48a911c459..921d116c24 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) { - CallService(MS_DB_MODULE_DELETE, cc->pSubs[nSub], (LPARAM)META_PROTO); + DbModule_Delete(cc->pSubs[nSub], META_PROTO); return 0; } diff --git a/plugins/Folders/src/services.cpp b/plugins/Folders/src/services.cpp index 619723ec1b..59f91d0829 100644 --- a/plugins/Folders/src/services.cpp +++ b/plugins/Folders/src/services.cpp @@ -79,8 +79,8 @@ INT_PTR GetPathService(WPARAM wParam, LPARAM lParam) int InitServices() { - CallService(MS_DB_GETPROFILEPATHW, _countof(szCurrentProfilePath), (LPARAM)szCurrentProfilePath); - CallService(MS_DB_GETPROFILENAMEW, _countof(szCurrentProfile), (LPARAM)szCurrentProfile); + Profile_GetPathW(_countof(szCurrentProfilePath), szCurrentProfilePath); + Profile_GetNameW(_countof(szCurrentProfile), szCurrentProfile); wchar_t *pos = wcsrchr(szCurrentProfile, '.'); if (pos) *pos = 0; GetModuleFileName(GetModuleHandleA("mir_app.mir"), szMirandaPath, _countof(szMirandaPath)); diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index 3fb5527318..3f52469e90 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -896,7 +896,7 @@ extern "C" __declspec(dllexport) int Load() return 1; } - if (CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szPluginPath)) { + if (Profile_GetPathA(MAX_PATH, szPluginPath)) { MessageBox(NULL, "Failed to retrieve plugin path.", MSG_BOX_TITEL, MB_OK); return 1; } diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index cd8fffbe8f..b634534e39 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -58,7 +58,7 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) date[0] = 0; time[0] = 0; - msg = DbGetEventTextW(dbei, CP_ACP); + msg = DbEvent_GetTextW(dbei, CP_ACP); if (msg == NULL) return 0; @@ -383,7 +383,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1); db_event_get(actualElement->hEvent, &dbe); dbe.pBlob[dbe.cbBlob] = 0; - LPTSTR msg = DbGetEventTextW(&dbe, CP_ACP); + LPTSTR msg = DbEvent_GetTextW(&dbe, CP_ACP); if ( wcsstr(msg, searchString)) filter3 = 1; @@ -617,7 +617,7 @@ void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos) dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1); db_event_get(hEvent, &dbe); dbe.pBlob[dbe.cbBlob] = 0; - LPCTSTR msg = DbGetEventTextW(&dbe, CP_ACP); + LPCTSTR msg = DbEvent_GetTextW(&dbe, CP_ACP); SetDlgItemText(hDlg, IDC_MESSAGE, NULL); SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); mir_free((void*)msg); diff --git a/plugins/HistoryPlusPlus/CustomizeToolbar.pas b/plugins/HistoryPlusPlus/CustomizeToolbar.pas index 3294a99d32..24bea5ae1e 100644 --- a/plugins/HistoryPlusPlus/CustomizeToolbar.pas +++ b/plugins/HistoryPlusPlus/CustomizeToolbar.pas @@ -335,7 +335,7 @@ begin if ToolbarStr = '' then ToolbarStr := DEF_HISTORY_TOOLBAR; if ToolbarStr = DEF_HISTORY_TOOLBAR then - DBDeleteContactSetting(0, hppDBName, 'HistoryToolbar') + db_unset(0, hppDBName, 'HistoryToolbar') else WriteDBStr(hppDBName, 'HistoryToolbar', ToolbarStr); end; @@ -557,7 +557,7 @@ end; procedure TfmCustomizeToolbar.bnResetClick(Sender: TObject); begin - DBDeleteContactSetting(0, hppDBName, 'HistoryToolbar'); + db_unset(0, hppDBName, 'HistoryToolbar'); NotifyAllForms(HM_NOTF_TOOLBARCHANGED, 0, 0); FillButtons; UpdateControlButtons; diff --git a/plugins/HistoryPlusPlus/HistoryForm.pas b/plugins/HistoryPlusPlus/HistoryForm.pas index 2eed1dd124..ba0337d818 100644 --- a/plugins/HistoryPlusPlus/HistoryForm.pas +++ b/plugins/HistoryPlusPlus/HistoryForm.pas @@ -860,7 +860,7 @@ begin end else begin - DBDeleteContactSetting(0, hppDBName, 'HistoryToolbar'); + db_unset(0, hppDBName, 'HistoryToolbar'); LoadToolbar; Exit; end; diff --git a/plugins/HistoryPlusPlus/hpp_contacts.pas b/plugins/HistoryPlusPlus/hpp_contacts.pas index e898d003f3..331efce404 100644 --- a/plugins/HistoryPlusPlus/hpp_contacts.pas +++ b/plugins/HistoryPlusPlus/hpp_contacts.pas @@ -152,7 +152,7 @@ begin Result := WideToAnsiString(dbv.szVal.w, hppCodepage); end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; end; @@ -230,7 +230,7 @@ begin if Proto = '' then exit; case RTLMode of - hppRTLDefault: DBDeleteContactSetting(hContact, PAnsiChar(Proto), 'RTL'); + hppRTLDefault: db_unset(hContact, PAnsiChar(Proto), 'RTL'); hppRTLEnable: WriteDBByte(hContact, Proto, 'RTL', Byte(True)); hppRTLDisable: WriteDBByte(hContact, Proto, 'RTL', Byte(false)); end; diff --git a/plugins/HistoryPlusPlus/hpp_database.pas b/plugins/HistoryPlusPlus/hpp_database.pas index 38f307c6ed..ead338fb9c 100644 --- a/plugins/HistoryPlusPlus/hpp_database.pas +++ b/plugins/HistoryPlusPlus/hpp_database.pas @@ -118,7 +118,7 @@ var begin Result := (db_get(hContact, PAnsiChar(Module), PAnsiChar(Param), @dbv) = 0); if Result then - DBFreeVariant(@dbv); + db_free(@dbv); end; function DBDelete(const Module, Param: AnsiString): Boolean; @@ -128,7 +128,7 @@ end; function DBDelete(const hContact: THandle; const Module, Param: AnsiString): Boolean; begin - Result := (DBDeleteContactSetting(hContact,PAnsiChar(Module),PAnsiChar(Param)) = 0); + Result := (db_unset(hContact,PAnsiChar(Module),PAnsiChar(Param)) = 0); end; function WriteDBBool(const Module,Param: AnsiString; Value: Boolean): Integer; @@ -148,7 +148,7 @@ end; function WriteDBByte(const hContact: THandle; const Module,Param: AnsiString; Value: Byte): Integer; begin - Result := DBWriteContactSettingByte(hContact,PAnsiChar(Module), PAnsiChar(Param), Value); + Result := db_set_b(hContact,PAnsiChar(Module), PAnsiChar(Param), Value); end; function WriteDBWord(const Module,Param: AnsiString; Value: Word): Integer; @@ -158,7 +158,7 @@ end; function WriteDBWord(const hContact: THandle; const Module,Param: AnsiString; Value: Word): Integer; begin - Result := DBWriteContactSettingWord(hContact,PAnsiChar(Module),PAnsiChar(Param),Value); + Result := db_set_w(hContact,PAnsiChar(Module),PAnsiChar(Param),Value); end; function WriteDBDWord(const Module,Param: AnsiString; Value: DWord): Integer; @@ -168,7 +168,7 @@ end; function WriteDBDWord(const hContact: THandle; const Module,Param: AnsiString; Value: DWord): Integer; begin - Result := DBWriteContactSettingDWord(hContact,PAnsiChar(Module),PAnsiChar(Param),Value); + Result := db_set_dw(hContact,PAnsiChar(Module),PAnsiChar(Param),Value); end; function WriteDBInt(const Module,Param: AnsiString; Value: Integer): Integer; @@ -188,7 +188,7 @@ end; function WriteDBStr(const hContact: THandle; const Module,Param: AnsiString; const Value: AnsiString): Integer; begin - Result := DBWriteContactSettingString(hContact,PAnsiChar(Module),PAnsiChar(Param),PAnsiChar(Value)); + Result := db_set_s(hContact,PAnsiChar(Module),PAnsiChar(Param),PAnsiChar(Value)); end; function WriteDBWideStr(const Module,Param: AnsiString; const Value: WideString): Integer; @@ -247,7 +247,7 @@ begin if dbv.cpbVal = 0 then exit; GetMem(Value,dbv.cpbVal); Move(dbv.pbVal^,PByte(Value)^,dbv.cpbVal); - DBFreeVariant(@dbv); + db_free(@dbv); Result := True; end; @@ -268,7 +268,7 @@ end; function GetDBByte(const hContact: THandle; const Module,Param: AnsiString; Default: Byte): Byte; begin - Result := DBGetContactSettingByte(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); + Result := db_get_b(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); end; function GetDBWord(const Module,Param: AnsiString; Default: Word): Word; @@ -278,7 +278,7 @@ end; function GetDBWord(const hContact: THandle; const Module,Param: AnsiString; Default: Word): Word; begin - Result := DBGetContactSettingWord(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); + Result := db_get_w(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); end; function GetDBDWord(const Module,Param: AnsiString; Default: DWord): DWord; @@ -288,7 +288,7 @@ end; function GetDBDWord(const hContact: THandle; const Module,Param: AnsiString; Default: DWord): DWord; begin - Result := DBGetContactSettingDWord(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); + Result := db_get_dw(hContact,PAnsiChar(Module),PAnsiChar(Param),Default); end; function GetDBInt(const Module,Param: AnsiString; Default: Integer): Integer; @@ -337,7 +337,7 @@ begin Result := WideToAnsiString(dbv.szVal.w,hppCodepage); end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; @@ -367,7 +367,7 @@ begin Result := WideString(dbv.szVal.w); end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; diff --git a/plugins/HistoryPlusPlus/hpp_itemprocess.pas b/plugins/HistoryPlusPlus/hpp_itemprocess.pas index 858bd2daa5..55518c0f41 100644 --- a/plugins/HistoryPlusPlus/hpp_itemprocess.pas +++ b/plugins/HistoryPlusPlus/hpp_itemprocess.pas @@ -479,7 +479,7 @@ begin begin // Get profile dir SetLength(hppProfileDir, MAX_PATH); - CallService(MS_DB_GETPROFILEPATH, MAX_PATH, lParam(@hppProfileDir[1])); + Profile_GetPathA(MAX_PATH, @hppProfileDir[1]); SetLength(hppProfileDir, StrLen(pAnsiChar(@hppProfileDir[1]))); Link := AnsiString(hppProfileDir) + '\' + ird.pExtended; //!! end; diff --git a/plugins/HistoryStats/src/mu_common.cpp b/plugins/HistoryStats/src/mu_common.cpp index ef5bfc66e2..d941c7c1c1 100644 --- a/plugins/HistoryStats/src/mu_common.cpp +++ b/plugins/HistoryStats/src/mu_common.cpp @@ -43,28 +43,6 @@ namespace mu } } - /* - * db - */ - - namespace db - { - int getProfilePath(int cbName, wchar_t* pszName) - { - return CallService(MS_DB_GETPROFILEPATHW, cbName, reinterpret_cast(pszName)); - } - - int getProfileName(int cbName, wchar_t* pszName) - { - return CallService(MS_DB_GETPROFILENAMEW, cbName, reinterpret_cast(pszName)); - } - - void setSafetyMode(bool safetyMode) - { - CallService(MS_DB_SETSAFETYMODE, BOOL_(safetyMode), 0); - } - } - /* * db_time */ diff --git a/plugins/HistoryStats/src/mu_common.h b/plugins/HistoryStats/src/mu_common.h index cc82ea61da..e8d407e928 100644 --- a/plugins/HistoryStats/src/mu_common.h +++ b/plugins/HistoryStats/src/mu_common.h @@ -17,17 +17,6 @@ namespace mu HGENMENU addContactMenuItem(const wchar_t* pszName, DWORD flags, int position, HICON hIcon, const char* pszService); } - /* - * db - */ - - namespace db - { - int getProfilePath(int cbName, wchar_t* pszName); - int getProfileName(int cbName, wchar_t* pszName); - void setSafetyMode(bool safetyMode); - } - /* * db_contact */ @@ -35,7 +24,6 @@ namespace mu namespace db_contact { int enumSettings(MCONTACT hContact, const char* szModule, DBSETTINGENUMPROC pEnumProc, LPARAM lProcParam); - int getCount(); } /* diff --git a/plugins/HistoryStats/src/utils.cpp b/plugins/HistoryStats/src/utils.cpp index bc1c1f272b..7c2d0f3a93 100644 --- a/plugins/HistoryStats/src/utils.cpp +++ b/plugins/HistoryStats/src/utils.cpp @@ -909,7 +909,7 @@ namespace utils if (strProfilePath.empty()) { wchar_t szPath[MAX_PATH] = { 0 }; - mu::db::getProfilePath(MAX_PATH, szPath); + Profile_GetPathW(MAX_PATH, szPath); strProfilePath = szPath; if (strProfilePath.empty() || strProfilePath[strProfilePath.length() - 1] != '\\') @@ -928,7 +928,7 @@ namespace utils if (strProfileName.empty()) { wchar_t szName[MAX_PATH] = { 0 }; - mu::db::getProfileName(MAX_PATH, szName); + Profile_GetNameW(MAX_PATH, szName); strProfileName = szName; ext::string::size_type posDot = strProfileName.rfind('.'); diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 8dd3337a13..6e6b4bf3c9 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -283,7 +283,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) eventData->bIsMe = FALSE; } if (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL || Utils::DbEventIsForMsgWindow(&dbei)) { - eventData->pszTextW = DbGetEventTextW(&dbei, newEvent.codepage); + eventData->pszTextW = DbEvent_GetTextW(&dbei, newEvent.codepage); if (dbei.eventType == EVENTTYPE_MESSAGE) eventData->iType = IEED_EVENT_MESSAGE; else if (dbei.eventType == EVENTTYPE_URL) @@ -295,25 +295,25 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) //blob is: sequenceid(DWORD),filename(ASCIIZ),description(ASCIIZ) char* filename = ((char *)dbei.pBlob) + sizeof(DWORD); char* descr = filename + mir_strlen(filename) + 1; - eventData->ptszText = DbGetEventStringT(&dbei, filename); + eventData->ptszText = DbEvent_GetString(&dbei, filename); if (*descr != '\0') - eventData->ptszText2 = DbGetEventStringT(&dbei, descr); + eventData->ptszText2 = DbEvent_GetString(&dbei, descr); eventData->iType = IEED_EVENT_FILE; } else if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) eventData->ptszText = mir_wstrdup(TranslateT(" requested authorization")); - eventData->ptszNick = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); + eventData->ptszNick = DbEvent_GetString(&dbei, (char *)dbei.pBlob + 8); eventData->iType = IEED_EVENT_SYSTEM; } else if (dbei.eventType == EVENTTYPE_ADDED) { //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) eventData->ptszText = mir_wstrdup(TranslateT(" was added.")); - eventData->ptszNick = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); + eventData->ptszNick = DbEvent_GetString(&dbei, (char *)dbei.pBlob + 8); eventData->iType = IEED_EVENT_SYSTEM; } else { // custom event - eventData->pszTextW = DbGetEventTextW(&dbei, newEvent.codepage); + eventData->pszTextW = DbEvent_GetTextW(&dbei, newEvent.codepage); eventData->iType = IEED_EVENT_MESSAGE; } free(dbei.pBlob); diff --git a/plugins/IEView/src/Utils.cpp b/plugins/IEView/src/Utils.cpp index 009c01a19e..2a7e48a0e3 100644 --- a/plugins/IEView/src/Utils.cpp +++ b/plugins/IEView/src/Utils.cpp @@ -118,12 +118,12 @@ void Utils::appendIcon(CMStringA &str, const char *iconFile) bool Utils::DbEventIsForMsgWindow(DBEVENTINFO *dbei) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); return et && (et->flags & DETF_MSGWINDOW); } bool Utils::DbEventIsForHistory(DBEVENTINFO *dbei) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); return et && (et->flags & DETF_HISTORY); } \ No newline at end of file diff --git a/plugins/ImportTXT/General.pas b/plugins/ImportTXT/General.pas index f68486afac..0a53d03ffc 100644 --- a/plugins/ImportTXT/General.pas +++ b/plugins/ImportTXT/General.pas @@ -342,11 +342,6 @@ begin result := Proto_GetProtoName(hContact); end; -function DBFreeVariant(dbv: PDBVARIANT): integer; -begin - result := db_free(dbv); -end; - function GetContactID(hContact: THandle; proto: AnsiString = ''; Contact: boolean = false): WideString; var @@ -387,7 +382,7 @@ begin result := dbv.szVal.w; end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; end; @@ -429,7 +424,7 @@ begin result := dbv.szVal.w; end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; end; diff --git a/plugins/KeyboardNotify/src/utils.cpp b/plugins/KeyboardNotify/src/utils.cpp index 1c4920c876..399ecafe31 100644 --- a/plugins/KeyboardNotify/src/utils.cpp +++ b/plugins/KeyboardNotify/src/utils.cpp @@ -34,11 +34,9 @@ char *fmtDBSettingName(const char *fmt, ...) wchar_t *getAbsoluteProfileName(wchar_t *absoluteProfileName, size_t maxLen) { wchar_t profilePath[MAX_PATH+1], profileName[MAX_PATH+1]; + Profile_GetPathW(MAX_PATH, profilePath); + Profile_GetNameW(MAX_PATH, profileName); - profilePath[0] = profileName[0] = '\0'; - CallService(MS_DB_GETPROFILEPATHW, MAX_PATH, (LPARAM)profilePath); - CallService(MS_DB_GETPROFILENAMEW, MAX_PATH, (LPARAM)profileName); mir_snwprintf(absoluteProfileName, maxLen, L"%s\\%s", profilePath, profileName); - return absoluteProfileName; } diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 7a9a5e54b1..93587d2d66 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -52,7 +52,7 @@ std::wstring& MirandaUtils::getProfileName() } wchar_t mirandaProfileNameW[128] = {0}; - CallService(MS_DB_GETPROFILENAMEW, _countof(mirandaProfileNameW), (WPARAM)mirandaProfileNameW); + Profile_GetNameW(_countof(mirandaProfileNameW), mirandaProfileNameW); profileName.append(mirandaProfileNameW); return profileName; @@ -527,6 +527,6 @@ void MirandaUtils::translateOldDBNames() { } //delete db module - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)OLD_PLUGIN_DB_ID); + DbModule_Delete(0, OLD_PLUGIN_DB_ID); } diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 5f5ea774d0..3a747f45aa 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -376,7 +376,7 @@ static int db_DeleteModule(lua_State *L) MCONTACT hContact = lua_tointeger(L, 1); LPCSTR szModule = luaL_checkstring(L, 2); - INT_PTR res = CallService(MS_DB_MODULE_DELETE, hContact, (LPARAM)szModule); + INT_PTR res = DbModule_Delete(hContact, szModule); lua_pushboolean(L, !res); return 1; diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 74bc251e71..6deb7aaccb 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -468,9 +468,9 @@ bool bReadMirandaDirAndPath() PathToAbsoluteW(L"miranda32.exe", tmp); sMirandaPath = tmp; sMirandaPath.erase(sMirandaPath.find_last_of(L"\\")); - CallService(MS_DB_GETPROFILEPATHW, (WPARAM)MAX_PATH - 1, (LPARAM)szDBPath); + Profile_GetPathW(MAX_PATH, szDBPath); sDBPath = szDBPath; - CallService(MS_DB_GETPROFILENAMEW, (WPARAM)MAX_PATH - 1, (LPARAM)szDBPath); + Profile_GetNameW(MAX_PATH, szDBPath); sDBPath.append(L"\\").append(szDBPath); sDBPath.erase(sDBPath.size() - 4); return true; @@ -1013,7 +1013,7 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) switch (dbei.eventType) { case EVENTTYPE_MESSAGE: { - wchar_t *msg = DbGetEventTextW(&dbei, CP_ACP); + wchar_t *msg = DbEvent_GetTextW(&dbei, CP_ACP); if (!bWriteIndentedToFile(hFile, nIndent, msg, bWriteUTF8Format)) { DisplayErrorDialog(LPGENW("Failed to write message to the file :\n"), sFilePath, &dbei); } diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp index 85fa3f1e9a..275372ef71 100644 --- a/plugins/NewEventNotify/src/main.cpp +++ b/plugins/NewEventNotify/src/main.cpp @@ -70,12 +70,10 @@ int HookedNewEvent(WPARAM hContact, LPARAM hDbEvent) return 0; //custom database event types - if (ServiceExists(MS_DB_EVENT_GETTYPE)) { - DBEVENTTYPEDESCR *pei = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbe.szModule, (LPARAM)dbe.eventType); - // ignore events according to flags - if (pei && pei->flags & DETF_NONOTIFY) - return 0; - } + DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbe.szModule, dbe.eventType); + // ignore events according to flags + if (pei && pei->flags & DETF_NONOTIFY) + return 0; //if event was allready read don't show it if (pluginOptions.bReadCheck && (dbe.flags & DBEF_READ)) diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index 219a65bee2..466cbf0661 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -369,29 +369,20 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) break; default: - if (ServiceExists(MS_DB_EVENT_GETTYPE)) { - DBEVENTTYPEDESCR *pei = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - // support for custom database event types - if (pei && dbei->pBlob) { - DBEVENTGETTEXT svc = {dbei, DBVT_WCHAR, CP_ACP}; - wchar_t *pet = (wchar_t*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&svc); - if (pet) { - // we've got event text, move to our memory space - comment1 = mir_wstrdup(pet); - mir_free(pet); - } - commentFix = pei->descr; - } - else commentFix = POPUP_COMMENT_OTHER; + DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbei->szModule, dbei->eventType); + // support for custom database event types + if (pei && dbei->pBlob) { + comment1 = DbEvent_GetTextW(dbei, CP_ACP); + commentFix = pei->descr; } else commentFix = POPUP_COMMENT_OTHER; } - if ( mir_wstrlen(comment1) > 0) { + if (mir_wstrlen(comment1) > 0) { mir_free(comment2); return comment1; } - if ( mir_wstrlen(comment2) > 0) { + if (mir_wstrlen(comment2) > 0) { mir_free(comment1); return comment2; } diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 98b5a307e4..8b559d2098 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -1183,7 +1183,7 @@ extern "C" int __declspec(dllexport) Load(void) evtype.descr = LPGEN("Status change"); evtype.eventIcon = iconList[0].hIcolib; evtype.flags = DETF_HISTORY | DETF_MSGWINDOW; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&evtype); + DbEvent_RegisterType(&evtype); hServiceMenu = CreateServiceFunction(MS_STATUSCHANGE_MENUCOMMAND, EnableDisableMenuCommand); diff --git a/plugins/NotifyAnything/src/options.cpp b/plugins/NotifyAnything/src/options.cpp index 377be8ac3a..8b26054f6f 100644 --- a/plugins/NotifyAnything/src/options.cpp +++ b/plugins/NotifyAnything/src/options.cpp @@ -66,7 +66,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara ofn.lpstrFilter = TranslateT("Log (*.log)\0*.log\0Text (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"); ofn.nFilterIndex = 1; // Use profile directory as default, if path is not specified - CallService(MS_DB_GETPROFILEPATHW, (WPARAM)MAX_PATH, (LPARAM)szProfileDir); + Profile_GetPathW(MAX_PATH, szProfileDir); ofn.lpstrInitialDir = szProfileDir; ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = L"log"; diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index f2c6a65a91..79b8a2f80c 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -354,7 +354,7 @@ extern "C" int __declspec(dllexport) Load(void) evtype.descr = LPGEN("Nudge"); evtype.eventIcon = iconList[0].hIcolib; evtype.flags = DETF_HISTORY | DETF_MSGWINDOW; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&evtype); + DbEvent_RegisterType(&evtype); return 0; } diff --git a/plugins/Ping/src/log.cpp b/plugins/Ping/src/log.cpp index ef50c5cb0b..6d1a2a9767 100644 --- a/plugins/Ping/src/log.cpp +++ b/plugins/Ping/src/log.cpp @@ -33,7 +33,7 @@ INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; wchar_t *filename = (wchar_t *)lParam; if (db_get_ws(0, PLUG, "LogFilename", &dbv)) { - CallService(MS_DB_GETPROFILEPATHW, wParam, (LPARAM)filename); + Profile_GetPathW(wParam, filename); mir_wstrncat(filename, L"\\ping_log.txt", wParam - mir_wstrlen(filename)); } else { diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp index a9763b64fd..05e81a89b7 100644 --- a/plugins/Popup/src/config.cpp +++ b/plugins/Popup/src/config.cpp @@ -158,7 +158,7 @@ static void CopyModule(const char *szModule, const char *szNewModule) dbces.lParam = (LPARAM)¶m; CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); + DbModule_Delete(0, szModule); } void UpgradeDb() diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index c8649ee804..8962d354fe 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1670,7 +1670,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(dat->hDbEventLast, &dbei); if (DbEventIsMessageOrCustom(&dbei)) { - buffer = DbGetEventTextW(&dbei, CP_ACP); + buffer = DbEvent_GetTextW(&dbei, CP_ACP); if (buffer != NULL) { wchar_t *quotedBuffer = GetQuotedTextW(buffer); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer); diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 129ad0818a..be1a850a03 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -85,7 +85,7 @@ struct LogStreamData int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); return et && (et->flags & DETF_MSGWINDOW); } @@ -151,11 +151,11 @@ EventData* getEventFromDB(SrmmWindowData *dat, MCONTACT hContact, MEVENT hDbEven if (evt->eventType == EVENTTYPE_FILE) { char *filename = ((char*)dbei.pBlob) + sizeof(DWORD); char *descr = filename + mir_strlen(filename) + 1; - evt->pszTextT = DbGetEventStringT(&dbei, filename); + evt->pszTextT = DbEvent_GetString(&dbei, filename); if (*descr != 0) - evt->pszText2T = DbGetEventStringT(&dbei, descr); + evt->pszText2T = DbEvent_GetString(&dbei, descr); } - else evt->pszTextT = DbGetEventTextW(&dbei, CP_UTF8); + else evt->pszTextT = DbEvent_GetTextW(&dbei, CP_UTF8); if (!(dat->flags & SMF_RTL) && RTL_Detect(evt->pszTextT)) evt->dwFlags |= IEEDF_RTL; diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index fafaf732ed..6f9475c6e8 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -425,7 +425,7 @@ void __stdcall ipcService(ULONG_PTR) if (pct != NULL) { // will actually return with .dat if there's space for it, not what the docs say pct->Status = STATUS_PROFILENAME; - CallService(MS_DB_GETPROFILENAME, 49, UINT_PTR(pct) + sizeof(TSlotIPC)); + Profile_GetNameA(49, (char*)pct + sizeof(TSlotIPC)); } } if (*bits & REQUEST_NEWICONS) diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index f85ad9bed1..36124651a1 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: - CallService(MS_DB_MODULE_DELETE, NULL, LPARAM("TabSRMM_Toolbar")); + DbModule_Delete(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 0694e9f815..aa1d32a4fd 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -242,7 +242,7 @@ static void CheckUpdate() mir_free(p); } - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)CHAT_OLDFONTMODULE); + DbModule_Delete(NULL, CHAT_OLDFONTMODULE); compat++; } diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 9c552aaaa9..ed7cc7618a 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -421,7 +421,7 @@ static wchar_t* ShortenPreview(DBEVENTINFO* dbe) if (iPreviewLimit > 500 || iPreviewLimit == 0) iPreviewLimit = 500; - wchar_t *buf = DbGetEventTextW(dbe, CP_ACP); + wchar_t *buf = DbEvent_GetTextW(dbe, CP_ACP); if (mir_wstrlen(buf) > iPreviewLimit) { fAddEllipsis = true; size_t iIndex = iPreviewLimit; @@ -462,11 +462,11 @@ static wchar_t* GetPreviewT(WORD eventType, DBEVENTINFO* dbe) if (dbe->cbBlob > (sizeof(DWORD) + namelength + 1)) szDescr = szFileName + namelength + 1; - ptrW tszFileName(DbGetEventStringT(dbe, szFileName)); + ptrW tszFileName(DbEvent_GetString(dbe, szFileName)); wchar_t buf[1024]; if (szDescr && Utils::safe_strlen(szDescr, dbe->cbBlob - sizeof(DWORD) - namelength - 1) > 0) { - ptrW tszDescr(DbGetEventStringT(dbe, szDescr)); + ptrW tszDescr(DbEvent_GetString(dbe, szDescr)); if (tszFileName && tszDescr) { mir_snwprintf(buf, L"%s: %s (%s)", TranslateT("Incoming file"), tszFileName, tszDescr); return mir_wstrdup(buf); @@ -591,7 +591,7 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, MEVENT hEve break; default: - pud.lchIcon = (HICON)CallService(MS_DB_EVENT_GETICON, LR_SHARED, (LPARAM)&dbe); + pud.lchIcon = DbEvent_GetIcon(&dbe, LR_SHARED); pud.colorBack = pluginOptions->bDefaultColorOthers ? 0 : pluginOptions->colBackOthers; pud.colorText = pluginOptions->bDefaultColorOthers ? 0 : pluginOptions->colTextOthers; iSeconds = pluginOptions->iDelayOthers; diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 6f0a78a476..eda978011e 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -387,7 +387,7 @@ int TSAPI DbEventIsShown(DBEVENTINFO *dbei) int DbEventIsForMsgWindow(DBEVENTINFO *dbei) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); return et && (et->flags & DETF_MSGWINDOW); } @@ -420,7 +420,7 @@ static char* Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, dat->cache->updateStats(TSessionStats::SET_LAST_RCV, mir_strlen((char *)dbei.pBlob)); wchar_t *formatted = NULL; - wchar_t *msg = DbGetEventTextW(&dbei, CP_UTF8); + wchar_t *msg = DbEvent_GetTextW(&dbei, CP_UTF8); if (!msg) { mir_free(dbei.pBlob); return NULL; @@ -824,11 +824,11 @@ static char* Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, } { char *szFileName = (char *)dbei.pBlob + sizeof(DWORD); - ptrW tszFileName(DbGetEventStringT(&dbei, szFileName)); + ptrW tszFileName(DbEvent_GetString(&dbei, szFileName)); char *szDescr = szFileName + mir_strlen(szFileName) + 1; if (*szDescr != 0) { - ptrW tszDescr(DbGetEventStringT(&dbei, szDescr)); + ptrW tszDescr(DbEvent_GetString(&dbei, szDescr)); wchar_t buf[1000]; mir_snwprintf(buf, L"%s (%s)", tszFileName, tszDescr); @@ -844,7 +844,7 @@ static char* Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, str.AppendChar(' '); } - ptrW tszText(DbGetEventTextW(&dbei, CP_ACP)); + ptrW tszText(DbEvent_GetTextW(&dbei, CP_ACP)); AppendUnicodeToBuffer(str, tszText, 0); } break; diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index 750f006ed3..d744568995 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -119,7 +119,7 @@ int _DebugTraceW(const wchar_t *fmt, ...) char szLogFileName[MAX_PATH], szDataPath[MAX_PATH]; FILE *f; - CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szDataPath); + Profile_GetPathA(MAX_PATH, szDataPath); mir_snprintf(szLogFileName, "%s\\%s", szDataPath, "tabsrmm_debug.log"); f = fopen(szLogFileName, "a+"); if (f) { diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index a68dae28fa..fe25c8d43c 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -173,7 +173,7 @@ wchar_t* GetLastMessageText(MCONTACT hContact, bool received) if (dbei.cbBlob == 0 || dbei.pBlob == 0) return 0; - wchar_t *buff = DbGetEventTextW( &dbei, CP_ACP ); + wchar_t *buff = DbEvent_GetTextW( &dbei, CP_ACP ); wchar_t *swzMsg = mir_wstrdup(buff); mir_free(buff); diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp index 36886e384f..466ad2a89c 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp @@ -69,7 +69,7 @@ static void InitAlteredPlacesBar() } // Miranda's profile path - if (!CallService(MS_DB_GETPROFILEPATH, _countof(szProfilePath), (LPARAM)szProfilePath)) + if (!Profile_GetPathA(_countof(szProfilePath), szProfilePath)) { // only add if different from profile path RegSetValueExA(hkPlacesBar, "Place4", 0, REG_SZ, (PBYTE)szProfilePath, (DWORD)mir_strlen(szProfilePath) + 1); diff --git a/plugins/UserInfoEx/src/svc_avatar.cpp b/plugins/UserInfoEx/src/svc_avatar.cpp index 9f26ba8a6a..bf510a731b 100644 --- a/plugins/UserInfoEx/src/svc_avatar.cpp +++ b/plugins/UserInfoEx/src/svc_avatar.cpp @@ -29,7 +29,7 @@ namespace NServices static int GetContactAvatarFileName(LPCTSTR zodiac, LPSTR szFileName, int cchFileName) { - if (!CallService(MS_DB_GETPROFILEPATH, (WPARAM)cchFileName, (LPARAM)szFileName)) { + if (!Profile_GetPathA(cchFileName, szFileName)) { size_t len = mir_strlen(szFileName); CHAR tmp[64]; diff --git a/plugins/Utils.pas/dbsettings.pas b/plugins/Utils.pas/dbsettings.pas index 8106fd7e66..df2b28aa22 100644 --- a/plugins/Utils.pas/dbsettings.pas +++ b/plugins/Utils.pas/dbsettings.pas @@ -32,7 +32,7 @@ function DBWriteString (hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiCha function DBWriteUTF8 (hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar;val:PAnsiChar):int_ptr; function DBWriteUnicode(hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar;val:PWideChar):int_ptr; -//function DBFreeVariant(dbv:PDBVARIANT):int_ptr; +//function db_free(dbv:PDBVARIANT):int_ptr; function DBDeleteSetting(hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar):int_ptr; function DBDeleteGroup(hContact:TMCONTACT;szModule:PAnsiChar;prefix:PAnsiChar=nil):int_ptr; @@ -87,7 +87,7 @@ begin else result:=StrLen(dbv.szVal.a); - DBFreeVariant(@dbv); + db_free(@dbv); end; function DBReadString(hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar; @@ -106,7 +106,7 @@ begin else StrDup(result,default); - DBFreeVariant(@dbv); + db_free(@dbv); end; function DBReadUTF8(hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar;default:PAnsiChar=nil):PAnsiChar; @@ -130,7 +130,7 @@ begin else StrDupW(result,default); - DBFreeVariant(@dbv); + db_free(@dbv); end; function DBReadStruct(hContact:TMCONTACT;szModule:PAnsiChar;szSetting:PAnsiChar; @@ -147,7 +147,7 @@ begin if ptr=nil then mGetMem(ptr,size); move(dbv.pbVal^,ptr^,size); - DBFreeVariant(@dbv); + db_free(@dbv); result:=uint_ptr(ptr) end else @@ -328,7 +328,7 @@ begin if DBReadSetting(hContact,szModule,szSetting,@ldbv)=0 then begin result:=ldbv._type; - DBFreeVariant(@ldbv); + db_free(@ldbv); end else result:=DBVT_DELETED; diff --git a/plugins/Utils.pas/mircontacts.pas b/plugins/Utils.pas/mircontacts.pas index 0863c0cd35..cb87d93b5a 100644 --- a/plugins/Utils.pas/mircontacts.pas +++ b/plugins/Utils.pas/mircontacts.pas @@ -131,9 +131,9 @@ begin uid := PAnsiChar(CallProtoService(Proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0)); if (uid <> PAnsiChar(CALLSERVICE_NOTFOUND)) and (uid <> nil) then begin - // DBGetContactSettingStr comparing to DBGetContactSetting don't translate strings + // db_get_s comparing to DBGetContactSetting don't translate strings // when uType=0 (DBVT_ASIS) - if DBGetContactSettingStr(hContact, Proto, uid, @dbv, DBVT_ASIS) = 0 then + if db_get_s(hContact, Proto, uid, @dbv, DBVT_ASIS) = 0 then begin case dbv._type of DBVT_BYTE: StrDup(Result, IntToStr(buf,dbv.bVal)); @@ -150,7 +150,7 @@ begin end; end; // free variant - DBFreeVariant(@dbv); + db_free(@dbv); end; end; end; @@ -315,7 +315,7 @@ begin end; end; end; - DBFreeVariant(@ldbv); + db_free(@ldbv); end; end; // added 2011.04.20 @@ -344,7 +344,7 @@ begin mFreeMem(Proto); if not is_chat then - DBFreeVariant(@dbv) + db_free(@dbv) else mFreeMem(dbv.szVal.W); end; @@ -378,7 +378,7 @@ begin if DBReadSetting(hContact,Proto,uid,@cws)=0 then begin StrCopy(p,opt_cuid); DBWriteSetting(0,group,section,@cws); - DBFreeVariant(@cws); + db_free(@cws); result:=1; end; end; @@ -613,7 +613,7 @@ begin StrReplaceW(buf,'%uid%',p); if ldbv._type in [DBVT_UTF8,DBVT_ASCIIZ] then mFreeMem(p); - DBFreeVariant(@ldbv); + db_free(@ldbv); end; end; StrReplaceW(buf,'%uid%',nil); diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index dee3bbdc87..bbedeb252b 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -299,7 +299,7 @@ var altfilename,filename:array [0..127] of AnsiChar; p:PAnsiChar; begin - CallService(MS_DB_GETPROFILEPATH,300,lparam(@profilepath)); + Profile_GetPathA(300,@profilepath); p:=StrEnd(profilepath); p^:='\'; inc(p); p^:=#0; @@ -309,7 +309,7 @@ begin begin StrCopy(filename,prefix); p:=StrEnd(filename); - CallService(MS_DB_GETPROFILENAME,SizeOf(filename)-integer(p-PAnsiChar(@filename)),lparam(p)); + Profile_GetNameA(Sizeof(filename)-integer(p-PAnsiChar(@filename)),p); ChangeExt(filename,ext); result:=CheckPath(filename,profilepath,path); end diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 72493df3da..243d3f8789 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -126,7 +126,7 @@ static wchar_t* parseDBProfileName(ARGUMENTSINFO *ai) return NULL; wchar_t name[MAX_PATH]; - if (CallService(MS_DB_GETPROFILENAMEW, _countof(name), (LPARAM)name)) + if (Profile_GetNameW(_countof(name), name)) return NULL; return mir_wstrdup(name); @@ -138,9 +138,7 @@ static wchar_t* parseDBProfilePath(ARGUMENTSINFO *ai) return NULL; wchar_t path[MAX_PATH]; - if (CallService(MS_DB_GETPROFILEPATHW, _countof(path), (LPARAM)path)) - return NULL; - + Profile_GetPathW(_countof(path), path); return mir_wstrdup(path); } @@ -579,7 +577,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) return NULL; } - wchar_t *res = DbGetEventTextW(&dbe, CP_ACP); + wchar_t *res = DbEvent_GetTextW(&dbe, CP_ACP); mir_free(dbe.pBlob); return res; } diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index 251ba8ca03..33498fe920 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -62,7 +62,7 @@ static void GetProfileDirectory(wchar_t *szPath, int cbPath) //This is copied from Miranda's sources. In 0.2.1.0 it is needed, in newer vesions of Miranda use MS_DB_GETPROFILEPATH service { wchar_t tszOldPath[MAX_PATH]; - CallService(MS_DB_GETPROFILEPATHW, _countof(tszOldPath), (LPARAM)tszOldPath); + Profile_GetPathW(_countof(tszOldPath), tszOldPath); mir_wstrcat(tszOldPath, L"\\*.book"); VARSW ptszNewPath( L"%miranda_userdata%"); @@ -268,7 +268,7 @@ extern "C" int __declspec(dllexport) Load(void) PathToAbsoluteW( L".", szMirandaDir); // retrieve the current profile name - CallService(MS_DB_GETPROFILENAMEW, (WPARAM)_countof(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn + Profile_GetNameW(_countof(ProfileName), ProfileName); wchar_t *fc = wcsrchr(ProfileName, '.'); if ( fc != NULL ) *fc = 0; diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr index 2d60f57c1b..6eb6e2321e 100644 --- a/plugins/mRadio/mradio.dpr +++ b/plugins/mRadio/mradio.dpr @@ -65,7 +65,7 @@ begin StrCopyW(pc,'plugins\mradio.ini'); FastWideToAnsi(buf,storage); mGetMem(storagep,MAX_PATH+32); - CallService(MS_DB_GETPROFILEPATH,MAX_PATH-1,tlparam(storagep)); + Profile_GetPathA(MAX_PATH,@storagep); StrCat(storagep,'\mradio.ini'); DBWriteDWord(0,PluginName,optVersion,PluginInfo.version); //?? diff --git a/plugins/wbOSD/src/events.cpp b/plugins/wbOSD/src/events.cpp index 2aba79e1dd..f1260e9ad0 100644 --- a/plugins/wbOSD/src/events.cpp +++ b/plugins/wbOSD/src/events.cpp @@ -185,12 +185,12 @@ int HookedNewEvent(WPARAM wParam, LPARAM hDBEvent) if ( i1 == 1 ) c1 = mir_wstrdup(pcli->pfnGetContactDisplayName(wParam, 0)); else if ( i1 == 2 ) - c1 = DbGetEventTextW( &dbe, 0 ); + c1 = DbEvent_GetTextW( &dbe, 0 ); if ( i2 == 1 ) c2 = mir_wstrdup(pcli->pfnGetContactDisplayName(wParam, 0)); else if ( i2 == 2 ) - c2 = DbGetEventTextW( &dbe, 0 ); + c2 = DbEvent_GetTextW( &dbe, 0 ); wchar_t buffer[512]; mir_snwprintf(buffer, buf, c1, c2); diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index 3530efa2ed..f4c9580841 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); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbsettings); + DbModule_Delete(0, szDbsettings); break; case EV_PROTO_ONCONTACTDELETED: diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 2e3c7c82ce..aac1821f0e 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -110,7 +110,7 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : evtype.descr = LPGEN("Video call"); evtype.eventIcon = GetIconHandle("facebook"); evtype.flags = DETF_HISTORY | DETF_MSGWINDOW; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&evtype); + DbEvent_RegisterType(&evtype); } FacebookProto::~FacebookProto() diff --git a/protocols/GTalkExt/src/avatar.cpp b/protocols/GTalkExt/src/avatar.cpp index 84de3a28d8..36c6f4ff6a 100644 --- a/protocols/GTalkExt/src/avatar.cpp +++ b/protocols/GTalkExt/src/avatar.cpp @@ -33,7 +33,7 @@ LPTSTR CreateAvaFile(HANDLE *hFile) { wchar_t name[MAX_PATH + 2]; - if (CallService(MS_DB_GETPROFILENAMEW, (WPARAM)_countof(name), (LPARAM)&name)) + if (Profile_GetNameW(_countof(name), name)) return NULL; wchar_t *p = wcsrchr(name, '.'); @@ -41,8 +41,7 @@ LPTSTR CreateAvaFile(HANDLE *hFile) *p = 0; wchar_t path[MAX_PATH + 2]; - if (CallService(MS_DB_GETPROFILEPATHW, (WPARAM)_countof(path), (LPARAM)&path)) - return NULL; + Profile_GetPathW(_countof(path), path); wchar_t full[MAX_PATH + 2]; mir_snwprintf(full, AVA_FILE_NAME_FORMAT, path, name); diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 940251a7ca..1a249a3fc3 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -747,7 +747,7 @@ void CConnectPrefsDlg::OnApply() if (m_serverlistModified) { m_serverlistModified = false; - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)SERVERSMODULE); + DbModule_Delete(0, SERVERSMODULE); int j = m_serverCombo.GetCount(); if (j != CB_ERR && j != 0) { diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index bfd2b1ee14..0ba204700d 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -99,7 +99,7 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, wchar_t *pszDest } else { wchar_t szBuf[MAX_PATH]; - if (CallService(MS_DB_GETPROFILENAMEW, MAX_PATH, (LPARAM)szBuf)) + if (Profile_GetNameW(MAX_PATH, szBuf)) mir_wstrcpy(pszDest + tPathLen, L"avatar"); else { wchar_t *szLastDot = wcsrchr(szBuf, '.'); diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index fe362f382a..91d2014802 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -188,7 +188,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : eventType.textService = ICQ_DB_GETEVENTTEXT_MISSEDMESSAGE; eventType.flags = DETF_HISTORY | DETF_MSGWINDOW; // for now keep default "message" icon - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&eventType); + DbEvent_RegisterType(&eventType); // Protocol instance is ready debugLogA("%s: Protocol instance '%s' created.", ICQ_PROTOCOL_NAME, m_szModuleName); @@ -1862,11 +1862,11 @@ int __cdecl CIcqProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l { char szDbSetting[MAX_PATH]; mir_snprintf(szDbSetting, "%sP2P", m_szModuleName); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); + DbModule_Delete(0, szDbSetting); mir_snprintf(szDbSetting, "%sSrvGroups", m_szModuleName); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); + DbModule_Delete(0, szDbSetting); mir_snprintf(szDbSetting, "%sGroups", m_szModuleName); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); + DbModule_Delete(0, szDbSetting); } break; diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index de90ee5bd8..9c9ae7a703 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -1180,7 +1180,7 @@ int CIcqProto::IsServerGroupsDefined() // flush obsolete linking data mir_snprintf(szModule, "%sGroups", m_szModuleName); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); + DbModule_Delete(0, szModule); iRes = 0; // no groups defined, or older version } @@ -1193,9 +1193,8 @@ int CIcqProto::IsServerGroupsDefined() void CIcqProto::FlushSrvGroupsCache() { char szModule[MAX_PATH]; - mir_snprintf(szModule, "%sSrvGroups", m_szModuleName); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); + DbModule_Delete(0, szModule); } // Look thru DB and collect all ContactIDs from a group diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index b1ec3e8330..fad62bf3e7 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -630,15 +630,15 @@ INT_PTR __cdecl CIcqProto::IcqCheckCapability(WPARAM hContact, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR icq_getEventTextMissedMessage(WPARAM, LPARAM lParam) +INT_PTR icq_getEventTextMissedMessage(WPARAM pEvent, LPARAM datatype) { - DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam; + DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; INT_PTR nRetVal = 0; char *pszText = NULL; - if (pEvent->dbei->cbBlob > 1) { - switch (((WORD*)pEvent->dbei->pBlob)[0]) { + if (dbei->cbBlob > 1) { + switch (((WORD*)dbei->pBlob)[0]) { case 0: pszText = LPGEN("** This message was blocked by the ICQ server ** The message was invalid."); break; @@ -659,18 +659,17 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM, LPARAM lParam) pszText = LPGEN("** Unknown missed message event."); break; } - if (pEvent->datatype == DBVT_WCHAR) { - WCHAR *pwszText; + if (datatype == DBVT_WCHAR) { int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), NULL, 0); - pwszText = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR)); + WCHAR *pwszText = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR)); pwszText[wchars] = 0; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), pwszText, wchars); nRetVal = (INT_PTR)mir_wstrdup(TranslateW(pwszText)); } - else if (pEvent->datatype == DBVT_ASCIIZ) + else if (datatype == DBVT_ASCIIZ) nRetVal = (INT_PTR)mir_strdup(Translate(pszText)); } diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 0ddbbee5fe..6922e35a59 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -242,11 +242,11 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) dbEventType.module = m_szModuleName; dbEventType.eventType = EVENTTYPE_JABBER_CHATSTATES; dbEventType.descr = "Chat state notifications"; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + DbEvent_RegisterType(&dbEventType); dbEventType.eventType = EVENTTYPE_JABBER_PRESENCE; dbEventType.descr = "Presence notifications"; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + DbEvent_RegisterType(&dbEventType); HookProtoEvent(ME_IDLE_CHANGED, &CJabberProto::OnIdleChanged); diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index 7255b5cc63..91774af02b 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -477,7 +477,7 @@ int CJabberProto::RcGetUnreadEventsCount() dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1); int nGetTextResult = db_event_get(hDbEvent, &dbei); if (!nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) { - wchar_t *szEventText = DbGetEventTextW(&dbei, CP_ACP); + wchar_t *szEventText = DbEvent_GetTextW(&dbei, CP_ACP); if (szEventText) { nEventsSent++; mir_free(szEventText); @@ -569,7 +569,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe if (dbei.eventType != EVENTTYPE_MESSAGE || (dbei.flags & (DBEF_READ | DBEF_SENT))) continue; - ptrW szEventText( DbGetEventTextW(&dbei, CP_ACP)); + ptrW szEventText( DbEvent_GetTextW(&dbei, CP_ACP)); if (szEventText == NULL) continue; diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 29b2cef6b5..9b9e75ff57 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -175,15 +175,15 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) //////////////////////////////////////////////////////////////////////////////////////// // JabberGetEventTextChatStates - retrieves a chat state description from an event -INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM, LPARAM lParam) +INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM pEvent, LPARAM datatype) { - DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam; - if (pdbEvent->dbei->cbBlob > 0) { - if (pdbEvent->dbei->pBlob[0] == JABBER_DB_EVENT_CHATSTATES_GONE) { - if (pdbEvent->datatype == DBVT_WCHAR) + DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; + if (dbei->cbBlob > 0) { + if (dbei->pBlob[0] == JABBER_DB_EVENT_CHATSTATES_GONE) { + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("closed chat session")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("closed chat session")); + + return (INT_PTR)mir_strdup(Translate("closed chat session")); } } @@ -193,52 +193,40 @@ INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM, LPARAM lParam) //////////////////////////////////////////////////////////////////////////////////////// // OnGetEventTextPresence - retrieves presence state description from an event -INT_PTR __cdecl CJabberProto::OnGetEventTextPresence(WPARAM, LPARAM lParam) +INT_PTR __cdecl CJabberProto::OnGetEventTextPresence(WPARAM pEvent, LPARAM datatype) { - DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam; - if (pdbEvent->dbei->cbBlob > 0) { - switch (pdbEvent->dbei->pBlob[0]) { + DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; + if (dbei->cbBlob > 0) { + switch (dbei->pBlob[0]) { case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("sent subscription request")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("sent subscription request")); - break; + return (INT_PTR)mir_strdup(Translate("sent subscription request")); case JABBER_DB_EVENT_PRESENCE_SUBSCRIBED: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("approved subscription request")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("approved subscription request")); - break; + return (INT_PTR)mir_strdup(Translate("approved subscription request")); case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("declined subscription")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("declined subscription")); - break; + return (INT_PTR)mir_strdup(Translate("declined subscription")); case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("declined subscription")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("declined subscription")); - break; + return (INT_PTR)mir_strdup(Translate("declined subscription")); case JABBER_DB_EVENT_PRESENCE_ERROR: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("sent error presence")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("sent error presence")); - break; + return (INT_PTR)mir_strdup(Translate("sent error presence")); default: - if (pdbEvent->datatype == DBVT_WCHAR) + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("sent unknown presence type")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("sent unknown presence type")); - break; + return (INT_PTR)mir_strdup(Translate("sent unknown presence type")); } } diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 41e853830d..f66e293edd 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -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); - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbsettings); + DbModule_Delete(0, szDbsettings); break; case EV_PROTO_ONCONTACTDELETED: diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index 01486d0729..b13aa96617 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -164,7 +164,7 @@ void CSkypeProto::InitDBEvents() dbEventType.descr = Translate(cur.name); dbEventType.flags |= cur.flags; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + DbEvent_RegisterType(&dbEventType); dbEventType.flags &= (~cur.flags); } diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index cb9a8bf3bb..51c0d40137 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -18,19 +18,19 @@ along with this program. If not, see . #include "stdafx.h" #define INVALID_DATA Translate("SkypeWeb error: Invalid data!") -INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam) +INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype) { - DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam; + DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; CMStringA szText; - BOOL bUseBB = db_get_b(NULL, pEvent->dbei->szModule, "UseBBCodes", 1); - switch (pEvent->dbei->eventType) + BOOL bUseBB = db_get_b(NULL, dbei->szModule, "UseBBCodes", 1); + switch (dbei->eventType) { case SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE: { - JSONNode jMsg = JSONNode::parse((char*)pEvent->dbei->pBlob); + JSONNode jMsg = JSONNode::parse((char*)dbei->pBlob); if (jMsg) { JSONNode &jOriginalMsg = jMsg["original_message"]; @@ -57,7 +57,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam) case SKYPE_DB_EVENT_TYPE_CALL_INFO: { - HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)pEvent->dbei->pBlob)), 0, L"partlist"); + HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"partlist"); if (xml != NULL) { ptrA type(mir_u2a(xmlGetAttrValue(xml, L"type"))); @@ -106,7 +106,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam) } case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO: { - HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)pEvent->dbei->pBlob)), 0, L"files"); + HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"files"); if (xml != NULL) { for (int i = 0; i < xmlGetChildCount(xml); i++) @@ -130,13 +130,14 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam) { szText = INVALID_DATA; } - break; } + break; + case SKYPE_DB_EVENT_TYPE_FILE: case SKYPE_DB_EVENT_TYPE_MOJI: case SKYPE_DB_EVENT_TYPE_URIOBJ: { - HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)pEvent->dbei->pBlob)), 0, L"URIObject"); + HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"URIObject"); if (xml != NULL) { //szText.Append(_T2A(xmlGetText(xml))); @@ -151,45 +152,22 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam) { szText = INVALID_DATA; } - break; - } + break; case SKYPE_DB_EVENT_TYPE_INCOMING_CALL: - { - szText = Translate("Incoming call"); - break; - } + szText = Translate("Incoming call"); + break; + case SKYPE_DB_EVENT_TYPE_UNKNOWN: - { - szText.Format(Translate("Unknown event, please send this text for developer: \"%s\""), mir_utf8decodeA((char*)pEvent->dbei->pBlob)); - break; - } - default: - { - szText = ptrA(mir_utf8decodeA((char*)pEvent->dbei->pBlob)); - } - } + szText.Format(Translate("Unknown event, please send this text for developer: \"%s\""), mir_utf8decodeA((char*)dbei->pBlob)); + break; - switch(pEvent->datatype) - { - case DBVT_WCHAR: - { - return (INT_PTR)mir_a2u(szText); - } - case DBVT_ASCIIZ: - { - return (INT_PTR)szText.Detach(); - } - case DBVT_UTF8: - { - return (INT_PTR)mir_utf8encode(szText); - } default: - { - return NULL; - } + szText = ptrA(mir_utf8decodeA((char*)dbei->pBlob)); } + + return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_a2u(szText) : (INT_PTR)szText.Detach(); } INT_PTR CSkypeProto::EventGetIcon(WPARAM wParam, LPARAM lParam) diff --git a/protocols/Steam/src/steam_events.cpp b/protocols/Steam/src/steam_events.cpp index 0303a9a08a..b545ec2808 100644 --- a/protocols/Steam/src/steam_events.cpp +++ b/protocols/Steam/src/steam_events.cpp @@ -13,8 +13,7 @@ int CSteamProto::OnModulesLoaded(WPARAM, LPARAM) dbEventType.module = m_szModuleName; dbEventType.eventType = EVENTTYPE_STEAM_CHATSTATES; dbEventType.descr = "Chat state notifications"; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); - + DbEvent_RegisterType(&dbEventType); return 0; } diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp index 0fb7f4474d..9a3633953f 100644 --- a/protocols/Steam/src/steam_utils.cpp +++ b/protocols/Steam/src/steam_utils.cpp @@ -184,17 +184,16 @@ void CSteamProto::ShowNotification(const wchar_t *message, int flags, MCONTACT h ShowNotification(MODULEW, message, flags, hContact); } -INT_PTR __cdecl CSteamProto::OnGetEventTextChatStates(WPARAM, LPARAM lParam) +INT_PTR __cdecl CSteamProto::OnGetEventTextChatStates(WPARAM pEvent, LPARAM datatype) { // Retrieves a chat state description from an event - DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam; - if (pdbEvent->dbei->cbBlob > 0) { - if (pdbEvent->dbei->pBlob[0] == STEAM_DB_EVENT_CHATSTATES_GONE) { - if (pdbEvent->datatype == DBVT_WCHAR) + DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent; + if (dbei->cbBlob > 0) { + if (dbei->pBlob[0] == STEAM_DB_EVENT_CHATSTATES_GONE) { + if (datatype == DBVT_WCHAR) return (INT_PTR)mir_wstrdup(TranslateT("closed chat session")); - else if (pdbEvent->datatype == DBVT_ASCIIZ) - return (INT_PTR)mir_strdup(Translate("closed chat session")); + return (INT_PTR)mir_strdup(Translate("closed chat session")); } } diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index fe1cb7abe5..9454085f55 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -24,10 +24,10 @@ void CToxProto::InitCustomDbEvents() dbEventType.eventType = DB_EVENT_ACTION; dbEventType.descr = Translate("Action"); - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + DbEvent_RegisterType(&dbEventType); dbEventType.eventType = DB_EVENT_CALL; dbEventType.descr = Translate("Call"); dbEventType.eventIcon = GetIconHandle(IDI_AUDIO_START); - CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + DbEvent_RegisterType(&dbEventType); } \ No newline at end of file diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index bfe83fcb81..763d269344 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -348,7 +348,7 @@ int TwitterProto::OnModulesLoaded(WPARAM, LPARAM) evt.module = m_szModuleName; evt.descr = "Tweet"; evt.flags = DETF_HISTORY | DETF_MSGWINDOW; - CallService(MS_DB_EVENT_REGISTERTYPE, 0, reinterpret_cast(&evt)); + DbEvent_RegisterType(&evt); SetAllContactStatuses(ID_STATUS_OFFLINE); // In case we crashed last time return 0; diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 2d38df4c64..4a55490432 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -231,13 +231,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; - ptrW ptszFileName(DbGetEventStringT(&dbei, str)); + ptrW ptszFileName(DbEvent_GetString(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)mir_strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; - ptrW pwszDescription(DbGetEventStringT(&dbei, str)); + ptrW pwszDescription(DbEvent_GetString(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, pwszDescription); } } diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index bb813b25a2..51e8900b93 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -193,7 +193,7 @@ static char* SetToStyle(int style) int DbEventIsForMsgWindow(DBEVENTINFO *dbei) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); return et && (et->flags & DETF_MSGWINDOW); } @@ -304,7 +304,7 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT AppendToBufferWithRTF(buffer, szName); AppendToBufferWithRTF(buffer, L" "); - msg = DbGetEventTextW(&dbei, CP_ACP); + msg = DbEvent_GetTextW(&dbei, CP_ACP); if (msg) { AppendToBufferWithRTF(buffer, msg); mir_free(msg); @@ -316,14 +316,14 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT char* filename = (char*)dbei.pBlob + sizeof(DWORD); char* descr = filename + mir_strlen(filename) + 1; - ptrW ptszFileName(DbGetEventStringT(&dbei, filename)); + ptrW ptszFileName(DbEvent_GetString(&dbei, filename)); buffer.AppendFormat(" %s ", SetToStyle(MSGFONTID_NOTICE)); AppendToBufferWithRTF(buffer, (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received")); buffer.Append(": "); AppendToBufferWithRTF(buffer, ptszFileName); if (*descr != 0) { - ptrW ptszDescr(DbGetEventStringT(&dbei, descr)); + ptrW ptszDescr(DbEvent_GetString(&dbei, descr)); buffer.Append(" ("); AppendToBufferWithRTF(buffer, ptszDescr); buffer.Append(")"); @@ -333,7 +333,7 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT case EVENTTYPE_MESSAGE: default: - msg = DbGetEventTextW(&dbei, CP_ACP); + msg = DbEvent_GetTextW(&dbei, CP_ACP); buffer.AppendFormat(" %s ", SetToStyle((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG) : MSGFONTID_NOTICE)); AppendToBufferWithRTF(buffer, msg); mir_free(msg); diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index d87b602c8d..8131f4eb3d 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -39,7 +39,7 @@ static HGENMENU hContactMenu = 0; static void GetMessageDescription(DBEVENTINFO *dbei, wchar_t* buf, int cbBuf) { - wchar_t *msg = DbGetEventTextW(dbei, CP_ACP); + wchar_t *msg = DbEvent_GetTextW(dbei, CP_ACP); wcsncpy(buf, msg ? msg : TranslateT("Invalid message"), cbBuf); buf[ cbBuf-1 ] = 0; mir_free(msg); @@ -87,7 +87,7 @@ static void GetObjectDescription(DBEVENTINFO *dbei, wchar_t* str, int cbStr) break; default: - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); if (et && (et->flags & DETF_HISTORY)) GetMessageDescription(dbei, str, cbStr); else @@ -115,7 +115,7 @@ static void GetObjectSummary(DBEVENTINFO *dbei, wchar_t* str, int cbStr) break; default: - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR* et = DbEvent_GetType(dbei->szModule, dbei->eventType); if (et && (et->flags & DETF_HISTORY)) { pszTmp = mir_a2u(et->descr); pszSrc = TranslateW(pszTmp); diff --git a/src/mir_app/src/dbini.cpp b/src/mir_app/src/dbini.cpp index 8c1c4f6c97..8239b448e2 100644 --- a/src/mir_app/src/dbini.cpp +++ b/src/mir_app/src/dbini.cpp @@ -110,7 +110,8 @@ static bool IsInSpaceSeparatedList(const char *szWord, const char *szList) } } -struct warnSettingChangeInfo_t { +struct warnSettingChangeInfo_t +{ wchar_t *szIniPath; char *szSection; char *szSafeSections; @@ -362,7 +363,7 @@ LBL_NewLine: if (szLine[1] == '?') { DBCONTACTENUMSETTINGS dbces; dbces.pfnEnumProc = SettingsEnumProc; - mir_strncpy(szSection, szLine+2, min(sizeof(szSection), (int)(szEnd-szLine-1))); + 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); @@ -387,7 +388,7 @@ LBL_NewLine: continue; char szName[128]; - mir_strncpy(szName, szLine, min(sizeof(szName), (int)(szValue-szLine+1))); + mir_strncpy(szName, szLine, min(sizeof(szName), (int)(szValue - szLine + 1))); szValue++; { warnSettingChangeInfo_t warnInfo; @@ -411,15 +412,15 @@ LBL_NewLine: switch (szValue[0]) { case 'b': case 'B': - db_set_b(NULL, szSection, szName, (BYTE)strtol(szValue+1, NULL, 0)); + db_set_b(NULL, szSection, szName, (BYTE)strtol(szValue + 1, NULL, 0)); break; case 'w': case 'W': - db_set_w(NULL, szSection, szName, (WORD)strtol(szValue+1, NULL, 0)); + db_set_w(NULL, szSection, szName, (WORD)strtol(szValue + 1, NULL, 0)); break; case 'd': case 'D': - db_set_dw(NULL, szSection, szName, (DWORD)strtoul(szValue+1, NULL, 0)); + db_set_dw(NULL, szSection, szName, (DWORD)strtoul(szValue + 1, NULL, 0)); break; case 'l': case 'L': @@ -442,10 +443,10 @@ LBL_NewLine: break; case 'e': case 'E': - ConvertBackslashes(szValue+1, Langpack_GetDefaultCodePage()); + ConvertBackslashes(szValue + 1, Langpack_GetDefaultCodePage()); case 's': case 'S': - db_set_s(NULL, szSection, szName, szValue+1); + db_set_s(NULL, szSection, szName, szValue + 1); break; case 'g': case 'G': @@ -589,14 +590,12 @@ static void DoAutoExec(void) mir_wstrcat(szNewPath, fd.cFileName); MoveFile(szIniPath, szNewPath); } - else if (!mir_wstrcmpi(szOnCompletion, L"ask")) - { + else if (!mir_wstrcmpi(szOnCompletion, L"ask")) { CIniImportDoneDlg dlg(szIniPath); dlg.DoModal(); } } - } - while (FindNextFile(hFind, &fd)); + } while (FindNextFile(hFind, &fd)); FindClose(hFind); } diff --git a/src/mir_app/src/dbutils.cpp b/src/mir_app/src/dbutils.cpp index a8003bec86..155851a2e5 100644 --- a/src/mir_app/src/dbutils.cpp +++ b/src/mir_app/src/dbutils.cpp @@ -36,11 +36,22 @@ static int CompareEventTypes(const DBEVENTTYPEDESCR *p1, const DBEVENTTYPEDESCR static LIST eventTypes(10, CompareEventTypes); -static BOOL bModuleInitialized = FALSE; +void UnloadEventsModule() +{ + for (int i = 0; i < eventTypes.getCount(); i++) { + DBEVENTTYPEDESCR *p = eventTypes[i]; + mir_free(p->module); + mir_free(p->descr); + mir_free(p->textService); + mir_free(p->iconService); + mir_free(p); + } +} -static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(int) DbEvent_RegisterType(DBEVENTTYPEDESCR *et) { - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)lParam; if (et == NULL || et->cbSize != sizeof(DBEVENTTYPEDESCR)) return -1; @@ -73,12 +84,12 @@ static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) return 0; } -static INT_PTR DbEventTypeGet(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(DBEVENTTYPEDESCR*) DbEvent_GetType(const char *szModule, int eventType) { DBEVENTTYPEDESCR tmp; - tmp.module = (char*)wParam; - tmp.eventType = lParam; - return (INT_PTR)eventTypes.find(&tmp); + tmp.module = (char*)szModule; + tmp.eventType = eventType; + return eventTypes.find(&tmp); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -90,19 +101,14 @@ static wchar_t* getEventString(DBEVENTINFO *dbei, LPSTR &buf) return (dbei->flags & DBEF_UTF) ? Utf8DecodeT(in) : mir_a2u(in); } -static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) +static INT_PTR DbEventGetTextWorker(DBEVENTINFO *dbei, int codepage, int datatype) { - DBEVENTGETTEXT* egt = (DBEVENTGETTEXT*)lParam; - if (egt == NULL) - return 0; - - DBEVENTINFO *dbei = egt->dbei; if (dbei == NULL || dbei->szModule == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 0; - DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)DbEventTypeGet((WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); if (et && ServiceExists(et->textService)) - return CallService(et->textService, wParam, lParam); + return CallService(et->textService, (WPARAM)dbei, datatype); if (!dbei->pBlob) return 0; @@ -143,7 +149,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) } else text.Format(TranslateT("You were added by %s%s"), (tszNick == NULL) ? cli.pfnGetContactDisplayName(hContact, 0) : tszNick, nick); - return (egt->datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text); + return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text); } if (dbei->eventType == EVENTTYPE_CONTACTS) { @@ -158,7 +164,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) if (tszUin && *tszUin) text.AppendFormat(L"<%s>; ", tszUin); } - return (egt->datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text); + return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text); } if (dbei->eventType == EVENTTYPE_FILE) { @@ -166,7 +172,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) ptrW tszFileName(getEventString(dbei, buf)); ptrW tszDescription(getEventString(dbei, buf)); ptrW &ptszText = (mir_wstrlen(tszDescription) == 0) ? tszFileName : tszDescription; - switch (egt->datatype) { + switch (datatype) { case DBVT_WCHAR: return (INT_PTR)ptszText.detach(); case DBVT_ASCIIZ: @@ -176,42 +182,53 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) } // by default treat an event's blob as a string - if (egt->datatype == DBVT_WCHAR) { + if (datatype == DBVT_WCHAR) { char *str = (char*)alloca(dbei->cbBlob + 1); memcpy(str, dbei->pBlob, dbei->cbBlob); str[dbei->cbBlob] = 0; if (dbei->flags & DBEF_UTF) { WCHAR *msg = NULL; - Utf8DecodeCP(str, egt->codepage, &msg); + Utf8DecodeCP(str, codepage, &msg); if (msg) return (INT_PTR)msg; } - return (INT_PTR)mir_a2u_cp(str, egt->codepage); + return (INT_PTR)mir_a2u_cp(str, codepage); } - if (egt->datatype == DBVT_ASCIIZ) { + if (datatype == DBVT_ASCIIZ) { char *msg = mir_strdup((char*)dbei->pBlob); if (dbei->flags & DBEF_UTF) - Utf8DecodeCP(msg, egt->codepage, NULL); + Utf8DecodeCP(msg, codepage, NULL); return (INT_PTR)msg; } return 0; } -static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(char*) DbEvent_GetTextA(DBEVENTINFO *dbei, int codepage) { - DBEVENTINFO* dbei = (DBEVENTINFO*)lParam; - HICON icon = NULL; - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)DbEventTypeGet((WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + return (char*)DbEventGetTextWorker(dbei, codepage, DBVT_ASCIIZ); +} + +MIR_APP_DLL(wchar_t*) DbEvent_GetTextW(DBEVENTINFO *dbei, int codepage) +{ + return (wchar_t*)DbEventGetTextWorker(dbei, codepage, DBVT_WCHAR); +} + +///////////////////////////////////////////////////////////////////////////////////////// +MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags) +{ + DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); if (et && ServiceExists(et->iconService)) { - icon = (HICON)CallService(et->iconService, wParam, lParam); + HICON icon = (HICON)CallService(et->iconService, (WPARAM)dbei, flags); if (icon) - return (INT_PTR)icon; + return icon; } + + HICON icon = NULL; if (et && et->eventIcon) icon = IcoLib_GetIconByHandle(et->eventIcon); if (!icon) { @@ -236,18 +253,17 @@ static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam) } } - return (INT_PTR)((wParam & LR_SHARED) ? icon : CopyIcon(icon)); + return (flags & LR_SHARED) ? icon : CopyIcon(icon); } -static INT_PTR DbEventGetStringT(WPARAM wParam, LPARAM lParam) -{ - DBEVENTINFO* dbei = (DBEVENTINFO*)wParam; - char *string = (char*)lParam; +///////////////////////////////////////////////////////////////////////////////////////// +MIR_APP_DLL(wchar_t*) DbEvent_GetString(DBEVENTINFO *dbei, const char *str) +{ if (dbei->flags & DBEF_UTF) - return (INT_PTR)Utf8DecodeW(string); + return Utf8DecodeW(str); - return (INT_PTR)mir_a2u(string); + return mir_a2u(str); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -259,109 +275,67 @@ static int sttEnumVars(const char *szVarName, LPARAM lParam) return 0; } -static INT_PTR DbDeleteModule(WPARAM hContact, LPARAM lParam) +MIR_APP_DLL(int) DbModule_Delete(MCONTACT hContact, const char *szModuleName) { LIST vars(20); DBCONTACTENUMSETTINGS dbces = { 0 }; dbces.pfnEnumProc = sttEnumVars; dbces.lParam = (LPARAM)&vars; - dbces.szModule = (char*)lParam; + dbces.szModule = (char*)szModuleName; CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces); for (int i = vars.getCount()-1; i >= 0; i--) { - db_unset(hContact, (char*)lParam, vars[i]); + db_unset(hContact, szModuleName, vars[i]); mir_free(vars[i]); } return 0; } -static INT_PTR GetProfilePath(WPARAM wParam, LPARAM lParam) +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(int) Profile_GetPathA(size_t cbLen, char *pszDest) { - if (!wParam || !lParam) + if (!pszDest || !cbLen) return 1; - char *dst = (char*)lParam; - strncpy(dst, _T2A(g_profileDir), wParam); - dst[wParam-1] = 0; + strncpy_s(pszDest, cbLen, _T2A(g_profileDir), _TRUNCATE); return 0; } -static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(int) Profile_GetPathW(size_t cbLen, wchar_t *pwszDest) { - if (!wParam || !lParam) + if (!pwszDest || !cbLen) return 1; - char *dst = (char*)lParam; - - char *tmp = makeFileName(g_profileName); - strncpy(dst, tmp, wParam); - mir_free(tmp); - - dst[wParam-1] = 0; + wcsncpy_s(pwszDest, cbLen, g_profileDir, _TRUNCATE); return 0; } -static INT_PTR GetProfilePathW(WPARAM wParam, LPARAM lParam) +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(int) Profile_GetNameA(size_t cbLen, char *pszDest) { - if (!wParam || !lParam) + if (!cbLen || !pszDest) return 1; - wchar_t *dst = (wchar_t*)lParam; - wcsncpy(dst, g_profileDir, wParam); - dst[wParam-1] = 0; + strncpy_s(pszDest, cbLen, ptrA(makeFileName(g_profileName)), _TRUNCATE); return 0; } -static INT_PTR GetProfileNameW(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(int) Profile_GetNameW(size_t cbLen, wchar_t *pwszDest) { - wchar_t *dst = (wchar_t*)lParam; - wcsncpy(dst, g_profileName, wParam); - dst[wParam-1] = 0; - return 0; -} + if (!cbLen || !pwszDest) + return 1; -static INT_PTR SetDefaultProfile(WPARAM wParam, LPARAM) -{ - extern wchar_t* g_defaultProfile; - replaceStrW(g_defaultProfile, (wchar_t*)wParam); + wcsncpy_s(pwszDest, cbLen, g_profileName, _TRUNCATE); return 0; } ///////////////////////////////////////////////////////////////////////////////////////// -int LoadEventsModule() -{ - bModuleInitialized = TRUE; - - CreateServiceFunction(MS_DB_EVENT_REGISTERTYPE, DbEventTypeRegister); - CreateServiceFunction(MS_DB_EVENT_GETTYPE, DbEventTypeGet); - CreateServiceFunction(MS_DB_EVENT_GETTEXT, DbEventGetText); - CreateServiceFunction(MS_DB_EVENT_GETICON, DbEventGetIcon); - CreateServiceFunction(MS_DB_EVENT_GETSTRINGT, DbEventGetStringT); - - CreateServiceFunction(MS_DB_MODULE_DELETE, DbDeleteModule); - - CreateServiceFunction(MS_DB_GETPROFILEPATH, GetProfilePath); - CreateServiceFunction(MS_DB_GETPROFILENAME, GetProfileName); - CreateServiceFunction(MS_DB_GETPROFILEPATHW, GetProfilePathW); - CreateServiceFunction(MS_DB_GETPROFILENAMEW, GetProfileNameW); - - CreateServiceFunction(MS_DB_SETDEFAULTPROFILE, SetDefaultProfile); - return 0; -} - -void UnloadEventsModule() +MIR_APP_DLL(void) Profile_SetDefault(const wchar_t *pwszPath) { - if (!bModuleInitialized) - return; - - for (int i=0; i < eventTypes.getCount(); i++) { - DBEVENTTYPEDESCR *p = eventTypes[i]; - mir_free(p->module); - mir_free(p->descr); - mir_free(p->textService); - mir_free(p->iconService); - mir_free(p); - } + extern wchar_t* g_defaultProfile; + replaceStrW(g_defaultProfile, pwszPath); } diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index c2d1bf2b5a..5a9a88b60c 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); - CallService(MS_DB_MODULE_DELETE, NULL, (LPARAM)szModule); + DbModule_Delete(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 22f5634e79..c714f06418 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 - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); + DbModule_Delete(NULL, szModule); db_set_b(NULL, szModule, "MenuFormat", true); MO_RecursiveWalkMenu(pmo->m_items.first, sttDumpItem, szModule); } diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index dfd4856bbf..dfc1f380b4 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -280,3 +280,15 @@ Srmm_GetNthIcon @279 Srmm_ModifyIcon @280 Srmm_RemoveIcon @281 ExtraIcon_AddIcon @282 +DbEvent_GetIcon @283 +DbEvent_GetString @284 +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 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6e1cfb3ff0..309b40d02d 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -280,3 +280,15 @@ Srmm_GetNthIcon @279 Srmm_ModifyIcon @280 Srmm_RemoveIcon @281 ExtraIcon_AddIcon @282 +DbEvent_GetIcon @283 +DbEvent_GetString @284 +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 diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index 13e23f6411..0e9f3f94db 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -38,7 +38,6 @@ int LoadProtocolsModule(void); // core: protocol manager int LoadAccountsModule(void); // core: account manager int LoadIgnoreModule(void); // protocol filter: ignore int LoadDbintfModule(void); -int LoadEventsModule(void); int LoadSrmmModule(void); int LoadContactsModule(void); @@ -52,7 +51,6 @@ int LoadSkinHotkeys(void); int LoadUserInfoModule(void); // ui: user info int LoadVisibilityModule(void); // ui: visibility control -int LoadPluginOptionsModule(void); // ui: plugin viewer int LoadAddContactModule(void); // ui: authcontrol contacts int LoadUtilsModule(void); // ui: utils (has a few window classes, like HyperLink) int LoadCLCModule(void); // window class: CLC control @@ -61,13 +59,11 @@ int LoadFontserviceModule(void); // ui: font manager int LoadIcoLibModule(void); // ui: icons manager int LoadServiceModePlugin(void); int LoadDefaultServiceModePlugin(void); -int LoadErrorsModule(void); void UnloadAccountsModule(void); void UnloadClcModule(void); void UnloadContactListModule(void); void UnloadDatabase(void); -void UnloadErrorsModule(void); void UnloadEventsModule(void); void UnloadExtraIconsModule(void); void UnloadIcoLibModule(void); @@ -80,9 +76,9 @@ void UnloadSkinHotkeys(void); void UnloadSrmmModule(void); void UnloadUtilsModule(void); -int LoadIcoTabsModule(); -int LoadHeaderbarModule(); -int LoadDescButtonModule(); +int LoadIcoTabsModule(); +int LoadHeaderbarModule(); +int LoadDescButtonModule(); int LoadDefaultModules(void) { @@ -94,7 +90,6 @@ int LoadDefaultModules(void) if (LoadIcoTabsModule()) return 1; if (LoadHeaderbarModule()) return 1; if (LoadDbintfModule()) return 1; - if (LoadEventsModule()) return 1; // load database drivers & service plugins without executing their Load() if (LoadNewPluginsModuleInfos()) return 1; diff --git a/src/mir_app/src/options_ei.cpp b/src/mir_app/src/options_ei.cpp index 060fa85b93..d38dc19f6a 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()); } - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)MODULE_NAME "Groups"); + DbModule_Delete(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 8999e88f06..5c8edc3d13 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -378,7 +378,7 @@ void DeactivateAccount(PROTOACCOUNT *pa, bool bIsDynamic, bool bErase) ///////////////////////////////////////////////////////////////////////////////////////// -void EraseAccount(const char* pszModuleName) +void EraseAccount(const char *pszModuleName) { // remove protocol contacts first for (MCONTACT hContact = db_find_first(pszModuleName); hContact != NULL;) { @@ -388,7 +388,7 @@ void EraseAccount(const char* pszModuleName) } // remove all protocol settings - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)pszModuleName); + DbModule_Delete(NULL, pszModuleName); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/utils/mir_options.cpp b/utils/mir_options.cpp index 71f9ae0ea9..20ae7d1f9f 100644 --- a/utils/mir_options.cpp +++ b/utils/mir_options.cpp @@ -69,7 +69,7 @@ static void PathToRelative(wchar_t *pOut, size_t outSize, const wchar_t *pSrc) else { if (dbPath[0] == '\0') { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp); + Profile_GetPathA(_countof(tmp), tmp); mir_snwprintf(dbPath, L"%S\\", tmp); } @@ -87,7 +87,7 @@ static void PathToAbsolute(wchar_t *pOut, size_t outSize, const wchar_t *pSrc) else { if (dbPath[0] == '\0') { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp); + Profile_GetPathA(_countof(tmp), tmp); mir_snwprintf(dbPath, L"%S\\", tmp); } -- cgit v1.2.3