From 0094bfe3eff72016d0a2dd039d93cc3ff3fcf273 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 29 Sep 2014 21:31:04 +0000 Subject: hot plugging metas after import git-svn-id: http://svn.miranda-ng.org/main/trunk@10645 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Import/src/import.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 3626aaacda..d2cbb2f39f 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -431,6 +431,30 @@ void ImportMeta(DBCachedContact *cc) hDest = CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, hDest, (LPARAM)META_PROTO); + CopySettings(cc->contactID, META_PROTO, hDest, META_PROTO); + + ccDst = dstDb->m_cache->GetCachedContact(hDest); + if (ccDst) { + ccDst->nDefault = cc->nDefault; + if (ccDst->nSubs = cc->nSubs) { + ccDst->pSubs = (MCONTACT*)mir_alloc(sizeof(MCONTACT)*cc->nSubs); + for (int i = 0; i < cc->nSubs; i++) { + ccDst->pSubs[i] = MapContact(cc->pSubs[i]); + + char szSettingName[100]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "Handle%d", i); + db_set_dw(hDest, META_PROTO, szSettingName, ccDst->pSubs[i]); + + db_set_b(ccDst->pSubs[i], META_PROTO, "IsSubcontact", 1); + db_set_dw(ccDst->pSubs[i], META_PROTO, "ParentMeta", hDest); + + DBCachedContact *ccSub = dstDb->m_cache->GetCachedContact(ccDst->pSubs[i]); + if (ccSub) + ccSub->parentID = hDest; + } + } + } + ptrT tszGroup(myGetWs(cc->contactID, "CList", "Group")), tszNick(myGetWs(cc->contactID, "CList", "MyHandle")); if (tszNick == NULL) tszNick = myGetWs(cc->contactID, cc->szProto, "Nick"); @@ -442,13 +466,6 @@ void ImportMeta(DBCachedContact *cc) AddMessage(LPGENT("Added metacontact '%s'"), tszNick); } else AddMessage(LPGENT("Added metacontact")); - - CopySettings(cc->contactID, META_PROTO, hDest, META_PROTO); - for (int i = 0; i < cc->nSubs; i++) { - char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "Handle%d", i); - db_set_dw(hDest, META_PROTO, szSettingName, MapContact(cc->pSubs[i])); - } } else hDest = ccDst->contactID; -- cgit v1.2.3