summaryrefslogtreecommitdiff
path: root/include/m_database.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/m_database.h')
-rw-r--r--include/m_database.h69
1 files changed, 53 insertions, 16 deletions
diff --git a/include/m_database.h b/include/m_database.h
index 9f3420d407..28489af914 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////////////
// Miranda NG: the free IM client for Microsoft* Windows*
//
-// Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
+// Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org)
// Copyright (c) 2000-08 Miranda ICQ/IM project,
// all portions of this codebase are copyrighted to the people
// listed in contributors.txt.
@@ -191,10 +191,27 @@ struct DBVARIANT
struct DBEVENTINFO
{
const char *szModule; // pointer to name of the module that 'owns' this event
- uint32_t 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.
- uint32_t flags; // combination of DBEF_* flags
+ uint64_t iTimestamp; // seconds or milliseconds since 00:00, 01/01/1970. In GMT.
+
+ union {
+ uint32_t flags; // combination of DBEF_* flags
+ struct {
+ bool bTemporary: 1; // disable notifications about temporary database events
+ bool bSent : 1; // this event was sent by the user. If not set this event was received.
+ bool bRead : 1; // event has been read by the user. It does not need to be processed any more except for history.
+ bool bRtl : 1; // event contains the right-to-left aligned text
+ bool bUtf : 1; // event contains a text in utf-8
+ bool isEncrypted : 1; // event is encrypted (never reported outside a driver)
+ bool hasId : 1; // event has unique server id
+ bool bSecure : 1; // event is encrypted
+ bool bStrong : 1; // event is encrypted by the verified sender
+ bool isBookmark : 1; // event is bookmarked
+ bool isJson : 1; // event's body is a JSON structure
+ bool bMsec : 1; // event's timestamp is in milliseconds
+ bool bEdited : 1; // event was edited
+ };
+ };
+
uint32_t eventType; // module-defined event type field
MCONTACT hContact; // contact to which this event belongs
int cbBlob; // size of pBlob in bytes
@@ -203,12 +220,12 @@ struct DBEVENTINFO
const char *szUserId; // user id (for group chats only)
const char *szReplyId; // this message is a reply to a message with that server id
- bool __forceinline markedRead() const {
- return (flags & (DBEF_SENT | DBEF_READ)) != 0;
+ uint32_t __forceinline getUnixtime() const {
+ return bMsec ? (iTimestamp / 1000) : iTimestamp;
}
bool __forceinline operator==(const DBEVENTINFO &e) {
- return (timestamp == e.timestamp && eventType == e.eventType && cbBlob == e.cbBlob && (flags & DBEF_SENT) == (e.flags & DBEF_SENT));
+ return (iTimestamp == e.iTimestamp && eventType == e.eventType && cbBlob == e.cbBlob && bSent == e.bSent);
}
};
@@ -384,6 +401,7 @@ EXTERN_C MIR_CORE_DLL(MEVENT) db_event_getById(const char *szModule, const char
// Sets a value to the JSON field in the blob
MIR_CORE_DLL(int) db_event_setJson(MEVENT hDbEvent, const char *szSetting, DBVARIANT *dbv);
+MIR_CORE_DLL(int) db_event_setJson(MEVENT hDbEvent, const char *pBlob);
// Updates the server ID associated with an event
// Returns 0 on success or a failure otherwise
@@ -557,7 +575,7 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags);
// DB/Event/Added event
// Called when a new event has been added to the event chain for a contact
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event. hContact is a valid handle to the
// contact to which hDbEvent refers.
// Since events are sorted chronologically, you cannot guarantee that hDbEvent is
@@ -569,17 +587,34 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags);
// DB/Event/Edited event
// Called when the existing event was changed
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event. hContact is a valid handle to the
// contact to which hDbEvent refers.
#define ME_DB_EVENT_EDITED "DB/Event/Edited"
/////////////////////////////////////////////////////////////////////////////////////////
+// DB/Event/Reaction event
+// Called when the JSON part of an existing event was changed
+// wParam = (DB::EventInfo*)pEvent
+// lParam = (DBEventReaction*)pReaction
+// hDbEvent is a valid handle to the event. hContact is a valid handle to the
+// contact to which hDbEvent refers.
+
+struct DBEventReaction
+{
+ MCONTACT hContact;
+ BOOL bAdded;
+ const char *pszReaction;
+};
+
+#define ME_DB_EVENT_REACTION "DB/Event/Reaction"
+
+/////////////////////////////////////////////////////////////////////////////////////////
// DB/Event/SetJson event
// Called when the JSON part of an existing event was changed
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event. hContact is a valid handle to the
// contact to which hDbEvent refers.
@@ -606,7 +641,7 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags);
// DB/Event/Marked/Read event
// Called when an event is marked read
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event.
// hContact is a valid handle to the contact to which hDbEvent refers, and will remain valid.
@@ -616,7 +651,7 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags);
// DB/Event/Deleted event
// Called when an event is about to be deleted from the event chain for a contact
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event which is about to be deleted, but it
// won't be once your hook has returned.
// hContact is a valid handle to the contact to which hDbEvent refers, and will
@@ -630,7 +665,7 @@ EXTERN_C MIR_APP_DLL(HICON) DbEvent_GetIcon(DBEVENTINFO *dbei, int flags);
// DB/Event/Delivered event
// Called when the server confirms that an event was successfully delivered to server
// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(HANDLE)hDbEvent
+// lParam = (HANDLE)hDbEvent
// hDbEvent is a valid handle to the event.
// hContact is a valid handle to the contact to which hDbEvent refers, and will remain valid.
@@ -741,6 +776,7 @@ namespace DB
void addReaction(const char *emoji);
void delReaction(const char *emoji);
+ void setReactions(class JSONNode &pNode);
void flushJson();
JSONNode& setJson();
@@ -781,9 +817,10 @@ namespace DB
__forceinline bool isOffline() const { return m_szProtoString != nullptr; }
__forceinline void setUrl(const char *pszUrl) { m_szProtoString = mir_strdup(pszUrl); }
- __forceinline void setName(const wchar_t *pszFileName) { m_wszFileName = mir_wstrdup(pszFileName); }
+ __forceinline void setName(const wchar_t *pwszFileName) { m_wszFileName = mir_wstrdup(pwszFileName); }
__forceinline void setSize(int64_t iSize) { m_iFileSize = iSize; }
- __forceinline void setLocalName(const wchar_t *pszFileName) { m_wszLocalName = mir_wstrdup(pszFileName); }
+ __forceinline void setDescr(const wchar_t *pwszDescription) { m_wszDescription = mir_wstrdup(pwszDescription); }
+ __forceinline void setLocalName(const wchar_t *pwszFileName) { m_wszLocalName = mir_wstrdup(pwszFileName); }
__forceinline void setUserInfo(void *pUserInfo) { m_pUserInfo = pUserInfo; }
};