diff options
Diffstat (limited to 'Swiften/FileTransfer')
41 files changed, 301 insertions, 314 deletions
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp index cd9fa4a..3fdff27 100644 --- a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp +++ b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,13 +19,19 @@ std::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) { if (position + readSize > data.size()) { readSize = data.size() - position; } - std::shared_ptr<ByteArray> result = std::make_shared<ByteArray>( - data.begin() + boost::numeric_cast<long long>(position), - data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize)); - - onRead(*result); - position += readSize; - return result; + try { + std::shared_ptr<ByteArray> result = std::make_shared<ByteArray>( + data.begin() + boost::numeric_cast<long long>(position), + data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize)); + onRead(*result); + position += readSize; + return result; + } + catch (const boost::numeric::bad_numeric_cast&) { + // If we cannot cast to long long, we probably ran out of memory long ago + assert(false); + return {}; + } } void ByteArrayReadBytestream::addData(const std::vector<unsigned char>& moreData) { diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index c6987c0..ae3d7e0 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -133,7 +133,7 @@ void DefaultFileTransferTransporter::handleActivateProxySessionResult(const std: void DefaultFileTransferTransporter::startActivatingProxy(const JID& proxyServiceJID) { // activate proxy - SWIFT_LOG(debug) << "Start activating proxy " << proxyServiceJID.toString() << " with sid = " << s5bSessionID << "." << std::endl; + SWIFT_LOG(debug) << "Start activating proxy " << proxyServiceJID.toString() << " with sid = " << s5bSessionID << "."; S5BProxyRequest::ref proxyRequest = std::make_shared<S5BProxyRequest>(); proxyRequest->setSID(s5bSessionID); proxyRequest->setActivate(role == Initiator ? responder : initiator); @@ -207,7 +207,7 @@ std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCan transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } else { - SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "." << std::endl; + SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "."; } } @@ -234,7 +234,7 @@ std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCan transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } else { - SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "." << std::endl; + SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "."; } } @@ -255,11 +255,11 @@ std::string DefaultFileTransferTransporter::getSOCKS5DstAddr() const { std::string result; if (role == Initiator) { result = getInitiatorCandidateSOCKS5DstAddr(); - SWIFT_LOG(debug) << "Initiator S5B DST.ADDR = " << s5bSessionID << " + " << initiator.toString() << " + " << responder.toString() << " : " << result << std::endl; + SWIFT_LOG(debug) << "Initiator S5B DST.ADDR = " << s5bSessionID << " + " << initiator.toString() << " + " << responder.toString() << " : " << result; } else { result = getResponderCandidateSOCKS5DstAddr(); - SWIFT_LOG(debug) << "Responder S5B DST.ADDR = " << s5bSessionID << " + " << responder.toString() << " + " << initiator.toString() << " : " << result << std::endl; + SWIFT_LOG(debug) << "Responder S5B DST.ADDR = " << s5bSessionID << " + " << responder.toString() << " + " << initiator.toString() << " : " << result; } return result; } diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.h b/Swiften/FileTransfer/DefaultFileTransferTransporter.h index 339232f..1bfe799 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.h +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/ErrorPayload.h> #include <Swiften/FileTransfer/FileTransferTransporter.h> @@ -48,35 +47,35 @@ namespace Swift { CryptoProvider*, IQRouter*, const FileTransferOptions&); - virtual ~DefaultFileTransferTransporter(); + virtual ~DefaultFileTransferTransporter() override; virtual void initialize(); virtual void initialize(const std::string& s5bSessionID); - virtual void startGeneratingLocalCandidates() SWIFTEN_OVERRIDE; - virtual void stopGeneratingLocalCandidates() SWIFTEN_OVERRIDE; + virtual void startGeneratingLocalCandidates() override; + virtual void stopGeneratingLocalCandidates() override; virtual void addRemoteCandidates( - const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) SWIFTEN_OVERRIDE; - virtual void startTryingRemoteCandidates() SWIFTEN_OVERRIDE; - virtual void stopTryingRemoteCandidates() SWIFTEN_OVERRIDE; + const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string&) override; + virtual void startTryingRemoteCandidates() override; + virtual void stopTryingRemoteCandidates() override; - virtual void startActivatingProxy(const JID& jid) SWIFTEN_OVERRIDE; - virtual void stopActivatingProxy() SWIFTEN_OVERRIDE; + virtual void startActivatingProxy(const JID& jid) override; + virtual void stopActivatingProxy() override; virtual std::shared_ptr<TransportSession> createIBBSendSession( - const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE; + const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) override; virtual std::shared_ptr<TransportSession> createIBBReceiveSession( - const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE; + const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) override; virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( - std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( - std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createLocalCandidateSession( - std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; virtual std::shared_ptr<TransportSession> createLocalCandidateSession( - std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) override; private: void handleLocalCandidatesGenerated(const std::vector<JingleS5BTransportPayload::Candidate>&); diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h index 3cc3455..fe4f6ea 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h +++ b/Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferTransporterFactory.h> namespace Swift { @@ -31,12 +30,12 @@ namespace Swift { TimerFactory*, CryptoProvider*, IQRouter*); - virtual ~DefaultFileTransferTransporterFactory(); + virtual ~DefaultFileTransferTransporterFactory() override; virtual FileTransferTransporter* createInitiatorTransporter( - const JID& initiator, const JID& responder, const FileTransferOptions&) SWIFTEN_OVERRIDE; + const JID& initiator, const JID& responder, const FileTransferOptions&) override; virtual FileTransferTransporter* createResponderTransporter( - const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) SWIFTEN_OVERRIDE; + const JID& initiator, const JID& responder, const std::string& s5bSessionID, const FileTransferOptions&) override; private: SOCKS5BytestreamRegistry* s5bRegistry; diff --git a/Swiften/FileTransfer/FailingTransportSession.cpp b/Swiften/FileTransfer/FailingTransportSession.cpp index d1eb6a6..b9c79a0 100644 --- a/Swiften/FileTransfer/FailingTransportSession.cpp +++ b/Swiften/FileTransfer/FailingTransportSession.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -14,7 +14,7 @@ FailingTransportSession::~FailingTransportSession() { } void FailingTransportSession::start() { - SWIFT_LOG(error) << "Trying to start failing transport." << std::endl; + SWIFT_LOG(error) << "Trying to start failing transport."; onFinished(FileTransferError(FileTransferError::PeerError)); } diff --git a/Swiften/FileTransfer/FailingTransportSession.h b/Swiften/FileTransfer/FailingTransportSession.h index 6e0e16e..489786b 100644 --- a/Swiften/FileTransfer/FailingTransportSession.h +++ b/Swiften/FileTransfer/FailingTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,10 +13,10 @@ namespace Swift { class SWIFTEN_API FailingTransportSession : public TransportSession { public: - virtual ~FailingTransportSession(); + virtual ~FailingTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; }; } diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp index 05dd3bb..98eb50e 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp +++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -156,7 +156,7 @@ OutgoingFileTransfer::ref FileTransferManagerImpl::createOutgoingFileTransfer( } } else { - SWIFT_LOG(warning) << "No entity capabilities information for " << receipient.toString() << std::endl; + SWIFT_LOG(warning) << "No entity capabilities information for " << receipient.toString(); } return outgoingFTManager->createOutgoingFileTransfer(iqRouter->getJID(), receipient, bytestream, fileInfo, options); diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h index 026c8b7..d3d55f0 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.h +++ b/Swiften/FileTransfer/FileTransferManagerImpl.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -22,7 +22,6 @@ #include <Swiften/Base/API.h> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/S5BProxyRequest.h> #include <Swiften/FileTransfer/FileTransferManager.h> #include <Swiften/FileTransfer/FileTransferOptions.h> @@ -65,14 +64,14 @@ namespace Swift { NetworkEnvironment* networkEnvironment, NATTraverser* natTraverser, CryptoProvider* crypto); - virtual ~FileTransferManagerImpl(); + virtual ~FileTransferManagerImpl() override; OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, const boost::filesystem::path& filepath, const std::string& description, std::shared_ptr<ReadBytestream> bytestream, - const FileTransferOptions&) SWIFTEN_OVERRIDE; + const FileTransferOptions&) override; OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, const std::string& filename, @@ -80,7 +79,7 @@ namespace Swift { const boost::uintmax_t sizeInBytes, const boost::posix_time::ptime& lastModified, std::shared_ptr<ReadBytestream> bytestream, - const FileTransferOptions&) SWIFTEN_OVERRIDE; + const FileTransferOptions&) override; void start(); void stop(); diff --git a/Swiften/FileTransfer/FileTransferOptions.h b/Swiften/FileTransfer/FileTransferOptions.h index 2bc4ee1..aa9aa97 100644 --- a/Swiften/FileTransfer/FileTransferOptions.h +++ b/Swiften/FileTransfer/FileTransferOptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,7 +7,6 @@ #pragma once #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> namespace Swift { class SWIFTEN_API FileTransferOptions { diff --git a/Swiften/FileTransfer/FileWriteBytestream.h b/Swiften/FileTransfer/FileWriteBytestream.h index c563789..26ab98e 100644 --- a/Swiften/FileTransfer/FileWriteBytestream.h +++ b/Swiften/FileTransfer/FileWriteBytestream.h @@ -19,7 +19,7 @@ namespace Swift { virtual ~FileWriteBytestream(); virtual bool write(const std::vector<unsigned char>&); - void close(); + virtual void close(); private: boost::filesystem::path file; diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.h b/Swiften/FileTransfer/IBBReceiveTransportSession.h index 8b304c3..5b1fd8d 100644 --- a/Swiften/FileTransfer/IBBReceiveTransportSession.h +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,10 +17,10 @@ namespace Swift { class SWIFTEN_API IBBReceiveTransportSession : public TransportSession { public: IBBReceiveTransportSession(std::shared_ptr<IBBReceiveSession> session); - virtual ~IBBReceiveTransportSession(); + virtual ~IBBReceiveTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; private: std::shared_ptr<IBBReceiveSession> session; diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp index e51c91c..258412b 100644 --- a/Swiften/FileTransfer/IBBSendSession.cpp +++ b/Swiften/FileTransfer/IBBSendSession.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -40,7 +40,7 @@ IBBSendSession::~IBBSendSession() { void IBBSendSession::start() { IBBRequest::ref request = IBBRequest::create( - from, to, IBB::createIBBOpen(id, boost::numeric_cast<int>(blockSize)), router); + from, to, IBB::createIBBOpen(id, blockSize), router); request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2)); active = true; request->send(); diff --git a/Swiften/FileTransfer/IBBSendTransportSession.h b/Swiften/FileTransfer/IBBSendTransportSession.h index d1e786b..7deaaac 100644 --- a/Swiften/FileTransfer/IBBSendTransportSession.h +++ b/Swiften/FileTransfer/IBBSendTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,10 +17,10 @@ namespace Swift { class SWIFTEN_API IBBSendTransportSession : public TransportSession { public: IBBSendTransportSession(std::shared_ptr<IBBSendSession> session); - virtual ~IBBSendTransportSession(); + virtual ~IBBSendTransportSession() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void stop() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void stop() override; private: std::shared_ptr<IBBSendSession> session; diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp index d5de5e4..7c46c60 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -67,8 +67,8 @@ IncomingJingleFileTransfer::~IncomingJingleFileTransfer() { void IncomingJingleFileTransfer::accept( std::shared_ptr<WriteBytestream> stream, const FileTransferOptions& options) { - SWIFT_LOG(debug) << std::endl; - if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state"; return; } assert(!this->stream); this->stream = stream; @@ -85,7 +85,7 @@ void IncomingJingleFileTransfer::accept( JingleS5BTransportPayload::ref s5bTransport = initialContent->getTransport<JingleS5BTransportPayload>(); JingleIBBTransportPayload::ref ibbTransport = initialContent->getTransport<JingleIBBTransportPayload>(); if (s5bTransport) { - SWIFT_LOG(debug) << "Got S5B transport as initial payload." << std::endl; + SWIFT_LOG(debug) << "Got S5B transport as initial payload."; setTransporter(transporterFactory->createResponderTransporter( getInitiator(), getResponder(), s5bTransport->getSessionID(), options)); transporter->addRemoteCandidates(s5bTransport->getCandidates(), s5bTransport->getDstAddr()); @@ -93,7 +93,7 @@ void IncomingJingleFileTransfer::accept( transporter->startGeneratingLocalCandidates(); } else if (ibbTransport && options.isInBandAllowed()) { - SWIFT_LOG(debug) << "Got IBB transport as initial payload." << std::endl; + SWIFT_LOG(debug) << "Got IBB transport as initial payload."; setTransporter(transporterFactory->createResponderTransporter( getInitiator(), getResponder(), ibbTransport->getSessionID(), options)); @@ -112,7 +112,7 @@ void IncomingJingleFileTransfer::accept( } void IncomingJingleFileTransfer::cancel() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); terminate(state == Initial ? JinglePayload::Reason::Decline : JinglePayload::Reason::Cancel); } @@ -120,8 +120,8 @@ void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( 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; } + SWIFT_LOG(debug); + if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state"; return; } fillCandidateMap(localCandidates, candidates); @@ -140,11 +140,11 @@ void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( void IncomingJingleFileTransfer::handleSessionInfoReceived(JinglePayload::ref jinglePayload) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); JingleFileTransferHash::ref transferHash = jinglePayload->getPayload<JingleFileTransferHash>(); if (transferHash) { - SWIFT_LOG(debug) << "Received hash information." << std::endl; + SWIFT_LOG(debug) << "Received hash information."; waitOnHashTimer->stop(); if (transferHash->getFileInfo().getHashes().find("sha-1") != transferHash->getFileInfo().getHashes().end()) { hashes["sha-1"] = transferHash->getFileInfo().getHash("sha-1").get(); @@ -157,16 +157,16 @@ void IncomingJingleFileTransfer::handleSessionInfoReceived(JinglePayload::ref ji } } else { - SWIFT_LOG(debug) << "Ignoring unknown session info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown session info"; } } void IncomingJingleFileTransfer::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) { - SWIFT_LOG(debug) << std::endl; - if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (state == Finished) { - SWIFT_LOG(debug) << "Already terminated" << std::endl; + SWIFT_LOG(debug) << "Already terminated"; return; } @@ -187,21 +187,21 @@ void IncomingJingleFileTransfer::checkHashAndTerminate() { terminate(JinglePayload::Reason::Success); } else { - SWIFT_LOG(warning) << "Hash verification failed" << std::endl; + SWIFT_LOG(warning) << "Hash verification failed"; terminate(JinglePayload::Reason::MediaError); } } void IncomingJingleFileTransfer::checkIfAllDataReceived() { if (receivedBytes == getFileSizeInBytes()) { - SWIFT_LOG(debug) << "All data received." << std::endl; + SWIFT_LOG(debug) << "All data received."; bool hashInfoAvailable = false; for (const auto& hashElement : hashes) { hashInfoAvailable |= !hashElement.second.empty(); } if (!hashInfoAvailable) { - SWIFT_LOG(debug) << "No hash information yet. Waiting a while on hash info." << std::endl; + SWIFT_LOG(debug) << "No hash information yet. Waiting a while on hash info."; setState(WaitingForHash); waitOnHashTimer->start(); } @@ -210,7 +210,7 @@ void IncomingJingleFileTransfer::checkIfAllDataReceived() { } } else if (receivedBytes > getFileSizeInBytes()) { - SWIFT_LOG(debug) << "We got more than we could handle!" << std::endl; + SWIFT_LOG(debug) << "We got more than we could handle!"; terminate(JinglePayload::Reason::MediaError); } } @@ -225,15 +225,15 @@ void IncomingJingleFileTransfer::handleWriteStreamDataReceived( void IncomingJingleFileTransfer::handleTransportReplaceReceived( const JingleContentID& content, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state != WaitingForFallbackOrTerminate) { - SWIFT_LOG(warning) << "Incorrect state" << std::endl; + SWIFT_LOG(warning) << "Incorrect state"; return; } JingleIBBTransportPayload::ref ibbTransport; if (options.isInBandAllowed() && (ibbTransport = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { - SWIFT_LOG(debug) << "transport replaced with IBB" << std::endl; + SWIFT_LOG(debug) << "transport replaced with IBB"; startTransferring(transporter->createIBBReceiveSession( ibbTransport->getSessionID(), @@ -242,7 +242,7 @@ void IncomingJingleFileTransfer::handleTransportReplaceReceived( session->sendTransportAccept(content, ibbTransport); } else { - SWIFT_LOG(debug) << "Unknown replace transport" << std::endl; + SWIFT_LOG(debug) << "Unknown replace transport"; session->sendTransportReject(content, transport); } } @@ -253,25 +253,25 @@ JingleContentID IncomingJingleFileTransfer::getContentID() const { bool IncomingJingleFileTransfer::verifyData() { if (hashes.empty()) { - SWIFT_LOG(debug) << "no verification possible, skipping" << std::endl; + SWIFT_LOG(debug) << "no verification possible, skipping"; return true; } if (hashes.find("sha-1") != hashes.end()) { - SWIFT_LOG(debug) << "Verify SHA-1 hash: " << (hashes["sha-1"] == hashCalculator->getSHA1Hash()) << std::endl; + SWIFT_LOG(debug) << "Verify SHA-1 hash: " << (hashes["sha-1"] == hashCalculator->getSHA1Hash()); return hashes["sha-1"] == hashCalculator->getSHA1Hash(); } else if (hashes.find("md5") != hashes.end()) { - SWIFT_LOG(debug) << "Verify MD5 hash: " << (hashes["md5"] == hashCalculator->getMD5Hash()) << std::endl; + SWIFT_LOG(debug) << "Verify MD5 hash: " << (hashes["md5"] == hashCalculator->getMD5Hash()); return hashes["md5"] == hashCalculator->getMD5Hash(); } else { - SWIFT_LOG(debug) << "Unknown hash, skipping" << std::endl; + SWIFT_LOG(debug) << "Unknown hash, skipping"; return true; } } void IncomingJingleFileTransfer::handleWaitOnHashTimerTicked() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); waitOnHashTimer->stop(); terminate(JinglePayload::Reason::Success); } @@ -285,14 +285,14 @@ const JID& IncomingJingleFileTransfer::getRecipient() const { } void IncomingJingleFileTransfer::setState(State state) { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; this->state = state; onStateChanged(FileTransfer::State(getExternalState(state))); } void IncomingJingleFileTransfer::setFinishedState( FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->state = Finished; onStateChanged(type); onFinished(error); @@ -340,7 +340,7 @@ void IncomingJingleFileTransfer::stopAll() { transportSession->stop(); transportSession.reset(); break; - case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; + case Finished: SWIFT_LOG(warning) << "Already finished"; break; } if (state != Initial) { removeTransporter(); @@ -356,7 +356,7 @@ void IncomingJingleFileTransfer::fallback() { } void IncomingJingleFileTransfer::startTransferViaRemoteCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setState(WaitingForPeerProxyActivate); @@ -367,7 +367,7 @@ void IncomingJingleFileTransfer::startTransferViaRemoteCandidate() { } void IncomingJingleFileTransfer::startTransferViaLocalCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setState(WaitingForLocalProxyActivate); @@ -379,7 +379,7 @@ void IncomingJingleFileTransfer::startTransferViaLocalCandidate() { } void IncomingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->transportSession = transportSession; transferFinishedConnection = transportSession->onFinished.connect( @@ -409,7 +409,7 @@ std::shared_ptr<TransportSession> IncomingJingleFileTransfer::createRemoteCandid } void IncomingJingleFileTransfer::terminate(JinglePayload::Reason::Type reason) { - SWIFT_LOG(debug) << reason << std::endl; + SWIFT_LOG(debug) << reason; if (state != Finished) { session->sendTerminate(reason); diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h index 3dd206d..f42004d 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.h +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,6 @@ #include <Swiften/Base/API.h> #include <Swiften/Base/ByteArray.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/IncomingFileTransfer.h> @@ -21,17 +20,15 @@ #include <Swiften/Jingle/JingleContentID.h> namespace Swift { - class JID; - class JingleSession; - class JingleContentPayload; - class FileTransferTransporter; - class FileTransferTransporterFactory; - class TimerFactory; - class Timer; class CryptoProvider; + class FileTransferTransporterFactory; class IncrementalBytestreamHashCalculator; + class JID; + class JingleContentPayload; class JingleFileTransferDescription; - class HashElement; + class JingleSession; + class Timer; + class TimerFactory; /** * @brief The IncomingJingleFileTransfer class contains the business logic for managing incoming @@ -51,10 +48,10 @@ namespace Swift { FileTransferTransporterFactory*, TimerFactory*, CryptoProvider*); - virtual ~IncomingJingleFileTransfer(); + virtual ~IncomingJingleFileTransfer() override; - virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) SWIFTEN_OVERRIDE; - virtual void cancel() SWIFTEN_OVERRIDE; + virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) override; + virtual void cancel() override; private: enum State { @@ -70,44 +67,44 @@ namespace Swift { }; virtual void handleSessionTerminateReceived( - boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE; - virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE; + boost::optional<JinglePayload::Reason> reason) override; + virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) override; virtual void handleTransportReplaceReceived( - const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; + const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; virtual void handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, - const std::string& dstAddr) SWIFTEN_OVERRIDE; + const std::string& dstAddr) override; void handleWriteStreamDataReceived(const std::vector<unsigned char>& data); void stopActiveTransport(); void checkCandidateSelected(); - virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE; + virtual JingleContentID getContentID() const override; void checkIfAllDataReceived(); bool verifyData(); void handleWaitOnHashTimerTicked(); void handleTransferFinished(boost::optional<FileTransferError>); private: - virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE; - virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE; + virtual void startTransferViaRemoteCandidate() override; + virtual void startTransferViaLocalCandidate() override; void checkHashAndTerminate(); void stopAll(); void setState(State state); void setFinishedState(FileTransfer::State::Type, const boost::optional<FileTransferError>& error); - const JID& getSender() const SWIFTEN_OVERRIDE; - const JID& getRecipient() const SWIFTEN_OVERRIDE; + const JID& getSender() const override; + const JID& getRecipient() const override; static FileTransfer::State::Type getExternalState(State state); - virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE; - virtual void fallback() SWIFTEN_OVERRIDE; - virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE; - virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; - virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE; + virtual bool hasPriorityOnCandidateTie() const override; + virtual void fallback() override; + virtual void startTransferring(std::shared_ptr<TransportSession>) override; + virtual bool isWaitingForPeerProxyActivate() const override; + virtual bool isWaitingForLocalProxyActivate() const override; + virtual bool isTryingCandidates() const override; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override; + virtual void terminate(JinglePayload::Reason::Type reason) override; private: diff --git a/Swiften/FileTransfer/IncrementalBytestreamHashCalculator.cpp b/Swiften/FileTransfer/IncrementalBytestreamHashCalculator.cpp index f177304..faddcb9 100644 --- a/Swiften/FileTransfer/IncrementalBytestreamHashCalculator.cpp +++ b/Swiften/FileTransfer/IncrementalBytestreamHashCalculator.cpp @@ -64,12 +64,12 @@ ByteArray IncrementalBytestreamHashCalculator::getMD5Hash() { std::string IncrementalBytestreamHashCalculator::getSHA1String() { assert(sha1Hasher); - return Hexify::hexify(getSHA1Hash());; + return Hexify::hexify(getSHA1Hash()); } std::string IncrementalBytestreamHashCalculator::getMD5String() { assert(md5Hasher); - return Hexify::hexify(getMD5Hash());; + return Hexify::hexify(getMD5Hash()); } } diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp index 62c3a53..3d05db9 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.cpp +++ b/Swiften/FileTransfer/JingleFileTransfer.cpp @@ -1,13 +1,11 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/JingleFileTransfer.h> -#include <boost/typeof/typeof.hpp> - #include <Swiften/Base/Log.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/FileTransfer/FileTransferTransporter.h> @@ -29,7 +27,6 @@ JingleFileTransfer::JingleFileTransfer( theirCandidateSelectFinished(false) { session->addListener(this); - } JingleFileTransfer::~JingleFileTransfer() { @@ -81,7 +78,7 @@ boost::optional<FileTransferError> JingleFileTransfer::getFileTransferError(Jing void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( const std::string& s5bSessionID, const boost::optional<JingleS5BTransportPayload::Candidate>& candidate) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); ourCandidateChoice = candidate; ourCandidateSelectFinished = true; @@ -101,42 +98,42 @@ void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( // decide on candidates according to http://xmpp.org/extensions/xep-0260.html#complete void JingleFileTransfer::decideOnCandidates() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (!ourCandidateSelectFinished || !theirCandidateSelectFinished) { - SWIFT_LOG(debug) << "Can't make a decision yet!" << std::endl; + SWIFT_LOG(debug) << "Can't make a decision yet!"; return; } if (!ourCandidateChoice && !theirCandidateChoice) { - SWIFT_LOG(debug) << "No candidates succeeded." << std::endl; + SWIFT_LOG(debug) << "No candidates succeeded."; fallback(); } else if (ourCandidateChoice && !theirCandidateChoice) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "."; startTransferViaRemoteCandidate(); } else if (theirCandidateChoice && !ourCandidateChoice) { - SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << "."; startTransferViaLocalCandidate(); } else { SWIFT_LOG(debug) << "Choosing between candidates " << ourCandidateChoice->cid << "(" << ourCandidateChoice->priority << ")" << " and " - << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")" << std::endl; + << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")"; if (ourCandidateChoice->priority > theirCandidateChoice->priority) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "."; startTransferViaRemoteCandidate(); } else if (ourCandidateChoice->priority < theirCandidateChoice->priority) { - SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << "."; startTransferViaLocalCandidate(); } else { if (hasPriorityOnCandidateTie()) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid; startTransferViaRemoteCandidate(); } else { - SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid; startTransferViaLocalCandidate(); } } @@ -145,11 +142,11 @@ void JingleFileTransfer::decideOnCandidates() { void JingleFileTransfer::handleProxyActivateFinished( const std::string& s5bSessionID, ErrorPayload::ref error) { - SWIFT_LOG(debug) << std::endl; - if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (error) { - SWIFT_LOG(debug) << "Error activating proxy" << std::endl; + SWIFT_LOG(debug) << "Error activating proxy"; JingleS5BTransportPayload::ref proxyError = std::make_shared<JingleS5BTransportPayload>(); proxyError->setSessionID(s5bSessionID); proxyError->setProxyError(true); @@ -167,18 +164,18 @@ void JingleFileTransfer::handleProxyActivateFinished( void JingleFileTransfer::handleTransportInfoReceived( const JingleContentID& /* contentID */, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport)) { if (s5bPayload->hasCandidateError() || !s5bPayload->getCandidateUsed().empty()) { - SWIFT_LOG(debug) << "Received candidate decision from peer" << std::endl; - if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug) << "Received candidate decision from peer"; + if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state"; return; } theirCandidateSelectFinished = true; if (!s5bPayload->hasCandidateError()) { - BOOST_AUTO(theirCandidate, localCandidates.find(s5bPayload->getCandidateUsed())); + auto theirCandidate = localCandidates.find(s5bPayload->getCandidateUsed()); if (theirCandidate == localCandidates.end()) { - SWIFT_LOG(warning) << "Got invalid candidate" << std::endl; + SWIFT_LOG(warning) << "Got invalid candidate"; terminate(JinglePayload::Reason::GeneralError); return; } @@ -187,27 +184,27 @@ void JingleFileTransfer::handleTransportInfoReceived( decideOnCandidates(); } else if (!s5bPayload->getActivated().empty()) { - SWIFT_LOG(debug) << "Received peer activate from peer" << std::endl; - if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug) << "Received peer activate from peer"; + if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (ourCandidateChoice->cid == s5bPayload->getActivated()) { startTransferring(createRemoteCandidateSession()); } else { - SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!" << std::endl; + SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!"; terminate(JinglePayload::Reason::GeneralError); } } else if (s5bPayload->hasProxyError()) { - SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB." << std::endl; + SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB."; fallback(); } else { - SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown info"; } } else { - SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown info"; } } @@ -231,4 +228,3 @@ void JingleFileTransfer::removeTransporter() { transporter = nullptr; } } - diff --git a/Swiften/FileTransfer/JingleFileTransfer.h b/Swiften/FileTransfer/JingleFileTransfer.h index 5b9dd62..dd9bcb9 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.h +++ b/Swiften/FileTransfer/JingleFileTransfer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,10 +19,6 @@ #include <Swiften/Jingle/JingleContentID.h> namespace Swift { - class CryptoProvider; - class IQRouter; - class RemoteJingleTransportCandidateSelector; - class LocalJingleTransportCandidateGenerator; class JingleSession; class FileTransferTransporter; class FileTransferTransporterFactory; diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp index 834a401..7cb4cbb 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -45,7 +45,7 @@ LocalJingleTransportCandidateGenerator::LocalJingleTransportCandidateGenerator( } LocalJingleTransportCandidateGenerator::~LocalJingleTransportCandidateGenerator() { - SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning) << std::endl; + SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning); } void LocalJingleTransportCandidateGenerator::start() { @@ -98,7 +98,7 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc } } else { - SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl; + SWIFT_LOG(warning) << "Unable to start SOCKS5 server"; if (s5bServerResourceUser_) { s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); } diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h index 2159063..8c53d16 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,6 @@ #include <boost/signals2.hpp> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h> diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index 367fc97..57a18a8 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -87,9 +87,9 @@ OutgoingJingleFileTransfer::~OutgoingJingleFileTransfer() { } void OutgoingJingleFileTransfer::start() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state != Initial) { - SWIFT_LOG(warning) << "Incorrect state" << std::endl; + SWIFT_LOG(warning) << "Incorrect state"; return; } @@ -109,7 +109,7 @@ void OutgoingJingleFileTransfer::cancel() { } void OutgoingJingleFileTransfer::terminate(JinglePayload::Reason::Type reason) { - SWIFT_LOG(debug) << reason << std::endl; + SWIFT_LOG(debug) << reason; if (state != Initial && state != GeneratingInitialLocalCandidates && state != Finished) { session->sendTerminate(reason); @@ -122,8 +122,8 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived( const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref transportPayload) { - SWIFT_LOG(debug) << std::endl; - if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) { transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr()); @@ -134,14 +134,14 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived( startTransferring(transporter->createIBBSendSession(ibbPayload->getSessionID(), ibbPayload->getBlockSize().get_value_or(DEFAULT_BLOCK_SIZE), stream)); } else { - SWIFT_LOG(debug) << "Unknown transport payload. Falling back." << std::endl; + SWIFT_LOG(debug) << "Unknown transport payload. Falling back."; fallback(); } } void OutgoingJingleFileTransfer::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) { - SWIFT_LOG(debug) << std::endl; - if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } stopAll(); if (state == WaitForTermination) { @@ -162,26 +162,26 @@ void OutgoingJingleFileTransfer::handleSessionTerminateReceived(boost::optional< } void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleContentID&, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; - if (state != FallbackRequested) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != FallbackRequested) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (JingleIBBTransportPayload::ref ibbPayload = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport)) { startTransferring(transporter->createIBBSendSession(ibbPayload->getSessionID(), ibbPayload->getBlockSize().get_value_or(DEFAULT_BLOCK_SIZE), stream)); } else { - SWIFT_LOG(debug) << "Unknown transport replacement" << std::endl; + SWIFT_LOG(debug) << "Unknown transport replacement"; terminate(JinglePayload::Reason::FailedTransport); } } void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); terminate(JinglePayload::Reason::UnsupportedTransports); } void OutgoingJingleFileTransfer::sendSessionInfoHash() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); JingleFileTransferHash::ref hashElement = std::make_shared<JingleFileTransferHash>(); hashElement->getFileInfo().addHash(HashElement("sha-1", hashCalculator->getSHA1Hash())); @@ -191,8 +191,8 @@ void OutgoingJingleFileTransfer::sendSessionInfoHash() { void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( 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: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } fillCandidateMap(localCandidates, candidates); @@ -203,7 +203,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( JingleTransportPayload::ref transport; if (candidates.empty()) { - SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate." << std::endl; + SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate."; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); @@ -216,7 +216,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( s5bTransport->setDstAddr(dstAddr); for (auto&& candidate : candidates) { s5bTransport->addCandidate(candidate); - SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl; + SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString(); } transport = s5bTransport; } @@ -226,7 +226,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( void OutgoingJingleFileTransfer::fallback() { if (options.isInBandAllowed()) { - SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl; + SWIFT_LOG(debug) << "Trying to fallback to IBB transport."; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); @@ -234,14 +234,14 @@ void OutgoingJingleFileTransfer::fallback() { session->sendTransportReplace(contentID, ibbTransport); } else { - SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl; + SWIFT_LOG(debug) << "Fallback to IBB transport not allowed."; terminate(JinglePayload::Reason::ConnectivityError); } } void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTransferError> error) { - SWIFT_LOG(debug) << std::endl; - if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } if (error) { terminate(JinglePayload::Reason::ConnectivityError); @@ -256,7 +256,7 @@ void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTran } void OutgoingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->transportSession = transportSession; processedBytesConnection = transportSession->onBytesSent.connect( @@ -269,14 +269,14 @@ void OutgoingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSess void OutgoingJingleFileTransfer::setInternalState(State state) { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; this->state = state; setState(FileTransfer::State(getExternalState(state))); } void OutgoingJingleFileTransfer::setFinishedState( FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->state = Finished; onStateChanged(type); onFinished(error); @@ -301,9 +301,9 @@ FileTransfer::State::Type OutgoingJingleFileTransfer::getExternalState(State sta } void OutgoingJingleFileTransfer::stopAll() { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; switch (state) { - case Initial: SWIFT_LOG(warning) << "Not yet started" << std::endl; break; + case Initial: SWIFT_LOG(warning) << "Not yet started"; break; case GeneratingInitialLocalCandidates: transporter->stopGeneratingLocalCandidates(); break; case WaitingForAccept: break; case TryingCandidates: transporter->stopTryingRemoteCandidates(); break; @@ -320,7 +320,7 @@ void OutgoingJingleFileTransfer::stopAll() { break; case WaitForTermination: break; - case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; + case Finished: SWIFT_LOG(warning) << "Already finished"; break; } if (state != Initial) { removeTransporter(); @@ -328,7 +328,7 @@ void OutgoingJingleFileTransfer::stopAll() { } void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setInternalState(WaitingForPeerProxyActivate); @@ -340,7 +340,7 @@ void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() { } void OutgoingJingleFileTransfer::startTransferViaLocalCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setInternalState(WaitingForLocalProxyActivate); @@ -400,7 +400,7 @@ std::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCandid void OutgoingJingleFileTransfer::handleWaitForRemoteTerminationTimeout() { assert(state == WaitForTermination); - SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now." << std::endl; + SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now."; waitForRemoteTermination->stop(); terminate(JinglePayload::Reason::MediaError); } diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h index cd45948..6db4e40 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,6 @@ #include <boost/optional/optional.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleFileTransferFileInfo.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/JingleFileTransfer.h> @@ -27,7 +26,6 @@ namespace Swift { class CryptoProvider; - class FileTransferTransporter; class FileTransferTransporterFactory; class IDGenerator; class IncrementalBytestreamHashCalculator; @@ -47,10 +45,10 @@ namespace Swift { const JingleFileTransferFileInfo&, const FileTransferOptions&, CryptoProvider*); - virtual ~OutgoingJingleFileTransfer(); + virtual ~OutgoingJingleFileTransfer() override; - virtual void start() SWIFTEN_OVERRIDE; - virtual void cancel() SWIFTEN_OVERRIDE; + virtual void start() override; + virtual void cancel() override; private: enum State { @@ -67,34 +65,34 @@ namespace Swift { Finished }; - virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE; - virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void startTransferViaRemoteCandidate() SWIFTEN_OVERRIDE; - virtual void startTransferViaLocalCandidate() SWIFTEN_OVERRIDE; + virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) override; + virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) override; + virtual void handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) override; + virtual void startTransferViaRemoteCandidate() override; + virtual void startTransferViaLocalCandidate() override; void startTransferringIfCandidateAcknowledged(); - virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) SWIFTEN_OVERRIDE; - virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE; + virtual void handleLocalTransportCandidatesGenerated(const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& dstAddr) override; + virtual void handleTransportInfoAcknowledged(const std::string& id) override; - virtual JingleContentID getContentID() const SWIFTEN_OVERRIDE; + virtual JingleContentID getContentID() const override; - virtual void terminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE; + virtual void terminate(JinglePayload::Reason::Type reason) override; - virtual void fallback() SWIFTEN_OVERRIDE; + virtual void fallback() override; void handleTransferFinished(boost::optional<FileTransferError>); void sendSessionInfoHash(); - virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE; + virtual void startTransferring(std::shared_ptr<TransportSession>) override; - virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForPeerProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isWaitingForLocalProxyActivate() const SWIFTEN_OVERRIDE; - virtual bool isTryingCandidates() const SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; + virtual bool hasPriorityOnCandidateTie() const override; + virtual bool isWaitingForPeerProxyActivate() const override; + virtual bool isWaitingForLocalProxyActivate() const override; + virtual bool isTryingCandidates() const override; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() override; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() override; void handleWaitForRemoteTerminationTimeout(); diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp index 56013ca..4023be3 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -56,14 +56,14 @@ void RemoteJingleTransportCandidateSelector::stopSelectingCandidate() { void RemoteJingleTransportCandidateSelector::tryNextCandidate() { if (candidates.empty()) { - SWIFT_LOG(debug) << "No more candidates" << std::endl; + SWIFT_LOG(debug) << "No more candidates"; onCandidateSelectFinished( boost::optional<JingleS5BTransportPayload::Candidate>(), std::shared_ptr<SOCKS5BytestreamClientSession>()); } else { lastCandidate = candidates.top(); candidates.pop(); - SWIFT_LOG(debug) << "Trying candidate " << lastCandidate.cid << std::endl; + SWIFT_LOG(debug) << "Trying candidate " << lastCandidate.cid; if ((lastCandidate.type == JingleS5BTransportPayload::Candidate::DirectType && options.isDirectAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::AssistedType && options.isAssistedAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::ProxyType && options.isProxiedAllowed())) { @@ -75,7 +75,7 @@ void RemoteJingleTransportCandidateSelector::tryNextCandidate() { s5bSession->start(); } else { - SWIFT_LOG(debug) << "Can't handle this type of candidate" << std::endl; + SWIFT_LOG(debug) << "Can't handle this type of candidate"; tryNextCandidate(); } } diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h index c4257f6..c205516 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ #include <queue> #include <vector> -#include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h> diff --git a/Swiften/FileTransfer/S5BTransportSession.h b/Swiften/FileTransfer/S5BTransportSession.h index 3e064fa..fd92f2e 100644 --- a/Swiften/FileTransfer/S5BTransportSession.h +++ b/Swiften/FileTransfer/S5BTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -35,10 +35,10 @@ class SWIFTEN_API S5BTransportSession : public TransportSession { initialize(); } - virtual ~S5BTransportSession() { + virtual ~S5BTransportSession() override { } - virtual void start() SWIFTEN_OVERRIDE { + virtual void start() override { if (readStream) { session->startSending(readStream); } @@ -47,7 +47,7 @@ class SWIFTEN_API S5BTransportSession : public TransportSession { } } - virtual void stop() SWIFTEN_OVERRIDE { + virtual void stop() override { session->stop(); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp index 5ddd32b..a3f0dab 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -49,7 +49,7 @@ SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() { void SOCKS5BytestreamClientSession::start() { assert(state == Initial); - SWIFT_LOG(debug) << "Trying to connect via TCP to " << addressPort.toString() << "." << std::endl; + SWIFT_LOG(debug) << "Trying to connect via TCP to " << addressPort.toString() << "."; weFailedTimeout->start(); connectFinishedConnection = connection->onConnectFinished.connect( boost::bind(&SOCKS5BytestreamClientSession::handleConnectFinished, this, _1)); @@ -57,7 +57,7 @@ void SOCKS5BytestreamClientSession::start() { } void SOCKS5BytestreamClientSession::stop() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state < Ready) { weFailedTimeout->stop(); } @@ -70,7 +70,7 @@ void SOCKS5BytestreamClientSession::stop() { } void SOCKS5BytestreamClientSession::process() { - SWIFT_LOG(debug) << "unprocessedData.size(): " << unprocessedData.size() << std::endl; + SWIFT_LOG(debug) << "unprocessedData.size(): " << unprocessedData.size(); ByteArray bndAddress; switch(state) { case Initial: @@ -124,19 +124,19 @@ void SOCKS5BytestreamClientSession::process() { } unprocessedData.clear(); state = Ready; - SWIFT_LOG(debug) << "session ready" << std::endl; + SWIFT_LOG(debug) << "session ready"; // issue ready signal so the bytestream can be used for reading or writing weFailedTimeout->stop(); onSessionReady(false); break; case Ready: - SWIFT_LOG(debug) << "Received further data in Ready state." << std::endl; + SWIFT_LOG(debug) << "Received further data in Ready state."; break; case Reading: case Writing: case Finished: - SWIFT_LOG(debug) << "Unexpected receive of data. Current state: " << state << std::endl; - SWIFT_LOG(debug) << "Data: " << Hexify::hexify(unprocessedData) << std::endl; + SWIFT_LOG(debug) << "Unexpected receive of data. Current state: " << state; + SWIFT_LOG(debug) << "Data: " << Hexify::hexify(unprocessedData); unprocessedData.clear(); //assert(false); } @@ -150,7 +150,7 @@ void SOCKS5BytestreamClientSession::hello() { } void SOCKS5BytestreamClientSession::authenticate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); SafeByteArray header = createSafeByteArray("\x05\x01\x00\x03", 4); SafeByteArray message = header; append(message, createSafeByteArray(boost::numeric_cast<char>(destination.size()))); @@ -168,7 +168,7 @@ void SOCKS5BytestreamClientSession::startReceiving(std::shared_ptr<WriteBytestre writeBytestream->write(unprocessedData); unprocessedData.clear(); } else { - SWIFT_LOG(debug) << "Session isn't ready for transfer yet!" << std::endl; + SWIFT_LOG(debug) << "Session isn't ready for transfer yet!"; } } @@ -180,7 +180,7 @@ void SOCKS5BytestreamClientSession::startSending(std::shared_ptr<ReadBytestream> boost::bind(&SOCKS5BytestreamClientSession::sendData, this)); sendData(); } else { - SWIFT_LOG(debug) << "Session isn't ready for transfer yet!" << std::endl; + SWIFT_LOG(debug) << "Session isn't ready for transfer yet!"; } } @@ -205,7 +205,7 @@ void SOCKS5BytestreamClientSession::sendData() { } void SOCKS5BytestreamClientSession::finish(bool error) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state < Ready) { weFailedTimeout->stop(); } @@ -227,10 +227,10 @@ void SOCKS5BytestreamClientSession::finish(bool error) { void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) { connectFinishedConnection.disconnect(); if (error) { - SWIFT_LOG(debug) << "Failed to connect via TCP to " << addressPort.toString() << "." << std::endl; + SWIFT_LOG(debug) << "Failed to connect via TCP to " << addressPort.toString() << "."; finish(true); } else { - SWIFT_LOG(debug) << "Successfully connected via TCP" << addressPort.toString() << "." << std::endl; + SWIFT_LOG(debug) << "Successfully connected via TCP" << addressPort.toString() << "."; disconnectedConnection = connection->onDisconnected.connect( boost::bind(&SOCKS5BytestreamClientSession::handleDisconnected, this, _1)); dataReadConnection = connection->onDataRead.connect( @@ -242,7 +242,7 @@ void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) { } void SOCKS5BytestreamClientSession::handleDataRead(std::shared_ptr<SafeByteArray> data) { - SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size() << std::endl; + SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size(); if (state != Reading) { append(unprocessedData, *data); process(); @@ -254,14 +254,14 @@ void SOCKS5BytestreamClientSession::handleDataRead(std::shared_ptr<SafeByteArray } void SOCKS5BytestreamClientSession::handleDisconnected(const boost::optional<Connection::Error>& error) { - SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error") << std::endl; + SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error"); if (error) { finish(true); } } void SOCKS5BytestreamClientSession::handleWeFailedTimeout() { - SWIFT_LOG(debug) << "Failed due to timeout!" << std::endl; + SWIFT_LOG(debug) << "Failed due to timeout!"; finish(true); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h index b819910..70a7c9c 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -28,7 +28,6 @@ namespace Swift { -class SOCKS5BytestreamRegistry; class Connection; class TimerFactory; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp index cd4cfaa..72c4d41 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -46,7 +46,7 @@ SOCKS5BytestreamProxiesManager::~SOCKS5BytestreamProxiesManager() { void SOCKS5BytestreamProxiesManager::addS5BProxy(S5BProxyRequest::ref proxy) { if (proxy) { - SWIFT_LOG_ASSERT(HostAddress::fromString(proxy->getStreamHost().get().host), warning) << std::endl; + SWIFT_LOG_ASSERT(HostAddress::fromString(proxy->getStreamHost().get().host), warning); if (!localS5BProxies_) { localS5BProxies_ = std::vector<S5BProxyRequest::ref>(); } @@ -62,7 +62,7 @@ const boost::optional<std::vector<S5BProxyRequest::ref> >& SOCKS5BytestreamProxi } void SOCKS5BytestreamProxiesManager::connectToProxies(const std::string& sessionID) { - SWIFT_LOG(debug) << "session ID: " << sessionID << std::endl; + SWIFT_LOG(debug) << "session ID: " << sessionID; ProxyJIDClientSessionVector clientSessions; if (localS5BProxies_) { @@ -71,7 +71,7 @@ void SOCKS5BytestreamProxiesManager::connectToProxies(const std::string& session if (proxyHostAddress) { std::shared_ptr<Connection> conn = connectionFactory_->createConnection(); HostAddressPort addressPort = HostAddressPort(proxyHostAddress.get(), proxy->getStreamHost().get().port); - SWIFT_LOG_ASSERT(addressPort.isValid(), warning) << std::endl; + SWIFT_LOG_ASSERT(addressPort.isValid(), warning); std::shared_ptr<SOCKS5BytestreamClientSession> session = std::make_shared<SOCKS5BytestreamClientSession>(conn, addressPort, sessionID, timerFactory_); JID proxyJid = proxy->getStreamHost().get().jid; clientSessions.push_back(std::pair<JID, std::shared_ptr<SOCKS5BytestreamClientSession> >(proxyJid, session)); @@ -103,7 +103,7 @@ std::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::g i->second->stop(); } } - SWIFT_LOG_ASSERT(activeSession, warning) << "No active session with matching ID found." << std::endl; + SWIFT_LOG_ASSERT(activeSession, warning) << "No active session with matching ID found."; proxySessions_.erase(sessionID); @@ -144,7 +144,7 @@ void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<Ho } else { if (addresses.empty()) { - SWIFT_LOG(warning) << "S5B proxy hostname does not resolve." << std::endl; + SWIFT_LOG(warning) << "S5B proxy hostname does not resolve."; } else { // generate proxy per returned address diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp index 90c42dd..1efc54a 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -71,10 +71,10 @@ void SOCKS5BytestreamProxyFinder::handleProxyResponse(std::shared_ptr<GenericReq requester->onResponse.disconnect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, requester, _1, _2)); pendingRequests.erase(requester); if (error) { - SWIFT_LOG(debug) << "ERROR" << std::endl; + SWIFT_LOG(debug) << "ERROR"; } else { if (request) { - SWIFT_LOG(debug) << "add request" << std::endl; + SWIFT_LOG(debug) << "add request"; proxyHosts.push_back(request); } } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h index 2fa67fa..33bc57c 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -14,8 +14,6 @@ #include <Swiften/Base/IDGenerator.h> namespace Swift { - class SOCKS5BytestreamServerSession; - class SWIFTEN_API SOCKS5BytestreamRegistry { public: SOCKS5BytestreamRegistry(); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.h b/Swiften/FileTransfer/SOCKS5BytestreamServer.h index c8866c4..16d3d29 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ namespace Swift { class SOCKS5BytestreamServerSession; - class CryptoProvider; class SWIFTEN_API SOCKS5BytestreamServer { public: diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp index f749735..7fc1388 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -48,12 +48,12 @@ SOCKS5BytestreamServerManager::SOCKS5BytestreamServerManager( } SOCKS5BytestreamServerManager::~SOCKS5BytestreamServerManager() { - SWIFT_LOG_ASSERT(!connectionServer, warning) << std::endl; - SWIFT_LOG_ASSERT(!getPublicIPRequest, warning) << std::endl; - SWIFT_LOG_ASSERT(!forwardPortRequest, warning) << std::endl; - SWIFT_LOG_ASSERT(state == Start, warning) << std::endl; + SWIFT_LOG_ASSERT(!connectionServer, warning); + SWIFT_LOG_ASSERT(!getPublicIPRequest, warning); + SWIFT_LOG_ASSERT(!forwardPortRequest, warning); + SWIFT_LOG_ASSERT(state == Start, warning); if (portMapping && !unforwardPortRequest) { - SWIFT_LOG(warning) << "Port forwarding still alive. Trying to remove it now." << std::endl; + SWIFT_LOG(warning) << "Port forwarding still alive. Trying to remove it now."; unforwardPortRequest = natTraverser->createRemovePortForwardingRequest(portMapping.get().getLocalPort(), portMapping.get().getPublicPort()); unforwardPortRequest->start(); } @@ -114,27 +114,27 @@ void SOCKS5BytestreamServerManager::initialize() { // Find a port to listen on assert(!connectionServer); - int port; + unsigned short port; for (port = LISTEN_PORTS_BEGIN; port < LISTEN_PORTS_END; ++port) { - SWIFT_LOG(debug) << "Trying to start server on port " << port << std::endl; + SWIFT_LOG(debug) << "Trying to start server on port " << port; connectionServer = connectionServerFactory->createConnectionServer(HostAddress::fromString("::").get(), port); boost::optional<ConnectionServer::Error> error = connectionServer->tryStart(); if (!error) { break; } else if (*error != ConnectionServer::Conflict) { - SWIFT_LOG(debug) << "Error starting server" << std::endl; + SWIFT_LOG(debug) << "Error starting server"; onInitialized(false); return; } connectionServer.reset(); } if (!connectionServer) { - SWIFT_LOG(debug) << "Unable to find an open port" << std::endl; + SWIFT_LOG(debug) << "Unable to find an open port"; onInitialized(false); return; } - SWIFT_LOG(debug) << "Server started succesfully" << std::endl; + SWIFT_LOG(debug) << "Server started succesfully"; connectionServerPort = port; // Start bytestream server. Should actually happen before the connectionserver is started @@ -164,7 +164,7 @@ void SOCKS5BytestreamServerManager::setupPortForwarding() { } // Forward ports - int port = server->getAddressPort().getPort(); + auto port = server->getAddressPort().getPort(); assert(!forwardPortRequest); portMapping = boost::optional<NATPortMapping>(); if ((forwardPortRequest = natTraverser->createForwardPortRequest(port, port))) { @@ -211,10 +211,10 @@ void SOCKS5BytestreamServerManager::stop() { void SOCKS5BytestreamServerManager::handleGetPublicIPResult(boost::optional<HostAddress> address) { if (address) { - SWIFT_LOG(debug) << "Public IP discovered as " << address.get().toString() << "." << std::endl; + SWIFT_LOG(debug) << "Public IP discovered as " << address.get().toString() << "."; } else { - SWIFT_LOG(debug) << "No public IP discoverable." << std::endl; + SWIFT_LOG(debug) << "No public IP discoverable."; } publicAddress = address; @@ -225,10 +225,10 @@ void SOCKS5BytestreamServerManager::handleGetPublicIPResult(boost::optional<Host void SOCKS5BytestreamServerManager::handleForwardPortResult(boost::optional<NATPortMapping> mapping) { if (mapping) { - SWIFT_LOG(debug) << "Mapping port was successful." << std::endl; + SWIFT_LOG(debug) << "Mapping port was successful."; } else { - SWIFT_LOG(debug) << "Mapping port has failed." << std::endl; + SWIFT_LOG(debug) << "Mapping port has failed."; } portMapping = mapping; @@ -243,7 +243,7 @@ void SOCKS5BytestreamServerManager::handleUnforwardPortResult(boost::optional<bo portMapping.reset(); } else { - SWIFT_LOG(warning) << "Failed to remove port forwarding." << std::endl; + SWIFT_LOG(warning) << "Failed to remove port forwarding."; } attemptedPortMapping_ = false; unforwardPortRequest.reset(); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h index 3c06513..74578cc 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -78,7 +78,7 @@ namespace Swift { enum { Start, Initializing, Initialized } state; SOCKS5BytestreamServer* server; std::shared_ptr<ConnectionServer> connectionServer; - int connectionServerPort = -1; + unsigned short connectionServerPort = 0; std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest; std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp index bc4e8e4..a4ab751 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -33,13 +33,13 @@ SOCKS5BytestreamServerSession::SOCKS5BytestreamServerSession( SOCKS5BytestreamServerSession::~SOCKS5BytestreamServerSession() { if (state != Finished && state != Initial) { - SWIFT_LOG(warning) << "SOCKS5BytestreamServerSession unfinished" << std::endl; + SWIFT_LOG(warning) << "SOCKS5BytestreamServerSession unfinished"; finish(); } } void SOCKS5BytestreamServerSession::start() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); dataReadConnection = connection->onDataRead.connect( boost::bind(&SOCKS5BytestreamServerSession::handleDataRead, this, _1)); state = WaitingForAuthentication; @@ -50,7 +50,7 @@ void SOCKS5BytestreamServerSession::stop() { } void SOCKS5BytestreamServerSession::startSending(std::shared_ptr<ReadBytestream> stream) { - if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } + if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!"; return; } readBytestream = stream; state = WritingData; @@ -62,7 +62,7 @@ void SOCKS5BytestreamServerSession::startSending(std::shared_ptr<ReadBytestream> } void SOCKS5BytestreamServerSession::startReceiving(std::shared_ptr<WriteBytestream> stream) { - if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } + if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!"; return; } writeBytestream = stream; state = ReadingData; @@ -93,7 +93,7 @@ void SOCKS5BytestreamServerSession::handleDataAvailable() { } void SOCKS5BytestreamServerSession::handleDisconnected(const boost::optional<Connection::Error>& error) { - SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error") << std::endl; + SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error"); finish(error ? boost::optional<FileTransferError>(FileTransferError::PeerError) : boost::optional<FileTransferError>()); } @@ -109,7 +109,7 @@ void SOCKS5BytestreamServerSession::process() { if (i == 2 + authCount) { // Authentication message is complete if (i != unprocessedData.size()) { - SWIFT_LOG(debug) << "Junk after authentication mechanism" << std::endl; + SWIFT_LOG(debug) << "Junk after authentication mechanism"; } unprocessedData.clear(); connection->write(createSafeByteArray("\x05\x00", 2)); @@ -130,7 +130,7 @@ void SOCKS5BytestreamServerSession::process() { i += 2; if (i <= unprocessedData.size()) { if (i != unprocessedData.size()) { - SWIFT_LOG(debug) << "Junk after authentication mechanism" << std::endl; + SWIFT_LOG(debug) << "Junk after authentication mechanism"; } unprocessedData.clear(); streamID = byteArrayToString(requestID); @@ -138,15 +138,22 @@ void SOCKS5BytestreamServerSession::process() { SafeByteArray result = createSafeByteArray("\x05", 1); result.push_back(hasBytestream ? 0x0 : 0x4); append(result, createByteArray("\x00\x03", 2)); - result.push_back(boost::numeric_cast<unsigned char>(requestID.size())); + try { + result.push_back(boost::numeric_cast<unsigned char>(requestID.size())); + } + catch (const boost::numeric::bad_numeric_cast& e) { + SWIFT_LOG(warning) << "SOCKS5 request ID is too long (" << requestID.size() << "): " << e.what(); + finish(); + return; + } append(result, concat(requestID, createByteArray("\x00\x00", 2))); if (!hasBytestream) { - SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl; + SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!"; connection->write(result); finish(boost::optional<FileTransferError>(FileTransferError::PeerError)); } else { - SWIFT_LOG(debug) << "Found stream. Sent OK." << std::endl; + SWIFT_LOG(debug) << "Found stream. Sent OK."; connection->write(result); state = ReadyForTransfer; } @@ -178,7 +185,7 @@ void SOCKS5BytestreamServerSession::sendData() { } void SOCKS5BytestreamServerSession::finish(const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << "state: " << state << std::endl; + SWIFT_LOG(debug) << "state: " << state; if (state == Finished) { return; } diff --git a/Swiften/FileTransfer/TransportSession.h b/Swiften/FileTransfer/TransportSession.h index dc6e59a..2d56517 100644 --- a/Swiften/FileTransfer/TransportSession.h +++ b/Swiften/FileTransfer/TransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -9,7 +9,6 @@ #include <boost/signals2.hpp> #include <Swiften/Base/API.h> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferError.h> namespace Swift { diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h index 03e2476..6119658 100644 --- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h +++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,6 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem/path.hpp> -#include <Swiften/Base/Override.h> #include <Swiften/FileTransfer/FileTransferManager.h> namespace Swift { @@ -34,7 +33,7 @@ namespace Swift { const boost::filesystem::path&, const std::string&, std::shared_ptr<ReadBytestream>, - const FileTransferOptions&) SWIFTEN_OVERRIDE { + const FileTransferOptions&) override { return OutgoingFileTransfer::ref(); } @@ -45,7 +44,7 @@ namespace Swift { const boost::uintmax_t, const boost::posix_time::ptime&, std::shared_ptr<ReadBytestream>, - const FileTransferOptions&) SWIFTEN_OVERRIDE { + const FileTransferOptions&) override { return OutgoingFileTransfer::ref(); } diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp index f9057f8..2399cbe 100644 --- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -58,7 +58,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<IBB>(0, JID("foo@bar.com/baz"), IQ::Set)); IBB::ref ibb = stanzaChannel->sentStanzas[0]->getPayload<IBB>(); CPPUNIT_ASSERT_EQUAL(IBB::Open, ibb->getAction()); - CPPUNIT_ASSERT_EQUAL(1234, ibb->getBlockSize()); + CPPUNIT_ASSERT_EQUAL(1234u, ibb->getBlockSize()); CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID()); } diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp index 72b933d..9793b87 100644 --- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/Base/Log.h> -#include <Swiften/Base/Override.h> #include <Swiften/Client/DummyStanzaChannel.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp index 3f4d20f..a0fe057 100644 --- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -21,7 +21,6 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/Base/IDGenerator.h> -#include <Swiften/Base/Override.h> #include <Swiften/Client/DummyStanzaChannel.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 290dda5..fad02da 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -59,8 +59,8 @@ public: crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); destination = "092a44d859d19c9eed676b551ee80025903351c2"; randomGen.seed(static_cast<unsigned int>(time(nullptr))); - eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop()); - timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); + eventLoop = std::make_unique<DummyEventLoop>(); + timerFactory = std::make_unique<DummyTimerFactory>(); connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get()); //connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); //stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); @@ -238,7 +238,7 @@ private: std::shared_ptr<SafeByteArray> dataToSend; //ByteArray failingData = Hexify::unhexify("8417947d1d305c72c11520ea7d2c6e787396705e72c312c6ccc3f66613d7cae1b91b7ab48e8b59a17d559c15fb51"); //append(dataToSend, failingData); - //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData) << std::endl; + //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData); do { ByteArray rndArray = generateRandomByteArray(correctData->size()); dataToSend = createSafeByteArrayRef(vecptr(rndArray), rndArray.size()); @@ -255,7 +255,7 @@ private: void handleConnectionDataWritten(const SafeByteArray& data) { append(unprocessedInput, data); - //SWIFT_LOG(debug) << "unprocessedInput (" << unprocessedInput.size() << "): " << Hexify::hexify(unprocessedInput) << std::endl; + //SWIFT_LOG(debug) << "unprocessedInput (" << unprocessedInput.size() << "): " << Hexify::hexify(unprocessedInput); } void handleSessionReady(bool error) { diff --git a/Swiften/FileTransfer/WriteBytestream.h b/Swiften/FileTransfer/WriteBytestream.h index 5d9c3f8..5452317 100644 --- a/Swiften/FileTransfer/WriteBytestream.h +++ b/Swiften/FileTransfer/WriteBytestream.h @@ -26,6 +26,7 @@ namespace Swift { * On success true is returned and \ref onWrite is called. On failure false is returned. */ virtual bool write(const std::vector<unsigned char>&) = 0; + virtual void close() {} boost::signals2::signal<void (const std::vector<unsigned char>&)> onWrite; }; |