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 | |
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')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 10 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 36 |
3 files changed, 36 insertions, 11 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index e48d7b5c89..05574fef89 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -96,17 +96,17 @@ CIcqProto::~CIcqProto() void CIcqProto::OnModulesLoaded() { - DWORD dwUin = getDword("UIN", -1); - if (dwUin != -1) { + // this was previously an old ICQ account + ptrW wszUin(GetUIN(0)); + if (wszUin != nullptr) { delSetting("UIN"); - wchar_t buf[100]; - _itow(dwUin, buf, 10); - m_szOwnId = buf; + m_szOwnId = wszUin; for (auto &it : AccContacts()) delSetting(it, "e-mail"); } + // this was previously an old MRA account else { CMStringW wszEmail(getMStringW("e-mail")); if (!wszEmail.IsEmpty()) { diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 40f0475fbf..5a27d13893 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -167,6 +167,7 @@ class CIcqProto : public PROTO<CIcqProto> void ConnectionFailed(int iReason, int iErrorCode = 0); void EmailNotification(const wchar_t *pwszText); void GetPermitDeny(); + wchar_t* GetUIN(MCONTACT hContact); void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId = -1); void RetrieveUserInfo(MCONTACT = INVALID_CONTACT_ID); 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); |