summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_polling.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-03-31 18:37:50 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-03-31 18:37:50 +0000
commitf9e66715bee0af7f9b1f2698da1fe11c35479210 (patch)
tree4cd3f42a1fd45ae54fa623f8758cbdd13d468b8c /protocols/SkypeWeb/src/skype_polling.cpp
parentd3a10049eee36dc0c451cbed542314a94f62ab3c (diff)
SteamWeb: contact's status support (patch from MikalaiR)
git-svn-id: http://svn.miranda-ng.org/main/trunk@12576 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
new file mode 100644
index 0000000000..8dc73280a7
--- /dev/null
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -0,0 +1,82 @@
+#include "common.h"
+
+#define POLLING_ERRORS_LIMIT 3
+
+void CSkypeProto::ParsePollData(JSONNODE *data)
+{
+ debugLogA("CSkypeProto::ParsePollData");
+ JSONNODE *node, *item = NULL;
+ node = json_get(data, "eventMessages");
+ if (node != NULL)
+ {
+ int index, length;
+ JSONNODE *messages = json_as_array(node);
+ for (int i = 0; i < json_size(messages); i++)
+ {
+ JSONNODE *message = json_at(messages, i);
+ JSONNODE *resType = json_get(message, "resourceType");
+ TCHAR *resourceType = json_as_string(resType);
+ JSONNODE *resource = json_get(message, "resource");
+
+ if (!mir_tstrcmpi(resourceType, L"NewMessage"))
+ {
+ continue;
+ }
+ else if (!mir_tstrcmpi(resourceType, L"UserPresence"))
+ {
+ ProcessUserPresenceRes(resource);
+ }
+ else if (!mir_tstrcmpi(resourceType, L"EndpointPresence"))
+ {
+ continue;
+ }
+ else if (!mir_tstrcmpi(resourceType, L"ConversationUpdate"))
+ {
+ continue;
+ }
+ else if (!mir_tstrcmpi(resourceType, L"ThreadUpdate"))
+ {
+ continue;
+ }
+
+ }
+ }
+
+}
+
+void CSkypeProto::PollingThread(void*)
+{
+ debugLog(_T("CSkypeProto::PollingThread: entering"));
+
+ ptrA regToken(getStringA("registrationToken"));
+
+ int errors = 0;
+ bool breaked = false;
+ while (!isTerminated && !breaked && errors < POLLING_ERRORS_LIMIT)
+ {
+ PollRequest *request = new PollRequest(regToken);
+ NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
+ delete request;
+
+ if (response != NULL)
+ {
+ JSONROOT root(response->pData);
+ ParsePollData (root);
+ }
+ /*if (response->resultCode != 200)
+ {
+ errors++;
+ continue;
+ }
+ else
+ errors = 0;*/
+ }
+ m_hPollingThread = NULL;
+ debugLog(_T("CSkypeProto::PollingThread: leaving"));
+
+ if (!isTerminated)
+ {
+ debugLog(_T("CSkypeProto::PollingThread: unexpected termination; switching protocol to offline"));
+ SetStatus(ID_STATUS_OFFLINE);
+ }
+} \ No newline at end of file