diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-03 11:29:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-03 11:29:13 +0000 |
commit | 8aa736c7efd509ca88679fbabb644e49f2c5ef07 (patch) | |
tree | afe231c5d9cb348d8402a3d1a70601be4b739b58 /plugins/Db3x_mmap | |
parent | d49f0bbe4eb6974bac650206effa7fdf58ea970b (diff) |
proper conversion of previously created metacontacts
git-svn-id: http://svn.miranda-ng.org/main/trunk@8374 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 46 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.cpp | 3 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 13 |
3 files changed, 43 insertions, 19 deletions
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;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 377c353bde..c17fdd0e05 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -50,7 +50,8 @@ CDb3Mmap::CDb3Mmap(const TCHAR *tszFileName, bool bReadOnly) : m_dwMaxContactId(1),
m_lMods(50, ModCompare),
m_lOfs(50, OfsCompare),
- m_lResidentSettings(50, stringCompare2)
+ m_lResidentSettings(50, stringCompare2),
+ m_contactsMap(50, NumericKeySortT)
{
m_tszProfileName = mir_tstrdup(tszFileName);
InitDbInstance(this);
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 6cb02f0344..6be58c9634 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -164,6 +164,14 @@ struct DBEvent #include <poppack.h>
+struct ConvertedContact
+{
+ ConvertedContact(MCONTACT _old, MCONTACT _new) :
+ hOld(_old), hNew(_new) {}
+
+ MCONTACT hOld, hNew;
+};
+
struct CDb3Mmap : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDb3Mmap(const TCHAR *tszFileName, bool bReadOnly);
@@ -292,6 +300,11 @@ protected: int m_codePage;
////////////////////////////////////////////////////////////////////////////
+ // contacts
+
+ OBJLIST<ConvertedContact> m_contactsMap;
+
+ ////////////////////////////////////////////////////////////////////////////
// modules
HANDLE m_hModHeap;
|