summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_polling.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-29 14:53:33 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-29 14:53:33 +0000
commit2fcca210a1f695d7a932b873ae00dc702d42cfeb (patch)
tree2f06ee3f54a5d7cd6f479497cfd2111c2f5afffa /protocols/SkypeWeb/src/skype_polling.cpp
parent72e13eb85e4b7aaf0ba82a2de750e1eee454bd6b (diff)
SkypeWeb to use new json parser
git-svn-id: http://svn.miranda-ng.org/main/trunk@13891 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp73
1 files changed, 36 insertions, 37 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 41ade45ec3..3ab4461079 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -17,40 +17,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-void CSkypeProto::ParsePollData(JSONNODE *data)
+void CSkypeProto::ParsePollData(const JSONNode &data)
{
debugLogA("CSkypeProto::ParsePollData");
- JSONNODE *node = json_get(data, "eventMessages");
- if (node != NULL)
+
+ const JSONNode &node = data["eventMessages"];
+ if (!node)
+ return;
+
+ const JSONNode &messages = node.as_array();
+ for (size_t i = 0; i < messages.size(); i++)
{
- JSONNODE *messages = json_as_array(node);
- for (size_t i = 0; i < json_size(messages); i++)
- {
- JSONNODE *message = json_at(messages, i);
- JSONNODE *resType = json_get(message, "resourceType");
- ptrA resourceType(mir_t2a(ptrT(json_as_string(resType))));
- JSONNODE *resource = json_get(message, "resource");
+ const JSONNode &message = messages.at(i);
+ const JSONNode &resType = message["resourceType"];
+ const JSONNode &resource = message["resource"];
- if (!mir_strcmpi(resourceType, "NewMessage"))
- {
- ProcessNewMessageRes(resource);
- }
- else if (!mir_strcmpi(resourceType, "UserPresence"))
- {
- ProcessUserPresenceRes(resource);
- }
- else if (!mir_strcmpi(resourceType, "EndpointPresence"))
- {
- ProcessEndpointPresenceRes(resource);
- }
- else if (!mir_strcmpi(resourceType, "ConversationUpdate"))
- {
- ProcessConversationUpdateRes(resource);
- }
- else if (!mir_strcmpi(resourceType, "ThreadUpdate"))
- {
- ProcessThreadUpdateRes(resource);
- }
+ std::string resourceType = resType.as_string();
+ if (!mir_strcmpi(resourceType.c_str(), "NewMessage"))
+ {
+ ProcessNewMessageRes(resource);
+ }
+ else if (!mir_strcmpi(resourceType.c_str(), "UserPresence"))
+ {
+ ProcessUserPresenceRes(resource);
+ }
+ else if (!mir_strcmpi(resourceType.c_str(), "EndpointPresence"))
+ {
+ ProcessEndpointPresenceRes(resource);
+ }
+ else if (!mir_strcmpi(resourceType.c_str(), "ConversationUpdate"))
+ {
+ ProcessConversationUpdateRes(resource);
+ }
+ else if (!mir_strcmpi(resourceType.c_str(), "ThreadUpdate"))
+ {
+ ProcessThreadUpdateRes(resource);
}
}
}
@@ -78,9 +79,8 @@ void CSkypeProto::PollingThread(void*)
{
if (response->pData)
{
- JSONROOT root(response->pData);
- JSONNODE *events = json_get(root, "eventMessages");
- if (events != NULL)
+ JSONNode root = JSONNode::parse(response->pData);
+ if (root["eventMessages"])
{
ParsePollData(root);
}
@@ -92,12 +92,11 @@ void CSkypeProto::PollingThread(void*)
if (response->pData)
{
- JSONROOT root(response->pData);
- JSONNODE *error = json_get(root, "errorCode");
+ JSONNode root = JSONNode::parse(response->pData);
+ const JSONNode &error = root["errorCode"];
if (error != NULL)
{
- int errorCode = json_as_int(error);
-
+ int errorCode = error.as_int();
if (errorCode == 729)
{
SendRequest(new CreateEndpointRequest(TokenSecret), &CSkypeProto::OnEndpointCreated);