From f5cb8bc39cf07e9727a0a03f1dbfcc1dcbc6fe2b Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 29 Nov 2017 16:44:52 +0300 Subject: Slack: moved to deprecated --- protocols/Slack/src/slack_connection.cpp | 71 -------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 protocols/Slack/src/slack_connection.cpp (limited to 'protocols/Slack/src/slack_connection.cpp') diff --git a/protocols/Slack/src/slack_connection.cpp b/protocols/Slack/src/slack_connection.cpp deleted file mode 100644 index 17f8eb5adf..0000000000 --- a/protocols/Slack/src/slack_connection.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "stdafx.h" - -bool CSlackProto::IsOnline() -{ - return !isTerminated && m_iStatus > ID_STATUS_OFFLINE; -} - -void CSlackProto::Login() -{ - ptrA token(getStringA("TokenSecret")); - if (mir_strlen(token)) - { - PushRequest(new GetUserListRequest(token), &CSlackProto::OnGotUserList); - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus = m_iDesiredStatus); - return; - } - - CSlackOAuth oauth(this); - if (!oauth.DoModal()) - { - SetStatus(ID_STATUS_OFFLINE); - return; - } - - PushRequest(new OAuhtAccessRequest(oauth.GetAuthCode()), &CSlackProto::OnAuthorize); -} - -void CSlackProto::OnAuthorize(JSONNode &root, void*) -{ - if (!root) - { - SetStatus(ID_STATUS_OFFLINE); - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, NULL); - return; - } - - bool isOk = root["ok"].as_bool(); - if (!isOk) - { - SetStatus(ID_STATUS_OFFLINE); - json_string error = root["error"].as_string(); - debugLogA(__FUNCTION__": %s", error); - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); - return; - } - - json_string token = root["access_token"].as_string(); - setString("TokenSecret", token.c_str()); - - json_string userId = root["user_id"].as_string(); - setString("UserId", userId.c_str()); - - CMStringW teamName = root["team_name"].as_mstring(); - setWString("TeamName", teamName); - if (!teamName.IsEmpty() && !Clist_GroupExists(teamName)) - Clist_GroupCreate(0, teamName); - - json_string teamId = root["team_id"].as_string(); - setString("TeamId", userId.c_str()); - - PushRequest(new GetUserListRequest(token.c_str()), &CSlackProto::OnGotUserList); - - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus = m_iDesiredStatus); -} - -void CSlackProto::LogOut() -{ - isTerminated = true; - if (hRequestQueueThread) - SetEvent(hRequestsQueueEvent); -} \ No newline at end of file -- cgit v1.2.3