summaryrefslogtreecommitdiffstats
blob: e45c7f29ad24e60a534ae1a93796bebf7f5ca65b (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
40
41
42
43
44
/*
 * Copyright (c) 2011 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#include "FileTransferOverview.h"

#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <Swiften/Base/boost_bsignals.h>

#include <Swiften/FileTransfer/FileTransferManager.h>

namespace Swift {

FileTransferOverview::FileTransferOverview(FileTransferManager* ftm) : fileTransferManager(ftm) {
	fileTransferManager->onIncomingFileTransfer.connect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1));
}

FileTransferOverview::~FileTransferOverview() {
	
}
	
void FileTransferOverview::sendFile(const JID& jid, const std::string& filename) {
	if (boost::filesystem2::exists(filename) && boost::filesystem2::file_size(filename) > 0) {
		FileTransferController* controller = new FileTransferController(jid, filename, fileTransferManager);
		fileTransfers.push_back(controller);

		onNewFileTransferController(controller);
	}
}

void FileTransferOverview::handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) {
	FileTransferController* controller = new FileTransferController(transfer);
	fileTransfers.push_back(controller);
	onNewFileTransferController(controller);
}

const std::vector<FileTransferController*>& FileTransferOverview::getFileTransfers() const {
	return fileTransfers;
}

}