diff options
author | George Hazan <ghazan@miranda.im> | 2018-10-10 23:26:08 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-10-10 23:26:08 +0300 |
commit | 39681c2aa83e33d46598f8aeecd10370b04cf364 (patch) | |
tree | ee9ef3cb681b97f5d9f8e046add17b8356e9d7ad /plugins/Db3x_mmap | |
parent | 802cbbae257dca16957d9b7e028be1d0d468e097 (diff) |
stupid schema with event handles sharing via CreateEventHook eliminated
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 16 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 10 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.cpp | 19 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 8 |
6 files changed, 19 insertions, 40 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index f7f913368d..d2433d2d46 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -55,7 +55,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID) log0("del contact");
// call notifier while outside mutex
- NotifyEventHooks(hContactDeletedEvent, contactID, 0);
+ NotifyEventHooks(g_hevEventDeleted, contactID, 0);
// get back in
lck.lock();
@@ -136,7 +136,7 @@ STDMETHODIMP_(MCONTACT) CDb3Mmap::AddContact() DBCachedContact *cc = m_cache->AddContactToCache(dbc.dwContactID);
cc->dwOfsContact = ofsNew;
- NotifyEventHooks(hContactAddedEvent, dbc.dwContactID, 0);
+ NotifyEventHooks(g_hevEventAdded, dbc.dwContactID, 0);
return dbc.dwContactID;
}
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 777baae06e..7324df3025 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -240,10 +240,10 @@ void CDb3Mmap::SetPassword(const wchar_t *ptszPassword) void CDb3Mmap::ToggleEncryption()
{
- HANDLE hSave1 = hSettingChangeEvent; hSettingChangeEvent = nullptr;
- HANDLE hSave2 = hEventAddedEvent; hEventAddedEvent = nullptr;
- HANDLE hSave3 = hEventDeletedEvent; hEventDeletedEvent = nullptr;
- HANDLE hSave4 = hEventFilterAddedEvent; hEventFilterAddedEvent = nullptr;
+ HANDLE hSave1 = g_hevSettingChanged; g_hevSettingChanged = nullptr;
+ HANDLE hSave2 = g_hevEventAdded; g_hevEventAdded = nullptr;
+ HANDLE hSave3 = g_hevEventDeleted; g_hevEventDeleted = nullptr;
+ HANDLE hSave4 = g_hevEventFiltered; g_hevEventFiltered = nullptr;
mir_cslock lck(m_csDbAccess);
ToggleSettingsEncryption(0);
@@ -261,10 +261,10 @@ void CDb3Mmap::ToggleEncryption() dbcws.value.bVal = m_bEncrypted;
WriteContactSetting(0, &dbcws);
- hSettingChangeEvent = hSave1;
- hEventAddedEvent = hSave2;
- hEventDeletedEvent = hSave3;
- hEventFilterAddedEvent = hSave4;
+ g_hevSettingChanged = hSave1;
+ g_hevEventAdded = hSave2;
+ g_hevEventDeleted = hSave3;
+ g_hevEventFiltered = hSave4;
}
void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 3f6d575329..d781616e25 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -57,7 +57,7 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) }
}
- if (NotifyEventHooks(hEventFilterAddedEvent, contactNotifyID, (LPARAM)dbei))
+ if (NotifyEventHooks(g_hevEventFiltered, contactNotifyID, (LPARAM)dbei))
return 0;
dbe.timestamp = dbei->timestamp;
@@ -157,7 +157,7 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) // Notify only in safe mode or on really new events
if (neednotify)
- NotifyEventHooks(hEventAddedEvent, contactNotifyID, (LPARAM)ofsNew);
+ NotifyEventHooks(g_hevEventAdded, contactNotifyID, (LPARAM)ofsNew);
return (MEVENT)ofsNew;
}
@@ -185,7 +185,7 @@ BOOL CDb3Mmap::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) log1("delete event @ %08x", hContact);
// call notifier while outside mutex
- NotifyEventHooks(hEventDeletedEvent, contactID, (LPARAM)hDbEvent);
+ NotifyEventHooks(g_hevEventDeleted, contactID, (LPARAM)hDbEvent);
// get back in
lck.lock();
@@ -257,7 +257,7 @@ BOOL CDb3Mmap::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) return 0;
}
-BOOL CDb3Mmap::EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbe)
+BOOL CDb3Mmap::EditEvent(MCONTACT, MEVENT, DBEVENTINFO*)
{
return 1;
}
@@ -357,7 +357,7 @@ BOOL CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) DBFlush(0);
lck.unlock();
- NotifyEventHooks(hEventMarkedRead, contactID, (LPARAM)hDbEvent);
+ NotifyEventHooks(g_hevMarkedRead, contactID, (LPARAM)hDbEvent);
return ret;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 7cb981591f..db74e4ffef 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -90,15 +90,6 @@ CDb3Mmap::~CDb3Mmap() if (m_hDbFile != INVALID_HANDLE_VALUE)
CloseHandle(m_hDbFile);
- DestroyHookableEvent(hContactDeletedEvent);
- DestroyHookableEvent(hContactAddedEvent);
- DestroyHookableEvent(hSettingChangeEvent);
- DestroyHookableEvent(hEventMarkedRead);
-
- DestroyHookableEvent(hEventAddedEvent);
- DestroyHookableEvent(hEventDeletedEvent);
- DestroyHookableEvent(hEventFilterAddedEvent);
-
mir_free(m_tszProfileName);
free(m_pNull);
@@ -133,16 +124,6 @@ int CDb3Mmap::Load(bool bSkipInit) if (!m_bReadOnly) {
if (m_dbHeader.version < DB_095_1_VERSION)
return EGROKPRF_CANTREAD;
-
- // retrieve the event handles
- hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
- hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
- hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
- hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
-
- hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
- hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
- hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
}
FillContacts();
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index c00c6d8321..4dc7e6a8d2 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -280,7 +280,6 @@ public: protected:
DWORD m_dwFileSize, m_dwMaxContactId;
- HANDLE hSettingChangeEvent, hContactDeletedEvent, hContactAddedEvent, hEventMarkedRead;
DWORD CreateNewSpace(int bytes);
void DeleteSpace(DWORD ofs, int bytes);
@@ -309,7 +308,6 @@ protected: HANDLE m_hModHeap;
LIST<ModuleName> m_lMods, m_lOfs;
- HANDLE hEventAddedEvent, hEventDeletedEvent, hEventFilterAddedEvent;
MCONTACT m_hLastCachedContact;
ModuleName *m_lastmn;
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 299fd1cefd..4db0770ff5 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -329,7 +329,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTW if (bIsResident) {
lck.unlock();
log2(" set resident as %s (%p)", printVariant(&dbcwWork.value), pCachedValue);
- NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwWork);
+ NotifyEventHooks(g_hevSettingChanged, contactID, (LPARAM)&dbcwWork);
return 0;
}
}
@@ -437,7 +437,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTW DBFlush(1);
lck.unlock();
// notify
- NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif);
+ NotifyEventHooks(g_hevSettingChanged, contactID, (LPARAM)&dbcwNotif);
return 0;
}
}
@@ -537,7 +537,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTW lck.unlock();
// notify
- NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif);
+ NotifyEventHooks(g_hevSettingChanged, contactID, (LPARAM)&dbcwNotif);
return 0;
}
@@ -627,7 +627,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz dbcws.szModule = szModule;
dbcws.szSetting = szSetting;
dbcws.value.type = DBVT_DELETED;
- NotifyEventHooks(hSettingChangeEvent, saveContact, (LPARAM)&dbcws);
+ NotifyEventHooks(g_hevSettingChanged, saveContact, (LPARAM)&dbcws);
return 0;
}
|