From 6481053a2d97d73902b4ba86b7a06812cff48ae1 Mon Sep 17 00:00:00 2001 From: aunsane Date: Sun, 9 Apr 2017 17:38:37 +0300 Subject: Dropbox: temporary url option --- plugins/Dropbox/src/dropbox_utils.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'plugins/Dropbox/src/dropbox_utils.cpp') 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) -- cgit v1.2.3