From f02dcd42ac54c448d5a3af69be87d971326b61b8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jul 2024 17:21:05 +0300 Subject: =?UTF-8?q?fixes=20#4553=20(NewStory:=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=BB=D0=B5=D0=BC=D0=B0=20=D1=81=20=D0=BF=D0=BE=D0=B4=D1=81?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=BE=D0=BC=20=D1=87=D0=B8=D1=81=D0=BB=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9=20=D0=B2=20=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=D0=BC=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Dbx_sqlite/src/dbcontacts.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'plugins/Dbx_sqlite/src/dbcontacts.cpp') 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() -- cgit v1.2.3