summaryrefslogtreecommitdiffstats
blob: ed2b4f0782ad28f3ea55c507eec4adb4c197e9a6 (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
/*
 * 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.
 */

#pragma once

#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h>

#include <Swiften/Base/IDGenerator.h>
#include <Swiften/Base/Override.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h>

namespace Swift {
	class SOCKS5BytestreamServerManager;
	class SOCKS5BytestreamProxiesManager;
	class SOCKS5BytestreamServerInitializeRequest;
	class JingleS5BTransportPayload;

	class LocalJingleTransportCandidateGenerator {
		public:
			LocalJingleTransportCandidateGenerator(
					SOCKS5BytestreamServerManager* s5bServerManager,
					SOCKS5BytestreamProxiesManager* s5bProxy, 
					const JID& ownJID,
					IDGenerator* idGenerator,
					const FileTransferOptions& options);
			virtual ~LocalJingleTransportCandidateGenerator();

			virtual void start();
			virtual void stop();

			boost::signal<void (const std::vector<JingleS5BTransportPayload::Candidate>&)> onLocalTransportCandidatesGenerated;

		private:
			void handleS5BServerInitialized(bool success);
			void handleDiscoveredProxiesChanged();

			void checkS5BCandidatesReady();
			void emitOnLocalTransportCandidatesGenerated();

		private:
			SOCKS5BytestreamServerManager* s5bServerManager;
			SOCKS5BytestreamProxiesManager* s5bProxy;
			JID ownJID;
			IDGenerator* idGenerator;
			boost::shared_ptr<SOCKS5BytestreamServerInitializeRequest> s5bServerInitializeRequest;
			FileTransferOptions options_;
	};
}