diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-31 14:38:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-31 14:38:25 +0000 |
commit | 1e31191afc0fbaeb211bc1f2c250ee155d21d0c0 (patch) | |
tree | de23ba08b6844791c8500c4f500129b27771939e /plugins/Db3x_mmap | |
parent | 9832b02f72a26c28e65ef4f281c16e684618d2b8 (diff) |
inline method markedRead() introduced instead of bits magic
git-svn-id: http://svn.miranda-ng.org/main/trunk@8807 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r-- | plugins/Db3x_mmap/src/commonheaders.h | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 8 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 12 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 6 |
4 files changed, 16 insertions, 12 deletions
diff --git a/plugins/Db3x_mmap/src/commonheaders.h b/plugins/Db3x_mmap/src/commonheaders.h index b6274b4868..4ddc34de68 100644 --- a/plugins/Db3x_mmap/src/commonheaders.h +++ b/plugins/Db3x_mmap/src/commonheaders.h @@ -47,8 +47,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "resource.h"
#include "version.h"
-#define NOT_UNREAD (DBEF_READ | DBEF_SENT)
-
extern HINSTANCE g_hInst;
extern LIST<CDb3Mmap> g_Dbs;
extern DBSignature dbSignatureU, dbSignatureE, dbSignatureIM, dbSignatureSA;
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 7f93d731a1..ef95d40e00 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -272,7 +272,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) DBEvent *pFirst = arEvents[0];
dbMeta->ofsFirstEvent = DWORD(PBYTE(pFirst) - m_pDbCache);
pFirst->ofsPrev = 0;
- dbMeta->ofsFirstUnread = (pFirst->flags & NOT_UNREAD) ? 0 : dbMeta->ofsFirstEvent;
+ dbMeta->ofsFirstUnread = pFirst->markedRead() ? 0 : dbMeta->ofsFirstEvent;
DBEvent *pLast = arEvents[arEvents.getCount() - 1];
dbMeta->ofsLastEvent = DWORD(PBYTE(pLast) - m_pDbCache);
@@ -283,7 +283,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) pPrev->ofsNext = DWORD(PBYTE(pNext) - m_pDbCache);
pNext->ofsPrev = DWORD(PBYTE(pPrev) - m_pDbCache);
- if (dbMeta->ofsFirstUnread == 0 && !(pNext->flags & NOT_UNREAD))
+ if (dbMeta->ofsFirstUnread == 0 && !pNext->markedRead())
dbMeta->ofsFirstUnread = pPrev->ofsNext;
}
}
@@ -338,7 +338,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dbSub.ofsFirstEvent = dwOffset;
evCurr->ofsPrev = 0;
}
- if (dbSub.ofsFirstUnread == 0 && !(evCurr->flags & NOT_UNREAD)) {
+ if (dbSub.ofsFirstUnread == 0 && !evCurr->markedRead()) {
dbSub.ofsFirstUnread = dwOffset;
dbSub.tsFirstUnread = evCurr->timestamp;
}
@@ -355,7 +355,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dbMeta.ofsFirstEvent = dwOffset;
evCurr->ofsPrev = 0;
}
- if (dbMeta.ofsFirstUnread == 0 && !(evCurr->flags & NOT_UNREAD)) {
+ if (dbMeta.ofsFirstUnread == 0 && !evCurr->markedRead()) {
dbMeta.ofsFirstUnread = dwOffset;
dbMeta.tsFirstUnread = evCurr->timestamp;
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 7be737b1ba..81fbfa1f9d 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -190,7 +190,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) }
DWORD ofsThis = dbeNext->ofsNext;
dbeNext = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL);
- if (!(dbeNext->flags & NOT_UNREAD)) {
+ if (!dbeNext->markedRead()) {
dbc.ofsFirstUnread = ofsThis;
dbc.tsFirstUnread = dbeNext->timestamp;
break;
@@ -298,10 +298,10 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE)
return -1;
- if ((dbe->flags & DBEF_READ) || (dbe->flags & DBEF_SENT))
- return (INT_PTR)dbe->flags;
+ if (dbe->markedRead())
+ return dbe->flags;
- //log1("mark read @ %08x", hContact);
+ // log1("mark read @ %08x", hContact);
dbe->flags |= DBEF_READ;
DBWrite((DWORD)hDbEvent, dbe, sizeof(DBEvent));
BOOL ret = dbe->flags;
@@ -314,7 +314,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) }
DWORD ofsThis = dbe->ofsNext;
dbe = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL);
- if (!(dbe->flags & (DBEF_READ | DBEF_SENT))) {
+ if (!dbe->markedRead()) {
dbc.ofsFirstUnread = ofsThis;
dbc.tsFirstUnread = dbe->timestamp;
break;
@@ -385,7 +385,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) DBEvent *dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE)
return NULL;
- if (dbe->contactID == contactID && !(dbe->flags & NOT_UNREAD))
+ if (dbe->contactID == contactID && !dbe->markedRead())
return HANDLE(dwOffset);
dwOffset = dbe->ofsNext;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 9582c928bb..88483226f1 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -60,6 +60,8 @@ DBHeader #define DBVT_ENCRYPTED 250
#define DBVT_UNENCRYPTED 251
+#define MARKED_READ (DBEF_READ | DBEF_SENT)
+
#define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (PBYTE)DBRead(ofsBlobPtr,(n),&bytesRemaining)
#define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);}
@@ -163,6 +165,10 @@ struct DBEvent WORD wEventType; // module-defined event type
DWORD cbBlob; // number of bytes in the blob
BYTE blob[1]; // the blob. module-defined formatting
+
+ bool __forceinline markedRead() const
+ { return (flags & MARKED_READ) != 0;
+ }
};
#include <poppack.h>
|