diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-28 20:30:46 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-28 20:30:46 +0300 |
commit | 3e34adae711d9ddf79b4959143a696b6a403a522 (patch) | |
tree | aebc8cc38c164558e6da1d9c30971592045e1617 /protocols/Discord/src/server.cpp | |
parent | e7a87b3c82204e048f23750a18b456e567a6f436 (diff) |
first version that logs in successfully
Diffstat (limited to 'protocols/Discord/src/server.cpp')
-rw-r--r-- | protocols/Discord/src/server.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 4b7c2afa13..62d2dfb17c 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -24,10 +24,30 @@ void CDiscordProto::RetrieveMyInfo() void CDiscordProto::SetServerStatus(int iStatus) { + if (!m_bOnline) + return; + int iOldStatus = m_iStatus; m_iStatus = iStatus; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); } -void CDiscordProto::OnReceiveToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) +void CDiscordProto::OnReceiveToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) { - + if (pReply->resultCode != 200) { +LBL_Error: + ConnectionFailed(LOGINERR_WRONGPASSWORD); + return; + } + + JSONNode *root = json_parse(pReply->pData); + if (root == NULL) + goto LBL_Error; + + CMStringA szToken = root->at("token").as_mstring(); + if (szToken.IsEmpty()) + goto LBL_Error; + + m_szAccessToken = szToken.Detach(); + setString("AccessToken", m_szAccessToken); + OnLoggedIn(); } |