summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-13 12:46:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-13 12:46:12 +0000
commite0ed9d34c0c21d3436e855fa1d32a0f824583116 (patch)
tree3af99c54d25ea730df7c32a5e37dd83087d4986e /plugins/Db3x_mmap
parent787fc82cd195c9d7c5f359c3a04e93c9ca797655 (diff)
another atavism died: DBEF_FIRST
git-svn-id: http://svn.miranda-ng.org/main/trunk@8590 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp20
-rw-r--r--plugins/Db3x_mmap/src/dbtool/eventchain.cpp21
2 files changed, 18 insertions, 23 deletions
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp
index 9ed871c5f1..7513348cad 100644
--- a/plugins/Db3x_mmap/src/dbevents.cpp
+++ b/plugins/Db3x_mmap/src/dbevents.cpp
@@ -85,21 +85,17 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
dbe.ofsModuleName = GetModuleNameOfs(dbei->szModule);
// find where to put it - sort by timestamp
if (dbc.eventCount == 0) {
- dbe.ofsPrev = ofsContact;
- dbe.ofsNext = 0;
- dbe.flags |= DBEF_FIRST;
+ dbe.ofsPrev = dbe.ofsNext = 0;
dbc.ofsFirstEvent = dbc.ofsLastEvent = ofsNew;
}
else {
DBEvent *dbeTest = (DBEvent*)DBRead(dbc.ofsFirstEvent, sizeof(DBEvent), NULL);
// Should new event be placed before first event in chain?
if (dbe.timestamp < dbeTest->timestamp) {
- dbe.ofsPrev = ofsContact;
+ dbe.ofsPrev = 0;
dbe.ofsNext = dbc.ofsFirstEvent;
- dbe.flags |= DBEF_FIRST;
dbc.ofsFirstEvent = ofsNew;
dbeTest = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL);
- dbeTest->flags &= ~DBEF_FIRST;
dbeTest->ofsPrev = ofsNew;
DBWrite(dbe.ofsNext, dbeTest, sizeof(DBEvent));
}
@@ -187,7 +183,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent)
}
DWORD ofsThis = dbeNext->ofsNext;
dbeNext = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL);
- if (!(dbeNext->flags & (DBEF_READ | DBEF_SENT))) {
+ if (!(dbeNext->flags & NOT_UNREAD)) {
dbc.ofsFirstUnread = ofsThis;
dbc.tsFirstUnread = dbeNext->timestamp;
break;
@@ -196,13 +192,12 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent)
}
//get previous and next events in chain and change offsets
- if (dbe.flags & DBEF_FIRST) {
+ if (dbe.ofsPrev == 0) {
if (dbe.ofsNext == 0)
dbc.ofsFirstEvent = dbc.ofsLastEvent = 0;
else {
DBEvent *dbeNext = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL);
- dbeNext->flags |= DBEF_FIRST;
- dbeNext->ofsPrev = dbe.ofsPrev;
+ dbeNext->ofsPrev = 0;
DBWrite(dbe.ofsNext, dbeNext, sizeof(DBEvent));
dbc.ofsFirstEvent = dbe.ofsNext;
}
@@ -499,6 +494,11 @@ void CDb3Mmap::ConvertContactEvents(DBContact *dbc)
memcpy(&pNew->ofsPrev, &pOld.ofsPrev, offsetof(DBEvent_094, blob) - sizeof(DWORD));
memcpy(&pNew->blob, pBlob, pNew->cbBlob);
+ if (pNew->flags & 1) {
+ pNew->flags &= ~1;
+ pNew->ofsPrev = 0;
+ }
+
if (ofsPrev == 0) // first event
dbc->ofsFirstEvent = ofsNew, pNew->ofsPrev = 0;
else {
diff --git a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
index ee3cb7b854..fd988fe2cc 100644
--- a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\commonheaders.h"
-#define DBEF_ALL (DBEF_FIRST | DBEF_READ | DBEF_SENT | DBEF_RTL | DBEF_UTF | DBEF_ENCRYPTED)
+#define DBEF_ALL (DBEF_READ | DBEF_SENT | DBEF_RTL | DBEF_UTF | DBEF_ENCRYPTED)
static BOOL backLookup;
static DWORD ofsThisEvent, ofsPrevEvent;
@@ -174,17 +174,15 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime)
}
if (firstTime) {
- if (!(dbeOld.flags & DBEF_FIRST)) {
+ if (dbeOld.ofsPrev != 0)
cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("First event not marked as such: correcting"));
- dbeOld.flags |= DBEF_FIRST;
- }
- dbeOld.ofsPrev = ofsContact;
+
+ dbeOld.ofsPrev = 0;
lastTimestamp = dbeOld.timestamp;
}
- else if (dbeOld.flags & DBEF_FIRST) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event marked as first which is not: correcting"));
- dbeOld.flags &= ~DBEF_FIRST;
- }
+
+ if (dbeOld.flags & 1)
+ dbeOld.flags &= ~1;
if (dbeOld.flags & ~DBEF_ALL) {
cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Extra flags found in event: removing"));
@@ -309,8 +307,7 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime)
// insert before FIRST
if (found == 1 && !cb->bCheckOnly) {
- dbeNew->flags |= DBEF_FIRST;
- dbeNew->ofsPrev = ofsContact;
+ dbeNew->ofsPrev = 0;
dbeNew->ofsNext = dbc->ofsFirstEvent;
ofsDestThis = WriteEvent(dbeNew);
@@ -325,8 +322,6 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime)
WriteOfsNextToPrevious(0, dbc, ofsDestThis);
// fix next event
WriteSegment(dbeNew->ofsNext + offsetof(DBEvent, ofsPrev), &ofsDestThis, sizeof(DWORD));
- dbeTmp.flags &= ~DBEF_FIRST;
- WriteSegment(dbeNew->ofsNext + offsetof(DBEvent, flags), &dbeTmp.flags, sizeof(DWORD));
}
else if (found == 2 && !cb->bCheckOnly) {
dbeNew->ofsPrev = ofsTmp;