diff options
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r-- | protocols/SkypeWeb/src/requests/poll.h | 38 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_polling.cpp | 30 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/stdafx.h | 1 |
3 files changed, 25 insertions, 44 deletions
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 <http://www.gnu.org/licenses/>.
-*/
-
-#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<PollRequest> 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<CSkypeProto> #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"
|