summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_trouter.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-04-16 20:27:26 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-04-16 20:27:26 +0300
commit3b576fbd2dc5359c9c2e3b79633f77ec97d307c9 (patch)
treee1ee7ed1f19ea84342e3f6b827d14be7f2c2a63c /protocols/SkypeWeb/src/skype_trouter.cpp
parenta1c32d8bf1118b20e9a701e2b6ac0300cf704e55 (diff)
SkypeWeb:
- fixes #2306 (SkypeWeb: sometimes plugin does not show contacts statuses); - obsoleted GetContactsInfoRequest removed (as well as its handler CSkypeProto::LoadContactsInfo); - major optimization for polling process; - ugly & crashy map Contacts removed; - old crappy timer code removed and replaced with CTimer; - version bump
Diffstat (limited to 'protocols/SkypeWeb/src/skype_trouter.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index cfc41f7b8c..79a4f12cf3 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -17,6 +17,63 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+void CSkypeProto::ProcessTimer()
+{
+ if (!IsOnline())
+ return;
+
+ PushRequest(new GetContactListRequest(this, nullptr), &CSkypeProto::LoadContactList);
+ SendPresence(false);
+
+ RefreshStatuses();
+}
+
+void CSkypeProto::OnReceiveStatus(const NETLIBHTTPREQUEST *response)
+{
+ JsonReply reply(response);
+ if (reply.error())
+ return;
+
+ auto &root = reply.data();
+ for (auto &it : root["Responses"]) {
+ std::string id = it["Contact"].as_string();
+ id.erase(0, 2);
+ MCONTACT hContact = AddContact(id.c_str());
+ if (hContact) {
+ int status = SkypeToMirandaStatus(it["Payload"]["status"].as_string().c_str());
+ setWord(hContact, "Status", status);
+ }
+ }
+}
+
+void CSkypeProto::RefreshStatuses(void)
+{
+ int nRecs = 0;
+ GetStatusRequest *pReq = nullptr;
+
+ for (auto &it : AccContacts()) {
+ CMStringA id(getId(it));
+ if (id.IsEmpty())
+ continue;
+
+ if (pReq == nullptr) {
+ pReq = new GetStatusRequest(this);
+ nRecs = 0;
+ }
+
+ pReq->Url << CHAR_VALUE("cMri", "8:" + id);
+ nRecs++;
+
+ if (nRecs >= 10) {
+ PushRequest(pReq, &CSkypeProto::OnReceiveStatus);
+ pReq = nullptr;
+ }
+ }
+
+ if (pReq)
+ PushRequest(pReq, &CSkypeProto::OnReceiveStatus);
+}
+
void CSkypeProto::OnCreateTrouter(const NETLIBHTTPREQUEST *response)
{
JsonReply reply(response);