summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-11 17:20:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-11 17:20:13 +0300
commit7fb93c40e30b6a88b1e8de5dfa09284aca50a891 (patch)
tree8bc40765d888d8340944577fd4396c617e6ffbc9 /plugins
parentc12e67f2ede11bb39e722895bffd258b03fe3b7a (diff)
fix for importing unknown / broken subs
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Import/src/import.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index bbb39911be..2d4e756943 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -671,16 +671,27 @@ void ImportMeta(DBCachedContact *ccSrc)
if (ccDst->nSubs = ccSrc->nSubs) {
ccDst->pSubs = (MCONTACT*)mir_alloc(sizeof(MCONTACT)*ccSrc->nSubs);
for (int i = 0; i < ccSrc->nSubs; i++) {
- ccDst->pSubs[i] = MapContact(ccSrc->pSubs[i]);
+ MCONTACT hSub = MapContact(ccSrc->pSubs[i]);
+ if (hSub == INVALID_CONTACT_ID) {
+ hSub = db_add_contact();
+
+ DBCachedContact *ccSub = srcDb->m_cache->GetCachedContact(ccSrc->pSubs[i]);
+ if (ccSub && ccSub->szProto) {
+ Proto_AddToContact(hDest, ccSub->szProto);
+ CopySettings(ccSrc->contactID, ccSub->szProto, hSub, ccSub->szProto);
+ }
+ }
+
+ ccDst->pSubs[i] = hSub;
char szSettingName[100];
mir_snprintf(szSettingName, "Handle%d", i);
- db_set_dw(hDest, META_PROTO, szSettingName, ccDst->pSubs[i]);
+ db_set_dw(hDest, META_PROTO, szSettingName, hSub);
- db_set_b(ccDst->pSubs[i], META_PROTO, "IsSubcontact", 1);
- db_set_dw(ccDst->pSubs[i], META_PROTO, "ParentMeta", hDest);
+ db_set_b(hSub, META_PROTO, "IsSubcontact", 1);
+ db_set_dw(hSub, META_PROTO, "ParentMeta", hDest);
- DBCachedContact *ccSub = dstDb->m_cache->GetCachedContact(ccDst->pSubs[i]);
+ DBCachedContact *ccSub = dstDb->m_cache->GetCachedContact(hSub);
if (ccSub)
ccSub->parentID = hDest;
}