summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/dbevents.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbevents.cpp')
-rwxr-xr-xplugins/Dbx_sqlite/src/dbevents.cpp36
1 files changed, 26 insertions, 10 deletions
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)