From 8aa736c7efd509ca88679fbabb644e49f2c5ef07 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Mar 2014 11:29:13 +0000 Subject: proper conversion of previously created metacontacts git-svn-id: http://svn.miranda-ng.org/main/trunk@8374 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcontacts.cpp | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'plugins/Db3x_mmap/src/dbcontacts.cpp') diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 7d2e9aad52..fcfd56afb9 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -221,6 +221,8 @@ void CDb3Mmap::ConvertContacts() else pPrev->ofsNext = dwNew; pPrev = pNew; + + m_contactsMap.insert(new ConvertedContact(dwOffset, pNew->dwContactID)); dwOffset = pNew->ofsNext; } @@ -253,31 +255,39 @@ void CDb3Mmap::FillContacts() 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; + MCONTACT hSub = (0 != GetContactSetting(dwContactID, META_PROTO, setting, &dbv)) ? NULL : dbv.dVal; + ConvertedContact *pcc = m_contactsMap.find((ConvertedContact*)&hSub); + if (pcc != NULL) { + hSub = pcc->hNew; + + DBCONTACTWRITESETTING dbws = { META_PROTO, setting }; + dbws.value.type = DBVT_DWORD; + dbws.value.dVal = hSub; + WriteContactSetting(dwContactID, &dbws); + } + cc->pSubs[i] = hSub; } } cc->activeID = (0 != GetContactSetting(dwContactID, META_PROTO, "Default", &dbv)) ? NULL : dbv.dVal; cc->parentID = (0 != GetContactSetting(dwContactID, META_PROTO, "Handle", &dbv)) ? NULL : dbv.dVal; - #ifdef _DEBUG - // 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); + // whether we need conversion or not + if (!GetContactSetting(dwContactID, META_PROTO, "MetaID", &dbv)) { + // we don't need it anymore + DeleteContactSetting(dwContactID, META_PROTO, "MetaID"); - // wipe out old data from subcontacts - DeleteContactSetting(cc->pSubs[i], META_PROTO, "ContactNumber"); - DeleteContactSetting(cc->pSubs[i], META_PROTO, "MetaLink"); - } + 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"); } - #endif + } dwOffset = p->ofsNext; } -- cgit v1.2.3