summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.cpp22
-rw-r--r--Swiften/FileTransfer/DefaultFileTransferTransporter.h31
-rw-r--r--Swiften/FileTransfer/DefaultFileTransferTransporterFactory.h9
-rw-r--r--Swiften/FileTransfer/FailingTransportSession.h8
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.h9
-rw-r--r--Swiften/FileTransfer/FileTransferOptions.h3
-rw-r--r--Swiften/FileTransfer/IBBReceiveTransportSession.h8
-rw-r--r--Swiften/FileTransfer/IBBSendSession.cpp4
-rw-r--r--Swiften/FileTransfer/IBBSendTransportSession.h8
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.h43
-rw-r--r--Swiften/FileTransfer/JingleFileTransfer.cpp8
-rw-r--r--Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h3
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.h43
-rw-r--r--Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h3
-rw-r--r--Swiften/FileTransfer/S5BTransportSession.h8
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp6
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.h4
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp11
-rw-r--r--Swiften/FileTransfer/TransportSession.h3
-rw-r--r--Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h7
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp4
-rw-r--r--Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp3
-rw-r--r--Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp3
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp4
24 files changed, 126 insertions, 129 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.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.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.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/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.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
index 7ddf700..f42004d 100644
--- a/Swiften/FileTransfer/IncomingJingleFileTransfer.h
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
@@ -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>
@@ -49,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 {
@@ -68,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/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp
index 62c3a53..cc1cd1c 100644
--- a/Swiften/FileTransfer/JingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/JingleFileTransfer.cpp
@@ -1,13 +1,11 @@
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2018 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() {
@@ -176,7 +173,7 @@ void JingleFileTransfer::handleTransportInfoReceived(
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;
terminate(JinglePayload::Reason::GeneralError);
@@ -231,4 +228,3 @@ void JingleFileTransfer::removeTransporter() {
transporter = nullptr;
}
}
-
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.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
index 9fd1d76..6db4e40 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
@@ -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>
@@ -46,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 {
@@ -66,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.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/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
index f749735..a6b75da 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp
@@ -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.
*/
@@ -114,7 +114,7 @@ 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;
connectionServer = connectionServerFactory->createConnectionServer(HostAddress::fromString("::").get(), port);
@@ -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))) {
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..0fd40bf 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.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.
*/
@@ -138,7 +138,14 @@ 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() << std::endl;
+ 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;
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..80667b6 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -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")));