summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-10 12:48:32 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-10 12:48:32 +0300
commit8a241ad63bf5d3ed0ac1d30dc9e257ca2b60d23e (patch)
tree32c1fb0425656fb72e5b3c33043355b29b966d69 /plugins
parent8a93bd50466b767582f8251f65b53ded89fbf526 (diff)
fixes problems with importing ICQ & MRA contacts from old Miranda versions
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Import/src/import.cpp73
1 files changed, 35 insertions, 38 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 7bd3746c4f..81d7a9d1f8 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -772,48 +772,45 @@ static MCONTACT ImportContact(MCONTACT hSrc)
}
}
+ wchar_t *pszUniqueID = L"<Unknown>";
DBVARIANT dbv;
- if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) {
- AddMessage(LPGENW("Skipping %S contact, ID not found"), cc->szProto);
- return 0;
- }
-
- // Does the contact already exist?
- MCONTACT hDst;
- wchar_t id[40], *pszUniqueID;
- switch (dbv.type) {
- case DBVT_DWORD:
- pszUniqueID = _ltow(dbv.dVal, id, 10);
- hDst = HContactFromNumericID(szDstModuleName, pszUniqueSetting, dbv.dVal);
- break;
+ if (!myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) {
+ // Does the contact already exist?
+ MCONTACT hDst;
+ wchar_t id[40];
+ switch (dbv.type) {
+ case DBVT_DWORD:
+ pszUniqueID = _ltow(dbv.dVal, id, 10);
+ hDst = HContactFromNumericID(szDstModuleName, pszUniqueSetting, dbv.dVal);
+ break;
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- pszUniqueID = NEWWSTR_ALLOCA(_A2T(dbv.pszVal));
- if (bIsChat)
- hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
- else
- hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
- break;
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ pszUniqueID = NEWWSTR_ALLOCA(_A2T(dbv.pszVal));
+ if (bIsChat)
+ hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
+ else
+ hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
+ break;
- case DBVT_WCHAR:
- pszUniqueID = NEWWSTR_ALLOCA(dbv.pwszVal);
- if (bIsChat)
- hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
- else
- hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
- break;
+ case DBVT_WCHAR:
+ pszUniqueID = NEWWSTR_ALLOCA(dbv.pwszVal);
+ if (bIsChat)
+ hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
+ else
+ hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
+ break;
- default:
- hDst = INVALID_CONTACT_ID;
- pszUniqueID = nullptr;
- }
+ default:
+ hDst = INVALID_CONTACT_ID;
+ }
- if (hDst != INVALID_CONTACT_ID) {
- AddMessage(LPGENW("Skipping duplicate %S contact %s"), cc->szProto, pszUniqueID);
- srcDb->FreeVariant(&dbv);
- arContactMap.insert(new ContactMap(hSrc, hDst));
- return 0;
+ if (hDst != INVALID_CONTACT_ID) {
+ AddMessage(LPGENW("Skipping duplicate %S contact %s"), cc->szProto, pszUniqueID);
+ srcDb->FreeVariant(&dbv);
+ arContactMap.insert(new ContactMap(hSrc, hDst));
+ return 0;
+ }
}
ptrW tszGroup(myGetWs(hSrc, "CList", "Group")), tszNick(myGetWs(hSrc, "CList", "MyHandle"));
@@ -821,7 +818,7 @@ static MCONTACT ImportContact(MCONTACT hSrc)
tszNick = myGetWs(hSrc, cc->szProto, "Nick");
// adding missing contact
- hDst = db_add_contact();
+ MCONTACT hDst = db_add_contact();
if (Proto_AddToContact(hDst, szDstModuleName) != 0) {
db_delete_contact(hDst);
AddMessage(LPGENW("Failed to add %S contact %s"), szDstModuleName, pszUniqueID);