diff options
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 1 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 16 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/contactchain.cpp | 6 |
3 files changed, 19 insertions, 4 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index bdc60424f6..7d8fc5a143 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -289,7 +289,6 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) }
// remove any traces of history from sub
- dbSub->eventCount = 0;
dbSub->ofsFirstEvent = dbSub->ofsLastEvent = dbSub->ofsFirstUnread = dbSub->tsFirstUnread = 0;
}
__except (EXCEPTION_EXECUTE_HANDLER)
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 7513348cad..7be737b1ba 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -46,12 +46,14 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) dbe.cbBlob = dbei->cbBlob;
BYTE *pBlob = dbei->pBlob;
+ DBCachedContact *ccSub = NULL;
if (contactID != 0) {
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (cc == NULL)
return NULL;
if (cc->IsSub()) {
+ ccSub = cc;
// set default sub to the event's source
db_mc_setDefault(cc->parentID, contactID);
contactID = cc->parentID; // and add an event to a metahistory
@@ -137,6 +139,11 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) }
else neednotify = m_safetyMode;
+ if (ccSub != NULL) {
+ DBContact *pSub = (DBContact*)DBRead(ccSub->dwDriverData, sizeof(DBContact), NULL);
+ pSub->eventCount++;
+ }
+
DBWrite(ofsContact, &dbc, sizeof(DBContact));
DBWrite(ofsNew, &dbe, offsetof(DBEvent, blob));
DBWrite(ofsNew + offsetof(DBEvent, blob), pBlob, dbe.cbBlob);
@@ -224,6 +231,15 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) //decrement event count
dbc.eventCount--;
DBWrite(ofsContact, &dbc, sizeof(DBContact));
+
+ // also update a sub
+ if (dbc.dwContactID != contactID) {
+ DBCachedContact *cc = m_cache->GetCachedContact(dbc.dwContactID);
+ DBContact *pSub = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL);
+ if (pSub->eventCount > 0)
+ pSub->eventCount--;
+ }
+
DBFlush(0);
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp index 979071fad4..f1ba3ebe61 100644 --- a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp @@ -70,7 +70,7 @@ LBL_FinishUp: contactCount++;
phase++; first = 1;
- //fall thru
+ // fall thru
case 1:
ret = WorkSettingsChain(ofsDestThis, &dbc, first);
if (ret == ERROR_NO_MORE_ITEMS) {
@@ -79,7 +79,7 @@ LBL_FinishUp: else if (ret) return ret;
else break;
- //fall thru
+ // fall thru
case 2:
ret = WorkEventChain(ofsDestThis, &dbc, first);
if (ret == ERROR_NO_MORE_ITEMS) {
@@ -88,7 +88,7 @@ LBL_FinishUp: else if (ret) return ret;
else break;
- //fall thru
+ // fall thru
case 3:
if (WriteSegment(ofsDestThis, &dbc, sizeof(DBContact)) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
|