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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Copyright (c) 2013 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <Swiften/Base/Override.h>
#include <Swiften/Base/API.h>
#include <Swiften/FileTransfer/FileTransferTransporter.h>
namespace Swift {
class LocalJingleTransportCandidateGenerator;
class RemoteJingleTransportCandidateSelector;
class SOCKS5BytestreamRegistry;
class SOCKS5BytestreamServerManager;
class SOCKS5BytestreamProxiesManager;
class SOCKS5BytestreamClientSession;
class SOCKS5BytestreamServerSession;
class IDGenerator;
class IQRouter;
class ReadBytestream;
class WriteBytestream;
class ConnectionFactory;
class TimerFactory;
class CryptoProvider;
class SWIFTEN_API DefaultFileTransferTransporter : public FileTransferTransporter {
public:
enum Role {
Initiator,
Responder
};
DefaultFileTransferTransporter(
const JID& initiator,
const JID& responder,
Role role,
SOCKS5BytestreamRegistry*,
SOCKS5BytestreamServerManager* s5bServerManager,
SOCKS5BytestreamProxiesManager* s5bProxy,
IDGenerator* idGenerator,
ConnectionFactory*,
TimerFactory*,
CryptoProvider*,
IQRouter*);
virtual ~DefaultFileTransferTransporter();
virtual void initialize();
virtual void initialize(const std::string& s5bSessionID);
virtual void startGeneratingLocalCandidates() SWIFTEN_OVERRIDE;
virtual void stopGeneratingLocalCandidates() SWIFTEN_OVERRIDE;
virtual void addRemoteCandidates(
const std::vector<JingleS5BTransportPayload::Candidate>&) SWIFTEN_OVERRIDE;
virtual void startTryingRemoteCandidates() SWIFTEN_OVERRIDE;
virtual void stopTryingRemoteCandidates() SWIFTEN_OVERRIDE;
virtual void startActivatingProxy(const JID& jid) SWIFTEN_OVERRIDE;
virtual void stopActivatingProxy() SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createIBBSendSession(
const std::string& sessionID, unsigned int blockSize, boost::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createIBBReceiveSession(
const std::string& sessionID, unsigned long long size, boost::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession(
boost::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession(
boost::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createLocalCandidateSession(
boost::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE;
virtual boost::shared_ptr<TransportSession> createLocalCandidateSession(
boost::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE;
private:
void handleLocalCandidatesGenerated(const std::vector<JingleS5BTransportPayload::Candidate>&);
void handleRemoteCandidateSelectFinished(
const boost::optional<JingleS5BTransportPayload::Candidate>&,
boost::shared_ptr<SOCKS5BytestreamClientSession>);
std::string getSOCKS5DstAddr() const;
void closeLocalSession();
void closeRemoteSession();
boost::shared_ptr<SOCKS5BytestreamServerSession> getServerSession();
private:
JID initiator;
JID responder;
Role role;
SOCKS5BytestreamRegistry* s5bRegistry;
SOCKS5BytestreamServerManager* s5bServerManager;
CryptoProvider* crypto;
IQRouter* router;
LocalJingleTransportCandidateGenerator* localCandidateGenerator;
RemoteJingleTransportCandidateSelector* remoteCandidateSelector;
std::string s5bSessionID;
boost::shared_ptr<SOCKS5BytestreamClientSession> remoteS5BClientSession;
};
}
|