summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_utils.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-04-09 17:38:37 +0300
committeraunsane <aunsane@gmail.com>2017-04-09 17:39:06 +0300
commit6481053a2d97d73902b4ba86b7a06812cff48ae1 (patch)
tree903ba40ce35761b32084951aede67c6eee9dd2c1 /plugins/Dropbox/src/dropbox_utils.cpp
parent3f6bdf928ebf7e7e70d999905eb363386db2868a (diff)
Dropbox: temporary url option
Diffstat (limited to 'plugins/Dropbox/src/dropbox_utils.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index cd71d187f7..39b76a9f2e 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -57,29 +57,34 @@ char* CDropbox::HttpStatusToText(HTTP_STATUS status)
return "Unknown error";
}
-void CDropbox::HandleJsonResponseError(NETLIBHTTPREQUEST *response)
+void CDropbox::HandleHttpResponse(NETLIBHTTPREQUEST *response)
{
if (response == NULL)
throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR));
+}
- if (response->resultCode == HTTP_STATUS_OK)
- return;
+JSONNode CDropbox::HandleJsonResponse(NETLIBHTTPREQUEST *response)
+{
+ HandleHttpResponse(response);
- if (response->resultCode != HTTP_STATUS_CONFLICT) {
+ if (response->resultCode != HTTP_STATUS_OK &&
+ response->resultCode != HTTP_STATUS_CONFLICT) {
if (response->dataLength)
throw DropboxException(response->pData);
throw DropboxException(HttpStatusToText((HTTP_STATUS)response->resultCode));
}
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
+ if (root.isnull())
throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR));
- JSONNode error = root.at("error_summary");
- if (error.empty())
- return;
+ JSONNode error = root.at("error");
+ if (!error.isnull()) {
+ json_string tag = error.at(".tag").as_string();
+ throw DropboxException(tag.c_str());
+ }
- throw DropboxException(error.as_string().c_str());
+ return root;
}
MEVENT CDropbox::AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD cbBlob, PBYTE pBlob)