summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_files.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-05-28 10:09:40 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-05-28 10:09:40 +0000
commit7b2a41081e47ef013f53145ae5d7f6395ff26833 (patch)
tree21e5da55ec137a67b76252b47f63cf7b61613249 /protocols/VKontakte/src/vk_files.cpp
parent5f288f2ae11634f7470e6ab5c09f9625c12021c6 (diff)
VKontakte:
rework code to JSONNode class upgrade vk api to 5.33 code cleanup version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@13868 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_files.cpp')
-rw-r--r--protocols/VKontakte/src/vk_files.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index bcc509c3e4..3cfbf27894 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -165,14 +165,14 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
return;
}
- JSONROOT pRoot;
- JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- if (pResponse == NULL) {
+ JSONNode jnRoot;
+ const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
+ if (!jnResponse) {
SendFileFiled(fup);
return;
}
- CMStringA uri = json_as_CMString(json_get(pResponse, "upload_url"));
+ CMStringA uri = jnResponse["upload_url"].as_mstring();
if (uri.IsEmpty()) {
SendFileFiled(fup);
return;
@@ -261,18 +261,18 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
return;
}
- JSONROOT pRoot;
- CheckJsonResponse(pReq, reply, pRoot);
+ JSONNode jnRoot;
+ CheckJsonResponse(pReq, reply, jnRoot);
- ptrT server(json_as_string(json_get(pRoot, "server")));
- ptrT hash(json_as_string(json_get(pRoot, "hash")));
+ CMString server(jnRoot["server"].as_mstring());
+ CMString hash(jnRoot["hash"].as_mstring());
CMString upload;
AsyncHttpRequest *pUploadReq;
switch (fup->GetType()) {
case CVkFileUploadParam::typeImg:
- upload = json_as_CMString(json_get(pRoot, "photo"));
+ upload = jnRoot["photo"].as_mstring();
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Photo"));
return;
@@ -284,7 +284,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeAudio:
- upload = json_as_CMString(json_get(pRoot, "audio"));
+ upload = jnRoot["audio"].as_mstring();
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Audio"));
return;
@@ -296,7 +296,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeDoc:
- upload = json_as_CMString(json_get(pRoot, "file"));
+ upload = jnRoot["file"].as_mstring();
if (upload.IsEmpty()) {
SendFileFiled(fup, _T("NotUpload Doc"));
return;
@@ -329,15 +329,15 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
return;
}
- JSONROOT pRoot;
- JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- if (pResponse == NULL) {
+ JSONNode jnRoot;
+ const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
+ if (!jnResponse) {
SendFileFiled(fup);
return;
}
- int id = json_as_int(json_get(fup->GetType() == CVkFileUploadParam::typeAudio ? pResponse : json_at(pResponse, 0), "id"));
- int owner_id = json_as_int(json_get(fup->GetType() == CVkFileUploadParam::typeAudio ? pResponse : json_at(pResponse, 0), "owner_id"));
+ int id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int();
+ int owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int();
if ((id == 0) || (owner_id == 0)) {
SendFileFiled(fup);
return;