summaryrefslogtreecommitdiffstats
blob: 0ed2395c4dcec577d1a5e4f9f53728bcb0e2a72f (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2011 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

/*
 * Copyright (c) 2013-2015 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <Swiften/FileTransfer/OutgoingFileTransferManager.h>

#include <boost/smart_ptr/make_shared.hpp>

#include <Swiften/JID/JID.h>
#include <Swiften/Jingle/JingleSessionManager.h>
#include <Swiften/Jingle/JingleSessionImpl.h>
#include <Swiften/Jingle/JingleContentID.h>
#include <Swiften/FileTransfer/OutgoingJingleFileTransfer.h>
#include <Swiften/Base/IDGenerator.h>

namespace Swift {

OutgoingFileTransferManager::OutgoingFileTransferManager(
		JingleSessionManager* jingleSessionManager, 
		IQRouter* router,
		FileTransferTransporterFactory* transporterFactory,
		TimerFactory* timerFactory,
		CryptoProvider* crypto) : 
			jingleSessionManager(jingleSessionManager), 
			iqRouter(router), 
			transporterFactory(transporterFactory),
			timerFactory(timerFactory),
			crypto(crypto) {
	idGenerator = new IDGenerator();
}

OutgoingFileTransferManager::~OutgoingFileTransferManager() {
	delete idGenerator;
}

boost::shared_ptr<OutgoingFileTransfer> OutgoingFileTransferManager::createOutgoingFileTransfer(
		const JID& from, 
		const JID& recipient, 
		boost::shared_ptr<ReadBytestream> readBytestream, 
		const JingleFileTransferFileInfo& fileInfo,
		const FileTransferOptions& config) {
	JingleSessionImpl::ref jingleSession = boost::make_shared<JingleSessionImpl>(
			from, recipient, idGenerator->generateID(), iqRouter);
	jingleSessionManager->registerOutgoingSession(from, jingleSession);
	return boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(
				recipient, 
				jingleSession, 
				readBytestream, 
				transporterFactory,
				timerFactory,
				idGenerator, 
				fileInfo, 
				config,
				crypto));
}

}