diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-13 14:32:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-13 14:32:47 +0300 |
commit | 35b895bb4d280991cf172c89ab61010edb36e31d (patch) | |
tree | ba654d9b46ee535f86ca32dcf6f22036a84daee7 /protocols/ICQ-WIM/src/utils.cpp | |
parent | c88b18efc8b4b3a84cac866dc9de4f424a05dbcb (diff) |
fixes #1895 (problem with importing old ICQ profiles where UIN was in the form of email)
Diffstat (limited to 'protocols/ICQ-WIM/src/utils.cpp')
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index 7004bfa6c1..1fe0e684b4 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -27,14 +27,13 @@ void CIcqProto::InitContactCache() if (isChatRoom(it)) continue; - DWORD dwUin = getDword(it, "UIN", -1); - if (dwUin != -1) { + // that was previously an ICQ contact + ptrW wszUin(GetUIN(it)); + if (wszUin != nullptr) { delSetting(it, "UIN"); - - wchar_t buf[100]; - _itow(dwUin, buf, 10); - setWString(it, DB_KEY_ID, buf); + setWString(it, DB_KEY_ID, wszUin); } + // that was previously a MRA contact else { CMStringW wszEmail(getMStringW(it, "e-mail")); if (!wszEmail.IsEmpty()) { @@ -55,6 +54,31 @@ IcqCacheItem* CIcqProto::FindContactByUIN(const CMStringW &wszId) return m_arCache.find(&tmp); } +wchar_t* CIcqProto::GetUIN(MCONTACT hContact) +{ + DBVARIANT dbv = {}; + if (!db_get_s(hContact, m_szModuleName, "UIN", &dbv)) { + switch (dbv.type) { + case DBVT_DWORD: + wchar_t buf[40], *ret; + _itow_s(dbv.dVal, buf, 10); + return mir_wstrdup(buf); + + case DBVT_ASCIIZ: + ret = mir_a2u(dbv.pszVal); + db_free(&dbv); + return ret; + + case DBVT_UTF8: + ret = mir_utf8decodeW(dbv.pszVal); + db_free(&dbv); + return ret; + } + db_free(&dbv); + } + return nullptr; +} + MCONTACT CIcqProto::CreateContact(const CMStringW &wszId, bool bTemporary) { auto *pCache = FindContactByUIN(wszId); |