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/Dbx_sqlite | |
parent | 802cbbae257dca16957d9b7e028be1d0d468e097 (diff) |
stupid schema with event handles sharing via CreateEventHook eliminated
Diffstat (limited to 'plugins/Dbx_sqlite')
-rw-r--r-- | plugins/Dbx_sqlite/src/dbcontacts.cpp | 4 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbevents.cpp | 10 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.cpp | 17 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.h | 9 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbsettings.cpp | 6 |
5 files changed, 10 insertions, 36 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp index 882b04d30e..7800e8b09a 100644 --- a/plugins/Dbx_sqlite/src/dbcontacts.cpp +++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp @@ -81,7 +81,7 @@ MCONTACT CDbxSQLite::AddContact() DBCachedContact *cc = m_cache->AddContactToCache(hContact); if (cc == nullptr) return INVALID_CONTACT_ID; - NotifyEventHooks(hContactAddedEvent, hContact); + NotifyEventHooks(g_hevEventAdded, hContact); return hContact; } @@ -104,7 +104,7 @@ LONG CDbxSQLite::DeleteContact(MCONTACT hContact) } m_cache->FreeCachedContact(hContact); - NotifyEventHooks(hContactDeletedEvent, hContact); + NotifyEventHooks(g_hevEventDeleted, hContact); return 0; } diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 0bdec1190f..0bde038173 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -115,7 +115,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, DBEVENTINFO *dbei) return 0; if (m_safetyMode) - if (NotifyEventHooks(hEventFilterAddedEvent, hNotifyContact, (LPARAM)dbei)) + if (NotifyEventHooks(g_hevEventFiltered, hNotifyContact, (LPARAM)dbei)) return 0; MEVENT hDbEvent = 0; @@ -174,7 +174,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, DBEVENTINFO *dbei) } if (m_safetyMode) - NotifyEventHooks(hEventAddedEvent, hNotifyContact, (LPARAM)hDbEvent); + NotifyEventHooks(g_hevEventAdded, hNotifyContact, (LPARAM)hDbEvent); return hDbEvent; } @@ -207,7 +207,7 @@ BOOL CDbxSQLite::DeleteEvent(MCONTACT hContact, MEVENT hDbEvent) cc->first = cc->unread = cc->last = 0; } - NotifyEventHooks(hEventDeletedEvent, hContact, (LPARAM)hDbEvent); + NotifyEventHooks(g_hevEventDeleted, hContact, (LPARAM)hDbEvent); return 0; } @@ -239,7 +239,7 @@ BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, DBEVENTINFO *dbei assert(rc == SQLITE_ROW || rc == SQLITE_DONE); if (rc == SQLITE_DONE) { cc->first = cc->unread = cc->last = 0; - NotifyEventHooks(hEventEditedEvent, hContact, (LPARAM)hDbEvent); + NotifyEventHooks(g_hevEventEdited, hContact, (LPARAM)hDbEvent); } sqlite3_reset(stmt); return (rc != SQLITE_DONE); @@ -346,7 +346,7 @@ BOOL CDbxSQLite::MarkEventRead(MCONTACT hContact, MEVENT hDbEvent) cc->unread = 0; } - NotifyEventHooks(hEventMarkedRead, hContact, (LPARAM)hDbEvent); + NotifyEventHooks(g_hevMarkedRead, hContact, (LPARAM)hDbEvent); return flags; } diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp index dc204d1b4e..35445fc017 100644 --- a/plugins/Dbx_sqlite/src/dbintf.cpp +++ b/plugins/Dbx_sqlite/src/dbintf.cpp @@ -4,27 +4,10 @@ CDbxSQLite::CDbxSQLite(sqlite3 *database) : m_db(database), m_safetyMode(true) { - hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED); - hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED); - hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED); - hEventEditedEvent = CreateHookableEvent(ME_DB_EVENT_EDITED); - hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED); - hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD); - hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ); - hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED); } CDbxSQLite::~CDbxSQLite() { - DestroyHookableEvent(hContactAddedEvent); - DestroyHookableEvent(hContactDeletedEvent); - DestroyHookableEvent(hEventAddedEvent); - DestroyHookableEvent(hEventEditedEvent); - DestroyHookableEvent(hEventDeletedEvent); - DestroyHookableEvent(hEventFilterAddedEvent); - DestroyHookableEvent(hEventMarkedRead); - DestroyHookableEvent(hSettingChangeEvent); - UninitEvents(); UninitContacts(); UninitSettings(); diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index 98c07991ce..85bf3106c5 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -19,15 +19,6 @@ struct CDbxSQLite : public MDatabaseCommon, public MZeroedObject private: sqlite3 *m_db; - HANDLE hContactAddedEvent; - HANDLE hContactDeletedEvent; - HANDLE hEventAddedEvent; - HANDLE hEventEditedEvent; - HANDLE hEventDeletedEvent; - HANDLE hEventFilterAddedEvent; - HANDLE hEventMarkedRead; - HANDLE hSettingChangeEvent; - DBCachedContact m_system; bool m_safetyMode; diff --git a/plugins/Dbx_sqlite/src/dbsettings.cpp b/plugins/Dbx_sqlite/src/dbsettings.cpp index 8008e451d8..964226ba9a 100644 --- a/plugins/Dbx_sqlite/src/dbsettings.cpp +++ b/plugins/Dbx_sqlite/src/dbsettings.cpp @@ -246,7 +246,7 @@ BOOL CDbxSQLite::WriteContactSetting(MCONTACT hContact, DBCONTACTWRITESETTING *d } if (isResident) { lock.unlock(); - NotifyEventHooks(hSettingChangeEvent, hContact, (LPARAM)&dbcwWork); + NotifyEventHooks(g_hevSettingChanged, hContact, (LPARAM)&dbcwWork); return 0; } } @@ -282,7 +282,7 @@ BOOL CDbxSQLite::WriteContactSetting(MCONTACT hContact, DBCONTACTWRITESETTING *d lock.unlock(); - NotifyEventHooks(hSettingChangeEvent, hContact, (LPARAM)&dbcwNotif); + NotifyEventHooks(g_hevSettingChanged, hContact, (LPARAM)&dbcwNotif); return 0; } @@ -324,7 +324,7 @@ BOOL CDbxSQLite::DeleteContactSetting(MCONTACT hContact, LPCSTR szModule, LPCSTR dbcws.szModule = szModule; dbcws.szSetting = szSetting; dbcws.value.type = DBVT_DELETED; - NotifyEventHooks(hSettingChangeEvent, hContact, (LPARAM)&dbcws); + NotifyEventHooks(g_hevSettingChanged, hContact, (LPARAM)&dbcws); return 0; } |