From 3cdfa14f90f20351f210eb3d519660b46141a440 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Apr 2025 17:06:06 +0300 Subject: =?UTF-8?q?fixes=20#4960=20(SkypeWeb:=20=D1=83=D1=82=D0=B5=D1=87?= =?UTF-8?q?=D0=BA=D0=B0,=20=D0=BF=D1=80=D0=B8=D0=B2=D0=BE=D0=B4=D1=8F?= =?UTF-8?q?=D1=89=D0=B0=D1=8F=20=D1=81=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BC=20=D0=BA=20=D0=BD=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BE=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D1=81=D0=B5=D1=82=D0=B8=20?= =?UTF-8?q?=D0=B2=D0=BE=20=D0=B2=D1=81=D0=B5=D0=B9=20=D0=9E=D0=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/SkypeWeb/src/requests/poll.h | 38 -------------------------------- protocols/SkypeWeb/src/skype_polling.cpp | 30 ++++++++++++++++++++----- protocols/SkypeWeb/src/stdafx.h | 1 - 3 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 protocols/SkypeWeb/src/requests/poll.h (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/requests/poll.h b/protocols/SkypeWeb/src/requests/poll.h deleted file mode 100644 index bf1850fd27..0000000000 --- a/protocols/SkypeWeb/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 . -*/ - -#ifndef _SKYPE_POLL_H_ -#define _SKYPE_POLL_H_ - -struct PollRequest : public AsyncHttpRequest -{ - PollRequest(CSkypeProto *ppro) : - AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(ppro->m_szId) + "/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/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index ed7b50938e..2821f06d34 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -27,14 +27,34 @@ void CSkypeProto::PollingThread(void *) if (m_isTerminated || m_szId == nullptr) break; - std::unique_ptr request(new PollRequest(this)); - request->nlc = m_hPollingConn; - NLHR_PTR response(DoSend(request.get())); + AsyncHttpRequest req(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(m_szId) + "/subscriptions/0/poll"); + req.flags |= NLHRF_PERSISTENT; + req.timeout = 120000; + req.nlc = m_hPollingConn; + + if (m_iPollingId != -1) + req.m_szUrl.AppendFormat("?ackId=%d", m_iPollingId); + + req.AddHeader("Referer", "https://web.skype.com/main"); + req.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"); + req.AddHeader("Accept", "application/json"); + req.AddHeader("Accept-Language", "en, C"); + + NLHR_PTR response(DoSend(&req)); if (m_isTerminated || m_szId == nullptr) break; - if (response == nullptr || response->resultCode != 200) { - m_hPollingConn = nullptr; + // no network?.. + if (response == nullptr) + break; + + if (response->resultCode != 200) { + auto reply = JSONNode::parse(response->body); + if (reply && reply["message"]["errorCode"] == 729) // endpoint broken, log off + break; + + Sleep(200); + m_hPollingConn = response->nlc; continue; } diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index ef94f3040c..263aefd914 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -119,7 +119,6 @@ struct AsyncHttpRequest : public MTHttpRequest #include "requests/history.h" #include "requests/login.h" #include "requests/oauth.h" -#include "requests/poll.h" #include "requests/profile.h" #include "requests/search.h" #include "requests/status.h" -- cgit v1.2.3