From 850c49bb75c0ac93c3a082cc51f82912309923df Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Apr 2021 13:18:11 +0300 Subject: dbx_sqlite: implemented database checker + version bump --- plugins/Dbx_sqlite/src/dbevents.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'plugins/Dbx_sqlite/src/dbevents.cpp') diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index b277bbbfbc..cbfa67485a 100755 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -149,6 +149,28 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei) return hDbEvent; } +///////////////////////////////////////////////////////////////////////////////////////// + +int CDbxSQLite::DeleteEventMain(MEVENT hDbEvent) +{ + auto *stmt = InitQuery("DELETE FROM events WHERE id = ?;", qEvDel); + sqlite3_bind_int64(stmt, 1, hDbEvent); + int rc = sqlite3_step(stmt); + logError(rc, __FILE__, __LINE__); + sqlite3_reset(stmt); + return rc; +} + +int CDbxSQLite::DeleteEventSrt(MEVENT hDbEvent) +{ + auto *stmt = InitQuery("DELETE FROM events_srt WHERE id = ?;", qEvDelSrt); + sqlite3_bind_int64(stmt, 1, hDbEvent); + int rc = sqlite3_step(stmt); + logError(rc, __FILE__, __LINE__); + sqlite3_reset(stmt); + return rc; +} + BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) { if (hDbEvent == 0) @@ -160,19 +182,11 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) return 1; mir_cslockfull lock(m_csDbAccess); - sqlite3_stmt *stmt = InitQuery("DELETE FROM events WHERE id = ?;", qEvDel); - sqlite3_bind_int64(stmt, 1, hDbEvent); - int rc = sqlite3_step(stmt); - logError(rc, __FILE__, __LINE__); - sqlite3_reset(stmt); + int rc = DeleteEventMain(hDbEvent); if (rc != SQLITE_DONE) return 1; - stmt = InitQuery("DELETE FROM events_srt WHERE id = ?;", qEvDelSrt); - sqlite3_bind_int64(stmt, 1, hDbEvent); - rc = sqlite3_step(stmt); - logError(rc, __FILE__, __LINE__); - sqlite3_reset(stmt); + rc = DeleteEventSrt(hDbEvent); if (rc != SQLITE_DONE) return 1; @@ -187,6 +201,8 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO *dbei) { if (dbei == nullptr) -- cgit v1.2.3