diff options
author | George Hazan <george.hazan@gmail.com> | 2015-03-11 22:04:58 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-03-11 22:04:58 +0000 |
commit | 6dfb8adb67adb1c01105804e329fcd4a2b152c06 (patch) | |
tree | ab8371809437508a19ce524eef625c0e3fe89f75 | |
parent | e27c16fd6a4a1f5b1191c0fd68c53ae459df386d (diff) |
all database functions moved to m_database.h
git-svn-id: http://svn.miranda-ng.org/main/trunk@12385 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_core.h | 285 | ||||
-rw-r--r-- | include/m_database.h | 370 | ||||
-rw-r--r-- | include/m_message.h | 2 | ||||
-rw-r--r-- | include/m_popup.h | 2 | ||||
-rw-r--r-- | include/m_protoint.h | 1 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_notify.h | 2 | ||||
-rw-r--r-- | plugins/ModernOpt/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/globals.h | 1 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/options.cpp | 2 | ||||
-rw-r--r-- | plugins/SkypeStatusChange/src/stdafx.h | 1 | ||||
-rw-r--r-- | plugins/StartPosition/src/Common.h | 1 | ||||
-rw-r--r-- | plugins/UserGuide/src/commonheaders.h | 1 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/WinterSpeak/src/Common.h | 1 | ||||
-rw-r--r-- | plugins/mTextControl/src/headers.h | 1 |
16 files changed, 333 insertions, 340 deletions
diff --git a/include/m_core.h b/include/m_core.h index 9f5bf4cbdb..78b33606b2 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -61,292 +61,7 @@ typedef uint32_t MCONTACT; typedef uint32_t MEVENT;
-// DBVARIANT: used by db/contact/getsetting and db/contact/writesetting
-#define DBVT_DELETED 0 // this setting just got deleted, no other values are valid
-#define DBVT_BYTE 1 // bVal and cVal are valid
-#define DBVT_WORD 2 // wVal and sVal are valid
-#define DBVT_DWORD 4 // dVal and lVal are valid
-#define DBVT_ASCIIZ 255 // pszVal is valid
-#define DBVT_BLOB 254 // cpbVal and pbVal are valid
-#define DBVT_UTF8 253 // pszVal is valid
-#define DBVT_WCHAR 252 // pszVal is valid
-#if defined(_UNICODE)
- #define DBVT_TCHAR DBVT_WCHAR
-#else
- #define DBVT_TCHAR DBVT_ASCIIZ
-#endif
-#define DBVTF_VARIABLELENGTH 0x80
-
-typedef struct
-{
- BYTE type;
- union {
- BYTE bVal; char cVal;
- WORD wVal; short sVal;
- DWORD dVal; long lVal;
- struct {
- union {
- char *pszVal;
- TCHAR *ptszVal;
- wchar_t *pwszVal;
- };
- WORD cchVal; //only used for db/contact/getsettingstatic
- };
- struct {
- WORD cpbVal;
- BYTE *pbVal;
- };
- };
-} DBVARIANT;
-
-#define DBEF_SENT 2 // this event was sent by the user. If not set this event was received.
-#define DBEF_READ 4 // event has been read by the user. It does not need to be processed any more except for history.
-#define DBEF_RTL 8 // event contains the right-to-left aligned text
-#define DBEF_UTF 16 // event contains a text in utf-8
-#define DBEF_ENCRYPTED 32 // event is encrypted (never reported outside a driver)
-
-typedef struct
-{
- int cbSize; // size of the structure in bytes
- char *szModule; // pointer to name of the module that 'owns' this
- // event, ie the one that is in control of the data format
- DWORD timestamp; // seconds since 00:00, 01/01/1970. Gives us times until
- // 2106 unless you use the standard C library which is
- // signed and can only do until 2038. In GMT.
- DWORD flags; // the omnipresent flags
- WORD eventType; // module-defined event type field
- DWORD cbBlob; // size of pBlob in bytes
- PBYTE pBlob; // pointer to buffer containing module-defined event data
-
-#if defined(__cplusplus)
- bool __forceinline markedRead() const
- { return (flags & (DBEF_SENT | DBEF_READ)) != 0;
- }
-#endif
-} DBEVENTINFO;
-
-MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv);
-
-/******************************************************************************
- * DATABASE CONTACTS
- */
-
-/*
-Gets the handle of the first contact in the database. This handle can be used
-with loads of functions. It does not need to be closed.
-You can specify szProto to find only its contacts
-Returns a handle to the first contact in the db on success, or NULL if there
-are no contacts in the db.
-*/
-
-#if defined(__cplusplus)
- MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = NULL);
-#else
- MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto);
-#endif
-
-/*
-Gets the handle of the next contact after hContact in the database. This handle
-can be used with loads of functions. It does not need to be closed.
-You can specify szProto to find only its contacts
-Returns a handle to the contact after hContact in the db on success or NULL if
-hContact was the last contact in the db or hContact was invalid.
-*/
-
-#if defined(__cplusplus)
- MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = NULL);
-#else
- MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto);
-#endif
-
-/******************************************************************************
- * DATABASE EVENTS
- */
-
-/*
-Adds a new event to a contact's event list
-Returns a handle to the newly added event, or NULL on failure
-Triggers a db/event/added event just before it returns.
-Events are sorted chronologically as they are entered, so you cannot guarantee
-that the new hEvent is the last event in the chain, however if a new event is
-added that has a timestamp less than 90 seconds *before* the event that should
-be after it, it will be added afterwards, to allow for protocols that only
-store times to the nearest minute, and slight delays in transports.
-There are a few predefined eventTypes below for easier compatibility, but
-modules are free to define their own, beginning at 2000
-DBEVENTINFO.timestamp is in GMT, as returned by time(). There are services
-db/time/x below with useful stuff for dealing with it.
-*/
-
-#define EVENTTYPE_MESSAGE 0
-#define EVENTTYPE_URL 1
-#define EVENTTYPE_CONTACTS 2 //v0.1.2.2+
-#define EVENTTYPE_ADDED 1000 //v0.1.1.0+: these used to be module-
-#define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module-
-#define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000
-
-MIR_CORE_DLL(MEVENT) db_event_add(MCONTACT hContact, DBEVENTINFO *dbei);
-
-/*
-Gets the number of events in the chain belonging to a contact in the database.
-Returns the number of events in the chain owned by hContact or -1 if hContact
-is invalid. They can be retrieved using the db_event_first/last() services.
-*/
-
-MIR_CORE_DLL(int) db_event_count(MCONTACT hContact);
-
-/*
-Removes a single event from the database
-hDbEvent should have been returned by db_event_add/first/last/next/prev()
-Returns 0 on success, or nonzero if hDbEvent was invalid
-Triggers a db/event/deleted event just *before* the event is deleted
-*/
-
-MIR_CORE_DLL(int) db_event_delete(MCONTACT hContact, MEVENT hDbEvent);
-
-/*
-Retrieves a handle to the first event in the chain for hContact
-Returns the handle, or NULL if hContact is invalid or has no events
-Events in a chain are sorted chronologically automatically
-*/
-
-MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact);
-
-/*
-Retrieves a handle to the first unread event in the chain for hContact
-Returns the handle, or NULL if hContact is invalid or all its events have been
-read
-
-Events in a chain are sorted chronologically automatically, but this does not
-necessarily mean that all events after the first unread are unread too. They
-should be checked individually with db_event_next() and db_event_get()
-This service is designed for startup, reloading all the events that remained
-unread from last time
-*/
-
-MIR_CORE_DLL(MEVENT) db_event_firstUnread(MCONTACT hContact);
-
-/*
-Retrieves all the information stored in hDbEvent
-hDbEvent should have been returned by db_event_add/first/last/next/prev()
-Returns 0 on success or nonzero if hDbEvent is invalid
-Don't forget to set dbe.cbSize, dbe.pBlob and dbe.cbBlob before calling this
-service
-The correct value dbe.cbBlob can be got using db/event/getblobsize
-If successful, all the fields of dbe are filled. dbe.cbBlob is set to the
-actual number of bytes retrieved and put in dbe.pBlob
-If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob
-and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob
-On return, dbe.szModule is a pointer to the database module's own internal list
-of modules. Look but don't touch.
-*/
-
-MIR_CORE_DLL(int) db_event_get(MEVENT hDbEvent, DBEVENTINFO *dbei);
-
-/*
-Retrieves the space in bytes required to store the blob in hDbEvent
-hDbEvent should have been returned by db_event_add/first/last/next/prev()
-Returns the space required in bytes, or -1 if hDbEvent is invalid
-*/
-
-MIR_CORE_DLL(int) db_event_getBlobSize(MEVENT hDbEvent);
-
-/*
-Retrieves a handle to the contact that owns hDbEvent.
-hDbEvent should have been returned by db_event_add/first/last/next/prev()
-NULL is a valid return value, meaning, as usual, the user.
-Returns INVALID_CONTACT_ID if hDbEvent is invalid, or the handle to the contact on success
-*/
-
-MIR_CORE_DLL(MCONTACT) db_event_getContact(MEVENT hDbEvent);
-
-/*
-Retrieves a handle to the last event in the chain for hContact
-Returns the handle, or NULL if hContact is invalid or has no events
-Events in a chain are sorted chronologically automatically
-*/
-
-MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact);
-
-/*
-Changes the flags for an event to mark it as read.
-hDbEvent should have been returned by db_event_add/first/last/next/prev()
-Returns the entire flag DWORD for the event after the change, or -1 if hDbEvent
-is invalid.
-This is the one database write operation that does not trigger an event.
-Modules should not save flags states for any length of time.
-*/
-
-MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent);
-
-/*
-Retrieves a handle to the next event in a chain after hDbEvent
-Returns the handle, or NULL if hDbEvent is invalid or is the last event
-Events in a chain are sorted chronologically automatically
-*/
-
-MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent);
-
-/*
-Retrieves a handle to the previous event in a chain before hDbEvent
-Returns the handle, or NULL if hDbEvent is invalid or is the first event
-Events in a chain are sorted chronologically automatically
-*/
-
-MIR_CORE_DLL(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);
-MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue);
-MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue);
-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);
-
-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);
-
-#if defined(__cplusplus)
- 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);
-#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);
-
-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);
-#else
- 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)
-#ifdef _UNICODE
- #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
- #define db_get_tsa db_get_wsa
- #define db_set_ts db_set_ws
- #define db_get_tstatic db_get_wstatic
-#else
- #define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_ASCIIZ)
- #define db_get_tsa db_get_sa
- #define db_set_ts db_set_s
- #define db_get_tstatic db_get_static
-#endif
///////////////////////////////////////////////////////////////////////////////
// events, hooks & services
diff --git a/include/m_database.h b/include/m_database.h index 21f5f73bc2..5b9f3a5407 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -25,45 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_DATABASE_H__
#define M_DATABASE_H__ 1
-/******************* DATABASE MODULE ***************************/
-
-/* Notes (as I think of them):
-- The module is 100% thread-safe
-- The database is the main routing point for the vast majority of Miranda.
- Events are sent from the protocol module to here, and the send/recv message
- module (for example) hooks the db/event/added event. Events like 'contact
- online status changed' do not come through here - icqlib will send that one.
-- contacts work much the same. the find/add users module calls db/contact/add
- and db/contact/writesetting and the contact list will get db/contact/added
- and db/contact/settingchanged events
-- The user is just a special contact. A hcontact of NULL in most functions
- means the user. Functions in which it cannot be used will be stated
-- events attached to the user are things like system messages
-- also in this module are crypt/decrypt functions for stuff that should be
- obfuscated on the disk, and some time functions for dealing with timestamps
- in events.
-- the contactsettings system is designed for being read by many different
- modules. eg lots of people will be interested in "ICQ"/"UIN", but the module
- name passed to contact/writesetting should always be your own. The Mirabilis
- ICQ database importer clearly has to be an exception to this rule, along with
- a few other bits.
-- the current database format means that geteventcontact is exceptionally slow.
- It should be avoidable in most cases so I'm not too concerned, but if people
- really need to use it a lot, I'll sort it out.
-- handles do not need to be closed unless stated
-- the database is loaded as a memory mapped file. This has various
- disadvantages but a massive advantage in speed for random access.
-- The database is optimised for reading. Write performance is fairly bad,
- except for adding events which is the most common activity and pretty good.
-- I'll work on caching to improve this later
-- Deleted items are left as empty space and never reused. All new items are
- put at the end. A count is kept of this slack space and at some point a
- separate programme will need to be written to repack the database when the
- slack gets too high. It's going to be a good few months of usage before this
- can happen to anyone though, so no rush.
-*/
-
-/******************** GENERALLY USEFUL STUFF***********************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// GENERALLY USEFUL STUFF
#if !defined(M_SYSTEM_H__)
#include "m_system.h"
@@ -77,9 +40,307 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma warning(disable:4201 4204)
#endif
-/******************************************************************/
-/************************* SERVICES *******************************/
-/******************************************************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// database functions
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// DBVARIANT: used by db/contact/getsetting and db/contact/writesetting
+
+#define DBVT_DELETED 0 // this setting just got deleted, no other values are valid
+#define DBVT_BYTE 1 // bVal and cVal are valid
+#define DBVT_WORD 2 // wVal and sVal are valid
+#define DBVT_DWORD 4 // dVal and lVal are valid
+#define DBVT_ASCIIZ 255 // pszVal is valid
+#define DBVT_BLOB 254 // cpbVal and pbVal are valid
+#define DBVT_UTF8 253 // pszVal is valid
+#define DBVT_WCHAR 252 // pszVal is valid
+#if defined(_UNICODE)
+#define DBVT_TCHAR DBVT_WCHAR
+#else
+#define DBVT_TCHAR DBVT_ASCIIZ
+#endif
+#define DBVTF_VARIABLELENGTH 0x80
+
+typedef struct
+{
+ BYTE type;
+ union {
+ BYTE bVal; char cVal;
+ WORD wVal; short sVal;
+ DWORD dVal; long lVal;
+ struct {
+ union {
+ char *pszVal;
+ TCHAR *ptszVal;
+ wchar_t *pwszVal;
+ };
+ WORD cchVal; //only used for db/contact/getsettingstatic
+ };
+ struct {
+ WORD cpbVal;
+ BYTE *pbVal;
+ };
+ };
+} DBVARIANT;
+
+#define DBEF_SENT 2 // this event was sent by the user. If not set this event was received.
+#define DBEF_READ 4 // event has been read by the user. It does not need to be processed any more except for history.
+#define DBEF_RTL 8 // event contains the right-to-left aligned text
+#define DBEF_UTF 16 // event contains a text in utf-8
+#define DBEF_ENCRYPTED 32 // event is encrypted (never reported outside a driver)
+
+typedef struct
+{
+ int cbSize; // size of the structure in bytes
+ char *szModule; // pointer to name of the module that 'owns' this
+ // event, ie the one that is in control of the data format
+ DWORD timestamp; // seconds since 00:00, 01/01/1970. Gives us times until
+ // 2106 unless you use the standard C library which is
+ // signed and can only do until 2038. In GMT.
+ DWORD flags; // the omnipresent flags
+ WORD eventType; // module-defined event type field
+ DWORD cbBlob; // size of pBlob in bytes
+ PBYTE pBlob; // pointer to buffer containing module-defined event data
+
+#if defined(__cplusplus)
+ bool __forceinline markedRead() const
+ {
+ return (flags & (DBEF_SENT | DBEF_READ)) != 0;
+ }
+#endif
+} DBEVENTINFO;
+
+MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Database contacts
+
+/*
+Gets the handle of the first contact in the database. This handle can be used
+with loads of functions. It does not need to be closed.
+You can specify szProto to find only its contacts
+Returns a handle to the first contact in the db on success, or NULL if there
+are no contacts in the db.
+*/
+
+#if defined(__cplusplus)
+MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = NULL);
+#else
+MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto);
+#endif
+
+/*
+Gets the handle of the next contact after hContact in the database. This handle
+can be used with loads of functions. It does not need to be closed.
+You can specify szProto to find only its contacts
+Returns a handle to the contact after hContact in the db on success or NULL if
+hContact was the last contact in the db or hContact was invalid.
+*/
+
+#if defined(__cplusplus)
+MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = NULL);
+#else
+MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto);
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Database events
+
+/*
+Adds a new event to a contact's event list
+Returns a handle to the newly added event, or NULL on failure
+Triggers a db/event/added event just before it returns.
+Events are sorted chronologically as they are entered, so you cannot guarantee
+that the new hEvent is the last event in the chain, however if a new event is
+added that has a timestamp less than 90 seconds *before* the event that should
+be after it, it will be added afterwards, to allow for protocols that only
+store times to the nearest minute, and slight delays in transports.
+There are a few predefined eventTypes below for easier compatibility, but
+modules are free to define their own, beginning at 2000
+DBEVENTINFO.timestamp is in GMT, as returned by time(). There are services
+db/time/x below with useful stuff for dealing with it.
+*/
+
+#define EVENTTYPE_MESSAGE 0
+#define EVENTTYPE_URL 1
+#define EVENTTYPE_CONTACTS 2 //v0.1.2.2+
+#define EVENTTYPE_ADDED 1000 //v0.1.1.0+: these used to be module-
+#define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module-
+#define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000
+
+MIR_CORE_DLL(MEVENT) db_event_add(MCONTACT hContact, DBEVENTINFO *dbei);
+
+/*
+Gets the number of events in the chain belonging to a contact in the database.
+Returns the number of events in the chain owned by hContact or -1 if hContact
+is invalid. They can be retrieved using the db_event_first/last() services.
+*/
+
+MIR_CORE_DLL(int) db_event_count(MCONTACT hContact);
+
+/*
+Removes a single event from the database
+hDbEvent should have been returned by db_event_add/first/last/next/prev()
+Returns 0 on success, or nonzero if hDbEvent was invalid
+Triggers a db/event/deleted event just *before* the event is deleted
+*/
+
+MIR_CORE_DLL(int) db_event_delete(MCONTACT hContact, MEVENT hDbEvent);
+
+/*
+Retrieves a handle to the first event in the chain for hContact
+Returns the handle, or NULL if hContact is invalid or has no events
+Events in a chain are sorted chronologically automatically
+*/
+
+MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact);
+
+/*
+Retrieves a handle to the first unread event in the chain for hContact
+Returns the handle, or NULL if hContact is invalid or all its events have been
+read
+
+Events in a chain are sorted chronologically automatically, but this does not
+necessarily mean that all events after the first unread are unread too. They
+should be checked individually with db_event_next() and db_event_get()
+This service is designed for startup, reloading all the events that remained
+unread from last time
+*/
+
+MIR_CORE_DLL(MEVENT) db_event_firstUnread(MCONTACT hContact);
+
+/*
+Retrieves all the information stored in hDbEvent
+hDbEvent should have been returned by db_event_add/first/last/next/prev()
+Returns 0 on success or nonzero if hDbEvent is invalid
+Don't forget to set dbe.cbSize, dbe.pBlob and dbe.cbBlob before calling this
+service
+The correct value dbe.cbBlob can be got using db/event/getblobsize
+If successful, all the fields of dbe are filled. dbe.cbBlob is set to the
+actual number of bytes retrieved and put in dbe.pBlob
+If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob
+and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob
+On return, dbe.szModule is a pointer to the database module's own internal list
+of modules. Look but don't touch.
+*/
+
+MIR_CORE_DLL(int) db_event_get(MEVENT hDbEvent, DBEVENTINFO *dbei);
+
+/*
+Retrieves the space in bytes required to store the blob in hDbEvent
+hDbEvent should have been returned by db_event_add/first/last/next/prev()
+Returns the space required in bytes, or -1 if hDbEvent is invalid
+*/
+
+MIR_CORE_DLL(int) db_event_getBlobSize(MEVENT hDbEvent);
+
+/*
+Retrieves a handle to the contact that owns hDbEvent.
+hDbEvent should have been returned by db_event_add/first/last/next/prev()
+NULL is a valid return value, meaning, as usual, the user.
+Returns INVALID_CONTACT_ID if hDbEvent is invalid, or the handle to the contact on success
+*/
+
+MIR_CORE_DLL(MCONTACT) db_event_getContact(MEVENT hDbEvent);
+
+/*
+Retrieves a handle to the last event in the chain for hContact
+Returns the handle, or NULL if hContact is invalid or has no events
+Events in a chain are sorted chronologically automatically
+*/
+
+MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact);
+
+/*
+Changes the flags for an event to mark it as read.
+hDbEvent should have been returned by db_event_add/first/last/next/prev()
+Returns the entire flag DWORD for the event after the change, or -1 if hDbEvent
+is invalid.
+This is the one database write operation that does not trigger an event.
+Modules should not save flags states for any length of time.
+*/
+
+MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent);
+
+/*
+Retrieves a handle to the next event in a chain after hDbEvent
+Returns the handle, or NULL if hDbEvent is invalid or is the last event
+Events in a chain are sorted chronologically automatically
+*/
+
+MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent);
+
+/*
+Retrieves a handle to the previous event in a chain before hDbEvent
+Returns the handle, or NULL if hDbEvent is invalid or is the first event
+Events in a chain are sorted chronologically automatically
+*/
+
+MIR_CORE_DLL(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);
+MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, int errorValue);
+MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, LPCSTR szModule, LPCSTR szSetting, DWORD errorValue);
+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);
+
+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);
+
+#if defined(__cplusplus)
+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);
+#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);
+
+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);
+#else
+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)
+
+#ifdef _UNICODE
+#define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_WCHAR)
+#define db_get_tsa db_get_wsa
+#define db_set_ts db_set_ws
+#define db_get_tstatic db_get_wstatic
+#else
+#define db_get_ts(a,b,c,d) db_get_s(a,b,c,d,DBVT_ASCIIZ)
+#define db_get_tsa db_get_sa
+#define db_set_ts db_set_s
+#define db_get_tstatic db_get_static
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Profile services
/* DB/GetProfileName service
Gets the name of the profile currently being used by the database module. This
@@ -133,7 +394,8 @@ Implemented in the dbchecker plugins, thus it might not exist #define MS_DB_CHECKPROFILE "DB/CheckProfile"
-/************************* Contact ********************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Contact services
typedef struct {
const char *szModule; // pointer to name of the module that wrote the
@@ -212,7 +474,8 @@ Returns 1 if the contact is a contact, or 0 if the contact is not valid. */
#define MS_DB_CONTACT_IS "DB/Contact/Is"
-/************************** Event *********************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Event services
/* DB/EventType/Register service (0.7+)
Registers the specified database event type, with module, id & description.
@@ -329,7 +592,8 @@ __forceinline TCHAR* DbGetEventStringT(DBEVENTINFO* dbei, const char* str) return (TCHAR*)CallService(MS_DB_EVENT_GETSTRINGT, (WPARAM)dbei, (LPARAM)str);
}
-/**************************** Time ********************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Time services
/* DB/Time/TimestampToLocal
Converts a GMT timestamp into local time
@@ -381,7 +645,8 @@ typedef struct { } DBTIMETOSTRINGT;
#define MS_DB_TIME_TIMESTAMPTOSTRINGT "DB/Time/TimestampToStringT"
-/*************************** Random *******************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Random services
/*
Switches safety settings on or off
@@ -400,7 +665,8 @@ so you need not use this service for that purpose. */
#define MS_DB_SETSAFETYMODE "DB/SetSafetyMode"
-/*************************** Modules ******************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module services
/* db/modules/enum v0.1.0.1+
Enumerates the names of all modules that have stored or requested information
@@ -432,9 +698,8 @@ lParam = (LPARAM)(char*)szModuleName - the module name to be deleted #define MS_DB_MODULE_DELETE "DB/Module/Delete"
-/******************************************************************/
-/************************** EVENTS ********************************/
-/******************************************************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Database events
/* DB/Event/Added event
Called when a new event has been added to the event chain for a contact
@@ -524,9 +789,8 @@ don't change any of the members. */
#define ME_DB_CONTACT_SETTINGCHANGED "DB/Contact/SettingChanged"
-/******************************************************************/
-/********************* SETTINGS HELPER FUNCTIONS ******************/
-/******************************************************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Settings helper functions
#ifndef DB_NOHELPERFUNCTIONS
diff --git a/include/m_message.h b/include/m_message.h index 3ec4f5ebb2..46b45813fc 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_MESSAGE_H__
#define M_MESSAGE_H__ 1
-#include <m_core.h>
+#include <m_database.h>
extern int hLangpack;
diff --git a/include/m_popup.h b/include/m_popup.h index 4729af7833..827615c902 100644 --- a/include/m_popup.h +++ b/include/m_popup.h @@ -18,6 +18,8 @@ them! #ifndef M_POPUP_H
#define M_POPUP_H
+#include <m_database.h>
+
/*
NOTE! Since Popup 1.0.1.2 there is a main meun group called "Popups" where I
have put a "Enable/Disable" item. You can add your own "enable/disable" items
diff --git a/include/m_protoint.h b/include/m_protoint.h index 9b062a7ce9..9c9befbe87 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_system_cpp.h>
#include <m_protomod.h>
+#include <m_database.h>
typedef enum
{
diff --git a/plugins/ExternalAPI/m_notify.h b/plugins/ExternalAPI/m_notify.h index 91c9bf4712..27d92f842e 100644 --- a/plugins/ExternalAPI/m_notify.h +++ b/plugins/ExternalAPI/m_notify.h @@ -1,6 +1,8 @@ #ifndef __m_notify_h__
#define __m_notify_h__
+#include <m_database.h>
+
/*** Miranda Notify Dispatcher ************************************************\
Notify Dispatcher provides common interface to different notification plugins
like osd, popup, ticker etc.
diff --git a/plugins/ModernOpt/src/commonheaders.h b/plugins/ModernOpt/src/commonheaders.h index c69438e42c..186bc8226b 100644 --- a/plugins/ModernOpt/src/commonheaders.h +++ b/plugins/ModernOpt/src/commonheaders.h @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <win2k.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_utils.h>
#include <m_langpack.h>
#include <m_clistint.h>
diff --git a/plugins/NotesAndReminders/src/globals.h b/plugins/NotesAndReminders/src/globals.h index e63446f5c9..246f71d23b 100644 --- a/plugins/NotesAndReminders/src/globals.h +++ b/plugins/NotesAndReminders/src/globals.h @@ -7,6 +7,7 @@ #include <win2k.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_utils.h>
#include <m_clist.h>
#include <m_langpack.h>
diff --git a/plugins/SimpleStatusMsg/src/commonheaders.h b/plugins/SimpleStatusMsg/src/commonheaders.h index b709b87837..26b6c9355e 100644 --- a/plugins/SimpleStatusMsg/src/commonheaders.h +++ b/plugins/SimpleStatusMsg/src/commonheaders.h @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <time.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_clistint.h>
#include <m_skin.h>
#include <m_options.h>
diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index a43ff3519a..73ce676ee0 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -942,7 +942,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (data->proto_msg[j].flags & PROTO_THIS_MSG)
{
- int len = mir_tstrlen(data->proto_msg[j].msg);
+ size_t len = mir_tstrlen(data->proto_msg[j].msg);
if (len > 0)
{
if (data->proto_msg[k+1].msg == NULL)
diff --git a/plugins/SkypeStatusChange/src/stdafx.h b/plugins/SkypeStatusChange/src/stdafx.h index c144cc9082..8acc6f684e 100644 --- a/plugins/SkypeStatusChange/src/stdafx.h +++ b/plugins/SkypeStatusChange/src/stdafx.h @@ -9,6 +9,7 @@ #include <commctrl.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_protocols.h>
#include <m_protosvc.h>
#include <m_awaymsg.h>
diff --git a/plugins/StartPosition/src/Common.h b/plugins/StartPosition/src/Common.h index 53509894d8..b962157adc 100644 --- a/plugins/StartPosition/src/Common.h +++ b/plugins/StartPosition/src/Common.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <windows.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_langpack.h>
#include <m_utils.h>
#include <m_options.h>
diff --git a/plugins/UserGuide/src/commonheaders.h b/plugins/UserGuide/src/commonheaders.h index e698d2adc0..341ac9537d 100644 --- a/plugins/UserGuide/src/commonheaders.h +++ b/plugins/UserGuide/src/commonheaders.h @@ -3,6 +3,7 @@ #include <windows.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_langpack.h>
#include <m_utils.h>
#include <m_clist.h>
diff --git a/plugins/Watrack_MPD/src/commonheaders.h b/plugins/Watrack_MPD/src/commonheaders.h index 0a8fe4494a..6accba7365 100755 --- a/plugins/Watrack_MPD/src/commonheaders.h +++ b/plugins/Watrack_MPD/src/commonheaders.h @@ -21,6 +21,7 @@ #include <windows.h> #include <newpluginapi.h> +#include <m_database.h>
#include <m_netlib.h> #include <m_utils.h> #include <m_options.h> diff --git a/plugins/WinterSpeak/src/Common.h b/plugins/WinterSpeak/src/Common.h index 59763967e0..07e2c85fbf 100644 --- a/plugins/WinterSpeak/src/Common.h +++ b/plugins/WinterSpeak/src/Common.h @@ -7,6 +7,7 @@ #include <newpluginapi.h>
#include <m_langpack.h>
+#include <m_database.h>
#include <m_genmenu.h>
#include <m_utils.h>
#include <win2k.h>
diff --git a/plugins/mTextControl/src/headers.h b/plugins/mTextControl/src/headers.h index c9eaed3639..3d81d9245e 100644 --- a/plugins/mTextControl/src/headers.h +++ b/plugins/mTextControl/src/headers.h @@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include <textserv.h>
#include <newpluginapi.h>
+#include <m_database.h>
#include <m_langpack.h>
#include <m_utils.h>
|