summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/transfers.cpp
blob: ca067399ca4558c7a3c3bdc0439fc9bd1936fefc (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 = service->Upload(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;
}