summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp')
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
index f9441cd..6369581 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
@@ -87,11 +87,11 @@ void OutgoingJingleFileTransfer::start() {
87 SWIFT_LOG(warning) << "Incorrect state" << std::endl; 87 SWIFT_LOG(warning) << "Incorrect state" << std::endl;
88 return; 88 return;
89 } 89 }
90 90
91 setTransporter(transporterFactory->createInitiatorTransporter(getInitiator(), getResponder(), options)); 91 setTransporter(transporterFactory->createInitiatorTransporter(getInitiator(), getResponder(), options));
92 setState(GeneratingInitialLocalCandidates); 92 setInternalState(GeneratingInitialLocalCandidates);
93 transporter->startGeneratingLocalCandidates(); 93 transporter->startGeneratingLocalCandidates();
94} 94}
95 95
96void OutgoingJingleFileTransfer::cancel() { 96void OutgoingJingleFileTransfer::cancel() {
97 terminate(JinglePayload::Reason::Cancel); 97 terminate(JinglePayload::Reason::Cancel);
@@ -114,11 +114,11 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived(
114 SWIFT_LOG(debug) << std::endl; 114 SWIFT_LOG(debug) << std::endl;
115 if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } 115 if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; }
116 116
117 if (JingleS5BTransportPayload::ref s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) { 117 if (JingleS5BTransportPayload::ref s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) {
118 transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr()); 118 transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr());
119 setState(TryingCandidates); 119 setInternalState(TryingCandidates);
120 transporter->startTryingRemoteCandidates(); 120 transporter->startTryingRemoteCandidates();
121 } 121 }
122 else { 122 else {
123 SWIFT_LOG(debug) << "Unknown transport payload. Falling back." << std::endl; 123 SWIFT_LOG(debug) << "Unknown transport payload. Falling back." << std::endl;
124 fallback(); 124 fallback();
@@ -176,11 +176,11 @@ void OutgoingJingleFileTransfer::sendSessionInfoHash() {
176} 176}
177 177
178void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( 178void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated(
179 const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) { 179 const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) {
180 SWIFT_LOG(debug) << std::endl; 180 SWIFT_LOG(debug) << std::endl;
181 if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } 181 if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; }
182 182
183 fillCandidateMap(localCandidates, candidates); 183 fillCandidateMap(localCandidates, candidates);
184 184
185 JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>(); 185 JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>();
186 fileInfo.addHash(HashElement("sha-1", ByteArray())); 186 fileInfo.addHash(HashElement("sha-1", ByteArray()));
@@ -193,21 +193,21 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated(
193 transport->setDstAddr(dstAddr); 193 transport->setDstAddr(dstAddr);
194 foreach(JingleS5BTransportPayload::Candidate candidate, candidates) { 194 foreach(JingleS5BTransportPayload::Candidate candidate, candidates) {
195 transport->addCandidate(candidate); 195 transport->addCandidate(candidate);
196 SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl; 196 SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl;
197 } 197 }
198 setState(WaitingForAccept); 198 setInternalState(WaitingForAccept);
199 session->sendInitiate(contentID, description, transport); 199 session->sendInitiate(contentID, description, transport);
200} 200}
201 201
202void OutgoingJingleFileTransfer::fallback() { 202void OutgoingJingleFileTransfer::fallback() {
203 if (options.isInBandAllowed()) { 203 if (options.isInBandAllowed()) {
204 SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl; 204 SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl;
205 JingleIBBTransportPayload::ref ibbTransport = boost::make_shared<JingleIBBTransportPayload>(); 205 JingleIBBTransportPayload::ref ibbTransport = boost::make_shared<JingleIBBTransportPayload>();
206 ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); 206 ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE);
207 ibbTransport->setSessionID(idGenerator->generateID()); 207 ibbTransport->setSessionID(idGenerator->generateID());
208 setState(FallbackRequested); 208 setInternalState(FallbackRequested);
209 session->sendTransportReplace(contentID, ibbTransport); 209 session->sendTransportReplace(contentID, ibbTransport);
210 } 210 }
211 else { 211 else {
212 SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl; 212 SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl;
213 terminate(JinglePayload::Reason::ConnectivityError); 213 terminate(JinglePayload::Reason::ConnectivityError);
@@ -223,11 +223,11 @@ void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTran
223 } 223 }
224 else { 224 else {
225 sendSessionInfoHash(); 225 sendSessionInfoHash();
226 226
227 // wait for other party to terminate session after they have verified the hash 227 // wait for other party to terminate session after they have verified the hash
228 setState(WaitForTermination); 228 setInternalState(WaitForTermination);
229 waitForRemoteTermination->start(); 229 waitForRemoteTermination->start();
230 } 230 }
231} 231}
232 232
233void OutgoingJingleFileTransfer::startTransferring(boost::shared_ptr<TransportSession> transportSession) { 233void OutgoingJingleFileTransfer::startTransferring(boost::shared_ptr<TransportSession> transportSession) {
@@ -236,19 +236,19 @@ void OutgoingJingleFileTransfer::startTransferring(boost::shared_ptr<TransportSe
236 this->transportSession = transportSession; 236 this->transportSession = transportSession;
237 processedBytesConnection = transportSession->onBytesSent.connect( 237 processedBytesConnection = transportSession->onBytesSent.connect(
238 boost::bind(boost::ref(onProcessedBytes), _1)); 238 boost::bind(boost::ref(onProcessedBytes), _1));
239 transferFinishedConnection = transportSession->onFinished.connect( 239 transferFinishedConnection = transportSession->onFinished.connect(
240 boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1)); 240 boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1));
241 setState(Transferring); 241 setInternalState(Transferring);
242 transportSession->start(); 242 transportSession->start();
243} 243}
244 244
245 245
246void OutgoingJingleFileTransfer::setState(State state) { 246void OutgoingJingleFileTransfer::setInternalState(State state) {
247 SWIFT_LOG(debug) << state << std::endl; 247 SWIFT_LOG(debug) << state << std::endl;
248 this->state = state; 248 this->state = state;
249 onStateChanged(FileTransfer::State(getExternalState(state))); 249 setState(FileTransfer::State(getExternalState(state)));
250} 250}
251 251
252void OutgoingJingleFileTransfer::setFinishedState( 252void OutgoingJingleFileTransfer::setFinishedState(
253 FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) { 253 FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) {
254 SWIFT_LOG(debug) << std::endl; 254 SWIFT_LOG(debug) << std::endl;
@@ -304,11 +304,11 @@ void OutgoingJingleFileTransfer::stopAll() {
304 304
305void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() { 305void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() {
306 SWIFT_LOG(debug) << std::endl; 306 SWIFT_LOG(debug) << std::endl;
307 307
308 if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { 308 if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) {
309 setState(WaitingForPeerProxyActivate); 309 setInternalState(WaitingForPeerProxyActivate);
310 } 310 }
311 else { 311 else {
312 transportSession = createRemoteCandidateSession(); 312 transportSession = createRemoteCandidateSession();
313 startTransferringIfCandidateAcknowledged(); 313 startTransferringIfCandidateAcknowledged();
314 } 314 }
@@ -316,11 +316,11 @@ void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() {
316 316
317void OutgoingJingleFileTransfer::startTransferViaLocalCandidate() { 317void OutgoingJingleFileTransfer::startTransferViaLocalCandidate() {
318 SWIFT_LOG(debug) << std::endl; 318 SWIFT_LOG(debug) << std::endl;
319 319
320 if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { 320 if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) {
321 setState(WaitingForLocalProxyActivate); 321 setInternalState(WaitingForLocalProxyActivate);
322 transporter->startActivatingProxy(theirCandidateChoice->jid); 322 transporter->startActivatingProxy(theirCandidateChoice->jid);
323 } 323 }
324 else { 324 else {
325 transportSession = createLocalCandidateSession(); 325 transportSession = createLocalCandidateSession();
326 startTransferringIfCandidateAcknowledged(); 326 startTransferringIfCandidateAcknowledged();
@@ -330,11 +330,11 @@ void OutgoingJingleFileTransfer::startTransferViaLocalCandidate() {
330void OutgoingJingleFileTransfer::startTransferringIfCandidateAcknowledged() { 330void OutgoingJingleFileTransfer::startTransferringIfCandidateAcknowledged() {
331 if (candidateAcknowledged) { 331 if (candidateAcknowledged) {
332 startTransferring(transportSession); 332 startTransferring(transportSession);
333 } 333 }
334 else { 334 else {
335 setState(WaitingForCandidateAcknowledge); 335 setInternalState(WaitingForCandidateAcknowledge);
336 } 336 }
337} 337}
338 338
339void OutgoingJingleFileTransfer::handleTransportInfoAcknowledged(const std::string& id) { 339void OutgoingJingleFileTransfer::handleTransportInfoAcknowledged(const std::string& id) {
340 if (id == candidateSelectRequestID) { 340 if (id == candidateSelectRequestID) {