diff options
-rw-r--r-- | plugins/Dbx_sqlite/src/dbcontacts.cpp | 16 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbevents.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.h | 3 |
3 files changed, 15 insertions, 6 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp index db392d303d..7f847c44bb 100644 --- a/plugins/Dbx_sqlite/src/dbcontacts.cpp +++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp @@ -14,11 +14,17 @@ void CDbxSQLite::InitContacts() logError(rc, __FILE__, __LINE__);
sqlite3_finalize(stmt);
- sqlite3_prepare_v2(m_db, "SELECT COUNT(1) FROM events_srt WHERE contact_id=0;", -1, &stmt, nullptr);
- rc = sqlite3_step(stmt);
- logError(rc, __FILE__, __LINE__);
- m_system.m_count = sqlite3_column_int64(stmt, 0);
- sqlite3_finalize(stmt);
+ m_system.m_count = GetContactEventCount(0);
+}
+
+int CDbxSQLite::GetContactEventCount(MCONTACT hContact)
+{
+ auto *stmt = InitQuery("SELECT COUNT(1) FROM events_srt WHERE contact_id = ?;", qCntCountEvents);
+ sqlite3_bind_int64(stmt, 1, hContact);
+ logError(sqlite3_step(stmt), __FILE__, __LINE__);
+ int count = sqlite3_column_int64(stmt, 0);
+ sqlite3_reset(stmt);
+ return count;
}
int CDbxSQLite::GetContactCount()
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 38a3546098..3071373b5b 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -713,6 +713,8 @@ BOOL CDbxSQLite::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSu sqlite3_reset(stmt);
if (rc != SQLITE_DONE)
return FALSE;
+
+ ccMeta->m_count = GetContactEventCount(ccMeta->contactID);
}
DBFlush();
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index 40fffafda1..ab45361bdf 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -69,7 +69,8 @@ class CDbxSQLite : public MDatabaseCommon, public MIDatabaseChecker, public MZer // contacts
void InitContacts();
- CQuery qCntCount, qCntAdd, qCntDel, qCntDelSettings, qCntDelEvents, qCntDelEventSrt;
+ int GetContactEventCount(MCONTACT hContact);
+ CQuery qCntCount, qCntAdd, qCntDel, qCntDelSettings, qCntCountEvents, qCntDelEvents, qCntDelEventSrt;
// encryption
void InitEncryption();
|