summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbcontacts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-18 16:47:07 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-18 16:47:07 +0000
commitcdad72e9512d163ed15bc89bd0a93e7da2ee4c50 (patch)
treef2b6f3e70745bfcb4aeb9b28d7db16016014feae /plugins/Dbx_mdb/src/dbcontacts.cpp
parent23344057b3fb532ad37ed5f761c2b31ab6ad017c (diff)
first working version of events
git-svn-id: http://svn.miranda-ng.org/main/trunk@11872 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index 48c8b7e7cb..cf13a782b9 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -171,38 +171,44 @@ BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
void CDbxMdb::FillContacts()
{
- m_contactCount = 0;
+ LIST<DBCachedContact> arContacts(10);
txn_ptr trnlck(m_pMdbEnv);
mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
+ {
+ cursor_ptr cursor(trnlck, m_dbContacts);
- cursor_ptr cursor(trnlck, m_dbContacts);
+ MDB_val key, data;
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
+ DBContact *dbc = (DBContact*)data.mv_data;
+ if (dbc->signature != DBCONTACT_SIGNATURE)
+ DatabaseCorruption(NULL);
- MDB_val key, data;
- while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
- DBContact *dbc = (DBContact*)data.mv_data;
- if (dbc->signature != DBCONTACT_SIGNATURE)
- DatabaseCorruption(NULL);
+ DBCachedContact *cc = m_cache->AddContactToCache(*(DWORD*)key.mv_data);
+ cc->dwDriverData = dbc->eventCount;
+ arContacts.insert(cc);
+ }
+ }
- DWORD dwContactId = *(DWORD*)key.mv_data;
- DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
- cc->dwDriverData = 0;
+ m_contactCount = 0;
+ for (int i = 0; i < arContacts.getCount(); i++) {
+ DBCachedContact *cc = arContacts[i];
CheckProto(cc, "");
-
- m_dwMaxContactId = dwContactId + 1;
+
+ m_dwMaxContactId = cc->contactID+1;
m_contactCount++;
DBVARIANT dbv; dbv.type = DBVT_DWORD;
- cc->nSubs = (0 != GetContactSetting(dwContactId, META_PROTO, "NumContacts", &dbv)) ? -1 : dbv.dVal;
+ cc->nSubs = (0 != GetContactSetting(cc->contactID, META_PROTO, "NumContacts", &dbv)) ? -1 : dbv.dVal;
if (cc->nSubs != -1) {
cc->pSubs = (MCONTACT*)mir_alloc(cc->nSubs*sizeof(MCONTACT));
for (int i = 0; i < cc->nSubs; i++) {
char setting[100];
mir_snprintf(setting, SIZEOF(setting), "Handle%d", i);
- cc->pSubs[i] = (0 != GetContactSetting(dwContactId, META_PROTO, setting, &dbv)) ? NULL : dbv.dVal;
+ cc->pSubs[i] = (0 != GetContactSetting(cc->contactID, META_PROTO, setting, &dbv)) ? NULL : dbv.dVal;
}
}
- cc->nDefault = (0 != GetContactSetting(dwContactId, META_PROTO, "Default", &dbv)) ? -1 : dbv.dVal;
- cc->parentID = (0 != GetContactSetting(dwContactId, META_PROTO, "ParentMeta", &dbv)) ? NULL : dbv.dVal;
+ cc->nDefault = (0 != GetContactSetting(cc->contactID, META_PROTO, "Default", &dbv)) ? -1 : dbv.dVal;
+ cc->parentID = (0 != GetContactSetting(cc->contactID, META_PROTO, "ParentMeta", &dbv)) ? NULL : dbv.dVal;
}
}