diff options
author | aunsane <aunsane@gmail.com> | 2018-11-01 16:15:37 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-11-01 16:15:37 +0300 |
commit | 9e3ee25d2f62ed95477616c2e15ddacdaa3f8ce2 (patch) | |
tree | c8522e869e0085c824ea1acce9a6a3b4a8989e5d /plugins/Dbx_sqlite/src/dbcontacts.cpp | |
parent | 7bdaaf97bc309212bab3a49d4e70af69222208fd (diff) |
dbx_sqlite:
- remove settings and events with contact
- code cleanup
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbcontacts.cpp')
-rw-r--r-- | plugins/Dbx_sqlite/src/dbcontacts.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp index ad4ed0ec7c..e2bef8664a 100644 --- a/plugins/Dbx_sqlite/src/dbcontacts.cpp +++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp @@ -4,13 +4,17 @@ enum { SQL_CTC_STMT_COUNT = 0, SQL_CTC_STMT_ADD, SQL_CTC_STMT_DELETE, + SQL_CTC_STMT_DELETESETTINGS, + SQL_CTC_STMT_DELETEEVENTS, SQL_CTC_STMT_NUM }; static char *ctc_stmts[SQL_CTC_STMT_NUM] = { "select count(1) from contacts limit 1;", "insert into contacts values (null);", - "delete from contacts where id = ?;" + "delete from contacts where id = ?;", + "delete from settings where contact_id = ?;", + "delete from events where contact_id = ?;" }; static sqlite3_stmt *ctc_stmts_prep[SQL_CTC_STMT_NUM] = { 0 }; @@ -94,10 +98,27 @@ LONG CDbxSQLite::DeleteContact(MCONTACT hContact) { mir_cslock lock(m_csDbAccess); - sqlite3_stmt *stmt = ctc_stmts_prep[SQL_CTC_STMT_DELETE]; + + sqlite3_stmt *stmt = ctc_stmts_prep[SQL_CTC_STMT_DELETEEVENTS]; sqlite3_bind_int64(stmt, 1, hContact); int rc = sqlite3_step(stmt); - assert(rc == SQLITE_ROW || rc == SQLITE_DONE); + assert(rc == SQLITE_DONE); + sqlite3_reset(stmt); + if (rc != SQLITE_DONE) + return 1; + + stmt = ctc_stmts_prep[SQL_CTC_STMT_DELETESETTINGS]; + sqlite3_bind_int64(stmt, 1, hContact); + rc = sqlite3_step(stmt); + assert(rc == SQLITE_DONE); + sqlite3_reset(stmt); + if (rc != SQLITE_DONE) + return 1; + + stmt = ctc_stmts_prep[SQL_CTC_STMT_DELETE]; + sqlite3_bind_int64(stmt, 1, hContact); + rc = sqlite3_step(stmt); + assert(rc == SQLITE_DONE); sqlite3_reset(stmt); if (rc != SQLITE_DONE) return 1; |