summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/JingleFileTransfer.cpp')
-rw-r--r--Swiften/FileTransfer/JingleFileTransfer.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp
index cc1cd1c..3d05db9 100644
--- a/Swiften/FileTransfer/JingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/JingleFileTransfer.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013-2018 Isode Limited. 2 * Copyright (c) 2013-2019 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -78,7 +78,7 @@ boost::optional<FileTransferError> JingleFileTransfer::getFileTransferError(Jing
78 78
79void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( 79void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished(
80 const std::string& s5bSessionID, const boost::optional<JingleS5BTransportPayload::Candidate>& candidate) { 80 const std::string& s5bSessionID, const boost::optional<JingleS5BTransportPayload::Candidate>& candidate) {
81 SWIFT_LOG(debug) << std::endl; 81 SWIFT_LOG(debug);
82 82
83 ourCandidateChoice = candidate; 83 ourCandidateChoice = candidate;
84 ourCandidateSelectFinished = true; 84 ourCandidateSelectFinished = true;
@@ -98,42 +98,42 @@ void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished(
98 98
99// decide on candidates according to http://xmpp.org/extensions/xep-0260.html#complete 99// decide on candidates according to http://xmpp.org/extensions/xep-0260.html#complete
100void JingleFileTransfer::decideOnCandidates() { 100void JingleFileTransfer::decideOnCandidates() {
101 SWIFT_LOG(debug) << std::endl; 101 SWIFT_LOG(debug);
102 if (!ourCandidateSelectFinished || !theirCandidateSelectFinished) { 102 if (!ourCandidateSelectFinished || !theirCandidateSelectFinished) {
103 SWIFT_LOG(debug) << "Can't make a decision yet!" << std::endl; 103 SWIFT_LOG(debug) << "Can't make a decision yet!";
104 return; 104 return;
105 } 105 }
106 if (!ourCandidateChoice && !theirCandidateChoice) { 106 if (!ourCandidateChoice && !theirCandidateChoice) {
107 SWIFT_LOG(debug) << "No candidates succeeded." << std::endl; 107 SWIFT_LOG(debug) << "No candidates succeeded.";
108 fallback(); 108 fallback();
109 } 109 }
110 else if (ourCandidateChoice && !theirCandidateChoice) { 110 else if (ourCandidateChoice && !theirCandidateChoice) {
111 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; 111 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << ".";
112 startTransferViaRemoteCandidate(); 112 startTransferViaRemoteCandidate();
113 } 113 }
114 else if (theirCandidateChoice && !ourCandidateChoice) { 114 else if (theirCandidateChoice && !ourCandidateChoice) {
115 SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << "." << std::endl; 115 SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << ".";
116 startTransferViaLocalCandidate(); 116 startTransferViaLocalCandidate();
117 } 117 }
118 else { 118 else {
119 SWIFT_LOG(debug) << "Choosing between candidates " 119 SWIFT_LOG(debug) << "Choosing between candidates "
120 << ourCandidateChoice->cid << "(" << ourCandidateChoice->priority << ")" << " and " 120 << ourCandidateChoice->cid << "(" << ourCandidateChoice->priority << ")" << " and "
121 << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")" << std::endl; 121 << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")";
122 if (ourCandidateChoice->priority > theirCandidateChoice->priority) { 122 if (ourCandidateChoice->priority > theirCandidateChoice->priority) {
123 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; 123 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << ".";
124 startTransferViaRemoteCandidate(); 124 startTransferViaRemoteCandidate();
125 } 125 }
126 else if (ourCandidateChoice->priority < theirCandidateChoice->priority) { 126 else if (ourCandidateChoice->priority < theirCandidateChoice->priority) {
127 SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << "." << std::endl; 127 SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << ".";
128 startTransferViaLocalCandidate(); 128 startTransferViaLocalCandidate();
129 } 129 }
130 else { 130 else {
131 if (hasPriorityOnCandidateTie()) { 131 if (hasPriorityOnCandidateTie()) {
132 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << std::endl; 132 SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid;
133 startTransferViaRemoteCandidate(); 133 startTransferViaRemoteCandidate();
134 } 134 }
135 else { 135 else {
136 SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << std::endl; 136 SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid;
137 startTransferViaLocalCandidate(); 137 startTransferViaLocalCandidate();
138 } 138 }
139 } 139 }
@@ -142,11 +142,11 @@ void JingleFileTransfer::decideOnCandidates() {
142 142
143void JingleFileTransfer::handleProxyActivateFinished( 143void JingleFileTransfer::handleProxyActivateFinished(
144 const std::string& s5bSessionID, ErrorPayload::ref error) { 144 const std::string& s5bSessionID, ErrorPayload::ref error) {
145 SWIFT_LOG(debug) << std::endl; 145 SWIFT_LOG(debug);
146 if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } 146 if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; }
147 147
148 if (error) { 148 if (error) {
149 SWIFT_LOG(debug) << "Error activating proxy" << std::endl; 149 SWIFT_LOG(debug) << "Error activating proxy";
150 JingleS5BTransportPayload::ref proxyError = std::make_shared<JingleS5BTransportPayload>(); 150 JingleS5BTransportPayload::ref proxyError = std::make_shared<JingleS5BTransportPayload>();
151 proxyError->setSessionID(s5bSessionID); 151 proxyError->setSessionID(s5bSessionID);
152 proxyError->setProxyError(true); 152 proxyError->setProxyError(true);
@@ -164,18 +164,18 @@ void JingleFileTransfer::handleProxyActivateFinished(
164 164
165void JingleFileTransfer::handleTransportInfoReceived( 165void JingleFileTransfer::handleTransportInfoReceived(
166 const JingleContentID& /* contentID */, JingleTransportPayload::ref transport) { 166 const JingleContentID& /* contentID */, JingleTransportPayload::ref transport) {
167 SWIFT_LOG(debug) << std::endl; 167 SWIFT_LOG(debug);
168 168
169 if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport)) { 169 if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport)) {
170 if (s5bPayload->hasCandidateError() || !s5bPayload->getCandidateUsed().empty()) { 170 if (s5bPayload->hasCandidateError() || !s5bPayload->getCandidateUsed().empty()) {
171 SWIFT_LOG(debug) << "Received candidate decision from peer" << std::endl; 171 SWIFT_LOG(debug) << "Received candidate decision from peer";
172 if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } 172 if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state"; return; }
173 173
174 theirCandidateSelectFinished = true; 174 theirCandidateSelectFinished = true;
175 if (!s5bPayload->hasCandidateError()) { 175 if (!s5bPayload->hasCandidateError()) {
176 auto theirCandidate = localCandidates.find(s5bPayload->getCandidateUsed()); 176 auto theirCandidate = localCandidates.find(s5bPayload->getCandidateUsed());
177 if (theirCandidate == localCandidates.end()) { 177 if (theirCandidate == localCandidates.end()) {
178 SWIFT_LOG(warning) << "Got invalid candidate" << std::endl; 178 SWIFT_LOG(warning) << "Got invalid candidate";
179 terminate(JinglePayload::Reason::GeneralError); 179 terminate(JinglePayload::Reason::GeneralError);
180 return; 180 return;
181 } 181 }
@@ -184,27 +184,27 @@ void JingleFileTransfer::handleTransportInfoReceived(
184 decideOnCandidates(); 184 decideOnCandidates();
185 } 185 }
186 else if (!s5bPayload->getActivated().empty()) { 186 else if (!s5bPayload->getActivated().empty()) {
187 SWIFT_LOG(debug) << "Received peer activate from peer" << std::endl; 187 SWIFT_LOG(debug) << "Received peer activate from peer";
188 if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } 188 if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; }
189 189
190 if (ourCandidateChoice->cid == s5bPayload->getActivated()) { 190 if (ourCandidateChoice->cid == s5bPayload->getActivated()) {
191 startTransferring(createRemoteCandidateSession()); 191 startTransferring(createRemoteCandidateSession());
192 } 192 }
193 else { 193 else {
194 SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!" << std::endl; 194 SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!";
195 terminate(JinglePayload::Reason::GeneralError); 195 terminate(JinglePayload::Reason::GeneralError);
196 } 196 }
197 } 197 }
198 else if (s5bPayload->hasProxyError()) { 198 else if (s5bPayload->hasProxyError()) {
199 SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB." << std::endl; 199 SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB.";
200 fallback(); 200 fallback();
201 } 201 }
202 else { 202 else {
203 SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; 203 SWIFT_LOG(debug) << "Ignoring unknown info";
204 } 204 }
205 } 205 }
206 else { 206 else {
207 SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; 207 SWIFT_LOG(debug) << "Ignoring unknown info";
208 } 208 }
209} 209}
210 210