summaryrefslogtreecommitdiff
path: root/protocols/Teams/src/teams_endpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Teams/src/teams_endpoint.cpp')
-rw-r--r--protocols/Teams/src/teams_endpoint.cpp122
1 files changed, 2 insertions, 120 deletions
diff --git a/protocols/Teams/src/teams_endpoint.cpp b/protocols/Teams/src/teams_endpoint.cpp
index c53c6f8eea..c29bc64ff9 100644
--- a/protocols/Teams/src/teams_endpoint.cpp
+++ b/protocols/Teams/src/teams_endpoint.cpp
@@ -76,135 +76,17 @@ void CTeamsProto::OnEndpointCreated(MHttpResponse *response, AsyncHttpRequest*)
else if (name == "endpointId") {
val.Replace("{", "");
val.Replace("}", "");
- m_szEndpoint = val.Detach();
+ m_szEndpoint = val;
}
}
}
SetServerStatus(m_iDesiredStatus);
StartTrouter();
- PushRequest(new CreateSubscriptionsRequest());
}
void CTeamsProto::OnEndpointDeleted(MHttpResponse *, AsyncHttpRequest *)
{
- m_szEndpoint = nullptr;
+ m_szEndpoint.Empty();
m_szToken = nullptr;
}
-
-void CTeamsProto::OnSubscriptionsCreated(MHttpResponse *response, AsyncHttpRequest*)
-{
- if (response == nullptr) {
- debugLogA(__FUNCTION__ ": failed to create subscription");
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, 1001);
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- SendPresence();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest *)
-{
- if (response == nullptr || response->body.IsEmpty()) {
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, 1001);
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- LIST<char> skypenames(1);
- for (auto &hContact : AccContacts())
- if (!isChatRoom(hContact))
- skypenames.insert(getId(hContact).Detach());
-
- PushRequest(new CreateContactsSubscriptionRequest(skypenames));
- FreeList(skypenames);
- skypenames.destroy();
-
- ReceiveAvatar(0);
- PushRequest(new AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/contacts", &CTeamsProto::LoadContactList));
- PushRequest(new SyncConversations());
-
- JSONNode root = JSONNode::parse(response->body);
- if (root)
- m_szOwnSkypeId = UrlToSkypeId(root["selfLink"].as_string().c_str()).Detach();
-
- PushRequest(new GetProfileRequest(this, 0));
-}
-
-void CTeamsProto::SendPresence()
-{
- ptrA epname;
-
- if (!m_bUseHostnameAsPlace && m_wstrPlace && *m_wstrPlace)
- epname = mir_utf8encodeW(m_wstrPlace);
- else {
- wchar_t compName[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = _countof(compName);
- GetComputerName(compName, &size);
- epname = mir_utf8encodeW(compName);
- }
-
- JSONNode privateInfo; privateInfo.set_name("privateInfo");
- privateInfo << CHAR_PARAM("epname", epname);
-
- JSONNode publicInfo; publicInfo.set_name("publicInfo");
- publicInfo << CHAR_PARAM("capabilities", "Audio|Video") << INT_PARAM("typ", 125)
- << CHAR_PARAM("skypeNameVersion", "Miranda NG Skype") << CHAR_PARAM("nodeInfo", "xx") << CHAR_PARAM("version", g_szMirVer);
-
- JSONNode node;
- node << CHAR_PARAM("id", "messagingService") << CHAR_PARAM("type", "EndpointPresenceDoc")
- << CHAR_PARAM("selfLink", "uri") << privateInfo << publicInfo;
-
- auto *pReq = new AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(m_szEndpoint) + "/presenceDocs/messagingService",
- &CTeamsProto::OnCapabilitiesSended);
- pReq->m_szParam = node.write().c_str();
- PushRequest(pReq);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CTeamsProto::OnStatusChanged(MHttpResponse *response, AsyncHttpRequest*)
-{
- if (response == nullptr || response->resultCode != 200) {
- debugLogA(__FUNCTION__ ": failed to change status");
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, 1001);
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- int oldStatus = m_iStatus;
- m_iStatus = m_iDesiredStatus;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
-}
-
-void CTeamsProto::SetServerStatus(int iStatus)
-{
- const char *pszAvailability;
- switch (iStatus) {
- case ID_STATUS_OFFLINE:
- pszAvailability = "Offline";
- break;
- case ID_STATUS_NA:
- case ID_STATUS_AWAY:
- pszAvailability = "Away";
- break;
- case ID_STATUS_DND:
- pszAvailability = "DoNotDisturb";
- break;
- case ID_STATUS_OCCUPIED:
- pszAvailability = "Busy";
- break;
- default:
- pszAvailability = "Available";
- }
-
- JSONNode node(JSON_NODE);
- node << CHAR_PARAM("availability", pszAvailability);
-
- auto *pReq = new AsyncHttpRequest(REQUEST_PUT, HOST_PRESENCE, "/me/forceavailability", &CTeamsProto::OnStatusChanged);
- pReq->m_szParam = node.write().c_str();
- PushRequest(pReq);
-}