summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbevents.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Db3x_mmap/src/dbevents.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp16
1 files changed, 16 insertions, 0 deletions
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;
}