diff options
-rw-r--r-- | include/m_core.h | 23 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/globals.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/mim.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 4 |
5 files changed, 30 insertions, 13 deletions
diff --git a/include/m_core.h b/include/m_core.h index d30bed459e..6bb86f68a6 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -66,7 +66,9 @@ typedef UINT32 MCONTACT; #define DBVT_TCHAR DBVT_ASCIIZ
#endif
#define DBVTF_VARIABLELENGTH 0x80
-typedef struct {
+
+typedef struct
+{
BYTE type;
union {
BYTE bVal; char cVal;
@@ -87,25 +89,30 @@ typedef struct { };
} 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_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
+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
+ 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);
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 81fbfa1f9d..66dded5f16 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -291,8 +291,18 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent)
{
+ DBCachedContact *cc;
+ if (contactID) {
+ if ((cc = m_cache->GetCachedContact(contactID)) == NULL)
+ return -1;
+ if (cc->IsSub())
+ if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
+ return -1;
+ }
+ else cc = NULL;
+
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = GetContactOffset(contactID);
+ DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser;
DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE)
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 3d5e7bd8f0..760718eb43 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -578,7 +578,7 @@ void CGlobals::RestoreUnreadMessageAlerts(void) while (hDbEvent) {
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEvent, &dbei);
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && dbei.eventType == EVENTTYPE_MESSAGE) {
+ if (!dbei.markedRead() && dbei.eventType == EVENTTYPE_MESSAGE) {
if (M.FindWindow(hContact) != NULL)
continue;
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 53dcd6aa31..0425068261 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -527,7 +527,7 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM lParam) BOOL isCustomEvent = IsCustomEvent(dbei.eventType);
BOOL isShownCustomEvent = DbEventIsForMsgWindow(&dbei);
- if ((dbei.flags & (DBEF_READ | DBEF_SENT)) || (isCustomEvent && !isShownCustomEvent))
+ if (dbei.markedRead() || (isCustomEvent && !isShownCustomEvent))
return 0;
CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1);
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 00ba701c84..e416f923e8 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -595,7 +595,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, }
}
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT | DBEF_READ)))
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.markedRead())
dat->cache->updateStats(TSessionStats::SET_LAST_RCV, lstrlenA((char *) dbei.pBlob));
if (rtfMessage == NULL) {
@@ -625,7 +625,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, dwEffectiveFlags = dat->dwFlags;
- dat->isHistory = (dbei.timestamp < dat->cache->getSessionStart() && (dbei.flags & DBEF_READ || dbei.flags & DBEF_SENT));
+ dat->isHistory = (dbei.timestamp < dat->cache->getSessionStart() && dbei.markedRead());
iFontIDOffset = dat->isHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set)
isSent = (dbei.flags & DBEF_SENT);
|