diff options
author | aunsane <aunsane@gmail.com> | 2017-12-09 23:39:16 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-12-09 23:39:16 +0300 |
commit | 6d27acd0a57bc6a228f1b6dd2ce451c02cc7419c (patch) | |
tree | a82b4c833eb6cec7ec81942d611ae708c0da0702 /plugins/CloudFile/src/Services/dropbox_service.cpp | |
parent | 15d04b366b37563254f914a41db97646730514b9 (diff) |
CloudFile: realized MS_DROPBOX_UPLOAD
Diffstat (limited to 'plugins/CloudFile/src/Services/dropbox_service.cpp')
-rw-r--r-- | plugins/CloudFile/src/Services/dropbox_service.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp index f1157a52b2..51e3c9a3c9 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.cpp +++ b/plugins/CloudFile/src/Services/dropbox_service.cpp @@ -4,6 +4,7 @@ CDropboxService::CDropboxService(HNETLIBUSER hConnection) : CCloudService(hConnection) { + CreateServiceFunctionObj(MS_DROPBOX_UPLOAD, &CDropboxService::UploadToDropbox, this); } const char* CDropboxService::GetModule() const @@ -234,7 +235,14 @@ UINT CDropboxService::Upload(FileTransferParam *ftp) mir_ptr<char>chunk((char*)mir_calloc(chunkSize)); char path[MAX_PATH]; - PreparePath(fileName, path); + const wchar_t *serverFolder = ftp->GetServerFolder(); + if (serverFolder) { + char serverPath[MAX_PATH] = { 0 }; + mir_snprintf(serverPath, "%s\\%s", T2Utf(serverFolder), fileName); + PreparePath(serverPath, path); + } + else + PreparePath(fileName, path); if (chunkSize == fileSize) { @@ -293,3 +301,35 @@ UINT CDropboxService::Upload(FileTransferParam *ftp) ftp->SetStatus(ACKRESULT_SUCCESS); return ACKRESULT_SUCCESS; } + +INT_PTR CDropboxService::UploadToDropbox(void *obj, WPARAM wParam, LPARAM lParam) +{ + CDropboxService *self = (CDropboxService*)obj; + DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam; + + FileTransferParam *ftp = new FileTransferParam(0); + ftp->SetWorkingDirectory(uploadInfo->localPath); + ftp->SetServerFolder(uploadInfo->serverFolder); + + if (PathIsDirectory(uploadInfo->localPath)) + { + // temporary unsupported + Transfers.remove(ftp); + delete ftp; + + return ACKRESULT_FAILED; + } + else + ftp->AddFile(uploadInfo->localPath); + + int res = self->Upload(ftp); + if (res == ACKRESULT_SUCCESS && wParam) { + char **data = (char**)wParam; + *data = mir_utf8encodeW(ftp->GetData()); + } + + Transfers.remove(ftp); + delete ftp; + + return res; +} |