diff options
Diffstat (limited to 'plugins/CloudFile/src/cloud_file.cpp')
-rw-r--r-- | plugins/CloudFile/src/cloud_file.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/CloudFile/src/cloud_file.cpp b/plugins/CloudFile/src/cloud_file.cpp index 86e65b6b34..3217716341 100644 --- a/plugins/CloudFile/src/cloud_file.cpp +++ b/plugins/CloudFile/src/cloud_file.cpp @@ -106,7 +106,7 @@ INT_PTR CCloudService::OnAccountManagerInit(WPARAM, LPARAM lParam) return (INT_PTR)page->GetHwnd(); } -std::string CCloudService::PreparePath(const char *path) +std::string CCloudService::PreparePath(const std::string &path) const { std::string newPath = path; if (newPath[0] != '/') @@ -146,6 +146,8 @@ char* CCloudService::HttpStatusToError(int status) void CCloudService::HttpResponseToError(NETLIBHTTPREQUEST *response) { + if (response == nullptr) + throw Exception(HttpStatusToError()); if (response->dataLength) throw Exception(response->pData); throw Exception(HttpStatusToError(response->resultCode)); @@ -177,3 +179,26 @@ JSONNode CCloudService::GetJsonResponse(NETLIBHTTPREQUEST *response) return root; } + +UINT CCloudService::Upload(CCloudService *service, FileTransferParam *ftp) +{ + try { + if (!service->IsLoggedIn()) + service->Login(); + + if (!service->IsLoggedIn()) { + ftp->SetStatus(ACKRESULT_FAILED); + return ACKRESULT_FAILED; + } + + service->Upload(ftp); + } + catch (Exception &ex) { + service->debugLogA("%s: %s", service->GetModuleName(), ex.what()); + ftp->SetStatus(ACKRESULT_FAILED); + return ACKRESULT_FAILED; + } + + ftp->SetStatus(ACKRESULT_SUCCESS); + return ACKRESULT_SUCCESS; +}
\ No newline at end of file |