summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/cloud_file.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-03-11 21:29:25 +0300
committeraunsane <aunsane@gmail.com>2018-03-11 21:30:54 +0300
commit5532fd4e1374c15c13e203a89b7cd060c7e15499 (patch)
treec96b03c78f6c9be6dd365e8c83f30090c58e6e22 /plugins/CloudFile/src/cloud_file.cpp
parent30b4b861bc47eab24d3236879d50791871d5c90a (diff)
CloudFile should create Miranda NG folder instead of placing files into Yandex Disk root (fixed #1184)
Diffstat (limited to 'plugins/CloudFile/src/cloud_file.cpp')
-rw-r--r--plugins/CloudFile/src/cloud_file.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/plugins/CloudFile/src/cloud_file.cpp b/plugins/CloudFile/src/cloud_file.cpp
index 9e40ac3db0..d4c082148f 100644
--- a/plugins/CloudFile/src/cloud_file.cpp
+++ b/plugins/CloudFile/src/cloud_file.cpp
@@ -70,17 +70,17 @@ void CCloudService::Report(MCONTACT hContact, const wchar_t *data)
PasteToClipboard(data);
}
-const char* CCloudService::PreparePath(const char *oldPath, CMStringA &newPath)
+std::string CCloudService::PreparePath(const char *path)
{
- if (oldPath == nullptr)
- newPath = "";
- else if (*oldPath != '/') {
- newPath = "/";
- newPath.Append(oldPath);
- newPath.Replace("\\", "/");
+ std::string newPath = path;
+ if (newPath[0] != '/')
+ newPath.insert(0, "/");
+ std::replace(newPath.begin(), newPath.end(), '\\', '/');
+ size_t pos = newPath.find("//");
+ while (pos != std::string::npos) {
+ newPath.replace(pos, 2, "/");
+ pos = newPath.find("//", pos + 1);
}
- else newPath = oldPath;
-
return newPath;
}
@@ -120,8 +120,13 @@ void CCloudService::HandleHttpError(NETLIBHTTPREQUEST *response)
if (response == nullptr)
throw Exception(HttpStatusToError());
- if (!HTTP_CODE_SUCCESS(response->resultCode))
- HttpResponseToError(response);
+ if (HTTP_CODE_SUCCESS(response->resultCode))
+ return;
+
+ if (response->resultCode == HTTP_CODE_UNAUTHORIZED)
+ delSetting("TokenSecret");
+
+ HttpResponseToError(response);
}
JSONNode CCloudService::GetJsonResponse(NETLIBHTTPREQUEST *response)