summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbevents.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-13 19:42:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-13 19:42:54 +0000
commit720783e4a86c5a89592847c79b4ab932f9ff6879 (patch)
tree1562c904cb15fa49c90002c7268510dccf8ede44 /plugins/Db3x_mmap/src/dbevents.cpp
parent1ad8eff2aba5649b8926bc040aad4917ce9156fe (diff)
fix for db_event_count in subs
git-svn-id: http://svn.miranda-ng.org/main/trunk@8598 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
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;
}