summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/dbcontacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_sqlite/src/dbcontacts.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp
index 2bcc0027c8..6a8568e2cb 100644
--- a/plugins/Dbx_sqlite/src/dbcontacts.cpp
+++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp
@@ -24,10 +24,13 @@ void CDbxSQLite::InitContacts()
//m_cache->AddContactToCache(0);
sqlite3_stmt *stmt = nullptr;
- sqlite3_prepare_v2(m_db, "select id from contacts;", -1, &stmt, nullptr);
+ sqlite3_prepare_v2(m_db, "select contact_events.contactid, count(eventid) from contact_events join contacts on contacts.id = contact_events.contactid group by contact_events.contactid;", -1, &stmt, nullptr);
while (sqlite3_step(stmt) == SQLITE_ROW) {
MCONTACT hContact = sqlite3_column_int64(stmt, 0);
- DBCachedContact *cc = m_cache->AddContactToCache(hContact);
+ DBCachedContact *cc = (hContact)
+ ? m_cache->AddContactToCache(hContact)
+ : &m_system;
+ cc->count = sqlite3_column_int64(stmt, 1);
DBVARIANT dbv = { DBVT_DWORD };
cc->nSubs = (0 != GetContactSetting(cc->contactID, META_PROTO, "NumContacts", &dbv)) ? -1 : dbv.dVal;