diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-01 17:23:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-04 08:28:23 (GMT) |
commit | 741c45b74d5f634622eb5f757c49323274fb8937 (patch) | |
tree | b9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swiften/FileTransfer | |
parent | eddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff) | |
download | swift-741c45b74d5f634622eb5f757c49323274fb8937.zip swift-741c45b74d5f634622eb5f757c49323274fb8937.tar.bz2 |
Modernize code to use C++11 shared_ptr instead of Boost's
This change was done by applying the following 'gsed'
replacement calls to all source files:
's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g'
's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g'
's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g'
's/boost::make_shared/std::make_shared/g'
's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g'
's/boost::shared_ptr/std::shared_ptr/g'
's/boost::weak_ptr/std::weak_ptr/g'
's/boost::enable_shared_from_this/std::enable_shared_from_this/g'
The remaining issues have been fixed manually.
Test-Information:
Code builds on OS X 10.11.4 and unit tests pass.
Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
Diffstat (limited to 'Swiften/FileTransfer')
62 files changed, 459 insertions, 456 deletions
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp index c1fadee..cd9fa4a 100644 --- a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp +++ b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp @@ -6,19 +6,20 @@ #include <Swiften/FileTransfer/ByteArrayReadBytestream.h> +#include <memory> + #include <boost/numeric/conversion/cast.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Algorithm.h> using namespace Swift; -boost::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) { +std::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) { size_t readSize = size; if (position + readSize > data.size()) { readSize = data.size() - position; } - boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>( + 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)); diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.h b/Swiften/FileTransfer/ByteArrayReadBytestream.h index a711acb..d90e5cc 100644 --- a/Swiften/FileTransfer/ByteArrayReadBytestream.h +++ b/Swiften/FileTransfer/ByteArrayReadBytestream.h @@ -18,7 +18,7 @@ namespace Swift { ByteArrayReadBytestream(const std::vector<unsigned char>& data) : data(data), position(0), dataComplete(true) { } - virtual boost::shared_ptr<ByteArray> read(size_t size); + virtual std::shared_ptr<ByteArray> read(size_t size); virtual bool isFinished() const { return position >= data.size() && dataComplete; diff --git a/Swiften/FileTransfer/BytestreamsRequest.h b/Swiften/FileTransfer/BytestreamsRequest.h index 7fa3660..d278e79 100644 --- a/Swiften/FileTransfer/BytestreamsRequest.h +++ b/Swiften/FileTransfer/BytestreamsRequest.h @@ -6,7 +6,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/Elements/Bytestreams.h> @@ -15,21 +15,21 @@ namespace Swift { class SWIFTEN_API BytestreamsRequest : public GenericRequest<Bytestreams> { public: - typedef boost::shared_ptr<BytestreamsRequest> ref; + typedef std::shared_ptr<BytestreamsRequest> ref; - static ref create(const JID& jid, boost::shared_ptr<Bytestreams> payload, IQRouter* router) { + static ref create(const JID& jid, std::shared_ptr<Bytestreams> payload, IQRouter* router) { return ref(new BytestreamsRequest(jid, payload, router)); } - static ref create(const JID& from, const JID& to, boost::shared_ptr<Bytestreams> payload, IQRouter* router) { + static ref create(const JID& from, const JID& to, std::shared_ptr<Bytestreams> payload, IQRouter* router) { return ref(new BytestreamsRequest(from, to, payload, router)); } private: - BytestreamsRequest(const JID& jid, boost::shared_ptr<Bytestreams> payload, IQRouter* router) : GenericRequest<Bytestreams>(IQ::Set, jid, payload, router) { + BytestreamsRequest(const JID& jid, std::shared_ptr<Bytestreams> payload, IQRouter* router) : GenericRequest<Bytestreams>(IQ::Set, jid, payload, router) { } - BytestreamsRequest(const JID& from, const JID& to, boost::shared_ptr<Bytestreams> payload, IQRouter* router) : GenericRequest<Bytestreams>(IQ::Set, from, to, payload, router) { + BytestreamsRequest(const JID& from, const JID& to, std::shared_ptr<Bytestreams> payload, IQRouter* router) : GenericRequest<Bytestreams>(IQ::Set, from, to, payload, router) { } }; } diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index b54f1c1..9428d0b 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp @@ -1,13 +1,14 @@ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/DefaultFileTransferTransporter.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> @@ -107,7 +108,7 @@ void DefaultFileTransferTransporter::handleLocalCandidatesGenerated( void DefaultFileTransferTransporter::handleRemoteCandidateSelectFinished( const boost::optional<JingleS5BTransportPayload::Candidate>& candidate, - boost::shared_ptr<SOCKS5BytestreamClientSession> session) { + std::shared_ptr<SOCKS5BytestreamClientSession> session) { remoteS5BClientSession = session; onRemoteCandidateSelectFinished(s5bSessionID, candidate); } @@ -134,11 +135,11 @@ 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; - S5BProxyRequest::ref proxyRequest = boost::make_shared<S5BProxyRequest>(); + S5BProxyRequest::ref proxyRequest = std::make_shared<S5BProxyRequest>(); proxyRequest->setSID(s5bSessionID); proxyRequest->setActivate(role == Initiator ? responder : initiator); - boost::shared_ptr<GenericRequest<S5BProxyRequest> > request = boost::make_shared<GenericRequest<S5BProxyRequest> >(IQ::Set, proxyServiceJID, proxyRequest, router); + std::shared_ptr<GenericRequest<S5BProxyRequest> > request = std::make_shared<GenericRequest<S5BProxyRequest> >(IQ::Set, proxyServiceJID, proxyRequest, router); request->onResponse.connect(boost::bind(&DefaultFileTransferTransporter::handleActivateProxySessionResult, this, s5bSessionID, _2)); request->send(); } @@ -148,97 +149,97 @@ void DefaultFileTransferTransporter::stopActivatingProxy() { assert(false); } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createIBBSendSession( - const std::string& sessionID, unsigned int blockSize, boost::shared_ptr<ReadBytestream> stream) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createIBBSendSession( + const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream> stream) { if (s5bServerManager->getServer()) { closeLocalSession(); } closeRemoteSession(); - boost::shared_ptr<IBBSendSession> ibbSession = boost::make_shared<IBBSendSession>( + std::shared_ptr<IBBSendSession> ibbSession = std::make_shared<IBBSendSession>( sessionID, initiator, responder, stream, router); ibbSession->setBlockSize(blockSize); - return boost::make_shared<IBBSendTransportSession>(ibbSession); + return std::make_shared<IBBSendTransportSession>(ibbSession); } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createIBBReceiveSession( - const std::string& sessionID, unsigned long long size, boost::shared_ptr<WriteBytestream> stream) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createIBBReceiveSession( + const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream> stream) { if (s5bServerManager->getServer()) { closeLocalSession(); } closeRemoteSession(); - boost::shared_ptr<IBBReceiveSession> ibbSession = boost::make_shared<IBBReceiveSession>( + std::shared_ptr<IBBReceiveSession> ibbSession = std::make_shared<IBBReceiveSession>( sessionID, initiator, responder, size, stream, router); - return boost::make_shared<IBBReceiveTransportSession>(ibbSession); + return std::make_shared<IBBReceiveTransportSession>(ibbSession); } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createRemoteCandidateSession( - boost::shared_ptr<ReadBytestream> stream, const JingleS5BTransportPayload::Candidate& /* candidate */) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createRemoteCandidateSession( + std::shared_ptr<ReadBytestream> stream, const JingleS5BTransportPayload::Candidate& /* candidate */) { closeLocalSession(); - return boost::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >( + return std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >( remoteS5BClientSession, stream); } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createRemoteCandidateSession( - boost::shared_ptr<WriteBytestream> stream, const JingleS5BTransportPayload::Candidate& /* candidate */) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createRemoteCandidateSession( + std::shared_ptr<WriteBytestream> stream, const JingleS5BTransportPayload::Candidate& /* candidate */) { closeLocalSession(); - return boost::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >( + return std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >( remoteS5BClientSession, stream); } -boost::shared_ptr<SOCKS5BytestreamServerSession> DefaultFileTransferTransporter::getServerSession() { +std::shared_ptr<SOCKS5BytestreamServerSession> DefaultFileTransferTransporter::getServerSession() { s5bRegistry->setHasBytestream(getSOCKS5DstAddr(), false); - std::vector<boost::shared_ptr<SOCKS5BytestreamServerSession> > serverSessions = + std::vector<std::shared_ptr<SOCKS5BytestreamServerSession> > serverSessions = s5bServerManager->getServer()->getSessions(getSOCKS5DstAddr()); while (serverSessions.size() > 1) { - boost::shared_ptr<SOCKS5BytestreamServerSession> session = serverSessions.back(); + std::shared_ptr<SOCKS5BytestreamServerSession> session = serverSessions.back(); serverSessions.pop_back(); session->stop(); } - return !serverSessions.empty() ? serverSessions.front() : boost::shared_ptr<SOCKS5BytestreamServerSession>(); + return !serverSessions.empty() ? serverSessions.front() : std::shared_ptr<SOCKS5BytestreamServerSession>(); } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCandidateSession( - boost::shared_ptr<ReadBytestream> stream, const JingleS5BTransportPayload::Candidate& candidate) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCandidateSession( + std::shared_ptr<ReadBytestream> stream, const JingleS5BTransportPayload::Candidate& candidate) { closeRemoteSession(); - boost::shared_ptr<TransportSession> transportSession; + std::shared_ptr<TransportSession> transportSession; if (candidate.type == JingleS5BTransportPayload::Candidate::ProxyType) { SOCKS5BytestreamClientSession::ref proxySession = s5bProxy->getProxySessionAndCloseOthers(candidate.jid, getLocalCandidateSOCKS5DstAddr()); assert(proxySession); - transportSession = boost::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); + transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } if (!transportSession) { - boost::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); + std::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); if (serverSession) { - transportSession = boost::make_shared<S5BTransportSession<SOCKS5BytestreamServerSession> >(serverSession, stream); + transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamServerSession> >(serverSession, stream); } } if (!transportSession) { - transportSession = boost::make_shared<FailingTransportSession>(); + transportSession = std::make_shared<FailingTransportSession>(); } return transportSession; } -boost::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCandidateSession( - boost::shared_ptr<WriteBytestream> stream, const JingleS5BTransportPayload::Candidate& candidate) { +std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCandidateSession( + std::shared_ptr<WriteBytestream> stream, const JingleS5BTransportPayload::Candidate& candidate) { closeRemoteSession(); - boost::shared_ptr<TransportSession> transportSession; + std::shared_ptr<TransportSession> transportSession; if (candidate.type == JingleS5BTransportPayload::Candidate::ProxyType) { SOCKS5BytestreamClientSession::ref proxySession = s5bProxy->getProxySessionAndCloseOthers(candidate.jid, getLocalCandidateSOCKS5DstAddr()); assert(proxySession); - transportSession = boost::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); + transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } if (!transportSession) { - boost::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); + std::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); if (serverSession) { - transportSession = boost::make_shared<S5BTransportSession<SOCKS5BytestreamServerSession> >(serverSession, stream); + transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamServerSession> >(serverSession, stream); } } if (!transportSession) { - transportSession = boost::make_shared<FailingTransportSession>(); + transportSession = std::make_shared<FailingTransportSession>(); } return transportSession; } @@ -285,8 +286,8 @@ std::string DefaultFileTransferTransporter::getLocalCandidateSOCKS5DstAddr() con void DefaultFileTransferTransporter::closeLocalSession() { s5bRegistry->setHasBytestream(getSOCKS5DstAddr(), false); if (s5bServerManager->getServer()) { - std::vector<boost::shared_ptr<SOCKS5BytestreamServerSession> > serverSessions = s5bServerManager->getServer()->getSessions(getSOCKS5DstAddr()); - foreach(boost::shared_ptr<SOCKS5BytestreamServerSession> session, serverSessions) { + std::vector<std::shared_ptr<SOCKS5BytestreamServerSession> > serverSessions = s5bServerManager->getServer()->getSessions(getSOCKS5DstAddr()); + foreach(std::shared_ptr<SOCKS5BytestreamServerSession> session, serverSessions) { session->stop(); } } diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.h b/Swiften/FileTransfer/DefaultFileTransferTransporter.h index 7ec6a12..339232f 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.h +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.h @@ -65,28 +65,28 @@ namespace Swift { virtual void startActivatingProxy(const JID& jid) SWIFTEN_OVERRIDE; virtual void stopActivatingProxy() SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createIBBSendSession( - const std::string& sessionID, unsigned int blockSize, boost::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createIBBReceiveSession( - const std::string& sessionID, unsigned long long size, boost::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createIBBSendSession( + const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createIBBReceiveSession( + const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) SWIFTEN_OVERRIDE; private: void handleLocalCandidatesGenerated(const std::vector<JingleS5BTransportPayload::Candidate>&); void handleRemoteCandidateSelectFinished( const boost::optional<JingleS5BTransportPayload::Candidate>&, - boost::shared_ptr<SOCKS5BytestreamClientSession>); + std::shared_ptr<SOCKS5BytestreamClientSession>); void handleActivateProxySessionResult(const std::string& sessionID, ErrorPayload::ref error); void closeLocalSession(); void closeRemoteSession(); - boost::shared_ptr<SOCKS5BytestreamServerSession> getServerSession(); + std::shared_ptr<SOCKS5BytestreamServerSession> getServerSession(); std::string getSOCKS5DstAddr() const; std::string getInitiatorCandidateSOCKS5DstAddr() const; @@ -106,7 +106,7 @@ namespace Swift { LocalJingleTransportCandidateGenerator* localCandidateGenerator; RemoteJingleTransportCandidateSelector* remoteCandidateSelector; std::string s5bSessionID; - boost::shared_ptr<SOCKS5BytestreamClientSession> remoteS5BClientSession; + std::shared_ptr<SOCKS5BytestreamClientSession> remoteS5BClientSession; }; } diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp index ad9a33b..2ff00dc 100644 --- a/Swiften/FileTransfer/FileReadBytestream.cpp +++ b/Swiften/FileTransfer/FileReadBytestream.cpp @@ -7,10 +7,10 @@ #include <Swiften/FileTransfer/FileReadBytestream.h> #include <cassert> +#include <memory> #include <boost/filesystem/fstream.hpp> #include <boost/numeric/conversion/cast.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/ByteArray.h> @@ -27,11 +27,11 @@ FileReadBytestream::~FileReadBytestream() { } } -boost::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) { +std::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) { if (!stream) { stream = new boost::filesystem::ifstream(file, std::ios_base::in|std::ios_base::binary); } - boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>(); + std::shared_ptr<ByteArray> result = std::make_shared<ByteArray>(); result->resize(size); assert(stream->good()); stream->read(reinterpret_cast<char*>(vecptr(*result)), boost::numeric_cast<std::streamsize>(size)); diff --git a/Swiften/FileTransfer/FileReadBytestream.h b/Swiften/FileTransfer/FileReadBytestream.h index 24cfbae..aaf3de3 100644 --- a/Swiften/FileTransfer/FileReadBytestream.h +++ b/Swiften/FileTransfer/FileReadBytestream.h @@ -18,7 +18,7 @@ namespace Swift { FileReadBytestream(const boost::filesystem::path& file); virtual ~FileReadBytestream(); - virtual boost::shared_ptr< std::vector<unsigned char> > read(size_t size); + virtual std::shared_ptr< std::vector<unsigned char> > read(size_t size); virtual bool isFinished() const; private: diff --git a/Swiften/FileTransfer/FileTransfer.h b/Swiften/FileTransfer/FileTransfer.h index b585ab9..e6442b7 100644 --- a/Swiften/FileTransfer/FileTransfer.h +++ b/Swiften/FileTransfer/FileTransfer.h @@ -5,16 +5,17 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <boost/cstdint.hpp> #include <boost/optional.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -46,7 +47,7 @@ namespace Swift { Type type; std::string message; }; - typedef boost::shared_ptr<FileTransfer> ref; + typedef std::shared_ptr<FileTransfer> ref; public: FileTransfer(); diff --git a/Swiften/FileTransfer/FileTransferManager.h b/Swiften/FileTransfer/FileTransferManager.h index be2902a..60deeaa 100644 --- a/Swiften/FileTransfer/FileTransferManager.h +++ b/Swiften/FileTransfer/FileTransferManager.h @@ -36,7 +36,7 @@ namespace Swift { const JID& to, const boost::filesystem::path& filepath, const std::string& description, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions& = FileTransferOptions()) = 0; virtual OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, @@ -44,7 +44,7 @@ namespace Swift { const std::string& description, const boost::uintmax_t sizeInBytes, const boost::posix_time::ptime& lastModified, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions& = FileTransferOptions()) = 0; static bool isSupportedBy(const DiscoInfo::ref info); diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp index 80993ef..d449179 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp +++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp @@ -125,7 +125,7 @@ OutgoingFileTransfer::ref FileTransferManagerImpl::createOutgoingFileTransfer( const JID& to, const boost::filesystem::path& filepath, const std::string& description, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions& config) { #if BOOST_FILESYSTEM_VERSION == 2 // TODO: Delete this when boost 1.44 becomes a minimum requirement, and we no longer need v2 std::string filename = filepath.filename(); @@ -144,7 +144,7 @@ OutgoingFileTransfer::ref FileTransferManagerImpl::createOutgoingFileTransfer( const std::string& description, const boost::uintmax_t sizeInBytes, const boost::posix_time::ptime& lastModified, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions& config) { JingleFileTransferFileInfo fileInfo; fileInfo.setDate(lastModified); diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h index a939ace..3566e92 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.h +++ b/Swiften/FileTransfer/FileTransferManagerImpl.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -71,7 +71,7 @@ namespace Swift { const JID& to, const boost::filesystem::path& filepath, const std::string& description, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions&) SWIFTEN_OVERRIDE; OutgoingFileTransfer::ref createOutgoingFileTransfer( const JID& to, @@ -79,7 +79,7 @@ namespace Swift { const std::string& description, const boost::uintmax_t sizeInBytes, const boost::posix_time::ptime& lastModified, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, const FileTransferOptions&) SWIFTEN_OVERRIDE; void start(); diff --git a/Swiften/FileTransfer/FileTransferTransporter.h b/Swiften/FileTransfer/FileTransferTransporter.h index dc12b0e..a680ca2 100644 --- a/Swiften/FileTransfer/FileTransferTransporter.h +++ b/Swiften/FileTransfer/FileTransferTransporter.h @@ -40,21 +40,21 @@ namespace Swift { virtual void startActivatingProxy(const JID& proxy) = 0; virtual void stopActivatingProxy() = 0; - virtual boost::shared_ptr<TransportSession> createIBBSendSession( - const std::string& sessionID, unsigned int blockSize, boost::shared_ptr<ReadBytestream>) = 0; - virtual boost::shared_ptr<TransportSession> createIBBReceiveSession( - const std::string& sessionID, unsigned long long size, boost::shared_ptr<WriteBytestream>) = 0; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; + virtual std::shared_ptr<TransportSession> createIBBSendSession( + const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream>) = 0; + virtual std::shared_ptr<TransportSession> createIBBReceiveSession( + const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream>) = 0; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& candidate) = 0; boost::signal<void (const std::string& /* sessionID */, const std::vector<JingleS5BTransportPayload::Candidate>&, const std::string& /* dstAddr */)> onLocalCandidatesGenerated; boost::signal<void (const std::string& /* sessionID */, const boost::optional<JingleS5BTransportPayload::Candidate>&)> onRemoteCandidateSelectFinished; - boost::signal<void (const std::string& /* sessionID */, boost::shared_ptr<ErrorPayload>)> onProxyActivated; + boost::signal<void (const std::string& /* sessionID */, std::shared_ptr<ErrorPayload>)> onProxyActivated; }; } diff --git a/Swiften/FileTransfer/IBBReceiveSession.cpp b/Swiften/FileTransfer/IBBReceiveSession.cpp index 5a29ccb..24996ed 100644 --- a/Swiften/FileTransfer/IBBReceiveSession.cpp +++ b/Swiften/FileTransfer/IBBReceiveSession.cpp @@ -72,7 +72,7 @@ IBBReceiveSession::IBBReceiveSession( const JID& from, const JID& to, unsigned long long size, - boost::shared_ptr<WriteBytestream> bytestream, + std::shared_ptr<WriteBytestream> bytestream, IQRouter* router) : id(id), from(from), diff --git a/Swiften/FileTransfer/IBBReceiveSession.h b/Swiften/FileTransfer/IBBReceiveSession.h index 3eec96e..c383455 100644 --- a/Swiften/FileTransfer/IBBReceiveSession.h +++ b/Swiften/FileTransfer/IBBReceiveSession.h @@ -6,8 +6,9 @@ #pragma once +#include <memory> + #include <boost/optional/optional_fwd.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -26,7 +27,7 @@ namespace Swift { const JID& from, const JID& to, unsigned long long size, - boost::shared_ptr<WriteBytestream> bytestream, + std::shared_ptr<WriteBytestream> bytestream, IQRouter* router); ~IBBReceiveSession(); @@ -55,7 +56,7 @@ namespace Swift { JID from; JID to; unsigned long long size; - boost::shared_ptr<WriteBytestream> bytestream; + std::shared_ptr<WriteBytestream> bytestream; IQRouter* router; IBBResponder* responder; bool active; diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.cpp b/Swiften/FileTransfer/IBBReceiveTransportSession.cpp index 2e19b75..6e47ac6 100644 --- a/Swiften/FileTransfer/IBBReceiveTransportSession.cpp +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.cpp @@ -10,7 +10,7 @@ namespace Swift { -IBBReceiveTransportSession::IBBReceiveTransportSession(boost::shared_ptr<IBBReceiveSession> session) : session(session) { +IBBReceiveTransportSession::IBBReceiveTransportSession(std::shared_ptr<IBBReceiveSession> session) : session(session) { finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); } diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.h b/Swiften/FileTransfer/IBBReceiveTransportSession.h index f66731b..65488d9 100644 --- a/Swiften/FileTransfer/IBBReceiveTransportSession.h +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.h @@ -15,14 +15,14 @@ namespace Swift { class SWIFTEN_API IBBReceiveTransportSession : public TransportSession { public: - IBBReceiveTransportSession(boost::shared_ptr<IBBReceiveSession> session); + IBBReceiveTransportSession(std::shared_ptr<IBBReceiveSession> session); virtual ~IBBReceiveTransportSession(); virtual void start() SWIFTEN_OVERRIDE; virtual void stop() SWIFTEN_OVERRIDE; private: - boost::shared_ptr<IBBReceiveSession> session; + std::shared_ptr<IBBReceiveSession> session; boost::bsignals::scoped_connection finishedConnection; boost::bsignals::scoped_connection bytesSentConnection; }; diff --git a/Swiften/FileTransfer/IBBRequest.h b/Swiften/FileTransfer/IBBRequest.h index 165dd21..67bd33a 100644 --- a/Swiften/FileTransfer/IBBRequest.h +++ b/Swiften/FileTransfer/IBBRequest.h @@ -13,14 +13,14 @@ namespace Swift { class SWIFTEN_API IBBRequest : public GenericRequest<IBB> { public: - typedef boost::shared_ptr<IBBRequest> ref; + typedef std::shared_ptr<IBBRequest> ref; - static ref create(const JID& from, const JID& to, boost::shared_ptr<IBB> payload, IQRouter* router) { + static ref create(const JID& from, const JID& to, std::shared_ptr<IBB> payload, IQRouter* router) { return ref(new IBBRequest(from, to, payload, router)); } private: - IBBRequest(const JID& from, const JID& to, boost::shared_ptr<IBB> payload, IQRouter* router) : GenericRequest<IBB>(IQ::Set, from, to, payload, router) { + IBBRequest(const JID& from, const JID& to, std::shared_ptr<IBB> payload, IQRouter* router) : GenericRequest<IBB>(IQ::Set, from, to, payload, router) { } }; } diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp index 10a36a9..e51c91c 100644 --- a/Swiften/FileTransfer/IBBSendSession.cpp +++ b/Swiften/FileTransfer/IBBSendSession.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -20,7 +20,7 @@ IBBSendSession::IBBSendSession( const std::string& id, const JID& from, const JID& to, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, IQRouter* router) : id(id), from(from), @@ -75,7 +75,7 @@ void IBBSendSession::handleIBBResponse(IBB::ref, ErrorPayload::ref error) { void IBBSendSession::sendMoreData() { try { - boost::shared_ptr<ByteArray> data = bytestream->read(blockSize); + std::shared_ptr<ByteArray> data = bytestream->read(blockSize); if (!data->empty()) { waitingForData = false; IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBData(id, sequenceNumber, *data), router); diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h index e62ef79..7988398 100644 --- a/Swiften/FileTransfer/IBBSendSession.h +++ b/Swiften/FileTransfer/IBBSendSession.h @@ -1,13 +1,14 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <boost/optional.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -27,7 +28,7 @@ namespace Swift { const std::string& id, const JID& from, const JID& to, - boost::shared_ptr<ReadBytestream> bytestream, + std::shared_ptr<ReadBytestream> bytestream, IQRouter* router); ~IBBSendSession(); @@ -59,12 +60,12 @@ namespace Swift { std::string id; JID from; JID to; - boost::shared_ptr<ReadBytestream> bytestream; + std::shared_ptr<ReadBytestream> bytestream; IQRouter* router; unsigned int blockSize; int sequenceNumber; bool active; bool waitingForData; - boost::shared_ptr<IBBRequest> currentRequest; + std::shared_ptr<IBBRequest> currentRequest; }; } diff --git a/Swiften/FileTransfer/IBBSendTransportSession.cpp b/Swiften/FileTransfer/IBBSendTransportSession.cpp index fd2d8e6..81972c9 100644 --- a/Swiften/FileTransfer/IBBSendTransportSession.cpp +++ b/Swiften/FileTransfer/IBBSendTransportSession.cpp @@ -10,7 +10,7 @@ namespace Swift { -IBBSendTransportSession::IBBSendTransportSession(boost::shared_ptr<IBBSendSession> session) : session(session) { +IBBSendTransportSession::IBBSendTransportSession(std::shared_ptr<IBBSendSession> session) : session(session) { finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); bytesSentConnection = session->onBytesSent.connect(boost::bind(boost::ref(onBytesSent), _1)); } diff --git a/Swiften/FileTransfer/IBBSendTransportSession.h b/Swiften/FileTransfer/IBBSendTransportSession.h index 812c42e..5b55215 100644 --- a/Swiften/FileTransfer/IBBSendTransportSession.h +++ b/Swiften/FileTransfer/IBBSendTransportSession.h @@ -15,14 +15,14 @@ namespace Swift { class SWIFTEN_API IBBSendTransportSession : public TransportSession { public: - IBBSendTransportSession(boost::shared_ptr<IBBSendSession> session); + IBBSendTransportSession(std::shared_ptr<IBBSendSession> session); virtual ~IBBSendTransportSession(); virtual void start() SWIFTEN_OVERRIDE; virtual void stop() SWIFTEN_OVERRIDE; private: - boost::shared_ptr<IBBSendSession> session; + std::shared_ptr<IBBSendSession> session; boost::bsignals::scoped_connection finishedConnection; boost::bsignals::scoped_connection bytesSentConnection; }; diff --git a/Swiften/FileTransfer/IncomingFileTransfer.h b/Swiften/FileTransfer/IncomingFileTransfer.h index 4cb18e8..2976216 100644 --- a/Swiften/FileTransfer/IncomingFileTransfer.h +++ b/Swiften/FileTransfer/IncomingFileTransfer.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -23,12 +23,12 @@ namespace Swift { */ class SWIFTEN_API IncomingFileTransfer : public FileTransfer { public: - typedef boost::shared_ptr<IncomingFileTransfer> ref; + typedef std::shared_ptr<IncomingFileTransfer> ref; virtual ~IncomingFileTransfer(); virtual void accept( - boost::shared_ptr<WriteBytestream>, + std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) = 0; virtual const JID& getSender() const = 0; diff --git a/Swiften/FileTransfer/IncomingFileTransferManager.cpp b/Swiften/FileTransfer/IncomingFileTransferManager.cpp index b0b4d49..1c2b788 100644 --- a/Swiften/FileTransfer/IncomingFileTransferManager.cpp +++ b/Swiften/FileTransfer/IncomingFileTransferManager.cpp @@ -6,7 +6,7 @@ #include <Swiften/FileTransfer/IncomingFileTransferManager.h> -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <Swiften/Base/Log.h> #include <Swiften/Elements/JingleDescription.h> @@ -43,7 +43,7 @@ bool IncomingFileTransferManager::handleIncomingJingleSession( if (content->getTransport<JingleS5BTransportPayload>() || content->getTransport<JingleIBBTransportPayload>()) { JingleFileTransferDescription::ref description = content->getDescription<JingleFileTransferDescription>(); if (description) { - IncomingJingleFileTransfer::ref transfer = boost::make_shared<IncomingJingleFileTransfer>( + IncomingJingleFileTransfer::ref transfer = std::make_shared<IncomingJingleFileTransfer>( recipient, session, content, transporterFactory, timerFactory, crypto); onIncomingFileTransfer(transfer); } diff --git a/Swiften/FileTransfer/IncomingFileTransferManager.h b/Swiften/FileTransfer/IncomingFileTransferManager.h index 7a34b2a..fa1b3bb 100644 --- a/Swiften/FileTransfer/IncomingFileTransferManager.h +++ b/Swiften/FileTransfer/IncomingFileTransferManager.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp index 526c54c..f73cd38 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp @@ -6,10 +6,10 @@ #include <Swiften/FileTransfer/IncomingJingleFileTransfer.h> +#include <memory> #include <set> #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> @@ -66,7 +66,7 @@ IncomingJingleFileTransfer::~IncomingJingleFileTransfer() { } void IncomingJingleFileTransfer::accept( - boost::shared_ptr<WriteBytestream> stream, + std::shared_ptr<WriteBytestream> stream, const FileTransferOptions& options) { SWIFT_LOG(debug) << std::endl; if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } @@ -126,7 +126,7 @@ void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( fillCandidateMap(localCandidates, candidates); - JingleS5BTransportPayload::ref transport = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref transport = std::make_shared<JingleS5BTransportPayload>(); transport->setSessionID(s5bSessionID); transport->setMode(JingleS5BTransportPayload::TCPMode); transport->setDstAddr(dstAddr); @@ -233,7 +233,7 @@ void IncomingJingleFileTransfer::handleTransportReplaceReceived( } JingleIBBTransportPayload::ref ibbTransport; - if (options.isInBandAllowed() && (ibbTransport = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { + if (options.isInBandAllowed() && (ibbTransport = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { SWIFT_LOG(debug) << "transport replaced with IBB" << std::endl; startTransferring(transporter->createIBBReceiveSession( @@ -379,7 +379,7 @@ void IncomingJingleFileTransfer::startTransferViaLocalCandidate() { } } -void IncomingJingleFileTransfer::startTransferring(boost::shared_ptr<TransportSession> transportSession) { +void IncomingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { SWIFT_LOG(debug) << std::endl; this->transportSession = transportSession; @@ -401,11 +401,11 @@ bool IncomingJingleFileTransfer::isTryingCandidates() const { return state == TryingCandidates; } -boost::shared_ptr<TransportSession> IncomingJingleFileTransfer::createLocalCandidateSession() { +std::shared_ptr<TransportSession> IncomingJingleFileTransfer::createLocalCandidateSession() { return transporter->createLocalCandidateSession(stream, theirCandidateChoice.get()); } -boost::shared_ptr<TransportSession> IncomingJingleFileTransfer::createRemoteCandidateSession() { +std::shared_ptr<TransportSession> IncomingJingleFileTransfer::createRemoteCandidateSession() { return transporter->createRemoteCandidateSession(stream, ourCandidateChoice.get()); } diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h index d3cc331..36b76b1 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.h +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h @@ -6,10 +6,10 @@ #pragma once +#include <memory> #include <string> #include <boost/cstdint.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/ByteArray.h> @@ -42,18 +42,18 @@ namespace Swift { */ class SWIFTEN_API IncomingJingleFileTransfer : public IncomingFileTransfer, public JingleFileTransfer { public: - typedef boost::shared_ptr<IncomingJingleFileTransfer> ref; + typedef std::shared_ptr<IncomingJingleFileTransfer> ref; IncomingJingleFileTransfer( const JID& recipient, - boost::shared_ptr<JingleSession>, - boost::shared_ptr<JingleContentPayload> content, + std::shared_ptr<JingleSession>, + std::shared_ptr<JingleContentPayload> content, FileTransferTransporterFactory*, TimerFactory*, CryptoProvider*); virtual ~IncomingJingleFileTransfer(); - virtual void accept(boost::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) SWIFTEN_OVERRIDE; + virtual void accept(std::shared_ptr<WriteBytestream>, const FileTransferOptions& = FileTransferOptions()) SWIFTEN_OVERRIDE; virtual void cancel() SWIFTEN_OVERRIDE; private: @@ -71,9 +71,9 @@ namespace Swift { virtual void handleSessionTerminateReceived( boost::optional<JinglePayload::Reason> reason) SWIFTEN_OVERRIDE; - virtual void handleSessionInfoReceived(boost::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE; + virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE; virtual void handleTransportReplaceReceived( - const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; + const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; virtual void handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, @@ -101,24 +101,24 @@ namespace Swift { static FileTransfer::State::Type getExternalState(State state); virtual bool hasPriorityOnCandidateTie() const SWIFTEN_OVERRIDE; virtual void fallback() SWIFTEN_OVERRIDE; - virtual void startTransferring(boost::shared_ptr<TransportSession>) 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 boost::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession() 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; private: - boost::shared_ptr<JingleContentPayload> initialContent; + std::shared_ptr<JingleContentPayload> initialContent; CryptoProvider* crypto; State state; - boost::shared_ptr<JingleFileTransferDescription> description; - boost::shared_ptr<WriteBytestream> stream; + std::shared_ptr<JingleFileTransferDescription> description; + std::shared_ptr<WriteBytestream> stream; boost::uintmax_t receivedBytes; IncrementalBytestreamHashCalculator* hashCalculator; - boost::shared_ptr<Timer> waitOnHashTimer; + std::shared_ptr<Timer> waitOnHashTimer; std::map<std::string, ByteArray> hashes; FileTransferOptions options; diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp index 53977ec..36725de 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.cpp +++ b/Swiften/FileTransfer/JingleFileTransfer.cpp @@ -19,7 +19,7 @@ using namespace Swift; JingleFileTransfer::JingleFileTransfer( - boost::shared_ptr<JingleSession> session, + std::shared_ptr<JingleSession> session, const JID& target, FileTransferTransporterFactory* transporterFactory) : session(session), @@ -87,7 +87,7 @@ void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( ourCandidateChoice = candidate; ourCandidateSelectFinished = true; - JingleS5BTransportPayload::ref s5bPayload = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref s5bPayload = std::make_shared<JingleS5BTransportPayload>(); s5bPayload->setSessionID(s5bSessionID); if (candidate) { s5bPayload->setCandidateUsed(candidate->cid); @@ -151,14 +151,14 @@ void JingleFileTransfer::handleProxyActivateFinished( if (error) { SWIFT_LOG(debug) << "Error activating proxy" << std::endl; - JingleS5BTransportPayload::ref proxyError = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref proxyError = std::make_shared<JingleS5BTransportPayload>(); proxyError->setSessionID(s5bSessionID); proxyError->setProxyError(true); session->sendTransportInfo(getContentID(), proxyError); fallback(); } else { - JingleS5BTransportPayload::ref proxyActivate = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref proxyActivate = std::make_shared<JingleS5BTransportPayload>(); proxyActivate->setSessionID(s5bSessionID); proxyActivate->setActivated(theirCandidateChoice->cid); session->sendTransportInfo(getContentID(), proxyActivate); @@ -170,7 +170,7 @@ void JingleFileTransfer::handleTransportInfoReceived( const JingleContentID& /* contentID */, JingleTransportPayload::ref transport) { SWIFT_LOG(debug) << std::endl; - if (JingleS5BTransportPayload::ref s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transport)) { + 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; } diff --git a/Swiften/FileTransfer/JingleFileTransfer.h b/Swiften/FileTransfer/JingleFileTransfer.h index 6862ba2..8a80e06 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.h +++ b/Swiften/FileTransfer/JingleFileTransfer.h @@ -1,15 +1,14 @@ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/ErrorPayload.h> @@ -31,7 +30,7 @@ namespace Swift { class SWIFTEN_API JingleFileTransfer : public AbstractJingleSessionListener { public: JingleFileTransfer( - boost::shared_ptr<JingleSession>, + std::shared_ptr<JingleSession>, const JID& target, FileTransferTransporterFactory*); virtual ~JingleFileTransfer(); @@ -49,15 +48,15 @@ namespace Swift { void handleRemoteTransportCandidateSelectFinished( const std::string& s5bSessionID, const boost::optional<JingleS5BTransportPayload::Candidate>&); virtual JingleContentID getContentID() const = 0; - virtual void startTransferring(boost::shared_ptr<TransportSession>) = 0; + virtual void startTransferring(std::shared_ptr<TransportSession>) = 0; virtual void terminate(JinglePayload::Reason::Type reason) = 0; virtual void fallback() = 0; virtual bool hasPriorityOnCandidateTie() const = 0; virtual bool isWaitingForPeerProxyActivate() const = 0; virtual bool isWaitingForLocalProxyActivate() const = 0; virtual bool isTryingCandidates() const = 0; - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession() = 0; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession() = 0; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() = 0; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() = 0; virtual void startTransferViaLocalCandidate() = 0; virtual void startTransferViaRemoteCandidate() = 0; @@ -75,7 +74,7 @@ namespace Swift { static FileTransfer::State::Type getExternalFinishedState(JinglePayload::Reason::Type); static boost::optional<FileTransferError> getFileTransferError(JinglePayload::Reason::Type); - boost::shared_ptr<JingleSession> session; + std::shared_ptr<JingleSession> session; JID target; FileTransferTransporterFactory* transporterFactory; FileTransferTransporter* transporter; @@ -87,7 +86,7 @@ namespace Swift { boost::optional<JingleS5BTransportPayload::Candidate> theirCandidateChoice; CandidateMap localCandidates; - boost::shared_ptr<TransportSession> transportSession; + std::shared_ptr<TransportSession> transportSession; boost::bsignals::scoped_connection localTransportCandidatesGeneratedConnection; boost::bsignals::scoped_connection remoteTransportCandidateSelectFinishedConnection; diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp index 3703ba1..2975193 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp @@ -5,18 +5,17 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h> +#include <memory> #include <vector> #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h index 74c6bfb..66b035e 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h @@ -58,9 +58,9 @@ namespace Swift { SOCKS5BytestreamProxiesManager* s5bProxy; JID ownJID; IDGenerator* idGenerator; - boost::shared_ptr<SOCKS5BytestreamServerInitializeRequest> s5bServerInitializeRequest; - boost::shared_ptr<SOCKS5BytestreamServerResourceUser> s5bServerResourceUser_; - boost::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> s5bServerPortForwardingUser_; + std::shared_ptr<SOCKS5BytestreamServerInitializeRequest> s5bServerInitializeRequest; + std::shared_ptr<SOCKS5BytestreamServerResourceUser> s5bServerResourceUser_; + std::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> s5bServerPortForwardingUser_; bool triedServerInit_; bool triedForwarding_; bool triedProxyDiscovery_; diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.h b/Swiften/FileTransfer/OutgoingFileTransfer.h index e83a893..07fc6d2 100644 --- a/Swiften/FileTransfer/OutgoingFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingFileTransfer.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/FileTransfer/FileTransfer.h> @@ -14,7 +14,7 @@ namespace Swift { class SWIFTEN_API OutgoingFileTransfer : public FileTransfer { public: - typedef boost::shared_ptr<OutgoingFileTransfer> ref; + typedef std::shared_ptr<OutgoingFileTransfer> ref; public: virtual ~OutgoingFileTransfer(); diff --git a/Swiften/FileTransfer/OutgoingFileTransferManager.cpp b/Swiften/FileTransfer/OutgoingFileTransferManager.cpp index f6d216e..c74aefb 100644 --- a/Swiften/FileTransfer/OutgoingFileTransferManager.cpp +++ b/Swiften/FileTransfer/OutgoingFileTransferManager.cpp @@ -12,7 +12,7 @@ #include <Swiften/FileTransfer/OutgoingFileTransferManager.h> -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <Swiften/Base/IDGenerator.h> #include <Swiften/FileTransfer/OutgoingJingleFileTransfer.h> @@ -41,16 +41,16 @@ OutgoingFileTransferManager::~OutgoingFileTransferManager() { delete idGenerator; } -boost::shared_ptr<OutgoingFileTransfer> OutgoingFileTransferManager::createOutgoingFileTransfer( +std::shared_ptr<OutgoingFileTransfer> OutgoingFileTransferManager::createOutgoingFileTransfer( const JID& from, const JID& recipient, - boost::shared_ptr<ReadBytestream> readBytestream, + std::shared_ptr<ReadBytestream> readBytestream, const JingleFileTransferFileInfo& fileInfo, const FileTransferOptions& config) { - JingleSessionImpl::ref jingleSession = boost::make_shared<JingleSessionImpl>( + JingleSessionImpl::ref jingleSession = std::make_shared<JingleSessionImpl>( from, recipient, idGenerator->generateID(), iqRouter); jingleSessionManager->registerOutgoingSession(from, jingleSession); - return boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer( + return std::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer( recipient, jingleSession, readBytestream, diff --git a/Swiften/FileTransfer/OutgoingFileTransferManager.h b/Swiften/FileTransfer/OutgoingFileTransferManager.h index 3981005..48a6e5a 100644 --- a/Swiften/FileTransfer/OutgoingFileTransferManager.h +++ b/Swiften/FileTransfer/OutgoingFileTransferManager.h @@ -5,14 +5,14 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> @@ -39,10 +39,10 @@ namespace Swift { CryptoProvider* crypto); ~OutgoingFileTransferManager(); - boost::shared_ptr<OutgoingFileTransfer> createOutgoingFileTransfer( + std::shared_ptr<OutgoingFileTransfer> createOutgoingFileTransfer( const JID& from, const JID& to, - boost::shared_ptr<ReadBytestream>, + std::shared_ptr<ReadBytestream>, const JingleFileTransferFileInfo&, const FileTransferOptions&); diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index c7573c2..fcc160a 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp @@ -17,8 +17,9 @@ #include <Swiften/FileTransfer/OutgoingJingleFileTransfer.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <boost/typeof/typeof.hpp> #include <Swiften/Base/IDGenerator.h> @@ -46,7 +47,7 @@ static const int DEFAULT_BLOCK_SIZE = 4096; OutgoingJingleFileTransfer::OutgoingJingleFileTransfer( const JID& toJID, JingleSession::ref session, - boost::shared_ptr<ReadBytestream> stream, + std::shared_ptr<ReadBytestream> stream, FileTransferTransporterFactory* transporterFactory, TimerFactory* timerFactory, IDGenerator* idGenerator, @@ -125,12 +126,12 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived( SWIFT_LOG(debug) << std::endl; if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } - if (JingleS5BTransportPayload::ref s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) { + if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) { transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr()); setInternalState(TryingCandidates); transporter->startTryingRemoteCandidates(); } - else if (JingleIBBTransportPayload::ref ibbPayload = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transportPayload)) { + else if (JingleIBBTransportPayload::ref ibbPayload = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transportPayload)) { startTransferring(transporter->createIBBSendSession(ibbPayload->getSessionID(), ibbPayload->getBlockSize().get_value_or(DEFAULT_BLOCK_SIZE), stream)); } else { @@ -165,7 +166,7 @@ void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleConte SWIFT_LOG(debug) << std::endl; if (state != FallbackRequested) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } - if (JingleIBBTransportPayload::ref ibbPayload = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport)) { + 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 { @@ -174,7 +175,7 @@ void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleConte } } -void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleContentID &, boost::shared_ptr<JingleTransportPayload>) { +void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) { SWIFT_LOG(debug) << std::endl; terminate(JinglePayload::Reason::UnsupportedTransports); @@ -183,7 +184,7 @@ void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleConte void OutgoingJingleFileTransfer::sendSessionInfoHash() { SWIFT_LOG(debug) << std::endl; - JingleFileTransferHash::ref hashElement = boost::make_shared<JingleFileTransferHash>(); + JingleFileTransferHash::ref hashElement = std::make_shared<JingleFileTransferHash>(); hashElement->getFileInfo().addHash(HashElement("sha-1", hashCalculator->getSHA1Hash())); hashElement->getFileInfo().addHash(HashElement("md5", hashCalculator->getMD5Hash())); session->sendInfo(hashElement); @@ -196,7 +197,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( fillCandidateMap(localCandidates, candidates); - JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>(); + JingleFileTransferDescription::ref description = std::make_shared<JingleFileTransferDescription>(); fileInfo.addHash(HashElement("sha-1", ByteArray())); fileInfo.addHash(HashElement("md5", ByteArray())); description->setFileInfo(fileInfo); @@ -204,13 +205,13 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( JingleTransportPayload::ref transport; if (candidates.empty()) { SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate." << std::endl; - JingleIBBTransportPayload::ref ibbTransport = boost::make_shared<JingleIBBTransportPayload>(); + JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); transport = ibbTransport; } else { - JingleS5BTransportPayload::ref s5bTransport = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref s5bTransport = std::make_shared<JingleS5BTransportPayload>(); s5bTransport->setSessionID(s5bSessionID); s5bTransport->setMode(JingleS5BTransportPayload::TCPMode); s5bTransport->setDstAddr(dstAddr); @@ -227,7 +228,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( void OutgoingJingleFileTransfer::fallback() { if (options.isInBandAllowed()) { SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl; - JingleIBBTransportPayload::ref ibbTransport = boost::make_shared<JingleIBBTransportPayload>(); + JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); setInternalState(FallbackRequested); @@ -255,7 +256,7 @@ void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTran } } -void OutgoingJingleFileTransfer::startTransferring(boost::shared_ptr<TransportSession> transportSession) { +void OutgoingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { SWIFT_LOG(debug) << std::endl; this->transportSession = transportSession; @@ -390,11 +391,11 @@ bool OutgoingJingleFileTransfer::isTryingCandidates() const { return state == TryingCandidates; } -boost::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createLocalCandidateSession() { +std::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createLocalCandidateSession() { return transporter->createLocalCandidateSession(stream, theirCandidateChoice.get()); } -boost::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCandidateSession() { +std::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCandidateSession() { return transporter->createRemoteCandidateSession(stream, ourCandidateChoice.get()); } diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h index a8dad1e..4f28433 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h @@ -5,15 +5,16 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <boost/optional/optional.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/Override.h> @@ -38,8 +39,8 @@ namespace Swift { public: OutgoingJingleFileTransfer( const JID& to, - boost::shared_ptr<JingleSession>, - boost::shared_ptr<ReadBytestream>, + std::shared_ptr<JingleSession>, + std::shared_ptr<ReadBytestream>, FileTransferTransporterFactory*, TimerFactory*, IDGenerator*, @@ -66,10 +67,10 @@ namespace Swift { Finished }; - virtual void handleSessionAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleDescription>, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; + 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&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE; - virtual void handleTransportRejectReceived(const JingleContentID &, boost::shared_ptr<JingleTransportPayload>) 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; void startTransferringIfCandidateAcknowledged(); @@ -86,14 +87,14 @@ namespace Swift { void sendSessionInfoHash(); - virtual void startTransferring(boost::shared_ptr<TransportSession>) SWIFTEN_OVERRIDE; + virtual void startTransferring(std::shared_ptr<TransportSession>) SWIFTEN_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 boost::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createLocalCandidateSession() SWIFTEN_OVERRIDE; + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession() SWIFTEN_OVERRIDE; void handleWaitForRemoteTerminationTimeout(); @@ -105,7 +106,7 @@ namespace Swift { private: IDGenerator* idGenerator; - boost::shared_ptr<ReadBytestream> stream; + std::shared_ptr<ReadBytestream> stream; JingleFileTransferFileInfo fileInfo; FileTransferOptions options; JingleContentID contentID; diff --git a/Swiften/FileTransfer/ReadBytestream.h b/Swiften/FileTransfer/ReadBytestream.h index e967c53..62542bc 100644 --- a/Swiften/FileTransfer/ReadBytestream.h +++ b/Swiften/FileTransfer/ReadBytestream.h @@ -6,10 +6,9 @@ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -22,7 +21,7 @@ namespace Swift { * Return an empty vector if no more data is available. * Use onDataAvailable signal for signaling there is data available again. */ - virtual boost::shared_ptr< std::vector<unsigned char> > read(size_t size) = 0; + virtual std::shared_ptr< std::vector<unsigned char> > read(size_t size) = 0; virtual bool isFinished() const = 0; diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp index 296723e..c29fd5c 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp @@ -12,8 +12,9 @@ #include <Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/boost_bsignals.h> @@ -58,7 +59,7 @@ void RemoteJingleTransportCandidateSelector::tryNextCandidate() { if (candidates.empty()) { SWIFT_LOG(debug) << "No more candidates" << std::endl; onCandidateSelectFinished( - boost::optional<JingleS5BTransportPayload::Candidate>(), boost::shared_ptr<SOCKS5BytestreamClientSession>()); + boost::optional<JingleS5BTransportPayload::Candidate>(), std::shared_ptr<SOCKS5BytestreamClientSession>()); } else { lastCandidate = candidates.top(); @@ -67,8 +68,8 @@ void RemoteJingleTransportCandidateSelector::tryNextCandidate() { if ((lastCandidate.type == JingleS5BTransportPayload::Candidate::DirectType && options.isDirectAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::AssistedType && options.isAssistedAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::ProxyType && options.isProxiedAllowed())) { - boost::shared_ptr<Connection> connection = connectionFactory->createConnection(); - s5bSession = boost::make_shared<SOCKS5BytestreamClientSession>( + std::shared_ptr<Connection> connection = connectionFactory->createConnection(); + s5bSession = std::make_shared<SOCKS5BytestreamClientSession>( connection, lastCandidate.hostPort, socks5DstAddr, timerFactory); sessionReadyConnection = s5bSession->onSessionReady.connect( boost::bind(&RemoteJingleTransportCandidateSelector::handleSessionReady, this, _1)); diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h index 5928754..1f24b6a 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h @@ -14,11 +14,10 @@ #include <Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h> +#include <memory> #include <queue> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/Override.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/FileTransferOptions.h> @@ -40,7 +39,7 @@ namespace Swift { virtual void startSelectingCandidate(); virtual void stopSelectingCandidate(); - boost::signal<void (const boost::optional<JingleS5BTransportPayload::Candidate>&, boost::shared_ptr<SOCKS5BytestreamClientSession>)> onCandidateSelectFinished; + boost::signal<void (const boost::optional<JingleS5BTransportPayload::Candidate>&, std::shared_ptr<SOCKS5BytestreamClientSession>)> onCandidateSelectFinished; private: void tryNextCandidate(); @@ -54,7 +53,7 @@ namespace Swift { JingleS5BTransportPayload::Candidate, std::vector<JingleS5BTransportPayload::Candidate>, JingleS5BTransportPayload::CompareCandidate> candidates; - boost::shared_ptr<SOCKS5BytestreamClientSession> s5bSession; + std::shared_ptr<SOCKS5BytestreamClientSession> s5bSession; boost::bsignals::connection sessionReadyConnection; JingleS5BTransportPayload::Candidate lastCandidate; std::string socks5DstAddr; diff --git a/Swiften/FileTransfer/S5BTransportSession.h b/Swiften/FileTransfer/S5BTransportSession.h index 95143bd..683e9c4 100644 --- a/Swiften/FileTransfer/S5BTransportSession.h +++ b/Swiften/FileTransfer/S5BTransportSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -20,16 +20,16 @@ template <typename T> class SWIFTEN_API S5BTransportSession : public TransportSession { public: S5BTransportSession( - boost::shared_ptr<T> session, - boost::shared_ptr<ReadBytestream> readStream) : + std::shared_ptr<T> session, + std::shared_ptr<ReadBytestream> readStream) : session(session), readStream(readStream) { initialize(); } S5BTransportSession( - boost::shared_ptr<T> session, - boost::shared_ptr<WriteBytestream> writeStream) : + std::shared_ptr<T> session, + std::shared_ptr<WriteBytestream> writeStream) : session(session), writeStream(writeStream) { initialize(); @@ -58,9 +58,9 @@ class SWIFTEN_API S5BTransportSession : public TransportSession { } private: - boost::shared_ptr<T> session; - boost::shared_ptr<ReadBytestream> readStream; - boost::shared_ptr<WriteBytestream> writeStream; + std::shared_ptr<T> session; + std::shared_ptr<ReadBytestream> readStream; + std::shared_ptr<WriteBytestream> writeStream; boost::bsignals::scoped_connection finishedConnection; boost::bsignals::scoped_connection bytesSentConnection; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp index 98a0988..5ddd32b 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp @@ -27,7 +27,7 @@ namespace Swift { SOCKS5BytestreamClientSession::SOCKS5BytestreamClientSession( - boost::shared_ptr<Connection> connection, + std::shared_ptr<Connection> connection, const HostAddressPort& addressPort, const std::string& destination, TimerFactory* timerFactory) : @@ -161,7 +161,7 @@ void SOCKS5BytestreamClientSession::authenticate() { state = Authenticating; } -void SOCKS5BytestreamClientSession::startReceiving(boost::shared_ptr<WriteBytestream> writeStream) { +void SOCKS5BytestreamClientSession::startReceiving(std::shared_ptr<WriteBytestream> writeStream) { if (state == Ready) { state = Reading; writeBytestream = writeStream; @@ -172,7 +172,7 @@ void SOCKS5BytestreamClientSession::startReceiving(boost::shared_ptr<WriteBytest } } -void SOCKS5BytestreamClientSession::startSending(boost::shared_ptr<ReadBytestream> readStream) { +void SOCKS5BytestreamClientSession::startSending(std::shared_ptr<ReadBytestream> readStream) { if (state == Ready) { state = Writing; readBytestream = readStream; @@ -191,7 +191,7 @@ HostAddressPort SOCKS5BytestreamClientSession::getAddressPort() const { void SOCKS5BytestreamClientSession::sendData() { if (!readBytestream->isFinished()) { try { - boost::shared_ptr<ByteArray> dataToSend = readBytestream->read(boost::numeric_cast<size_t>(chunkSize)); + std::shared_ptr<ByteArray> dataToSend = readBytestream->read(boost::numeric_cast<size_t>(chunkSize)); connection->write(createSafeByteArray(*dataToSend)); onBytesSent(dataToSend->size()); } @@ -241,7 +241,7 @@ void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) { } } -void SOCKS5BytestreamClientSession::handleDataRead(boost::shared_ptr<SafeByteArray> data) { +void SOCKS5BytestreamClientSession::handleDataRead(std::shared_ptr<SafeByteArray> data) { SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size() << std::endl; if (state != Reading) { append(unprocessedData, *data); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h index 5aea7d0..2a73a79 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h @@ -5,15 +5,16 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <boost/optional.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/API.h> #include <Swiften/Base/ByteArray.h> @@ -48,11 +49,11 @@ public: }; public: - typedef boost::shared_ptr<SOCKS5BytestreamClientSession> ref; + typedef std::shared_ptr<SOCKS5BytestreamClientSession> ref; public: SOCKS5BytestreamClientSession( - boost::shared_ptr<Connection> connection, + std::shared_ptr<Connection> connection, const HostAddressPort&, const std::string&, TimerFactory*); @@ -61,8 +62,8 @@ public: void start(); void stop(); - void startReceiving(boost::shared_ptr<WriteBytestream>); - void startSending(boost::shared_ptr<ReadBytestream>); + void startReceiving(std::shared_ptr<WriteBytestream>); + void startSending(std::shared_ptr<ReadBytestream>); HostAddressPort getAddressPort() const; @@ -78,7 +79,7 @@ private: void authenticate(); void handleConnectFinished(bool error); - void handleDataRead(boost::shared_ptr<SafeByteArray>); + void handleDataRead(std::shared_ptr<SafeByteArray>); void handleDisconnected(const boost::optional<Connection::Error>&); void handleWeFailedTimeout(); @@ -87,7 +88,7 @@ private: void closeConnection(); private: - boost::shared_ptr<Connection> connection; + std::shared_ptr<Connection> connection; HostAddressPort addressPort; std::string destination; // hexify(SHA1(sessionID + requester + target)) @@ -97,8 +98,8 @@ private: ByteArray authenticateAddress; int chunkSize; - boost::shared_ptr<WriteBytestream> writeBytestream; - boost::shared_ptr<ReadBytestream> readBytestream; + std::shared_ptr<WriteBytestream> writeBytestream; + std::shared_ptr<ReadBytestream> readBytestream; Timer::ref weFailedTimeout; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp index 881a82d..6a738ee 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,8 +13,9 @@ #include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> @@ -67,13 +68,13 @@ void SOCKS5BytestreamProxiesManager::connectToProxies(const std::string& session if (localS5BProxies_) { foreach(S5BProxyRequest::ref proxy, localS5BProxies_.get()) { - boost::shared_ptr<Connection> conn = connectionFactory_->createConnection(); + std::shared_ptr<Connection> conn = connectionFactory_->createConnection(); HostAddressPort addressPort = HostAddressPort(proxy->getStreamHost().get().host, proxy->getStreamHost().get().port); SWIFT_LOG_ASSERT(addressPort.isValid(), warning) << std::endl; - boost::shared_ptr<SOCKS5BytestreamClientSession> session = boost::make_shared<SOCKS5BytestreamClientSession>(conn, addressPort, sessionID, timerFactory_); + 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, boost::shared_ptr<SOCKS5BytestreamClientSession> >(proxyJid, session)); + clientSessions.push_back(std::pair<JID, std::shared_ptr<SOCKS5BytestreamClientSession> >(proxyJid, session)); session->onSessionReady.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionReady, this,sessionID, proxyJid, session, _1)); session->onFinished.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionFinished, this, sessionID, proxyJid, session, _1)); session->start(); @@ -83,14 +84,14 @@ void SOCKS5BytestreamProxiesManager::connectToProxies(const std::string& session proxySessions_[sessionID] = clientSessions; } -boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID) { +std::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID) { // checking parameters if (proxySessions_.find(sessionID) == proxySessions_.end()) { - return boost::shared_ptr<SOCKS5BytestreamClientSession>(); + return std::shared_ptr<SOCKS5BytestreamClientSession>(); } // get active session - boost::shared_ptr<SOCKS5BytestreamClientSession> activeSession; + std::shared_ptr<SOCKS5BytestreamClientSession> activeSession; for (ProxyJIDClientSessionVector::iterator i = proxySessions_[sessionID].begin(); i != proxySessions_[sessionID].end(); i++) { i->second->onSessionReady.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionReady, this,sessionID, proxyJID, i->second, _1)); i->second->onFinished.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionFinished, this, sessionID, proxyJID, i->second, _1)); @@ -107,8 +108,8 @@ boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager: return activeSession; } -boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr) { - SOCKS5BytestreamClientSession::ref connection = boost::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_); +std::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr) { + SOCKS5BytestreamClientSession::ref connection = std::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_); return connection; } @@ -146,7 +147,7 @@ void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<Ho // generate proxy per returned address foreach (const HostAddress& address, addresses) { S5BProxyRequest::StreamHost streamHost = proxy->getStreamHost().get(); - S5BProxyRequest::ref proxyForAddress = boost::make_shared<S5BProxyRequest>(*proxy); + S5BProxyRequest::ref proxyForAddress = std::make_shared<S5BProxyRequest>(*proxy); streamHost.host = address.toString(); proxyForAddress->setStreamHost(streamHost); addS5BProxy(proxyForAddress); @@ -157,13 +158,13 @@ void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<Ho } void SOCKS5BytestreamProxiesManager::queryForProxies() { - proxyFinder_ = boost::make_shared<SOCKS5BytestreamProxyFinder>(serviceRoot_, iqRouter_); + proxyFinder_ = std::make_shared<SOCKS5BytestreamProxyFinder>(serviceRoot_, iqRouter_); proxyFinder_->onProxiesFound.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxiesFound, this, _1)); proxyFinder_->start(); } -void SOCKS5BytestreamProxiesManager::handleProxySessionReady(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, bool error) { +void SOCKS5BytestreamProxiesManager::handleProxySessionReady(const std::string& sessionID, const JID& jid, std::shared_ptr<SOCKS5BytestreamClientSession> session, bool error) { session->onSessionReady.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionReady, this, boost::cref(sessionID), boost::cref(jid), session, _1)); if (!error) { // The SOCKS5 bytestream session to the proxy succeeded; stop and remove other sessions. @@ -181,7 +182,7 @@ void SOCKS5BytestreamProxiesManager::handleProxySessionReady(const std::string& } } -void SOCKS5BytestreamProxiesManager::handleProxySessionFinished(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, boost::optional<FileTransferError> error) { +void SOCKS5BytestreamProxiesManager::handleProxySessionFinished(const std::string& sessionID, const JID& jid, std::shared_ptr<SOCKS5BytestreamClientSession> session, boost::optional<FileTransferError> error) { session->onFinished.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionFinished, this, sessionID, jid, session, _1)); if (error.is_initialized()) { // The SOCKS5 bytestream session to the proxy failed; remove it. diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h index b490ffa..0b566f3 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -49,9 +49,9 @@ namespace Swift { const boost::optional<std::vector<S5BProxyRequest::ref> >& getOrDiscoverS5BProxies(); void connectToProxies(const std::string& sessionID); - boost::shared_ptr<SOCKS5BytestreamClientSession> getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID); + std::shared_ptr<SOCKS5BytestreamClientSession> getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID); - boost::shared_ptr<SOCKS5BytestreamClientSession> createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr); + std::shared_ptr<SOCKS5BytestreamClientSession> createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr); public: boost::signal<void ()> onDiscoveredProxiesChanged; @@ -62,8 +62,8 @@ namespace Swift { void queryForProxies(); - void handleProxySessionReady(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, bool error); - void handleProxySessionFinished(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, boost::optional<FileTransferError> error); + void handleProxySessionReady(const std::string& sessionID, const JID& jid, std::shared_ptr<SOCKS5BytestreamClientSession> session, bool error); + void handleProxySessionFinished(const std::string& sessionID, const JID& jid, std::shared_ptr<SOCKS5BytestreamClientSession> session, boost::optional<FileTransferError> error); private: ConnectionFactory* connectionFactory_; @@ -72,11 +72,11 @@ namespace Swift { IQRouter* iqRouter_; JID serviceRoot_; - typedef std::vector<std::pair<JID, boost::shared_ptr<SOCKS5BytestreamClientSession> > > ProxyJIDClientSessionVector; + typedef std::vector<std::pair<JID, std::shared_ptr<SOCKS5BytestreamClientSession> > > ProxyJIDClientSessionVector; typedef std::map<std::string, ProxyJIDClientSessionVector> ProxySessionsMap; ProxySessionsMap proxySessions_; - boost::shared_ptr<SOCKS5BytestreamProxyFinder> proxyFinder_; + std::shared_ptr<SOCKS5BytestreamProxyFinder> proxyFinder_; boost::optional<std::vector<S5BProxyRequest::ref> > localS5BProxies_; }; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp index e6c85cf..9624d4c 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp @@ -5,15 +5,16 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> @@ -30,14 +31,14 @@ SOCKS5BytestreamProxyFinder::~SOCKS5BytestreamProxyFinder() { } void SOCKS5BytestreamProxyFinder::start() { - serviceWalker = boost::make_shared<DiscoServiceWalker>(service, iqRouter); + serviceWalker = std::make_shared<DiscoServiceWalker>(service, iqRouter); serviceWalker->onServiceFound.connect(boost::bind(&SOCKS5BytestreamProxyFinder::handleServiceFound, this, _1, _2)); serviceWalker->onWalkComplete.connect(boost::bind(&SOCKS5BytestreamProxyFinder::handleWalkEnded, this)); serviceWalker->beginWalk(); } void SOCKS5BytestreamProxyFinder::stop() { - typedef boost::shared_ptr<GenericRequest<S5BProxyRequest> > S5BProxyRequestGenericRequest; + typedef std::shared_ptr<GenericRequest<S5BProxyRequest> > S5BProxyRequestGenericRequest; foreach (S5BProxyRequestGenericRequest requester, pendingRequests) { requester->onResponse.disconnect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, requester, _1, _2)); } @@ -49,14 +50,14 @@ void SOCKS5BytestreamProxyFinder::stop() { } void SOCKS5BytestreamProxyFinder::sendBytestreamQuery(const JID& jid) { - S5BProxyRequest::ref proxyRequest = boost::make_shared<S5BProxyRequest>(); - boost::shared_ptr<GenericRequest<S5BProxyRequest> > request = boost::make_shared<GenericRequest<S5BProxyRequest> >(IQ::Get, jid, proxyRequest, iqRouter); + S5BProxyRequest::ref proxyRequest = std::make_shared<S5BProxyRequest>(); + std::shared_ptr<GenericRequest<S5BProxyRequest> > request = std::make_shared<GenericRequest<S5BProxyRequest> >(IQ::Get, jid, proxyRequest, iqRouter); request->onResponse.connect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, request, _1, _2)); pendingRequests.insert(request); request->send(); } -void SOCKS5BytestreamProxyFinder::handleServiceFound(const JID& jid, boost::shared_ptr<DiscoInfo> discoInfo) { +void SOCKS5BytestreamProxyFinder::handleServiceFound(const JID& jid, std::shared_ptr<DiscoInfo> discoInfo) { if (discoInfo->hasFeature(DiscoInfo::Bytestream)) { sendBytestreamQuery(jid); } @@ -68,7 +69,7 @@ void SOCKS5BytestreamProxyFinder::handleWalkEnded() { } } -void SOCKS5BytestreamProxyFinder::handleProxyResponse(boost::shared_ptr<GenericRequest<S5BProxyRequest> > requester, boost::shared_ptr<S5BProxyRequest> request, ErrorPayload::ref error) { +void SOCKS5BytestreamProxyFinder::handleProxyResponse(std::shared_ptr<GenericRequest<S5BProxyRequest> > requester, std::shared_ptr<S5BProxyRequest> request, ErrorPayload::ref error) { requester->onResponse.disconnect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, requester, _1, _2)); pendingRequests.erase(requester); if (error) { diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h index 1047df0..55e499e 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -13,7 +13,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/Disco/DiscoServiceWalker.h> @@ -36,21 +36,21 @@ class SWIFTEN_API SOCKS5BytestreamProxyFinder { void start(); void stop(); - boost::signal<void(std::vector<boost::shared_ptr<S5BProxyRequest> >)> onProxiesFound; + boost::signal<void(std::vector<std::shared_ptr<S5BProxyRequest> >)> onProxiesFound; private: void sendBytestreamQuery(const JID&); - void handleServiceFound(const JID&, boost::shared_ptr<DiscoInfo>); - void handleProxyResponse(boost::shared_ptr<GenericRequest<S5BProxyRequest> > requester, boost::shared_ptr<S5BProxyRequest>, ErrorPayload::ref); + void handleServiceFound(const JID&, std::shared_ptr<DiscoInfo>); + void handleProxyResponse(std::shared_ptr<GenericRequest<S5BProxyRequest> > requester, std::shared_ptr<S5BProxyRequest>, ErrorPayload::ref); void handleWalkEnded(); private: JID service; IQRouter* iqRouter; - boost::shared_ptr<DiscoServiceWalker> serviceWalker; + std::shared_ptr<DiscoServiceWalker> serviceWalker; std::vector<S5BProxyRequest::ref> proxyHosts; - std::set<boost::shared_ptr<GenericRequest<S5BProxyRequest> > > pendingRequests; + std::set<std::shared_ptr<GenericRequest<S5BProxyRequest> > > pendingRequests; }; } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp index 2f66dff..1591e24 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp @@ -1,12 +1,12 @@ /* - * Copyright (c) 2010-2013 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h> -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <Swiften/Base/Algorithm.h> #include <Swiften/Base/Log.h> diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp index f25227a..b68bd58 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp @@ -18,7 +18,7 @@ namespace Swift { SOCKS5BytestreamServer::SOCKS5BytestreamServer( - boost::shared_ptr<ConnectionServer> connectionServer, + std::shared_ptr<ConnectionServer> connectionServer, SOCKS5BytestreamRegistry* registry) : connectionServer(connectionServer), registry(registry) { @@ -30,16 +30,16 @@ void SOCKS5BytestreamServer::start() { void SOCKS5BytestreamServer::stop() { connectionServer->onNewConnection.disconnect(boost::bind(&SOCKS5BytestreamServer::handleNewConnection, this, _1)); - foreach (boost::shared_ptr<SOCKS5BytestreamServerSession> session, sessions) { + foreach (std::shared_ptr<SOCKS5BytestreamServerSession> session, sessions) { session->onFinished.disconnect(boost::bind(&SOCKS5BytestreamServer::handleSessionFinished, this, session)); session->stop(); } sessions.clear(); } -void SOCKS5BytestreamServer::handleNewConnection(boost::shared_ptr<Connection> connection) { - boost::shared_ptr<SOCKS5BytestreamServerSession> session = - boost::make_shared<SOCKS5BytestreamServerSession>(connection, registry); +void SOCKS5BytestreamServer::handleNewConnection(std::shared_ptr<Connection> connection) { + std::shared_ptr<SOCKS5BytestreamServerSession> session = + std::make_shared<SOCKS5BytestreamServerSession>(connection, registry); session->onFinished.connect(boost::bind(&SOCKS5BytestreamServer::handleSessionFinished, this, session)); sessions.push_back(session); session->start(); @@ -49,10 +49,10 @@ HostAddressPort SOCKS5BytestreamServer::getAddressPort() const { return connectionServer->getAddressPort(); } -std::vector< boost::shared_ptr<SOCKS5BytestreamServerSession> > SOCKS5BytestreamServer::getSessions( +std::vector< std::shared_ptr<SOCKS5BytestreamServerSession> > SOCKS5BytestreamServer::getSessions( const std::string& streamID) const { - std::vector< boost::shared_ptr<SOCKS5BytestreamServerSession> > result; - foreach (boost::shared_ptr<SOCKS5BytestreamServerSession> session, sessions) { + std::vector< std::shared_ptr<SOCKS5BytestreamServerSession> > result; + foreach (std::shared_ptr<SOCKS5BytestreamServerSession> session, sessions) { if (session->getStreamID() == streamID) { result.push_back(session); } @@ -60,7 +60,7 @@ std::vector< boost::shared_ptr<SOCKS5BytestreamServerSession> > SOCKS5Bytestream return result; } -void SOCKS5BytestreamServer::handleSessionFinished(boost::shared_ptr<SOCKS5BytestreamServerSession> session) { +void SOCKS5BytestreamServer::handleSessionFinished(std::shared_ptr<SOCKS5BytestreamServerSession> session) { sessions.erase(std::remove(sessions.begin(), sessions.end(), session), sessions.end()); session->onFinished.disconnect(boost::bind(&SOCKS5BytestreamServer::handleSessionFinished, this, session)); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.h b/Swiften/FileTransfer/SOCKS5BytestreamServer.h index f9b293e..c8866c4 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.h @@ -7,10 +7,9 @@ #pragma once #include <map> +#include <memory> #include <string> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/API.h> #include <Swiften/FileTransfer/ReadBytestream.h> #include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h> @@ -24,7 +23,7 @@ namespace Swift { class SWIFTEN_API SOCKS5BytestreamServer { public: SOCKS5BytestreamServer( - boost::shared_ptr<ConnectionServer> connectionServer, + std::shared_ptr<ConnectionServer> connectionServer, SOCKS5BytestreamRegistry* registry); HostAddressPort getAddressPort() const; @@ -32,18 +31,18 @@ namespace Swift { void start(); void stop(); - std::vector< boost::shared_ptr<SOCKS5BytestreamServerSession> > getSessions(const std::string& id) const; + std::vector< std::shared_ptr<SOCKS5BytestreamServerSession> > getSessions(const std::string& id) const; private: - void handleNewConnection(boost::shared_ptr<Connection> connection); - void handleSessionFinished(boost::shared_ptr<SOCKS5BytestreamServerSession>); + void handleNewConnection(std::shared_ptr<Connection> connection); + void handleSessionFinished(std::shared_ptr<SOCKS5BytestreamServerSession>); private: friend class SOCKS5BytestreamServerSession; - boost::shared_ptr<ConnectionServer> connectionServer; + std::shared_ptr<ConnectionServer> connectionServer; SOCKS5BytestreamRegistry* registry; - std::vector<boost::shared_ptr<SOCKS5BytestreamServerSession> > sessions; + std::vector<std::shared_ptr<SOCKS5BytestreamServerSession> > sessions; }; } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp index 22a07fd..33a5283 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp @@ -12,8 +12,9 @@ #include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h> +#include <memory> + #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> @@ -59,10 +60,10 @@ SOCKS5BytestreamServerManager::~SOCKS5BytestreamServerManager() { } } -boost::shared_ptr<SOCKS5BytestreamServerResourceUser> SOCKS5BytestreamServerManager::aquireResourceUser() { - boost::shared_ptr<SOCKS5BytestreamServerResourceUser> resourceUser; +std::shared_ptr<SOCKS5BytestreamServerResourceUser> SOCKS5BytestreamServerManager::aquireResourceUser() { + std::shared_ptr<SOCKS5BytestreamServerResourceUser> resourceUser; if (s5bServerResourceUser_.expired()) { - resourceUser = boost::make_shared<SOCKS5BytestreamServerResourceUser>(this); + resourceUser = std::make_shared<SOCKS5BytestreamServerResourceUser>(this); s5bServerResourceUser_ = resourceUser; } else { @@ -71,10 +72,10 @@ boost::shared_ptr<SOCKS5BytestreamServerResourceUser> SOCKS5BytestreamServerMana return resourceUser; } -boost::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> SOCKS5BytestreamServerManager::aquirePortForwardingUser() { - boost::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> portForwardingUser; +std::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> SOCKS5BytestreamServerManager::aquirePortForwardingUser() { + std::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> portForwardingUser; if (s5bServerPortForwardingUser_.expired()) { - portForwardingUser = boost::make_shared<SOCKS5BytestreamServerPortForwardingUser>(this); + portForwardingUser = std::make_shared<SOCKS5BytestreamServerPortForwardingUser>(this); s5bServerPortForwardingUser_ = portForwardingUser; } else { diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h index ab12dfe..98b5bea 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h @@ -6,11 +6,9 @@ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> - #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Network/HostAddressPort.h> @@ -41,8 +39,8 @@ namespace Swift { NATTraverser* natTraverser); ~SOCKS5BytestreamServerManager(); - boost::shared_ptr<SOCKS5BytestreamServerResourceUser> aquireResourceUser(); - boost::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> aquirePortForwardingUser(); + std::shared_ptr<SOCKS5BytestreamServerResourceUser> aquireResourceUser(); + std::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> aquirePortForwardingUser(); void stop(); @@ -78,18 +76,18 @@ namespace Swift { NATTraverser* natTraverser; enum { Start, Initializing, Initialized } state; SOCKS5BytestreamServer* server; - boost::shared_ptr<ConnectionServer> connectionServer; + std::shared_ptr<ConnectionServer> connectionServer; int connectionServerPort; - boost::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest; - boost::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest; - boost::shared_ptr<NATTraversalRemovePortForwardingRequest> unforwardPortRequest; + std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest; + std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest; + std::shared_ptr<NATTraversalRemovePortForwardingRequest> unforwardPortRequest; boost::optional<HostAddress> publicAddress; boost::optional<NATPortMapping> portMapping; bool attemptedPortMapping_; - boost::weak_ptr<SOCKS5BytestreamServerResourceUser> s5bServerResourceUser_; - boost::weak_ptr<SOCKS5BytestreamServerPortForwardingUser> s5bServerPortForwardingUser_; + std::weak_ptr<SOCKS5BytestreamServerResourceUser> s5bServerResourceUser_; + std::weak_ptr<SOCKS5BytestreamServerPortForwardingUser> s5bServerPortForwardingUser_; }; } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp index e2d46f4..bc4e8e4 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp @@ -21,7 +21,7 @@ namespace Swift { SOCKS5BytestreamServerSession::SOCKS5BytestreamServerSession( - boost::shared_ptr<Connection> connection, + std::shared_ptr<Connection> connection, SOCKS5BytestreamRegistry* bytestreams) : connection(connection), bytestreams(bytestreams), @@ -49,7 +49,7 @@ void SOCKS5BytestreamServerSession::stop() { finish(); } -void SOCKS5BytestreamServerSession::startSending(boost::shared_ptr<ReadBytestream> stream) { +void SOCKS5BytestreamServerSession::startSending(std::shared_ptr<ReadBytestream> stream) { if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } readBytestream = stream; @@ -61,7 +61,7 @@ void SOCKS5BytestreamServerSession::startSending(boost::shared_ptr<ReadBytestrea sendData(); } -void SOCKS5BytestreamServerSession::startReceiving(boost::shared_ptr<WriteBytestream> stream) { +void SOCKS5BytestreamServerSession::startReceiving(std::shared_ptr<WriteBytestream> stream) { if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } writeBytestream = stream; @@ -75,7 +75,7 @@ HostAddressPort SOCKS5BytestreamServerSession::getAddressPort() const { return connection->getLocalAddress(); } -void SOCKS5BytestreamServerSession::handleDataRead(boost::shared_ptr<SafeByteArray> data) { +void SOCKS5BytestreamServerSession::handleDataRead(std::shared_ptr<SafeByteArray> data) { if (state != ReadingData) { append(unprocessedData, *data); process(); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h index a90e8c5..d530a06 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h @@ -6,7 +6,7 @@ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> @@ -20,7 +20,7 @@ namespace Swift { class SWIFTEN_API SOCKS5BytestreamServerSession { public: - typedef boost::shared_ptr<SOCKS5BytestreamServerSession> ref; + typedef std::shared_ptr<SOCKS5BytestreamServerSession> ref; public: enum State { @@ -33,7 +33,7 @@ namespace Swift { Finished }; - SOCKS5BytestreamServerSession(boost::shared_ptr<Connection> connection, SOCKS5BytestreamRegistry* registry); + SOCKS5BytestreamServerSession(std::shared_ptr<Connection> connection, SOCKS5BytestreamRegistry* registry); ~SOCKS5BytestreamServerSession(); void setChunkSize(int chunkSize) { @@ -43,8 +43,8 @@ namespace Swift { void start(); void stop(); - void startSending(boost::shared_ptr<ReadBytestream>); - void startReceiving(boost::shared_ptr<WriteBytestream>); + void startSending(std::shared_ptr<ReadBytestream>); + void startReceiving(std::shared_ptr<WriteBytestream>); HostAddressPort getAddressPort() const; @@ -58,20 +58,20 @@ namespace Swift { private: void finish(const boost::optional<FileTransferError>& error = boost::optional<FileTransferError>()); void process(); - void handleDataRead(boost::shared_ptr<SafeByteArray>); + void handleDataRead(std::shared_ptr<SafeByteArray>); void handleDisconnected(const boost::optional<Connection::Error>&); void handleDataAvailable(); void sendData(); private: - boost::shared_ptr<Connection> connection; + std::shared_ptr<Connection> connection; SOCKS5BytestreamRegistry* bytestreams; ByteArray unprocessedData; State state; int chunkSize; std::string streamID; - boost::shared_ptr<ReadBytestream> readBytestream; - boost::shared_ptr<WriteBytestream> writeBytestream; + std::shared_ptr<ReadBytestream> readBytestream; + std::shared_ptr<WriteBytestream> writeBytestream; bool waitingForData; boost::bsignals::connection disconnectedConnection; diff --git a/Swiften/FileTransfer/StreamInitiationRequest.h b/Swiften/FileTransfer/StreamInitiationRequest.h index c03fae6..44e826c 100644 --- a/Swiften/FileTransfer/StreamInitiationRequest.h +++ b/Swiften/FileTransfer/StreamInitiationRequest.h @@ -13,21 +13,21 @@ namespace Swift { class SWIFTEN_API StreamInitiationRequest : public GenericRequest<StreamInitiation> { public: - typedef boost::shared_ptr<StreamInitiationRequest> ref; + typedef std::shared_ptr<StreamInitiationRequest> ref; - static ref create(const JID& jid, boost::shared_ptr<StreamInitiation> payload, IQRouter* router) { + static ref create(const JID& jid, std::shared_ptr<StreamInitiation> payload, IQRouter* router) { return ref(new StreamInitiationRequest(jid, payload, router)); } - static ref create(const JID& from, const JID& to, boost::shared_ptr<StreamInitiation> payload, IQRouter* router) { + static ref create(const JID& from, const JID& to, std::shared_ptr<StreamInitiation> payload, IQRouter* router) { return ref(new StreamInitiationRequest(from, to, payload, router)); } private: - StreamInitiationRequest(const JID& jid, boost::shared_ptr<StreamInitiation> payload, IQRouter* router) : GenericRequest<StreamInitiation>(IQ::Set, jid, payload, router) { + StreamInitiationRequest(const JID& jid, std::shared_ptr<StreamInitiation> payload, IQRouter* router) : GenericRequest<StreamInitiation>(IQ::Set, jid, payload, router) { } - StreamInitiationRequest(const JID& from, const JID& to, boost::shared_ptr<StreamInitiation> payload, IQRouter* router) : GenericRequest<StreamInitiation>(IQ::Set, from, to, payload, router) { + StreamInitiationRequest(const JID& from, const JID& to, std::shared_ptr<StreamInitiation> payload, IQRouter* router) : GenericRequest<StreamInitiation>(IQ::Set, from, to, payload, router) { } }; } diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h index 70d25a5..03e2476 100644 --- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h +++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h @@ -33,7 +33,7 @@ namespace Swift { const JID&, const boost::filesystem::path&, const std::string&, - boost::shared_ptr<ReadBytestream>, + std::shared_ptr<ReadBytestream>, const FileTransferOptions&) SWIFTEN_OVERRIDE { return OutgoingFileTransfer::ref(); } @@ -44,12 +44,12 @@ namespace Swift { const std::string&, const boost::uintmax_t, const boost::posix_time::ptime&, - boost::shared_ptr<ReadBytestream>, + std::shared_ptr<ReadBytestream>, const FileTransferOptions&) SWIFTEN_OVERRIDE { return OutgoingFileTransfer::ref(); } - virtual void addS5BProxy(boost::shared_ptr<S5BProxyRequest>) { + virtual void addS5BProxy(std::shared_ptr<S5BProxyRequest>) { } }; diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferTransporterFactory.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferTransporterFactory.h index f3972ab..5db3368 100644 --- a/Swiften/FileTransfer/UnitTest/DummyFileTransferTransporterFactory.h +++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferTransporterFactory.h @@ -84,37 +84,37 @@ public: virtual void stopActivatingProxy() { } - virtual boost::shared_ptr<TransportSession> createIBBSendSession(const std::string& sessionID, unsigned int blockSize, boost::shared_ptr<ReadBytestream> stream) { - boost::shared_ptr<IBBSendSession> ibbSession = boost::make_shared<IBBSendSession>( + virtual std::shared_ptr<TransportSession> createIBBSendSession(const std::string& sessionID, unsigned int blockSize, std::shared_ptr<ReadBytestream> stream) { + std::shared_ptr<IBBSendSession> ibbSession = std::make_shared<IBBSendSession>( sessionID, initiator_, responder_, stream, iqRouter_); ibbSession->setBlockSize(blockSize); - return boost::make_shared<IBBSendTransportSession>(ibbSession); + return std::make_shared<IBBSendTransportSession>(ibbSession); } - virtual boost::shared_ptr<TransportSession> createIBBReceiveSession(const std::string& sessionID, unsigned long long size, boost::shared_ptr<WriteBytestream> stream) { - boost::shared_ptr<IBBReceiveSession> ibbSession = boost::make_shared<IBBReceiveSession>( + virtual std::shared_ptr<TransportSession> createIBBReceiveSession(const std::string& sessionID, unsigned long long size, std::shared_ptr<WriteBytestream> stream) { + std::shared_ptr<IBBReceiveSession> ibbSession = std::make_shared<IBBReceiveSession>( sessionID, initiator_, responder_, size, stream, iqRouter_); - return boost::make_shared<IBBReceiveTransportSession>(ibbSession); + return std::make_shared<IBBReceiveTransportSession>(ibbSession); } - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { - return boost::shared_ptr<TransportSession>(); + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { + return std::shared_ptr<TransportSession>(); } - virtual boost::shared_ptr<TransportSession> createRemoteCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { - return boost::shared_ptr<TransportSession>(); + virtual std::shared_ptr<TransportSession> createRemoteCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { + return std::shared_ptr<TransportSession>(); } - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { - return boost::shared_ptr<TransportSession>(); + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<ReadBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { + return std::shared_ptr<TransportSession>(); } - virtual boost::shared_ptr<TransportSession> createLocalCandidateSession( - boost::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { - return boost::shared_ptr<TransportSession>(); + virtual std::shared_ptr<TransportSession> createLocalCandidateSession( + std::shared_ptr<WriteBytestream>, const JingleS5BTransportPayload::Candidate& /* candidate */) { + return std::shared_ptr<TransportSession>(); } private: diff --git a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp index d78f4f0..31f46de 100644 --- a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp @@ -5,10 +5,10 @@ */ +#include <memory> #include <vector> #include <boost/bind.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -38,7 +38,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { stanzaChannel = new DummyStanzaChannel(); iqRouter = new IQRouter(stanzaChannel); finished = false; - bytestream = boost::make_shared<ByteArrayWriteBytestream>(); + bytestream = std::make_shared<ByteArrayWriteBytestream>(); } void tearDown() { @@ -47,7 +47,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testOpen() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -58,7 +58,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveData() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -72,7 +72,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveMultipleData() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -87,7 +87,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveDataForOtherSession() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -99,7 +99,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveDataOutOfOrder() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -114,7 +114,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveLastData() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession", 6)); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession", 6)); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -130,7 +130,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testReceiveClose() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -143,7 +143,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { } void testStopWhileActive() { - boost::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); + std::shared_ptr<IBBReceiveSession> testling(createSession("foo@bar.com/baz", "mysession")); testling->start(); stanzaChannel->onIQReceived(createIBBRequest(IBB::createIBBOpen("mysession", 0x10), "foo@bar.com/baz", "id-open")); @@ -181,7 +181,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture { IQRouter* iqRouter; bool finished; boost::optional<FileTransferError> error; - boost::shared_ptr<ByteArrayWriteBytestream> bytestream; + std::shared_ptr<ByteArrayWriteBytestream> bytestream; }; CPPUNIT_TEST_SUITE_REGISTRATION(IBBReceiveSessionTest); diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp index e417c77..f9057f8 100644 --- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp @@ -39,7 +39,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { void setUp() { stanzaChannel = new DummyStanzaChannel(); iqRouter = new IQRouter(stanzaChannel); - bytestream = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")); + bytestream = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")); finished = false; } @@ -49,7 +49,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testStart() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(1234); testling->start(); @@ -63,7 +63,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testStart_ResponseStartsSending() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(3); testling->start(); @@ -79,7 +79,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testResponseContinuesSending() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(3); testling->start(); stanzaChannel->onIQReceived(createIBBResult()); @@ -95,7 +95,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testRespondToAllFinishes() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(3); testling->start(); stanzaChannel->onIQReceived(createIBBResult()); @@ -108,7 +108,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testErrorResponseFinishesWithError() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(3); testling->start(); stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID())); @@ -118,7 +118,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testStopDuringSessionCloses() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(3); testling->start(); testling->stop(); @@ -133,7 +133,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testStopAfterFinishedDoesNotClose() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); testling->setBlockSize(16); testling->start(); stanzaChannel->onIQReceived(createIBBResult()); @@ -146,7 +146,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testDataStreamPauseStopsSendingData() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); bytestream->setDataComplete(false); testling->setBlockSize(3); testling->start(); @@ -162,7 +162,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testDataStreamResumeAfterPauseSendsData() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); bytestream->setDataComplete(false); testling->setBlockSize(3); testling->start(); @@ -177,7 +177,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testDataStreamResumeBeforePauseDoesNotSendData() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); bytestream->setDataComplete(false); testling->setBlockSize(3); testling->start(); @@ -189,7 +189,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } void testDataStreamResumeAfterResumeDoesNotSendData() { - boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); + std::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz"); bytestream->setDataComplete(false); testling->setBlockSize(3); testling->start(); @@ -206,12 +206,12 @@ class IBBSendSessionTest : public CppUnit::TestFixture { private: IQ::ref createIBBResult() { - return IQ::createResult(JID("baz@fum.com/dum"), stanzaChannel->sentStanzas[stanzaChannel->sentStanzas.size()-1]->getTo(), stanzaChannel->sentStanzas[stanzaChannel->sentStanzas.size()-1]->getID(), boost::shared_ptr<IBB>()); + return IQ::createResult(JID("baz@fum.com/dum"), stanzaChannel->sentStanzas[stanzaChannel->sentStanzas.size()-1]->getTo(), stanzaChannel->sentStanzas[stanzaChannel->sentStanzas.size()-1]->getID(), std::shared_ptr<IBB>()); } private: - boost::shared_ptr<IBBSendSession> createSession(const std::string& to) { - boost::shared_ptr<IBBSendSession> session(new IBBSendSession("myid", JID(), JID(to), bytestream, iqRouter)); + std::shared_ptr<IBBSendSession> createSession(const std::string& to) { + std::shared_ptr<IBBSendSession> session(new IBBSendSession("myid", JID(), JID(to), bytestream, iqRouter)); session->onFinished.connect(boost::bind(&IBBSendSessionTest::handleFinished, this, _1)); return session; } @@ -226,7 +226,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { IQRouter* iqRouter; bool finished; boost::optional<FileTransferError> error; - boost::shared_ptr<ByteArrayReadBytestream> bytestream; + std::shared_ptr<ByteArrayReadBytestream> bytestream; }; CPPUNIT_TEST_SUITE_REGISTRATION(IBBSendSessionTest); diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp index a76773c..72b933d 100644 --- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp @@ -5,14 +5,13 @@ */ /* - * Copyright (c) 2013-2015 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <iostream> - -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -45,7 +44,6 @@ #include <Swiften/Queries/IQRouter.h> using namespace Swift; -using namespace boost; class IncomingJingleFileTransferTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(IncomingJingleFileTransferTest); @@ -54,9 +52,9 @@ class IncomingJingleFileTransferTest : public CppUnit::TestFixture { //CPPUNIT_TEST(test_AcceptFailingS5BFallsBackToIBB); CPPUNIT_TEST_SUITE_END(); public: - shared_ptr<IncomingJingleFileTransfer> createTestling() { + std::shared_ptr<IncomingJingleFileTransfer> createTestling() { JID ourJID("our@jid.org/full"); - return boost::make_shared<IncomingJingleFileTransfer>(ourJID, shared_ptr<JingleSession>(session), jingleContentPayload, ftTransporterFactory, timerFactory, crypto.get()); + return std::make_shared<IncomingJingleFileTransfer>(ourJID, std::shared_ptr<JingleSession>(session), jingleContentPayload, ftTransporterFactory, timerFactory, crypto.get()); } IQ::ref createIBBRequest(IBB::ref ibb, const JID& from, const std::string& id) { @@ -66,13 +64,13 @@ public: } void setUp() { - crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); + crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); eventLoop = new DummyEventLoop(); resolver = new StaticDomainNameResolver(eventLoop); - session = boost::make_shared<FakeJingleSession>("foo@bar.com/baz", "mysession"); - jingleContentPayload = make_shared<JingleContentPayload>(); - // fakeRJTCSF = make_shared<FakeRemoteJingleTransportCandidateSelectorFactory>(); - // fakeLJTCF = make_shared<FakeLocalJingleTransportCandidateGeneratorFactory>(); + session = std::make_shared<FakeJingleSession>("foo@bar.com/baz", "mysession"); + jingleContentPayload = std::make_shared<JingleContentPayload>(); + // fakeRJTCSF = std::make_shared<FakeRemoteJingleTransportCandidateSelectorFactory>(); + // fakeLJTCF = std::make_shared<FakeLocalJingleTransportCandidateGeneratorFactory>(); stanzaChannel = new DummyStanzaChannel(); connectionFactory = new DummyConnectionFactory(eventLoop); serverConnectionFactory = new DummyConnectionServerFactory(eventLoop); @@ -108,17 +106,17 @@ public: // Tests whether IncomingJingleFileTransfer would accept a IBB only file transfer. void test_AcceptOnyIBBSendsSessionAccept() { //1. create your test incoming file transfer - shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>(); + std::shared_ptr<JingleFileTransferDescription> desc = std::make_shared<JingleFileTransferDescription>(); desc->setFileInfo(JingleFileTransferFileInfo("foo.txt", "", 10)); jingleContentPayload->addDescription(desc); - JingleIBBTransportPayload::ref tpRef = make_shared<JingleIBBTransportPayload>(); + JingleIBBTransportPayload::ref tpRef = std::make_shared<JingleIBBTransportPayload>(); tpRef->setSessionID("mysession"); jingleContentPayload->addTransport(tpRef); - shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); + std::shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); //2. do 'accept' on a dummy writebytestream (you'll have to look if there already is one) - shared_ptr<ByteArrayWriteBytestream> byteStream = make_shared<ByteArrayWriteBytestream>(); + std::shared_ptr<ByteArrayWriteBytestream> byteStream = std::make_shared<ByteArrayWriteBytestream>(); fileTransfer->accept(byteStream); // check whether accept has been called @@ -127,17 +125,17 @@ public: void test_OnlyIBBTransferReceiveWorks() { //1. create your test incoming file transfer - shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>(); + std::shared_ptr<JingleFileTransferDescription> desc = std::make_shared<JingleFileTransferDescription>(); desc->setFileInfo(JingleFileTransferFileInfo("file.txt", "", 10)); jingleContentPayload->addDescription(desc); - JingleIBBTransportPayload::ref tpRef = make_shared<JingleIBBTransportPayload>(); + JingleIBBTransportPayload::ref tpRef = std::make_shared<JingleIBBTransportPayload>(); tpRef->setSessionID("mysession"); jingleContentPayload->addTransport(tpRef); - shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); + std::shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); //2. do 'accept' on a dummy writebytestream (you'll have to look if there already is one) - shared_ptr<ByteArrayWriteBytestream> byteStream = make_shared<ByteArrayWriteBytestream>(); + std::shared_ptr<ByteArrayWriteBytestream> byteStream = std::make_shared<ByteArrayWriteBytestream>(); fileTransfer->accept(byteStream); // check whether accept has been called @@ -154,10 +152,10 @@ public: // add SOCKS5BytestreamTransportPayload JingleS5BTransportPayload::ref payLoad = addJingleS5BPayload(); - shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); + std::shared_ptr<IncomingJingleFileTransfer> fileTransfer = createTestling(); //2. do 'accept' on a dummy writebytestream (you'll have to look if there already is one) - shared_ptr<ByteArrayWriteBytestream> byteStream = make_shared<ByteArrayWriteBytestream>(); + std::shared_ptr<ByteArrayWriteBytestream> byteStream = std::make_shared<ByteArrayWriteBytestream>(); fileTransfer->accept(byteStream); // candidates are gathered @@ -168,7 +166,7 @@ public: // check for candidate error FakeJingleSession::InfoTransportCall infoTransportCall = getCall<FakeJingleSession::InfoTransportCall>(1); - JingleS5BTransportPayload::ref s5bPayload = dynamic_pointer_cast<JingleS5BTransportPayload>(infoTransportCall.payload); + JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(infoTransportCall.payload); CPPUNIT_ASSERT(s5bPayload->hasCandidateError()); // indicate transport replace (Romeo) @@ -189,20 +187,20 @@ public: #endif private: void addFileTransferDescription() { - shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>(); + std::shared_ptr<JingleFileTransferDescription> desc = std::make_shared<JingleFileTransferDescription>(); desc->setFileInfo(JingleFileTransferFileInfo("file.txt", "", 10)); jingleContentPayload->addDescription(desc); } - shared_ptr<JingleS5BTransportPayload> addJingleS5BPayload() { - JingleS5BTransportPayload::ref payLoad = make_shared<JingleS5BTransportPayload>(); + std::shared_ptr<JingleS5BTransportPayload> addJingleS5BPayload() { + JingleS5BTransportPayload::ref payLoad = std::make_shared<JingleS5BTransportPayload>(); payLoad->setSessionID("mysession"); jingleContentPayload->addTransport(payLoad); return payLoad; } - shared_ptr<JingleIBBTransportPayload> addJingleIBBPayload() { - JingleIBBTransportPayload::ref payLoad = make_shared<JingleIBBTransportPayload>(); + std::shared_ptr<JingleIBBTransportPayload> addJingleIBBPayload() { + JingleIBBTransportPayload::ref payLoad = std::make_shared<JingleIBBTransportPayload>(); payLoad->setSessionID("mysession"); jingleContentPayload->addTransport(payLoad); return payLoad; @@ -222,9 +220,9 @@ private: private: EventLoop* eventLoop; - boost::shared_ptr<CryptoProvider> crypto; - boost::shared_ptr<FakeJingleSession> session; - shared_ptr<JingleContentPayload> jingleContentPayload; + std::shared_ptr<CryptoProvider> crypto; + std::shared_ptr<FakeJingleSession> session; + std::shared_ptr<JingleContentPayload> jingleContentPayload; // shared_ptr<FakeRemoteJingleTransportCandidateSelectorFactory> fakeRJTCSF; // shared_ptr<FakeLocalJingleTransportCandidateGeneratorFactory> fakeLJTCF; FileTransferTransporterFactory* ftTransporterFactory; diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp index 401463c..3f4d20f 100644 --- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp +++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp @@ -11,10 +11,10 @@ */ #include <iostream> +#include <memory> #include <boost/bind.hpp> #include <boost/optional.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -81,16 +81,16 @@ class OutgoingJingleFileTransferTest : public CppUnit::TestFixture { public: - boost::shared_ptr<OutgoingJingleFileTransfer> createTestling(const FileTransferOptions& options = FileTransferOptions().withAssistedAllowed(false).withDirectAllowed(false).withProxiedAllowed(false)) { + std::shared_ptr<OutgoingJingleFileTransfer> createTestling(const FileTransferOptions& options = FileTransferOptions().withAssistedAllowed(false).withDirectAllowed(false).withProxiedAllowed(false)) { JID to("test@foo.com/bla"); JingleFileTransferFileInfo fileInfo; fileInfo.setDescription("some file"); fileInfo.setName("test.bin"); fileInfo.addHash(HashElement("sha-1", ByteArray())); fileInfo.setSize(1024 * 1024); - return boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer( + return std::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer( to, - boost::shared_ptr<JingleSession>(fakeJingleSession), + std::shared_ptr<JingleSession>(fakeJingleSession), stream, ftTransportFactory, timerFactory, @@ -107,9 +107,9 @@ public: } void setUp() { - crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); + crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); fakeJingleSession = new FakeJingleSession("foo@bar.com/baz", "mysession"); - jingleContentPayload = boost::make_shared<JingleContentPayload>(); + jingleContentPayload = std::make_shared<JingleContentPayload>(); stanzaChannel = new DummyStanzaChannel(); iqRouter = new IQRouter(stanzaChannel); eventLoop = new DummyEventLoop(); @@ -126,7 +126,7 @@ public: data.push_back(34); } - stream = boost::make_shared<ByteArrayReadBytestream>(data); + stream = std::make_shared<ByteArrayReadBytestream>(data); idGen = new IDGenerator(); s5bProxy = new SOCKS5BytestreamProxiesManager(connectionFactory, timerFactory, resolver, iqRouter, "bar.com"); @@ -151,29 +151,29 @@ public: void test_SendSessionInitiateOnStart() { - boost::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); + std::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); transfer->start(); FakeJingleSession::InitiateCall call = getCall<FakeJingleSession::InitiateCall>(0); - JingleFileTransferDescription::ref description = boost::dynamic_pointer_cast<JingleFileTransferDescription>(call.description); + JingleFileTransferDescription::ref description = std::dynamic_pointer_cast<JingleFileTransferDescription>(call.description); CPPUNIT_ASSERT(description); CPPUNIT_ASSERT(static_cast<size_t>(1048576) == description->getFileInfo().getSize()); - JingleIBBTransportPayload::ref transport = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(call.payload); + JingleIBBTransportPayload::ref transport = std::dynamic_pointer_cast<JingleIBBTransportPayload>(call.payload); CPPUNIT_ASSERT(transport); } void test_FallbackToIBBAfterFailingS5B() { - boost::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(FileTransferOptions().withAssistedAllowed(true).withDirectAllowed(true).withProxiedAllowed(true)); + std::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(FileTransferOptions().withAssistedAllowed(true).withDirectAllowed(true).withProxiedAllowed(true)); transfer->start(); FakeJingleSession::InitiateCall call = getCall<FakeJingleSession::InitiateCall>(0); - CPPUNIT_ASSERT(boost::dynamic_pointer_cast<JingleS5BTransportPayload>(call.payload)); + CPPUNIT_ASSERT(std::dynamic_pointer_cast<JingleS5BTransportPayload>(call.payload)); fakeJingleSession->handleSessionAcceptReceived(call.id, call.description, call.payload); // send candidate failure - JingleS5BTransportPayload::ref candidateFailurePayload = boost::make_shared<JingleS5BTransportPayload>(); + JingleS5BTransportPayload::ref candidateFailurePayload = std::make_shared<JingleS5BTransportPayload>(); candidateFailurePayload->setCandidateError(true); candidateFailurePayload->setSessionID(call.payload->getSessionID()); fakeJingleSession->handleTransportInfoReceived(call.id, candidateFailurePayload); @@ -193,7 +193,7 @@ public: } void test_ReceiveSessionTerminateAfterSessionInitiate() { - boost::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); + std::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); transfer->start(); getCall<FakeJingleSession::InitiateCall>(0); @@ -207,7 +207,7 @@ public: } void test_DeclineEmitsFinishedStateCanceled() { - boost::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); + std::shared_ptr<OutgoingJingleFileTransfer> transfer = createTestling(); transfer->start(); getCall<FakeJingleSession::InitiateCall>(0); @@ -227,20 +227,20 @@ public: private: void addFileTransferDescription() { - boost::shared_ptr<JingleFileTransferDescription> desc = boost::make_shared<JingleFileTransferDescription>(); + std::shared_ptr<JingleFileTransferDescription> desc = std::make_shared<JingleFileTransferDescription>(); desc->setFileInfo(JingleFileTransferFileInfo()); jingleContentPayload->addDescription(desc); } - boost::shared_ptr<JingleS5BTransportPayload> addJingleS5BPayload() { - JingleS5BTransportPayload::ref payLoad = boost::make_shared<JingleS5BTransportPayload>(); + std::shared_ptr<JingleS5BTransportPayload> addJingleS5BPayload() { + JingleS5BTransportPayload::ref payLoad = std::make_shared<JingleS5BTransportPayload>(); payLoad->setSessionID("mysession"); jingleContentPayload->addTransport(payLoad); return payLoad; } - boost::shared_ptr<JingleIBBTransportPayload> addJingleIBBPayload() { - JingleIBBTransportPayload::ref payLoad = boost::make_shared<JingleIBBTransportPayload>(); + std::shared_ptr<JingleIBBTransportPayload> addJingleIBBPayload() { + JingleIBBTransportPayload::ref payLoad = std::make_shared<JingleIBBTransportPayload>(); payLoad->setSessionID("mysession"); jingleContentPayload->addTransport(payLoad); return payLoad; @@ -260,9 +260,9 @@ private: private: std::vector<unsigned char> data; - boost::shared_ptr<ByteArrayReadBytestream> stream; + std::shared_ptr<ByteArrayReadBytestream> stream; FakeJingleSession* fakeJingleSession; - boost::shared_ptr<JingleContentPayload> jingleContentPayload; + std::shared_ptr<JingleContentPayload> jingleContentPayload; FileTransferTransporterFactory* ftTransportFactory; SOCKS5BytestreamServerManager* bytestreamServerManager; DummyStanzaChannel* stanzaChannel; @@ -274,7 +274,7 @@ private: DummyTimerFactory* timerFactory; DummyConnectionFactory* connectionFactory; DummyConnectionServerFactory* serverConnectionFactory; - boost::shared_ptr<CryptoProvider> crypto; + std::shared_ptr<CryptoProvider> crypto; NetworkEnvironment* networkEnvironment; NATTraverser* natTraverser; DomainNameResolver* resolver; diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 9690c09..5408cd4 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -10,11 +10,12 @@ * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int.hpp> #include <boost/random/variate_generator.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <QA/Checker/IO.h> @@ -55,14 +56,14 @@ public: SOCKS5BytestreamClientSessionTest() : destinationAddressPort(HostAddressPort(HostAddress("127.0.0.1"), 8888)) {} void setUp() { - crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); + crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); destination = "092a44d859d19c9eed676b551ee80025903351c2"; randomGen.seed(static_cast<unsigned int>(time(nullptr))); eventLoop = new DummyEventLoop(); timerFactory = new DummyTimerFactory(); - connection = boost::make_shared<MockeryConnection>(failingPorts, true, eventLoop); + connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop); //connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); - //stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); + //stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); // connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1)); } @@ -76,7 +77,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -102,7 +103,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -122,7 +123,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -149,7 +150,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -165,7 +166,7 @@ public: CPPUNIT_ASSERT_EQUAL(true, helper.sessionReadyCalled); CPPUNIT_ASSERT_EQUAL(false, helper.sessionReadyError); - boost::shared_ptr<ByteArrayWriteBytestream> output = boost::make_shared<ByteArrayWriteBytestream>(); + std::shared_ptr<ByteArrayWriteBytestream> output = std::make_shared<ByteArrayWriteBytestream>(); clientSession->startReceiving(output); ByteArray transferData = generateRandomByteArray(1024); @@ -177,7 +178,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -195,7 +196,7 @@ public: helper.unprocessedInput.clear(); ByteArray transferData = generateRandomByteArray(1024); - boost::shared_ptr<ByteArrayReadBytestream> input = boost::make_shared<ByteArrayReadBytestream>(transferData); + std::shared_ptr<ByteArrayReadBytestream> input = std::make_shared<ByteArrayReadBytestream>(transferData); clientSession->startSending(input); eventLoop->processEvents(); @@ -225,7 +226,7 @@ private: } void serverRespondRequestOK() { - boost::shared_ptr<SafeByteArray> dataToSend = createSafeByteArrayRef("\x05\x00\x00\x03", 4); + std::shared_ptr<SafeByteArray> dataToSend = createSafeByteArrayRef("\x05\x00\x00\x03", 4); append(*dataToSend, createSafeByteArray(static_cast<char>(destination.size()))); append(*dataToSend, createSafeByteArray(destination)); append(*dataToSend, createSafeByteArray("\x00", 1)); @@ -233,12 +234,12 @@ private: } void serverRespondRequestFail() { - boost::shared_ptr<SafeByteArray> correctData = createSafeByteArrayRef("\x05\x00\x00\x03", 4); + std::shared_ptr<SafeByteArray> correctData = createSafeByteArrayRef("\x05\x00\x00\x03", 4); append(*correctData, createSafeByteArray(static_cast<char>(destination.size()))); append(*correctData, createSafeByteArray(destination)); append(*correctData, createSafeByteArray("\x00", 1)); - boost::shared_ptr<SafeByteArray> dataToSend; + std::shared_ptr<SafeByteArray> dataToSend; //ByteArray failingData = Hexify::unhexify("8417947d1d305c72c11520ea7d2c6e787396705e72c312c6ccc3f66613d7cae1b91b7ab48e8b59a17d559c15fb51"); //append(dataToSend, failingData); //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData) << std::endl; @@ -269,7 +270,7 @@ private: private: - struct MockeryConnection : public Connection, public EventOwner, public boost::enable_shared_from_this<MockeryConnection> { + struct MockeryConnection : public Connection, public EventOwner, public std::enable_shared_from_this<MockeryConnection> { public: MockeryConnection(const std::vector<HostAddressPort>& failingPorts, bool isResponsive, EventLoop* eventLoop) : eventLoop(eventLoop), failingPorts(failingPorts), isResponsive(isResponsive), disconnectCalled(false) {} @@ -309,9 +310,9 @@ private: std::string destination; DummyEventLoop* eventLoop; DummyTimerFactory* timerFactory; - boost::shared_ptr<MockeryConnection> connection; + std::shared_ptr<MockeryConnection> connection; const std::vector<HostAddressPort> failingPorts; - boost::shared_ptr<CryptoProvider> crypto; + std::shared_ptr<CryptoProvider> crypto; }; CPPUNIT_TEST_SUITE_REGISTRATION(SOCKS5BytestreamClientSessionTest); diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp index 12690ff..d419b8a 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp @@ -37,9 +37,9 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { receivedDataChunks = 0; eventLoop = new DummyEventLoop(); bytestreams = new SOCKS5BytestreamRegistry(); - connection = boost::make_shared<DummyConnection>(eventLoop); + connection = std::make_shared<DummyConnection>(eventLoop); connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); - stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")); + stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")); finished = false; } @@ -50,7 +50,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testAuthenticate() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); receive(createSafeByteArray("\x05\x02\x01\x02")); @@ -59,7 +59,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testAuthenticate_Chunked() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); receive(createSafeByteArray("\x05\x02\x01")); @@ -70,7 +70,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testRequest() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); bytestreams->setHasBytestream("abcdef", true); authenticate(); @@ -81,7 +81,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testRequest_UnknownBytestream() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); authenticate(); @@ -91,7 +91,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testReceiveData() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); bytestreams->setHasBytestream("abcdef", true); authenticate(); @@ -106,7 +106,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testReceiveData_Chunked() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); testling->setChunkSize(3); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); bytestreams->setHasBytestream("abcdef", true); @@ -121,7 +121,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testDataStreamPauseStopsSendingData() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); testling->setChunkSize(3); stream1->setDataComplete(false); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); @@ -140,7 +140,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void testDataStreamResumeAfterPauseSendsData() { - boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); + std::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); testling->setChunkSize(3); stream1->setDataComplete(false); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); @@ -202,10 +202,10 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { private: DummyEventLoop* eventLoop; SOCKS5BytestreamRegistry* bytestreams; - boost::shared_ptr<DummyConnection> connection; + std::shared_ptr<DummyConnection> connection; std::vector<unsigned char> receivedData; int receivedDataChunks; - boost::shared_ptr<ByteArrayReadBytestream> stream1; + std::shared_ptr<ByteArrayReadBytestream> stream1; bool finished; boost::optional<FileTransferError> error; }; diff --git a/Swiften/FileTransfer/WriteBytestream.h b/Swiften/FileTransfer/WriteBytestream.h index ffcfdcc..ccc7880 100644 --- a/Swiften/FileTransfer/WriteBytestream.h +++ b/Swiften/FileTransfer/WriteBytestream.h @@ -6,17 +6,16 @@ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/API.h> #include <Swiften/Base/boost_bsignals.h> namespace Swift { class SWIFTEN_API WriteBytestream { public: - typedef boost::shared_ptr<WriteBytestream> ref; + typedef std::shared_ptr<WriteBytestream> ref; virtual ~WriteBytestream(); |