summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp')
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
index 07e927e..7ff1a08 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
@@ -108,25 +108,25 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived(
JingleDescription::ref,
JingleTransportPayload::ref transportPayload) {
SWIFT_LOG(debug) << std::endl;
if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; }
if (JingleS5BTransportPayload::ref s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) {
- transporter->addRemoteCandidates(s5bPayload->getCandidates());
+ transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr());
setState(TryingCandidates);
transporter->startTryingRemoteCandidates();
}
else {
SWIFT_LOG(debug) << "Unknown transport payload. Falling back." << std::endl;
fallback();
}
}
void OutgoingJingleFileTransfer::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) {
SWIFT_LOG(debug) << std::endl;
- if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; }
+ if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; }
stopAll();
if (reason && reason->type == JinglePayload::Reason::Cancel) {
setFinishedState(FileTransfer::State::Canceled, FileTransferError(FileTransferError::PeerError));
}
else if (reason && reason->type == JinglePayload::Reason::Success) {
@@ -147,23 +147,29 @@ void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleConte
else {
SWIFT_LOG(debug) << "Unknown transport replacement" << std::endl;
terminate(JinglePayload::Reason::FailedTransport);
}
}
+void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleContentID &, boost::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(debug) << std::endl;
+
+ terminate(JinglePayload::Reason::UnsupportedTransports);
+}
+
void OutgoingJingleFileTransfer::sendSessionInfoHash() {
SWIFT_LOG(debug) << std::endl;
JingleFileTransferHash::ref hashElement = boost::make_shared<JingleFileTransferHash>();
hashElement->getFileInfo().addHash(HashElement("sha-1", hashCalculator->getSHA1Hash()));
hashElement->getFileInfo().addHash(HashElement("md5", hashCalculator->getMD5Hash()));
session->sendInfo(hashElement);
}
void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated(
- const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates) {
+ const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) {
SWIFT_LOG(debug) << std::endl;
if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; }
fillCandidateMap(localCandidates, candidates);
JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>();
@@ -171,36 +177,38 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated(
fileInfo.addHash(HashElement("md5", ByteArray()));
description->setFileInfo(fileInfo);
JingleS5BTransportPayload::ref transport = boost::make_shared<JingleS5BTransportPayload>();
transport->setSessionID(s5bSessionID);
transport->setMode(JingleS5BTransportPayload::TCPMode);
+ transport->setDstAddr(dstAddr);
foreach(JingleS5BTransportPayload::Candidate candidate, candidates) {
transport->addCandidate(candidate);
}
setState(WaitingForAccept);
session->sendInitiate(contentID, description, transport);
}
void OutgoingJingleFileTransfer::fallback() {
- SWIFT_LOG(debug) << std::endl;
if (options.isInBandAllowed()) {
+ SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl;
JingleIBBTransportPayload::ref ibbTransport = boost::make_shared<JingleIBBTransportPayload>();
ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE);
ibbTransport->setSessionID(idGenerator->generateID());
setState(FallbackRequested);
session->sendTransportReplace(contentID, ibbTransport);
}
else {
+ SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl;
terminate(JinglePayload::Reason::ConnectivityError);
}
}
void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTransferError> error) {
SWIFT_LOG(debug) << std::endl;
- if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; }
+ if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; }
if (error) {
terminate(JinglePayload::Reason::ConnectivityError);
}
else {
sendSessionInfoHash();
@@ -344,17 +352,17 @@ bool OutgoingJingleFileTransfer::isWaitingForLocalProxyActivate() const {
bool OutgoingJingleFileTransfer::isTryingCandidates() const {
return state == TryingCandidates;
}
boost::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createLocalCandidateSession() {
- return transporter->createLocalCandidateSession(stream);
+ return transporter->createLocalCandidateSession(stream, theirCandidateChoice.get());
}
boost::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCandidateSession() {
- return transporter->createRemoteCandidateSession(stream);
+ return transporter->createRemoteCandidateSession(stream, ourCandidateChoice.get());
}
void OutgoingJingleFileTransfer::handleWaitForRemoteTerminationTimeout() {
assert(state == WaitForTermination);
SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now." << std::endl;
waitForRemoteTermination->stop();