summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-07 19:10:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-07 19:10:44 +0300
commitb396750fae7f9f41043ddeb849e5cff29cbcca9c (patch)
tree64fc971e06729c748c7d1ecd9896841adf50104f /protocols/ICQ-WIM
parentc13e5563e2e248992a201466a9ce1c73b3c58808 (diff)
ICQ-WIM:
- DWORD UIN dumped and replaced everywhere with CMStringW aimId; - additional Email field removed from options, now UIN acts like email - MRA is fully supported - version bump
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r--protocols/ICQ-WIM/res/resources.rc49
-rw-r--r--protocols/ICQ-WIM/src/groupchats.cpp15
-rw-r--r--protocols/ICQ-WIM/src/http.cpp2
-rw-r--r--protocols/ICQ-WIM/src/ignore.cpp12
-rw-r--r--protocols/ICQ-WIM/src/main.cpp2
-rw-r--r--protocols/ICQ-WIM/src/options.cpp10
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp10
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp44
-rw-r--r--protocols/ICQ-WIM/src/proto.h17
-rw-r--r--protocols/ICQ-WIM/src/resource.h1
-rw-r--r--protocols/ICQ-WIM/src/server.cpp35
-rw-r--r--protocols/ICQ-WIM/src/stdafx.h2
-rw-r--r--protocols/ICQ-WIM/src/userinfo.cpp2
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp38
-rw-r--r--protocols/ICQ-WIM/src/version.h2
15 files changed, 128 insertions, 113 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc
index b2ccdc6a82..084705d83d 100644
--- a/protocols/ICQ-WIM/res/resources.rc
+++ b/protocols/ICQ-WIM/res/resources.rc
@@ -23,44 +23,40 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Dialog
//
-IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 186, 69
+IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 189, 51
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "ICQ number:",IDC_STATIC,0,2,53,8
+ LTEXT "UIN/e-mail:",IDC_STATIC,0,2,53,8
EDITTEXT IDC_UIN,54,0,131,12,ES_AUTOHSCROLL
- LTEXT "Email:",IDC_STATIC,0,18,53,8
- EDITTEXT IDC_EMAIL,54,16,131,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,0,33,53,8
- EDITTEXT IDC_PASSWORD,54,32,131,12,ES_PASSWORD | ES_AUTOHSCROLL
- PUSHBUTTON "Sign in/sign up using phone",IDC_REGISTER,42,49,142,14
+ LTEXT "Password:",IDC_STATIC,0,18,53,8
+ EDITTEXT IDC_PASSWORD,54,17,131,12,ES_PASSWORD | ES_AUTOHSCROLL
+ PUSHBUTTON "Sign in/sign up using phone",IDC_REGISTER,42,34,142,14
END
-IDD_OPTIONS_FULL DIALOGEX 0, 0, 310, 174
+IDD_OPTIONS_FULL DIALOGEX 0, 0, 310, 161
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "ICQ",IDC_STATIC,4,0,302,75
- RTEXT "ICQ number:",IDC_STATIC,12,14,51,8
+ GROUPBOX "ICQ",IDC_STATIC,4,0,302,63
+ RTEXT "UIN/e-mail:",IDC_STATIC,12,14,51,8
EDITTEXT IDC_UIN,68,12,106,12,ES_AUTOHSCROLL
- RTEXT "Email:",IDC_STATIC,12,29,51,8
- EDITTEXT IDC_EMAIL,68,27,106,12,ES_AUTOHSCROLL
- RTEXT "Password:",IDC_STATIC,12,43,51,8
- EDITTEXT IDC_PASSWORD,68,42,106,12,ES_PASSWORD | ES_AUTOHSCROLL
+ RTEXT "Password:",IDC_STATIC,12,30,51,8
+ EDITTEXT IDC_PASSWORD,68,29,106,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Do not open chat windows on creation",IDC_HIDECHATS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,61,285,10
- GROUPBOX "Advanced",IDC_STATIC,4,75,302,77
- LTEXT "If a contact goes Offline, set this status instead and cache it for given timeout in seconds (0 - disabled)",IDC_STATIC,12,88,204,23
- EDITTEXT IDC_DIFF1,221,85,54,12,ES_AUTOHSCROLL
- CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,84,11,14
- COMBOBOX IDC_STATUS1,221,100,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "After that, set this status to a contact and move it offline after specified timeout in seconds (0 - disabled)",IDC_STATIC,12,121,204,23
- EDITTEXT IDC_DIFF2,221,118,54,12,ES_AUTOHSCROLL
- CONTROL "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,117,11,14
- COMBOBOX IDC_STATUS2,221,133,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Sign in/sign up using phone",IDC_REGISTER,165,155,142,14
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,48,285,10
+ GROUPBOX "Advanced",IDC_STATIC,4,62,302,77
+ LTEXT "If a contact goes Offline, set this status instead and cache it for given timeout in seconds (0 - disabled)",IDC_STATIC,12,75,204,23
+ EDITTEXT IDC_DIFF1,221,72,54,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,71,11,14
+ COMBOBOX IDC_STATUS1,221,87,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "After that, set this status to a contact and move it offline after specified timeout in seconds (0 - disabled)",IDC_STATIC,12,108,204,23
+ EDITTEXT IDC_DIFF2,221,105,54,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,104,11,14
+ COMBOBOX IDC_STATUS2,221,120,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Sign in/sign up using phone",IDC_REGISTER,165,143,142,14
END
IDD_GROUPCHAT_INVITE DIALOGEX 0, 0, 215, 263
@@ -128,11 +124,12 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS_ACCMGR, DIALOG
BEGIN
+ RIGHTMARGIN, 186
END
IDD_OPTIONS_FULL, DIALOG
BEGIN
- BOTTOMMARGIN, 169
+ BOTTOMMARGIN, 156
END
IDD_GROUPCHAT_INVITE, DIALOG
diff --git a/protocols/ICQ-WIM/src/groupchats.cpp b/protocols/ICQ-WIM/src/groupchats.cpp
index 5d4253bc15..7d61b15407 100644
--- a/protocols/ICQ-WIM/src/groupchats.cpp
+++ b/protocols/ICQ-WIM/src/groupchats.cpp
@@ -40,7 +40,7 @@ void CIcqProto::LoadChatInfo(SESSION_INFO *si)
gce.ptszNick = nick;
gce.ptszUID = sn;
gce.time = ::time(0);
- gce.bIsMe = _wtoi(sn) == (int)m_dwUin;
+ gce.bIsMe = sn == m_szOwnId;
gce.ptszStatus = TranslateW(role);
Chat_Event(&gce);
@@ -136,7 +136,7 @@ public:
bool OnApply() override
{
- CMStringA szMembers;
+ CMStringW szMembers;
for (auto &hContact : m_proto->AccContacts()) {
if (m_proto->isChatRoom(hContact))
continue;
@@ -151,7 +151,7 @@ public:
}
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/mchat/AddChat");
- pReq << CHAR_PARAM("f", "json") << WCHAR_PARAM("chat_id", m_si->ptszID) << CHAR_PARAM("aimsid", m_proto->m_aimsid) << CHAR_PARAM("r", pReq->m_reqId) << CHAR_PARAM("members", szMembers);
+ pReq << CHAR_PARAM("f", "json") << WCHAR_PARAM("chat_id", m_si->ptszID) << CHAR_PARAM("aimsid", m_proto->m_aimsid) << CHAR_PARAM("r", pReq->m_reqId) << WCHAR_PARAM("members", szMembers);
m_proto->Push(pReq);
return true;
}
@@ -258,10 +258,9 @@ void CIcqProto::Chat_ProcessLogMenu(SESSION_INFO *si, int iChoice)
void CIcqProto::Chat_SendPrivateMessage(GCHOOK *gch)
{
MCONTACT hContact;
- DWORD dwUin = _wtoi(gch->ptszUID);
- auto *pCache = FindContactByUIN(dwUin);
+ auto *pCache = FindContactByUIN(gch->ptszUID);
if (pCache == nullptr) {
- hContact = CreateContact(dwUin, true);
+ hContact = CreateContact(gch->ptszUID, true);
setWString(hContact, "Nick", gch->ptszNick);
db_set_b(hContact, "CList", "Hidden", 1);
db_set_dw(hContact, "Ignore", "Mask1", 0);
@@ -289,14 +288,14 @@ void CIcqProto::ProcessGroupChat(const JSONNode &ev)
if (member.IsEmpty())
break;
- auto *pCache = FindContactByUIN(_wtoi(member));
+ auto *pCache = FindContactByUIN(member);
if (pCache == nullptr)
continue;
gce.ptszNick = Clist_GetContactDisplayName(pCache->m_hContact);
gce.ptszUID = member;
gce.time = ::time(0);
- gce.bIsMe = _wtoi(member) == (int)m_dwUin;
+ gce.bIsMe = member == m_szOwnId;
Chat_Event(&gce);
}
}
diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp
index 7e262d659d..e31cc46fe8 100644
--- a/protocols/ICQ-WIM/src/http.cpp
+++ b/protocols/ICQ-WIM/src/http.cpp
@@ -144,7 +144,7 @@ void CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
if (pReq->m_conn == CONN_RAPI) {
- CMStringA szAgent(FORMAT, "%d Mail.ru Windows ICQ (version 10.0.1999)", DWORD(m_dwUin));
+ CMStringA szAgent(FORMAT, "%S Mail.ru Windows ICQ (version 10.0.1999)", (wchar_t*)m_szOwnId);
pReq->AddHeader("User-Agent", szAgent);
if (m_szRToken.IsEmpty()) {
diff --git a/protocols/ICQ-WIM/src/ignore.cpp b/protocols/ICQ-WIM/src/ignore.cpp
index a7617506d6..435cd5b417 100644
--- a/protocols/ICQ-WIM/src/ignore.cpp
+++ b/protocols/ICQ-WIM/src/ignore.cpp
@@ -95,7 +95,7 @@ public:
for (auto &it : pData["ignores"]) {
CMStringW wszId(it.as_mstring());
- auto *p = m_proto->FindContactByUIN(_wtoi(wszId));
+ auto *p = m_proto->FindContactByUIN(wszId);
if (p) {
lvi.pszText = Clist_GetContactDisplayName(p->m_hContact);
lvi.lParam = p->m_hContact;
@@ -127,7 +127,7 @@ public:
if (IDYES != MessageBoxW(m_hwnd, TranslateT("Do you really want to remove it from ignore list?"), m_proto->m_tszUserName, MB_YESNO))
return;
- CMStringA userId;
+ CMStringW userId;
INT_PTR data = m_list.GetItemData(hti.iItem);
if (data == -1) {
wchar_t buf[100];
@@ -185,13 +185,13 @@ void CIcqProto::ProcessPermissions(const JSONNode &ev)
it->m_iApparentMode = 0;
for (auto &it : ev["allows"]) {
- auto *p = FindContactByUIN(_wtoi(it.as_mstring()));
+ auto *p = FindContactByUIN(it.as_mstring());
if (p)
p->m_iApparentMode = ID_STATUS_ONLINE;
}
for (auto &it : ev["ignores"]) {
- auto *p = FindContactByUIN(_wtoi(it.as_mstring()));
+ auto *p = FindContactByUIN(it.as_mstring());
if (p)
p->m_iApparentMode = ID_STATUS_OFFLINE;
}
@@ -207,10 +207,10 @@ void CIcqProto::ProcessPermissions(const JSONNode &ev)
}
}
-void CIcqProto::SetPermitDeny(const CMStringA &userId, bool bAllow)
+void CIcqProto::SetPermitDeny(const CMStringW &userId, bool bAllow)
{
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/preference/setPermitDeny");
pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("r", pReq->m_reqId)
- << CHAR_PARAM((bAllow) ? "pdIgnoreRemove" : "pdIgnore", userId);
+ << WCHAR_PARAM((bAllow) ? "pdIgnoreRemove" : "pdIgnore", userId);
Push(pReq);
}
diff --git a/protocols/ICQ-WIM/src/main.cpp b/protocols/ICQ-WIM/src/main.cpp
index c0428cb7d0..d3175491ac 100644
--- a/protocols/ICQ-WIM/src/main.cpp
+++ b/protocols/ICQ-WIM/src/main.cpp
@@ -41,7 +41,7 @@ static PLUGININFOEX pluginInfoEx = {
CMPlugin::CMPlugin() :
ACCPROTOPLUGIN<CIcqProto>(MODULENAME, pluginInfoEx)
{
- SetUniqueId(DB_KEY_UIN);
+ SetUniqueId(DB_KEY_ID);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp
index 68b3ea8520..1f4ba7a39c 100644
--- a/protocols/ICQ-WIM/src/options.cpp
+++ b/protocols/ICQ-WIM/src/options.cpp
@@ -146,7 +146,7 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
m_szSessionKey = data["sessionKey"].as_mstring();
setString(DB_KEY_SESSIONKEY, m_szSessionKey);
- m_dwUin = _wtoi(data["loginId"].as_mstring());
+ m_szOwnId = data["loginId"].as_mstring();
setByte(DB_KEY_PHONEREG, 1);
}
@@ -154,7 +154,7 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto>
{
- CCtrlEdit edtUin, edtEmail, edtPassword, edtDiff1, edtDiff2;
+ CCtrlEdit edtUin, edtPassword, edtDiff1, edtDiff2;
CCtrlSpin spin1, spin2;
CCtrlCombo cmbStatus1, cmbStatus2;
CCtrlCheck chkHideChats;
@@ -167,7 +167,6 @@ public:
spin1(this, IDC_SPIN1, 3600),
spin2(this, IDC_SPIN2, 3600),
edtUin(this, IDC_UIN),
- edtEmail(this, IDC_EMAIL),
edtDiff1(this, IDC_DIFF1),
edtDiff2(this, IDC_DIFF2),
btnCreate(this, IDC_REGISTER),
@@ -181,8 +180,7 @@ public:
edtDiff1.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Timeout1);
edtDiff2.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Timeout2);
- CreateLink(edtUin, ppro->m_dwUin);
- CreateLink(edtEmail, ppro->m_szEmail);
+ CreateLink(edtUin, ppro->m_szOwnId);
CreateLink(edtPassword, ppro->m_szPassword);
if (bFullDlg) {
CreateLink(spin1, ppro->m_iTimeDiff1);
@@ -211,8 +209,6 @@ public:
onChange_Timeout1(0);
}
- if (m_proto->m_dwUin == 0)
- edtUin.SetText(L"");
return true;
}
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index b25dd4c71e..907505dc28 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -143,7 +143,7 @@ void CIcqProto::ProcessHistData(const JSONNode &ev)
else LoadChatInfo(si);
}
}
- else hContact = CreateContact(_wtol(wszId), true);
+ else hContact = CreateContact(wszId, true);
__int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID);
if (lastMsgId == 0) {
@@ -200,9 +200,9 @@ void CIcqProto::ProcessMyInfo(const JSONNode &ev)
void CIcqProto::ProcessPresence(const JSONNode &ev)
{
- DWORD dwUin = _wtol(ev["aimId"].as_mstring());
+ CMStringW aimId = ev["aimId"].as_mstring();
- IcqCacheItem *pCache = FindContactByUIN(dwUin);
+ IcqCacheItem *pCache = FindContactByUIN(aimId);
if (pCache) {
int iNewStatus = StatusFromString(ev["state"].as_mstring());
@@ -227,10 +227,10 @@ void CIcqProto::ProcessPresence(const JSONNode &ev)
void CIcqProto::ProcessTyping(const JSONNode &ev)
{
- DWORD dwUin = _wtol(ev["aimId"].as_mstring());
+ CMStringW aimId = ev["aimId"].as_mstring();
CMStringW wszStatus = ev["typingStatus"].as_mstring();
- IcqCacheItem *pCache = FindContactByUIN(dwUin);
+ IcqCacheItem *pCache = FindContactByUIN(aimId);
if (pCache) {
if (wszStatus == "typing")
CallService(MS_PROTO_CONTACTISTYPING, pCache->m_hContact, 60);
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 2e225891c4..ba57b37cdc 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -33,15 +33,19 @@
#pragma warning(disable:4355)
+static int CompareCache(const IcqCacheItem *p1, const IcqCacheItem *p2)
+{
+ return mir_wstrcmp(p1->m_aimid, p2->m_aimid);
+}
+
CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) :
PROTO<CIcqProto>(aProtoName, aUserName),
m_arHttpQueue(10),
m_arOwnIds(1, PtrKeySortT),
- m_arCache(20, NumericKeySortT),
+ m_arCache(20, &CompareCache),
arMarkReadQueue(10, NumericKeySortT),
m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
- m_dwUin(this, DB_KEY_UIN, 0),
- m_szEmail(this, "Email"),
+ m_szOwnId(this, DB_KEY_ID),
m_iStatus1(this, "Status1", ID_STATUS_AWAY),
m_iStatus2(this, "Status2", ID_STATUS_NA),
m_iTimeDiff1(this, "TimeDiff1", 0),
@@ -88,6 +92,20 @@ CIcqProto::~CIcqProto()
void CIcqProto::OnModulesLoaded()
{
+ DWORD dwUin = getDword("UIN", -1);
+ if (dwUin != -1) {
+ delSetting("UIN");
+
+ wchar_t buf[100];
+ _itow(dwUin, buf, 10);
+ m_szOwnId = buf;
+ }
+ else {
+ CMStringW wszEmail(getMStringW("Email"));
+ if (!wszEmail.IsEmpty())
+ m_szOwnId = wszEmail;
+ }
+
InitContactCache();
GCREGISTER gcr = {};
@@ -108,12 +126,12 @@ void CIcqProto::OnShutdown()
void CIcqProto::OnContactDeleted(MCONTACT hContact)
{
- CMStringA szId(GetUserId(hContact));
+ CMStringW szId(GetUserId(hContact));
if (!isChatRoom(hContact))
- m_arCache.remove(FindContactByUIN(atoi(szId)));
+ m_arCache.remove(FindContactByUIN(szId));
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/removeBuddy");
- pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("buddy", szId)
+ pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << WCHAR_PARAM("buddy", szId)
<< CHAR_PARAM("r", pReq->m_reqId) << INT_PARAM("allGroups", 1);
pReq->flags |= NLHRF_NODUMPSEND;
Push(pReq);
@@ -185,7 +203,7 @@ void CIcqProto::MarkReadTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD)
auto *pReq = new AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER);
JSONNode request, params; params.set_name("params");
- params << CHAR_PARAM("sn", ppro->GetUserId(pUser->m_hContact)) << INT64_PARAM("lastRead", ppro->getId(pUser->m_hContact, DB_KEY_LASTMSGID));
+ params << WCHAR_PARAM("sn", ppro->GetUserId(pUser->m_hContact)) << INT64_PARAM("lastRead", ppro->getId(pUser->m_hContact, DB_KEY_LASTMSGID));
request << CHAR_PARAM("method", "setDlgStateWim") << CHAR_PARAM("reqId", pReq->m_reqId)
<< CHAR_PARAM("authToken", ppro->m_szRToken) << INT_PARAM("clientId", ppro->m_iRClientId) << params;
pReq->m_szParam = ptrW(json_write(&request));
@@ -210,7 +228,7 @@ int CIcqProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
if (m_bOnline) {
SetTimer(g_hwndHeartbeat, UINT_PTR(this), 200, &CIcqProto::MarkReadTimerProc);
- IcqCacheItem *pCache = FindContactByUIN(getDword(hContact, DB_KEY_UIN));
+ IcqCacheItem *pCache = FindContactByUIN(GetUserId(hContact));
if (pCache) {
mir_cslock lck(csMarkReadQueue);
if (arMarkReadQueue.indexOf(pCache) == -1)
@@ -256,9 +274,7 @@ MCONTACT CIcqProto::AddToList(int, PROTOSEARCHRESULT *psr)
if (mir_wstrlen(psr->id.w) == 0)
return 0;
- DWORD dwUin = _wtol(psr->id.w);
-
- MCONTACT hContact = CreateContact(dwUin, true);
+ MCONTACT hContact = CreateContact(psr->id.w, true);
if (psr->nick.w)
setWString(hContact, "Nick", psr->nick.w);
if (psr->firstName.w)
@@ -276,7 +292,7 @@ int CIcqProto::AuthRequest(MCONTACT hContact, const wchar_t* szMessage)
{
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, ICQ_API_SERVER "/buddylist/addBuddy", &CIcqProto::OnAddBuddy);
pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("r", pReq->m_reqId) << WCHAR_PARAM("authorizationMsg", szMessage)
- << CHAR_PARAM("buddy", GetUserId(hContact)) << CHAR_PARAM("group", "General") << INT_PARAM("preAuthorized", 1);
+ << WCHAR_PARAM("buddy", GetUserId(hContact)) << CHAR_PARAM("group", "General") << INT_PARAM("preAuthorized", 1);
pReq->flags |= NLHRF_NODUMPSEND;
pReq->hContact = hContact;
Push(pReq);
@@ -430,7 +446,7 @@ int CIcqProto::SetStatus(int iNewStatus)
m_iStatus = ID_STATUS_CONNECTING;
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
- if (m_dwUin == 0 && mir_wstrlen(m_szEmail) == 0) {
+ if (mir_wstrlen(m_szOwnId) == 0) {
debugLogA("Thread ended, UIN/password are not configured");
ConnectionFailed(LOGINERR_BADUSERID);
return 0;
@@ -484,7 +500,7 @@ int CIcqProto::UserIsTyping(MCONTACT hContact, int type)
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/im/setTyping");
pReq->flags |= NLHRF_NODUMPSEND;
pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("f", "json")
- << CHAR_PARAM("t", GetUserId(hContact)) << CHAR_PARAM("r", pReq->m_reqId)
+ << WCHAR_PARAM("t", GetUserId(hContact)) << CHAR_PARAM("r", pReq->m_reqId)
<< CHAR_PARAM("typingStatus", (type == PROTOTYPE_SELFTYPING_ON) ? "typing" : "typed");
Push(pReq);
return 0;
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index 7bae6ec031..564865f7db 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -55,12 +55,12 @@ enum ChatMenuItems
struct IcqCacheItem
{
- IcqCacheItem(DWORD _uin, MCONTACT _contact) :
- m_uin(_uin),
+ IcqCacheItem(const CMStringW &wszId, MCONTACT _contact) :
+ m_aimid(wszId),
m_hContact(_contact)
{}
- DWORD m_uin;
+ CMStringW m_aimid;
MCONTACT m_hContact;
bool m_bInList = false;
int m_iApparentMode;
@@ -250,8 +250,8 @@ class CIcqProto : public PROTO<CIcqProto>
OBJLIST<IcqCacheItem> m_arCache;
void InitContactCache(void);
- IcqCacheItem* FindContactByUIN(DWORD);
- MCONTACT CreateContact(DWORD dwUin, bool bTemporary);
+ IcqCacheItem* FindContactByUIN(const CMStringW &pwszId);
+ MCONTACT CreateContact(const CMStringW &pwszId, bool bTemporary);
void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen);
@@ -317,8 +317,7 @@ public:
CIcqProto(const char*, const wchar_t*);
~CIcqProto();
- CMOption<DWORD> m_dwUin; // our own id
- CMOption<wchar_t*> m_szEmail; // email, if present
+ CMOption<wchar_t*> m_szOwnId; // our own aim id
CMOption<wchar_t*> m_szPassword; // password, if present
CMOption<BYTE> m_bHideGroupchats; // don't pop up group chat windows on startup
CMOption<DWORD> m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs
@@ -327,10 +326,10 @@ public:
CMOption<DWORD> m_iStatus2;
void CheckStatus(void);
- CMStringA GetUserId(MCONTACT);
+ CMStringW GetUserId(MCONTACT);
int __cdecl OnContactMenu(WPARAM, LPARAM);
- void SetPermitDeny(const CMStringA &userId, bool bAllow);
+ void SetPermitDeny(const CMStringW &userId, bool bAllow);
};
struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto>
diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h
index ee3336bc9e..9d8b7a0d2f 100644
--- a/protocols/ICQ-WIM/src/resource.h
+++ b/protocols/ICQ-WIM/src/resource.h
@@ -22,7 +22,6 @@
#define IDC_NICK 1012
#define IDC_MEMBERSINCE 1013
#define IDC_LASTSEEN 1014
-#define IDC_EMAIL 1015
#define IDC_LIST 1016
#define IDC_DIFF1 1017
#define IDC_SPIN1 1018
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 3a5004addf..8c4fc52b78 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -80,17 +80,13 @@ void CIcqProto::CheckPassword()
char mirVer[100];
Miranda_GetVersionText(mirVer, _countof(mirVer));
- CMStringW wszId(m_szEmail);
- if (wszId.IsEmpty())
- wszId.Format(L"%d", (DWORD)m_dwUin);
-
m_szAToken = getMStringA(DB_KEY_ATOKEN);
m_iRClientId = getDword(DB_KEY_RCLIENTID);
m_szSessionKey = getMStringA(DB_KEY_SESSIONKEY);
if (m_szAToken.IsEmpty() || m_szSessionKey.IsEmpty()) {
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, "https://api.login.icq.net/auth/clientLogin", &CIcqProto::OnCheckPassword);
pReq << CHAR_PARAM("clientName", "Miranda NG") << CHAR_PARAM("clientVersion", mirVer) << CHAR_PARAM("devId", ICQ_APP_ID)
- << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << WCHAR_PARAM("s", wszId) << WCHAR_PARAM("pwd", m_szPassword);
+ << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << WCHAR_PARAM("s", m_szOwnId) << WCHAR_PARAM("pwd", m_szPassword);
pReq->flags |= NLHRF_NODUMPSEND;
Push(pReq);
}
@@ -161,7 +157,7 @@ void CIcqProto::MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup,
{
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/moveBuddy");
pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("r", pReq->m_reqId)
- << CHAR_PARAM("buddy", GetUserId(hContact)) << WCHAR_PARAM("group", pwszGroup) << WCHAR_PARAM("newGroup", pwszNewGroup);
+ << WCHAR_PARAM("buddy", GetUserId(hContact)) << WCHAR_PARAM("group", pwszGroup) << WCHAR_PARAM("newGroup", pwszNewGroup);
Push(pReq);
}
@@ -209,10 +205,11 @@ void CIcqProto::OnLoggedOut()
MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact)
{
// user chat?
- if (buddy["userType"].as_mstring() == "interop") {
+ CMStringW wszId(buddy["aimId"].as_mstring());
+ if (IsChat(wszId)) {
CMStringW wszChatId(buddy["aimId"].as_mstring());
CMStringW wszChatName(buddy["friendly"].as_mstring());
-
+
SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszChatId, wszChatName);
if (si == nullptr)
return INVALID_CONTACT_ID;
@@ -223,12 +220,10 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact)
Chat_Control(m_szModuleName, wszChatId, SESSION_ONLINE);
return si->hContact;
}
-
- DWORD dwUin = _wtol(buddy["aimId"].as_mstring());
-
+
if (hContact == -1) {
- hContact = CreateContact(dwUin, false);
- FindContactByUIN(dwUin)->m_bInList = true;
+ hContact = CreateContact(wszId, false);
+ FindContactByUIN(wszId)->m_bInList = true;
}
bool bVersionDetected = false;
@@ -353,7 +348,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
gce.ptszUID = wszSender;
gce.ptszText = wszText;
gce.time = iMsgTime;
- gce.bIsMe = _wtoi(wszSender) == (int)m_dwUin;
+ gce.bIsMe = wszSender == m_szOwnId;
Chat_Event(&gce);
}
else {
@@ -397,7 +392,7 @@ bool CIcqProto::RefreshRobustToken()
tmp->pData = tmp->m_szParam.Detach();
tmp->szUrl = tmp->m_szUrl.GetBuffer();
- CMStringA szAgent(FORMAT, "%d Mail.ru Windows ICQ (version 10.0.1999)", DWORD(m_dwUin));
+ CMStringA szAgent(FORMAT, "%S Mail.ru Windows ICQ (version 10.0.1999)", (wchar_t*)m_szOwnId);
tmp->AddHeader("User-Agent", szAgent);
NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, tmp);
@@ -434,9 +429,9 @@ void CIcqProto::RetrieveUserInfo(MCONTACT hContact)
pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << INT_PARAM("mdir", 1) << INT_PARAM("capabilities", 1);
if (hContact == INVALID_CONTACT_ID)
for (auto &it : m_arCache)
- pReq << CHAR_PARAM("t", GetUserId(it->m_hContact));
+ pReq << WCHAR_PARAM("t", GetUserId(it->m_hContact));
else
- pReq << CHAR_PARAM("t", GetUserId(hContact));
+ pReq << WCHAR_PARAM("t", GetUserId(hContact));
Push(pReq);
}
@@ -456,7 +451,7 @@ void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, __int
pReq->hContact = hContact;
JSONNode request, params; params.set_name("params");
- params << CHAR_PARAM("sn", GetUserId(hContact)) << INT64_PARAM("fromMsgId", startMsgId);
+ params << WCHAR_PARAM("sn", GetUserId(hContact)) << INT64_PARAM("fromMsgId", startMsgId);
if (endMsgId != -1)
params << INT64_PARAM("tillMsgId", endMsgId);
params << INT_PARAM("count", 1000) << CHAR_PARAM("aimSid", m_aimsid) << CHAR_PARAM("patchVersion", "1") << CHAR_PARAM("language", "ru-ru");
@@ -606,9 +601,9 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
m_szSessionKey = ptrA(mir_base64_encode(hashOut, sizeof(hashOut)));
setString(DB_KEY_SESSIONKEY, m_szSessionKey);
- CMStringA szUin = data["loginId"].as_mstring();
+ CMStringW szUin = data["loginId"].as_mstring();
if (szUin)
- m_dwUin = atoi(szUin);
+ m_szOwnId = szUin;
StartSession();
}
diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h
index c651820f1e..1116920bfc 100644
--- a/protocols/ICQ-WIM/src/stdafx.h
+++ b/protocols/ICQ-WIM/src/stdafx.h
@@ -80,7 +80,7 @@
#define MODULENAME "ICQ"
-#define DB_KEY_UIN "UIN"
+#define DB_KEY_ID "aimId"
#define DB_KEY_IDLE "IdleTS"
#define DB_KEY_ABOUT "About"
#define DB_KEY_ATOKEN "AToken"
diff --git a/protocols/ICQ-WIM/src/userinfo.cpp b/protocols/ICQ-WIM/src/userinfo.cpp
index 6cc56fefb2..f30cbc37cd 100644
--- a/protocols/ICQ-WIM/src/userinfo.cpp
+++ b/protocols/ICQ-WIM/src/userinfo.cpp
@@ -33,7 +33,7 @@ static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
CIcqProto *ppro = (CIcqProto*)((PSHNOTIFY*)lParam)->lParam;
- SetDlgItemTextA(hwndDlg, IDC_UIN, ppro->GetUserId(hContact));
+ SetDlgItemTextW(hwndDlg, IDC_UIN, ppro->GetUserId(hContact));
SetDlgItemTextW(hwndDlg, IDC_NICK, ppro->getMStringW(hContact, DB_KEY_ICQNICK));
SetDlgItemTextA(hwndDlg, IDC_IDLETIME, time2text(ppro->getDword(hContact, DB_KEY_IDLE)));
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index afebaba7f4..cd5265674f 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -23,27 +23,41 @@
void CIcqProto::InitContactCache()
{
mir_cslock l(m_csCache);
- for (auto &it : AccContacts())
- if (!isChatRoom(it))
- m_arCache.insert(new IcqCacheItem(getDword(it, DB_KEY_UIN), it));
+ for (auto &it : AccContacts()) {
+ if (isChatRoom(it))
+ continue;
+
+ DWORD dwUin = getDword(it, "UIN", -1);
+ if (dwUin != -1) {
+ delSetting(it, "UIN");
+
+ wchar_t buf[100];
+ _itow(dwUin, buf, 10);
+ setWString(it, DB_KEY_ID, buf);
+ }
+
+ m_arCache.insert(new IcqCacheItem(GetUserId(it), it));
+ }
}
-IcqCacheItem* CIcqProto::FindContactByUIN(DWORD dwUin)
+IcqCacheItem* CIcqProto::FindContactByUIN(const CMStringW &wszId)
{
+ IcqCacheItem tmp(wszId, -1);
+
mir_cslock l(m_csCache);
- return m_arCache.find((IcqCacheItem*)&dwUin);
+ return m_arCache.find(&tmp);
}
-MCONTACT CIcqProto::CreateContact(DWORD dwUin, bool bTemporary)
+MCONTACT CIcqProto::CreateContact(const CMStringW &wszId, bool bTemporary)
{
- auto *pCache = FindContactByUIN(dwUin);
+ auto *pCache = FindContactByUIN(wszId);
if (pCache != nullptr)
return pCache->m_hContact;
MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
- setDword(hContact, DB_KEY_UIN, dwUin);
- pCache = new IcqCacheItem(dwUin, hContact);
+ setWString(hContact, DB_KEY_ID, wszId);
+ pCache = new IcqCacheItem(wszId, hContact);
{
mir_cslock l(m_csCache);
m_arCache.insert(pCache);
@@ -211,12 +225,12 @@ INT_PTR __cdecl CIcqProto::SetAvatar(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-CMStringA CIcqProto::GetUserId(MCONTACT hContact)
+CMStringW CIcqProto::GetUserId(MCONTACT hContact)
{
if (isChatRoom(hContact))
- return getMStringA(hContact, "ChatRoomID");
+ return getMStringW(hContact, "ChatRoomID");
- return CMStringA(FORMAT, "%d", getDword(hContact, DB_KEY_UIN));
+ return getMStringW(hContact, DB_KEY_ID);
}
bool IsChat(const CMStringW &aimid)
diff --git a/protocols/ICQ-WIM/src/version.h b/protocols/ICQ-WIM/src/version.h
index 3c290b0655..9a15a7e5ae 100644
--- a/protocols/ICQ-WIM/src/version.h
+++ b/protocols/ICQ-WIM/src/version.h
@@ -1,6 +1,6 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
-#define __RELEASE_NUM 10
+#define __RELEASE_NUM 11
#define __BUILD_NUM 1
#include <stdver.h>