summaryrefslogtreecommitdiffstats
blob: 2a8c3195d576ae087c3895fd9b066facefd938eb (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::filesystem::exists(filename) && boost::filesystem::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;
}

}