summaryrefslogtreecommitdiff
path: root/protocols/CloudFile/src/transfers.cpp
blob: 5236e0c9f0239f97263c57ecf88c510812304d2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "stdafx.h"

LIST<FileTransferParam> Transfers(1, HandleKeySortT);

INT_PTR SendFileInterceptor(WPARAM, LPARAM lParam)
{
	CCSDATA *pccsd = (CCSDATA*)lParam;
	for (auto &service : Services) {
		auto it = service->InterceptedContacts.find(pccsd->hContact);
		if (it == service->InterceptedContacts.end())
			continue;
		service->InterceptedContacts.erase(it);
		return (INT_PTR)service->SendFile(pccsd->hContact, (wchar_t*)pccsd->wParam, (wchar_t**)pccsd->lParam);
	}
	return CALLSERVICE_NOTFOUND;
}

UINT UploadAndReportProgressThread(void *owner, void *arg)
{
	CCloudService *service = (CCloudService*)owner;
	FileTransferParam *ftp = (FileTransferParam*)arg;

	int res = CCloudService::Upload(service, ftp);
	if (res == ACKRESULT_SUCCESS) {
		CMStringW data = ftp->GetDescription();
		size_t linkCount;
		auto links = ftp->GetSharedLinks(linkCount);
		for (size_t i = 0; i < linkCount; i++) {
			data.Append(ptrW(mir_utf8decodeW(links[i])));
			data.AppendChar(0x0A);
		}
		Report(ftp->GetContact(), data);
	}

	Transfers.remove(ftp);
	delete ftp;

	return res;
}