diff options
author | Tobias Markmann <tm@ayena.de> | 2015-01-11 15:40:09 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2015-02-11 09:36:03 (GMT) |
commit | f176050a50fb846bbad3fb49d6b2f7a2c81e3589 (patch) | |
tree | bd93b8b540cb3818cc0d47d44b9dd8751dd17dd5 /Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp | |
parent | 71e34ffa7144441bc5a7fce15728f506daffc756 (diff) | |
download | swift-f176050a50fb846bbad3fb49d6b2f7a2c81e3589.zip swift-f176050a50fb846bbad3fb49d6b2f7a2c81e3589.tar.bz2 |
Wait for responder to terminate the the file transfer session after data
verification.
Test-Information:
Tested with FileTransferTest (coming with future commit) and inspected
the logs.
Change-Id: Idd2739e15ab944e8486065cb2a3bc559ce9053d1
Diffstat (limited to 'Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp')
-rw-r--r-- | Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index 4183af7..07e927e 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp @@ -36,6 +36,7 @@ #include <Swiften/FileTransfer/ReadBytestream.h> #include <Swiften/FileTransfer/TransportSession.h> #include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/Network/TimerFactory.h> #include <Swiften/Base/Log.h> @@ -48,6 +49,7 @@ OutgoingJingleFileTransfer::OutgoingJingleFileTransfer( JingleSession::ref session, boost::shared_ptr<ReadBytestream> stream, FileTransferTransporterFactory* transporterFactory, + TimerFactory* timerFactory, IDGenerator* idGenerator, const JingleFileTransferFileInfo& fileInfo, const FileTransferOptions& options, @@ -67,6 +69,9 @@ OutgoingJingleFileTransfer::OutgoingJingleFileTransfer( hashCalculator = new IncrementalBytestreamHashCalculator(true, true, crypto); stream->onRead.connect( boost::bind(&IncrementalBytestreamHashCalculator::feedData, hashCalculator, _1)); + + waitForRemoteTermination = timerFactory->createTimer(5000); + waitForRemoteTermination->onTick.connect(boost::bind(&OutgoingJingleFileTransfer::handleWaitForRemoteTerminationTimeout, this)); } OutgoingJingleFileTransfer::~OutgoingJingleFileTransfer() { @@ -199,7 +204,10 @@ void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTran } else { sendSessionInfoHash(); - terminate(JinglePayload::Reason::Success); + + // wait for other party to terminate session after they have verified the hash + setState(WaitForTermination); + waitForRemoteTermination->start(); } } @@ -241,6 +249,7 @@ FileTransfer::State::Type OutgoingJingleFileTransfer::getExternalState(State sta case WaitingForCandidateAcknowledge: return FileTransfer::State::Negotiating; case FallbackRequested: return FileTransfer::State::Negotiating; case Transferring: return FileTransfer::State::Transferring; + case WaitForTermination: return FileTransfer::State::Transferring; case Finished: return FileTransfer::State::Finished; } assert(false); @@ -265,6 +274,8 @@ void OutgoingJingleFileTransfer::stopAll() { transportSession->stop(); transportSession.reset(); break; + case WaitForTermination: + break; case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; } if (state != Initial) { @@ -343,3 +354,10 @@ boost::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCand return transporter->createRemoteCandidateSession(stream); } +void OutgoingJingleFileTransfer::handleWaitForRemoteTerminationTimeout() { + assert(state == WaitForTermination); + SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now." << std::endl; + waitForRemoteTermination->stop(); + terminate(JinglePayload::Reason::MediaError); +} + |