summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/transfers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CloudFile/src/transfers.cpp')
-rw-r--r--plugins/CloudFile/src/transfers.cpp71
1 files changed, 40 insertions, 31 deletions
diff --git a/plugins/CloudFile/src/transfers.cpp b/plugins/CloudFile/src/transfers.cpp
index 0f79f970d9..0c76247b6b 100644
--- a/plugins/CloudFile/src/transfers.cpp
+++ b/plugins/CloudFile/src/transfers.cpp
@@ -2,18 +2,36 @@
LIST<FileTransferParam> Transfers(1, HandleKeySortT);
-INT_PTR ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
+INT_PTR CCloudService::SendFileInterceptor(WPARAM wParam, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA*)lParam;
- CCloudService *service = (CCloudService*)obj;
+ for (size_t i = 0; i < Services.getCount(); i++) {
+ CCloudService *service = Services[i];
+ auto it = service->InterceptedContacts.find(pccsd->hContact);
+ if (it == service->InterceptedContacts.end())
+ return CALLSERVICE_NOTFOUND;
+ service->InterceptedContacts.erase(it);
+ return (INT_PTR)service->SendFile(pccsd->hContact, (wchar_t*)pccsd->wParam, (wchar_t**)pccsd->lParam);
+ }
+ return CALLSERVICE_NOTFOUND;
+}
- FileTransferParam *ftp = new FileTransferParam(pccsd->hContact);
+INT_PTR CCloudService::FileCancel(MCONTACT, HANDLE hTransfer)
+{
+ FileTransferParam *ftp = Transfers.find((FileTransferParam*)&hTransfer);
+ if (ftp)
+ ftp->Terminate();
+
+ return 0;
+}
+
+HANDLE CCloudService::SendFile(MCONTACT hContact, const wchar_t *description, wchar_t **paths)
+{
+ FileTransferParam *ftp = new FileTransferParam(hContact);
- const wchar_t *description = (wchar_t*)pccsd->wParam;
if (description && description[0])
- ftp->AppendFormatData(L"%s\r\n", (wchar_t*)pccsd->wParam);
+ ftp->AppendFormatData(L"%s\r\n", description);
- wchar_t **paths = (wchar_t**)pccsd->lParam;
ftp->SetWorkingDirectory(paths[0]);
for (int i = 0; paths[i]; i++) {
if (PathIsDirectory(paths[i]))
@@ -23,34 +41,25 @@ INT_PTR ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
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);
+ mir_forkthreadowner(UploadAndReportProgressThread, this, ftp);
- return ProtoSendFile(obj, wParam, lParam);
+ return (HANDLE)ftp->GetId();
}
-INT_PTR ProtoCancelFile(WPARAM, LPARAM lParam)
+void CCloudService::OpenUploadDialog(MCONTACT hContact)
{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- HANDLE hTransfer = (HANDLE)pccsd->wParam;
- FileTransferParam *ftp = Transfers.find((FileTransferParam*)&hTransfer);
- if (ftp)
- ftp->Terminate();
-
- return 0;
+ char *proto = GetContactProto(hContact);
+ if (!mir_strcmpi(proto, META_PROTO))
+ hContact = CallService(MS_MC_GETMOSTONLINECONTACT, hContact);
+
+ auto it = InterceptedContacts.find(hContact);
+ if (it == InterceptedContacts.end())
+ {
+ HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, hContact, 0);
+ InterceptedContacts[hContact] = hwnd;
+ }
+ else
+ SetActiveWindow(it->second);
}
UINT UploadAndReportProgressThread(void *owner, void *arg)
@@ -66,4 +75,4 @@ UINT UploadAndReportProgressThread(void *owner, void *arg)
delete ftp;
return res;
-} \ No newline at end of file
+}