From 2cbc7f36727cc86800c0866df859a0ab473b678e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Mar 2014 14:35:33 +0000 Subject: to convert metas we must wait for the end of contact cache filling git-svn-id: http://svn.miranda-ng.org/main/trunk@8379 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcontacts.cpp | 43 ++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'plugins') diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 5420037b90..ebdc9c6cfd 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -240,6 +240,8 @@ void CDb3Mmap::ConvertContacts() void CDb3Mmap::FillContacts() { + LIST arMetas(10); + for (DWORD dwOffset = m_dbHeader.ofsFirstContact; dwOffset != 0;) { DBContact *p = (DBContact*)DBRead(dwOffset, sizeof(DBContact), NULL); if (p->signature != DBCONTACT_SIGNATURE) @@ -281,25 +283,34 @@ void CDb3Mmap::FillContacts() cc->parentID = (0 != GetContactSetting(dwContactID, META_PROTO, "Handle", &dbv)) ? NULL : dbv.dVal; // whether we need conversion or not - if (!GetContactSetting(dwContactID, META_PROTO, "MetaID", &dbv)) { - // we don't need it anymore - DeleteContactSetting(dwContactID, META_PROTO, "MetaID"); - - for (int i = 0; i < cc->nSubs; i++) { - // store contact id instead of the old mc number - DBCONTACTWRITESETTING dbws = { META_PROTO, "ParentMeta" }; - dbws.value.type = DBVT_DWORD; - dbws.value.dVal = dwContactID; - WriteContactSetting(cc->pSubs[i], &dbws); - - // wipe out old data from subcontacts - DeleteContactSetting(cc->pSubs[i], META_PROTO, "ContactNumber"); - DeleteContactSetting(cc->pSubs[i], META_PROTO, "MetaLink"); - } - } + if (!GetContactSetting(dwContactID, META_PROTO, "MetaID", &dbv)) + arMetas.insert((void*)dwContactID); dwOffset = p->ofsNext; } + + for (int i = 0; i < arMetas.getCount(); i++) { + MCONTACT hContact = (MCONTACT)arMetas[i]; + DBCachedContact *cc = m_cache->GetCachedContact(hContact); + if (cc == NULL) + continue; + + // we don't need it anymore + DeleteContactSetting(hContact, META_PROTO, "MetaID"); + + for (int k = 0; k < cc->nSubs; k++) { + // store contact id instead of the old mc number + DBCONTACTWRITESETTING dbws = { META_PROTO, "ParentMeta" }; + dbws.value.type = DBVT_DWORD; + dbws.value.dVal = hContact; + WriteContactSetting(cc->pSubs[k], &dbws); + + // wipe out old data from subcontacts + DeleteContactSetting(cc->pSubs[k], META_PROTO, "ContactNumber"); + DeleteContactSetting(cc->pSubs[k], META_PROTO, "IsSubcontact"); + DeleteContactSetting(cc->pSubs[k], META_PROTO, "MetaLink"); + } + } } DWORD CDb3Mmap::GetContactOffset(MCONTACT contactID) -- cgit v1.2.3