From 048e1f421b84529aa2b29da09027ce997573afd7 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 25 Feb 2016 15:49:58 +0000 Subject: Dropbox: reworked files sending git-svn-id: http://svn.miranda-ng.org/main/trunk@16337 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_utils.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 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 fbc48ae395..c6f029be0d 100644 --- a/plugins/Dropbox/src/dropbox_utils.cpp +++ b/plugins/Dropbox/src/dropbox_utils.cpp @@ -1,19 +1,17 @@ #include "stdafx.h" -CMStringA CDropbox::PreparePath(const char *path) +char* CDropbox::PreparePath(const char *oldPath, char *newPath) { CMStringA result("/"); - result.Append(path); + result.Append(oldPath); result.Replace("\\", "/"); - return result; + mir_strcpy(newPath, result); + return newPath; } -CMStringA CDropbox::PreparePath(const TCHAR *path) +char* CDropbox::PreparePath(const TCHAR *oldPath, char *newPath) { - CMStringA result("/"); - result.Append(ptrA(mir_utf8encodeW(path))); - result.Replace("\\", "/"); - return result; + return PreparePath(ptrA(mir_utf8encodeW(oldPath)), newPath); } char* CDropbox::HttpStatusToText(HTTP_STATUS status) @@ -49,13 +47,19 @@ void CDropbox::HandleJsonResponseError(NETLIBHTTPREQUEST *response) if (response == NULL) throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR)); - JSONNode root = JSONNode::parse(response->pData); - if (root.empty()) { + if (response->resultCode == HTTP_STATUS_OK) + return; + + if (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()) + throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR)); + JSONNode error = root.at("error_summary"); if (error.empty()) return; -- cgit v1.2.3