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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#pragma once
#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Elements/JingleContentPayload.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/Elements/StreamInitiationFileInfo.h>
#include <Swiften/Elements/S5BProxyRequest.h>
#include <Swiften/Elements/ErrorPayload.h>
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServerSession.h>
#include <Swiften/Jingle/JingleContentID.h>
#include <Swiften/Jingle/JingleSession.h>
namespace Swift {
class RemoteJingleTransportCandidateSelectorFactory;
class RemoteJingleTransportCandidateSelector;
class LocalJingleTransportCandidateGeneratorFactory;
class LocalJingleTransportCandidateGenerator;
class IQRouter;
class ReadBytestream;
class IBBSendSession;
class IDGenerator;
class IncrementalBytestreamHashCalculator;
class SOCKS5BytestreamRegistry;
class SOCKS5BytestreamProxy;
class CryptoProvider;
class SWIFTEN_API OutgoingJingleFileTransfer : public OutgoingFileTransfer {
public:
OutgoingJingleFileTransfer(JingleSession::ref,
RemoteJingleTransportCandidateSelectorFactory*,
LocalJingleTransportCandidateGeneratorFactory*,
IQRouter*,
IDGenerator*,
const JID& from,
const JID& to,
boost::shared_ptr<ReadBytestream>,
const StreamInitiationFileInfo&,
SOCKS5BytestreamRegistry*,
SOCKS5BytestreamProxy*,
CryptoProvider*);
virtual ~OutgoingJingleFileTransfer();
void start();
void stop();
void cancel();
private:
void handleSessionAcceptReceived(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref);
void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason);
void handleTransportAcceptReceived(const JingleContentID&, JingleTransportPayload::ref);
void handleTransportInfoReceived(const JingleContentID&, JingleTransportPayload::ref);
void handleLocalTransportCandidatesGenerated(JingleTransportPayload::ref);
void handleRemoteTransportCandidateSelectFinished(JingleTransportPayload::ref);
private:
void replaceTransportWithIBB(const JingleContentID&);
void handleTransferFinished(boost::optional<FileTransferError>);
void activateProxySession(const JID &proxy);
void handleActivateProxySessionResult(boost::shared_ptr<S5BProxyRequest> request, ErrorPayload::ref error);
void proxySessionReady(const JID& proxy, bool error);
private:
typedef std::map<std::string, JingleS5BTransportPayload::Candidate> CandidateMap;
private:
void startTransferViaOurCandidateChoice(JingleS5BTransportPayload::Candidate);
void startTransferViaTheirCandidateChoice(JingleS5BTransportPayload::Candidate);
void decideOnCandidates();
void fillCandidateMap(CandidateMap& map, JingleS5BTransportPayload::ref s5bPayload);
private:
void sendSessionInfoHash();
private:
JingleSession::ref session;
RemoteJingleTransportCandidateSelector* remoteCandidateSelector;
LocalJingleTransportCandidateGenerator* localCandidateGenerator;
IQRouter* router;
IDGenerator* idGenerator;
JID fromJID;
JID toJID;
boost::shared_ptr<ReadBytestream> readStream;
StreamInitiationFileInfo fileInfo;
IncrementalBytestreamHashCalculator *hashCalculator;
boost::shared_ptr<IBBSendSession> ibbSession;
JingleS5BTransportPayload::ref ourCandidateChoice;
JingleS5BTransportPayload::ref theirCandidateChoice;
CandidateMap ourCandidates;
CandidateMap theirCandidates;
SOCKS5BytestreamRegistry* s5bRegistry;
SOCKS5BytestreamProxy* s5bProxy;
CryptoProvider* crypto;
SOCKS5BytestreamClientSession::ref clientSession;
SOCKS5BytestreamServerSession* serverSession;
JingleContentID contentID;
std::string s5bSessionID;
bool canceled;
};
}
|