summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/SkypeWeb/src/requests/status.h7
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp46
4 files changed, 58 insertions, 1 deletions
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
index 9aafe49678..166b2e7bbe 100644
--- a/protocols/SkypeWeb/src/requests/status.h
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -18,6 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _SKYPE_REQUEST_STATUS_H_
#define _SKYPE_REQUEST_STATUS_H_
+struct GetStatusRequest : public AsyncHttpRequest
+{
+ GetStatusRequest() :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/contacts/ALL/presenceDocs/messagingService", &CSkypeProto::OnReceiveStatus)
+ {}
+};
+
struct SetStatusRequest : public AsyncHttpRequest
{
SetStatusRequest(const char *status) :
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 0bb7711995..2cf41db7c2 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -182,7 +182,9 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
m_szId = val.Detach();
}
}
-
+
+ RefreshStatuses();
+
PushRequest(new CreateSubscriptionsRequest());
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 8355e0e33c..8a9a243afe 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -114,6 +114,7 @@ public:
void OnLoginOAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnSubscriptionsCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnCapabilitiesSended(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
+ void OnReceiveStatus(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnStatusChanged(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
@@ -300,6 +301,7 @@ private:
void ProcessEndpointPresence(const JSONNode &node);
void ProcessConversationUpdate(const JSONNode &node);
+ void RefreshStatuses(void);
void ReadHistoryRest(const char *url);
// utils
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index f0c07d5ede..9d9a9a9cb0 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -25,3 +25,49 @@ void CSkypeProto::ProcessTimer()
SendRequest(new GetContactListRequest(this, nullptr));
SendPresence();
}
+
+void CSkypeProto::OnReceiveStatus(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
+{
+ 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();
+ nRecs = 0;
+ }
+
+ pReq << CHAR_PARAM("cMri", "8:" + id);
+ nRecs++;
+
+ if (nRecs >= 10) {
+ PushRequest(pReq);
+ pReq = nullptr;
+ }
+ }
+
+ if (pReq)
+ PushRequest(pReq);
+}