summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/transfers.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-04-16 01:32:19 +0300
committeraunsane <aunsane@gmail.com>2017-04-16 01:32:58 +0300
commit0b9fa1d90f8d0aff7118837ceb1211b578a5a9c8 (patch)
tree3b8be7b839a98a3a52a38d713c2d708ada015510 /plugins/CloudFile/src/transfers.cpp
parent008fb731e3e3b587f596afba1cfe7446de7f0cac (diff)
CloudFile: initial commit
- Dropbox (worked) - Yandex.Disk (worked) - GDrive (not worked)
Diffstat (limited to 'plugins/CloudFile/src/transfers.cpp')
-rw-r--r--plugins/CloudFile/src/transfers.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/plugins/CloudFile/src/transfers.cpp b/plugins/CloudFile/src/transfers.cpp
new file mode 100644
index 0000000000..0f79f970d9
--- /dev/null
+++ b/plugins/CloudFile/src/transfers.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+
+LIST<FileTransferParam> Transfers(1, HandleKeySortT);
+
+INT_PTR ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
+{
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+ CCloudService *service = (CCloudService*)obj;
+
+ FileTransferParam *ftp = new FileTransferParam(pccsd->hContact);
+
+ const wchar_t *description = (wchar_t*)pccsd->wParam;
+ if (description && description[0])
+ ftp->AppendFormatData(L"%s\r\n", (wchar_t*)pccsd->wParam);
+
+ wchar_t **paths = (wchar_t**)pccsd->lParam;
+ ftp->SetWorkingDirectory(paths[0]);
+ for (int i = 0; paths[i]; i++) {
+ if (PathIsDirectory(paths[i]))
+ continue;
+ ftp->AddFile(paths[i]);
+ }
+
+ Transfers.insert(ftp);
+
+ mir_forkthreadowner(UploadAndReportProgressThread, service, ftp);
+
+ return ftp->GetId();
+}
+
+INT_PTR ProtoSendFileInterceptor(void *obj, WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+ CCloudService *service = (CCloudService*)obj;
+
+ auto it = service->InterceptedContacts.find(pccsd->hContact);
+ if (it == service->InterceptedContacts.end())
+ return CALLSERVICE_NOTFOUND;
+ service->InterceptedContacts.erase(it);
+
+ return ProtoSendFile(obj, wParam, lParam);
+}
+
+INT_PTR ProtoCancelFile(WPARAM, LPARAM lParam)
+{
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+
+ HANDLE hTransfer = (HANDLE)pccsd->wParam;
+ FileTransferParam *ftp = Transfers.find((FileTransferParam*)&hTransfer);
+ if (ftp)
+ ftp->Terminate();
+
+ return 0;
+}
+
+UINT UploadAndReportProgressThread(void *owner, void *arg)
+{
+ CCloudService *service = (CCloudService*)owner;
+ FileTransferParam *ftp = (FileTransferParam*)arg;
+
+ int res = service->Upload(ftp);
+ if (res == ACKRESULT_SUCCESS)
+ service->Report(ftp->GetHContact(), ftp->GetData());
+
+ Transfers.remove(ftp);
+ delete ftp;
+
+ return res;
+} \ No newline at end of file