summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/requests
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/requests
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/requests')
-rw-r--r--protocols/SkypeWeb/src/requests/capabilities.h54
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h32
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h48
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h27
-rw-r--r--protocols/SkypeWeb/src/requests/trouter.h89
5 files changed, 108 insertions, 142 deletions
diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h
index fb7c668c20..ef0da77f92 100644
--- a/protocols/SkypeWeb/src/requests/capabilities.h
+++ b/protocols/SkypeWeb/src/requests/capabilities.h
@@ -30,38 +30,30 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- char compName[MAX_COMPUTERNAME_LENGTH + 1];
+ TCHAR compName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = SIZEOF(compName);
- GetComputerNameA(compName, &size);
-
- JSONNODE *node = json_new(5);
- JSONNODE *privateInfo = json_new(5);
- JSONNODE *publicInfo = json_new(5);
-
- json_set_name(privateInfo, "privateInfo");
- json_set_name(publicInfo, "publicInfo");
-
- json_push_back(node, json_new_a("id", "messagingService"));
- json_push_back(node, json_new_a("type", "EndpointPresenceDoc"));
- json_push_back(node, json_new_a("selfLink", "uri"));
-
- json_push_back(privateInfo, json_new_a("epname", compName));
-
- json_push_back(publicInfo, json_new_a("capabilities", "Audio|Video"));
- json_push_back(publicInfo, json_new_i("typ", 125));
- json_push_back(publicInfo, json_new_a("skypeNameVersion", "Miranda NG Skype"));
- json_push_back(publicInfo, json_new_a("nodeInfo", "xx"));
- json_push_back(publicInfo, json_new_a("version", g_szMirVer));
-
- json_push_back(node, privateInfo);
- json_push_back(node, publicInfo);
-
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
-
- Body <<
- VALUE(data);
-
- json_delete(node);
+ GetComputerName(compName, &size);
+
+ JSONNode privateInfo(JSON_NODE);
+ privateInfo.set_name("privateInfo");
+ privateInfo.push_back(JSONNode("epname", T2Utf(compName)));
+
+ JSONNode publicInfo(JSON_NODE);
+ publicInfo.set_name("publicInfo");
+ publicInfo.push_back(JSONNode("capabilities", "Audio|Video"));
+ publicInfo.push_back(JSONNode("typ", 125));
+ publicInfo.push_back(JSONNode("skypeNameVersion", "Miranda NG Skype"));
+ publicInfo.push_back(JSONNode("nodeInfo", "xx"));
+ publicInfo.push_back(JSONNode("version", g_szMirVer));
+
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("id", "messagingService"));
+ node.push_back(JSONNode("type", "EndpointPresenceDoc"));
+ node.push_back(JSONNode("selfLink", "uri"));
+ node.push_back(privateInfo);
+ node.push_back(publicInfo);
+
+ Body << VALUE(node.write().c_str());
}
};
#endif //_SKYPE_REQUEST_CAPS_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index 57e76b2cf2..fa91a712a9 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -48,16 +48,13 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_i("clientmessageid", timestamp));
- json_push_back(node, json_new_a("messagetype", "RichText"));
- json_push_back(node, json_new_a("contenttype", "text"));
- json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("clientmessageid", (long)timestamp));
+ node.push_back(JSONNode("messagetype", "RichText"));
+ node.push_back(JSONNode("contenttype", "text"));
+ node.push_back(JSONNode("content", ptrA(mir_utf8encode(message))));
- T2Utf data(ptrT(json_write(node)));
- Body << VALUE(data);
-
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
@@ -72,17 +69,14 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_i("clientmessageid", timestamp));
- json_push_back(node, json_new_a("messagetype", "RichText"));
- json_push_back(node, json_new_a("contenttype", "text"));
- json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
- json_push_back(node, json_new_i("skypeemoteoffset", 4));
-
- T2Utf data(ptrT(json_write(node)));
- Body << VALUE(data);
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("clientmessageid", (long)timestamp));
+ node.push_back(JSONNode("messagetype", "RichText"));
+ node.push_back(JSONNode("contenttype", "text"));
+ node.push_back(JSONNode("content", ptrA(mir_utf8encode(message))));
+ node.push_back(JSONNode("skypeemoteoffset", 4));
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index 3523a95f47..b55d759a22 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -28,16 +28,14 @@ public:
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_i("clientmessageid", timestamp));
- json_push_back(node, json_new_a("messagetype", "RichText"));
- json_push_back(node, json_new_a("contenttype", "text"));
- json_push_back(node, json_new_a("content", message));
- T2Utf data(ptrT(json_write(node)));
- Body << VALUE(data);
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("clientmessageid", (long)timestamp));
+ node.push_back(JSONNode("messagetype", "RichText"));
+ node.push_back(JSONNode("contenttype", "text"));
+ node.push_back(JSONNode("content", message));
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
@@ -55,17 +53,14 @@ public:
CMStringA content;
content.AppendFormat("%s %s", username, message);
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_i("clientmessageid", timestamp));
- json_push_back(node, json_new_a("messagetype", "RichText"));
- json_push_back(node, json_new_a("contenttype", "text"));
- json_push_back(node, json_new_a("content", content));
- json_push_back(node, json_new_i("skypeemoteoffset", (int)(mir_strlen(username) + 1)));
-
- T2Utf data(ptrT(json_write(node)));
- Body << VALUE(data);
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("clientmessageid", (long)timestamp));
+ node.push_back(JSONNode("messagetype", "RichText"));
+ node.push_back(JSONNode("contenttype", "text"));
+ node.push_back(JSONNode("content", content));
+ node.push_back(JSONNode("skypeemoteoffset", (int)(mir_strlen(username) + 1)));
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
@@ -82,23 +77,20 @@ public:
char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_i("clientmessageid", time(NULL)));
- json_push_back(node, json_new_a("messagetype", state));
- json_push_back(node, json_new_a("contenttype", "text"));
- json_push_back(node, json_new_a("content", ""));
-
- T2Utf data(ptrT(json_write(node)));
- Body << VALUE(data);
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("clientmessageid", (long)time(NULL)));
+ node.push_back(JSONNode("messagetype", state));
+ node.push_back(JSONNode("contenttype", "text"));
+ node.push_back(JSONNode("content", ""));
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
class MarkMessageReadRequest : public HttpRequest
{
public:
- MarkMessageReadRequest(const char *username, const char *regToken, LONGLONG msgId = 0, LONGLONG msgTimestamp = 0, bool isChat = false, const char *server = SKYPE_ENDPOINTS_HOST) :
+ MarkMessageReadRequest(const char *username, const char *regToken, LONGLONG /*msgId*/ = 0, LONGLONG msgTimestamp = 0, bool isChat = false, const char *server = SKYPE_ENDPOINTS_HOST) :
HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/conversations/%s:%s/properties?name=consumptionhorizon", server, !isChat ? "8" : "19", username)
{
Headers
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index c0777819b0..7c46df3f35 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -29,24 +29,19 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNODE *node = json_new(5);
- JSONNODE *interestedResources = json_new(4);
- json_set_name(interestedResources, "interestedResources");
+ JSONNode interestedResources(JSON_ARRAY);
+ interestedResources.set_name("interestedResources");
+ interestedResources.push_back(JSONNode("", "/v1/users/ME/conversations/ALL/properties"));
+ interestedResources.push_back(JSONNode("", "/v1/users/ME/conversations/ALL/messages"));
+ interestedResources.push_back(JSONNode("", "/v1/users/ME/contacts/ALL"));
+ interestedResources.push_back(JSONNode("", "/v1/threads/ALL"));
- json_push_back(node, json_new_a("channelType", "httpLongPoll"));
- json_push_back(node, json_new_a("template", "raw"));
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("channelType", "httpLongPoll"));
+ node.push_back(JSONNode("template", "raw"));
+ node.push_back(interestedResources);
- json_push_back(interestedResources, json_new_a(NULL, "/v1/users/ME/conversations/ALL/properties"));
- json_push_back(interestedResources, json_new_a(NULL, "/v1/users/ME/conversations/ALL/messages"));
- json_push_back(interestedResources, json_new_a(NULL, "/v1/users/ME/contacts/ALL"));
- json_push_back(interestedResources, json_new_a(NULL, "/v1/threads/ALL"));
- json_push_back(node, interestedResources);
-
- T2Utf data(ptrT(json_write(node)));
-
- Body << VALUE(data);
-
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h
index 1d68e78470..7a9a0ca684 100644
--- a/protocols/SkypeWeb/src/requests/trouter.h
+++ b/protocols/SkypeWeb/src/requests/trouter.h
@@ -38,11 +38,10 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< CHAR_VALUE("X-Skypetoken", token);
- JSONNODE *node = json_new(5);
- json_push_back(node, json_new_a("sr", sr));
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("sr", sr));
- Body << VALUE(T2Utf(ptrT(json_write(node))));
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
//{"sr":"AUKRNgA8_eKV0Ibsx037Gbd8GVrsDg8zLQRt1pH8sCyIAile3gtoWmlq2x1yZ_VNZ3tf","issuer":"edf","sp":"connect","st":"1430236511619","se":"1430318082619","sig":"nYczCdlBENCxoAFLy7lPkGELVV1w5TcUnpSUE2G7GLA"}
};
@@ -57,37 +56,31 @@ public:
<< CHAR_VALUE("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml")
<< CHAR_VALUE("X-Skypetoken", token);
- JSONNODE *node = json_new(5);
- JSONNODE *clientDescription = json_new(5);
- JSONNODE *transports = json_new(5);
- JSONNODE *TRouter = json_new(5);
- JSONNODE *TROUTER = json_new(4);
+ JSONNode clientDescription(JSON_NODE);
+ clientDescription.set_name("clientDescription");
+ clientDescription.push_back(JSONNode("aesKey", ""));
+ clientDescription.push_back(JSONNode("languageId", "en-US"));
+ clientDescription.push_back(JSONNode("platform", "SWX"));
+ clientDescription.push_back(JSONNode("templateKey", "SkypeWeb_1.0"));
- json_set_name(clientDescription, "clientDescription");
- json_set_name(transports, "transports");
- json_set_name(TROUTER, "TROUTER");
+ JSONNode TRouter(JSON_NODE);
+ TRouter.push_back(JSONNode("context", ""));
+ TRouter.push_back(JSONNode("path", trouterUrl));
+ TRouter.push_back(JSONNode("ttl", 3600));
- json_push_back(node, json_new_a("registrationId", id));
- json_push_back(node, json_new_a("nodeId", ""));
+ JSONNode TROUTER (JSON_ARRAY); TROUTER.set_name("TROUTER");
+ TROUTER.push_back(TRouter);
- json_push_back(clientDescription, json_new_a("aesKey", ""));
- json_push_back(clientDescription, json_new_a("languageId", "en-US"));
- json_push_back(clientDescription, json_new_a("platform", "SWX"));
- json_push_back(clientDescription, json_new_a("templateKey", "SkypeWeb_1.0"));
- json_push_back(node, clientDescription);
+ JSONNode transports(JSON_NODE); transports.set_name("transports");
+ transports.push_back(TROUTER);
- json_push_back(TRouter, json_new_a("context", ""));
- json_push_back(TRouter, json_new_a("path", trouterUrl));
- json_push_back(TRouter, json_new_i("ttl", 3600));
- json_push_back(TROUTER, TRouter);
- json_push_back(transports, TROUTER);
- json_push_back(node, transports);
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode("registrationId", id));
+ node.push_back(JSONNode("nodeId", ""));
+ node.push_back(clientDescription);
+ node.push_back(transports);
- T2Utf data(ptrT(json_write(node)));
-
- Body << VALUE(data);
-
- json_delete(node);
+ Body << VALUE(node.write().c_str());
}
};
@@ -109,21 +102,21 @@ public:
class GetTrouterRequest : public HttpRequest
{
public:
- GetTrouterRequest(const char *socketio, const char *sr, const char *st, const char *se, const char *sig,
- const char *instance, const char *ccid) :
- HttpRequest(REQUEST_GET, FORMAT, "%ssocket.io/1/", socketio)
+ GetTrouterRequest(const std::string &socketio, const std::string &sr, const std::string &st, const std::string &se, const std::string &sig,
+ const std::string &instance, const std::string &ccid) :
+ HttpRequest(REQUEST_GET, FORMAT, "%ssocket.io/1/", socketio.c_str())
{
Url
- << CHAR_VALUE("sr", sr)
+ << CHAR_VALUE("sr", sr.c_str())
<< CHAR_VALUE("issuer", "edf")
<< CHAR_VALUE("sp", "connect")
- << CHAR_VALUE("st", st)
- << CHAR_VALUE("se", se)
- << CHAR_VALUE("sig", sig)
- << CHAR_VALUE("r", instance)
+ << CHAR_VALUE("st", st.c_str())
+ << CHAR_VALUE("se", se.c_str())
+ << CHAR_VALUE("sig", sig.c_str())
+ << CHAR_VALUE("r", instance.c_str())
<< CHAR_VALUE("v", "v2")
<< INT_VALUE("p", 443)
- << CHAR_VALUE("ccid", ccid)
+ << CHAR_VALUE("ccid", ccid.c_str())
<< CHAR_VALUE("tc", ptrA(mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}")))
<< INT_VALUE("t", time(NULL) * 1000);
@@ -135,23 +128,23 @@ public:
class TrouterPollRequest : public HttpRequest
{
public:
- TrouterPollRequest(const char *socketio, const char *sr, const char *st, const char *se, const char *sig,
- const char *instance, const char *ccid, const char *sessId) :
- HttpRequest(REQUEST_GET, FORMAT, "%ssocket.io/1/xhr-polling/%s", socketio, sessId)
+ TrouterPollRequest(const std::string &socketio, const std::string &sr, const std::string &st, const std::string &se, const std::string &sig,
+ const std::string &instance, const std::string &ccid, const std::string &sessId) :
+ HttpRequest(REQUEST_GET, FORMAT, "%ssocket.io/1/xhr-polling/%s", socketio.c_str(), sessId.c_str())
{
timeout = INFINITE;
flags |= NLHRF_PERSISTENT;
Url
- << CHAR_VALUE("sr", sr)
+ << CHAR_VALUE("sr", sr.c_str())
<< CHAR_VALUE("issuer", "edf")
<< CHAR_VALUE("sp", "connect")
- << CHAR_VALUE("st", st)
- << CHAR_VALUE("se", se)
- << CHAR_VALUE("sig", sig)
- << CHAR_VALUE("r", instance)
+ << CHAR_VALUE("st", st.c_str())
+ << CHAR_VALUE("se", se.c_str())
+ << CHAR_VALUE("sig", sig.c_str())
+ << CHAR_VALUE("r", instance.c_str())
<< CHAR_VALUE("v", "v2")
<< INT_VALUE("p", 443)
- << CHAR_VALUE("ccid", ccid)
+ << CHAR_VALUE("ccid", ccid.c_str())
<< CHAR_VALUE("tc", ptrA(mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}")))
<< INT_VALUE("t", time(NULL) * 1000);