diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-04-06 14:53:00 +0300 |
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-04-06 14:53:00 +0300 |
| commit | e47229ff357022582a8196481aad3b2066064ced (patch) | |
| tree | 8953dcea6f3f943203230e1f2021f94d5df10d6b | |
| parent | 1369c9ee56e668a42cbf3c0316fe440036bb5dfa (diff) | |
more code cleaning
| -rw-r--r-- | protocols/Teams/src/requests/capabilities.h | 41 | ||||
| -rw-r--r-- | protocols/Teams/src/requests/poll.h | 38 | ||||
| -rw-r--r-- | protocols/Teams/src/stdafx.h | 4 | ||||
| -rw-r--r-- | protocols/Teams/src/teams_endpoint.cpp | 50 |
4 files changed, 35 insertions, 98 deletions
diff --git a/protocols/Teams/src/requests/capabilities.h b/protocols/Teams/src/requests/capabilities.h deleted file mode 100644 index b9785a2a92..0000000000 --- a/protocols/Teams/src/requests/capabilities.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright (c) 2015-25 Miranda NG team (https://miranda-ng.org) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _SKYPE_REQUEST_CAPS_H_ -#define _SKYPE_REQUEST_CAPS_H_ - -struct SendCapabilitiesRequest : public AsyncHttpRequest -{ - SendCapabilitiesRequest(const char *hostname, CTeamsProto *ppro) : - AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(ppro->m_szEndpoint) + "/presenceDocs/messagingService", &CTeamsProto::OnCapabilitiesSended) - { - JSONNode privateInfo; privateInfo.set_name("privateInfo"); - privateInfo << CHAR_PARAM("epname", hostname); - - 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; - - m_szParam = node.write().c_str(); - } -}; - -#endif //_SKYPE_REQUEST_CAPS_H_ diff --git a/protocols/Teams/src/requests/poll.h b/protocols/Teams/src/requests/poll.h deleted file mode 100644 index 008873cd14..0000000000 --- a/protocols/Teams/src/requests/poll.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (c) 2015-25 Miranda NG team (https://miranda-ng.org) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _SKYPE_POLL_H_ -#define _SKYPE_POLL_H_ - -struct PollRequest : public AsyncHttpRequest -{ - PollRequest(CTeamsProto *ppro) : - AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(ppro->m_szEndpoint) + "/subscriptions/0/poll") - { - flags |= NLHRF_PERSISTENT; - timeout = 120000; - - if (ppro->m_iPollingId != -1) - m_szUrl.AppendFormat("?ackId=%d", ppro->m_iPollingId); - - AddHeader("Referer", "https://web.skype.com/main"); - AddHeader("ClientInfo", "os=Windows; osVer=8.1; proc=Win32; lcid=en-us; deviceType=1; country=n/a; clientName=swx-skype.com; clientVer=908/1.85.0.29"); - AddHeader("Accept", "application/json"); - AddHeader("Accept-Language", "en, C"); - } -}; -#endif //_SKYPE_POLL_H_
\ No newline at end of file diff --git a/protocols/Teams/src/stdafx.h b/protocols/Teams/src/stdafx.h index 45fbabe8cb..7cbbec2676 100644 --- a/protocols/Teams/src/stdafx.h +++ b/protocols/Teams/src/stdafx.h @@ -88,13 +88,11 @@ struct AsyncHttpRequest : public MTHttpRequest<CTeamsProto> #include "teams_proto.h" -#include "requests/capabilities.h" #include "requests/chatrooms.h" #include "requests/history.h" -#include "requests/poll.h" #include "requests/profile.h" #include "requests/search.h" #include "requests/status.h" #include "requests/subscriptions.h" -#endif //_COMMON_H_
\ No newline at end of file +#endif //_COMMON_H_ diff --git a/protocols/Teams/src/teams_endpoint.cpp b/protocols/Teams/src/teams_endpoint.cpp index b304cd135b..733008ee75 100644 --- a/protocols/Teams/src/teams_endpoint.cpp +++ b/protocols/Teams/src/teams_endpoint.cpp @@ -100,23 +100,9 @@ void CTeamsProto::OnSubscriptionsCreated(MHttpResponse *response, AsyncHttpReque SendPresence(); } -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); - } - - PushRequest(new SendCapabilitiesRequest(epname, this)); -} - -void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest*) +void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest *) { if (response == nullptr || response->body.IsEmpty()) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, 1001); @@ -146,6 +132,38 @@ void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest 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->body.IsEmpty()) { |
