summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_utils.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-02-22 21:12:25 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-02-22 21:12:25 +0000
commit0b82b879821c7e73b86f189be747c5634c8b46b7 (patch)
tree28c7e3b06c25a7b9fbd49a33972e7fae07dd2e56 /plugins/Dropbox/src/dropbox_utils.cpp
parent477664ed5c4b018562e9419428175ae938cf2761 (diff)
Dropbox:
- updated api to v2 - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@16326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/dropbox_utils.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index aee70273eb..f9e726fe92 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -1,5 +1,21 @@
#include "stdafx.h"
+CMStringA CDropbox::PreparePath(const char *path)
+{
+ CMStringA result("/");
+ result.Append(path);
+ result.Replace("\\", "/");
+ return result;
+}
+
+CMStringA CDropbox::PreparePath(const TCHAR *path)
+{
+ CMStringA result("/");
+ result.Append(ptrA(mir_utf8encodeW(path)));
+ result.Replace("\\", "/");
+ return result;
+}
+
char* CDropbox::HttpStatusToText(HTTP_STATUS status)
{
switch (status) {
@@ -28,13 +44,23 @@ char* CDropbox::HttpStatusToText(HTTP_STATUS status)
return "Unknown error";
}
-void CDropbox::HandleHttpResponseError(NETLIBHTTPREQUEST *response)
+void CDropbox::HandleJsonResponseError(NETLIBHTTPREQUEST *response)
{
if (response == NULL)
- throw TransferException(HttpStatusToText(HTTP_STATUS_ERROR));
+ throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR));
+
+ JSONNode root = JSONNode::parse(response->pData);
+ if (root.empty()) {
+ if (response->dataLength)
+ throw DropboxException(response->pData);
+ throw DropboxException(HttpStatusToText((HTTP_STATUS)response->resultCode));
+ }
+
+ JSONNode error = root.at("error_summary");
+ if (error.empty())
+ return;
- if (response->resultCode != HTTP_STATUS_OK)
- throw TransferException(HttpStatusToText((HTTP_STATUS)response->resultCode));
+ throw DropboxException(error.as_string().c_str());
}
MEVENT CDropbox::AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD cbBlob, PBYTE pBlob)