summaryrefslogtreecommitdiff
path: root/protocols/Slack/src/slack_connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Slack/src/slack_connection.cpp')
-rw-r--r--protocols/Slack/src/slack_connection.cpp71
1 files changed, 0 insertions, 71 deletions
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