diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/FileTransfer/DefaultFileTransferTransporter.cpp | 105 | ||||
-rw-r--r-- | Swiften/FileTransfer/FailingTransportSession.h | 28 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBReceiveTransportSession.cpp | 28 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBReceiveTransportSession.h | 30 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBSendTransportSession.cpp | 29 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBSendTransportSession.h | 30 | ||||
-rw-r--r-- | Swiften/FileTransfer/S5BTransportSession.h | 67 | ||||
-rw-r--r-- | Swiften/FileTransfer/SConscript | 2 |
8 files changed, 218 insertions, 101 deletions
diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index 22b4a84..568fa7c 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp @@ -12,11 +12,15 @@ #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> #include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/FileTransfer/FailingTransportSession.h> #include <Swiften/FileTransfer/FileTransferOptions.h> #include <Swiften/FileTransfer/IBBReceiveSession.h> +#include <Swiften/FileTransfer/IBBReceiveTransportSession.h> #include <Swiften/FileTransfer/IBBSendSession.h> +#include <Swiften/FileTransfer/IBBSendTransportSession.h> #include <Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h> #include <Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h> +#include <Swiften/FileTransfer/S5BTransportSession.h> #include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h> #include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h> #include <Swiften/FileTransfer/SOCKS5BytestreamServer.h> @@ -28,107 +32,6 @@ using namespace Swift; -namespace { - class IBBSendTransportSession : public TransportSession { - public: - IBBSendTransportSession(boost::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)); - } - - virtual void start() SWIFTEN_OVERRIDE { - session->start(); - } - - virtual void stop() SWIFTEN_OVERRIDE { - session->stop(); - } - - private: - boost::shared_ptr<IBBSendSession> session; - boost::bsignals::scoped_connection finishedConnection; - boost::bsignals::scoped_connection bytesSentConnection; - }; - - class IBBReceiveTransportSession : public TransportSession { - public: - IBBReceiveTransportSession(boost::shared_ptr<IBBReceiveSession> session) : session(session) { - finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); - } - - virtual void start() SWIFTEN_OVERRIDE { - session->start(); - } - - virtual void stop() SWIFTEN_OVERRIDE { - session->stop(); - } - - private: - boost::shared_ptr<IBBReceiveSession> session; - boost::bsignals::scoped_connection finishedConnection; - boost::bsignals::scoped_connection bytesSentConnection; - }; - - class FailingTransportSession : public TransportSession { - public: - virtual void start() SWIFTEN_OVERRIDE { - assert(false); - onFinished(FileTransferError(FileTransferError::PeerError)); - } - - virtual void stop() SWIFTEN_OVERRIDE { - } - }; - - template <typename T> - class S5BTransportSession : public TransportSession { - public: - S5BTransportSession( - boost::shared_ptr<T> session, - boost::shared_ptr<ReadBytestream> readStream) : - session(session), - readStream(readStream) { - initialize(); - } - - S5BTransportSession( - boost::shared_ptr<T> session, - boost::shared_ptr<WriteBytestream> writeStream) : - session(session), - writeStream(writeStream) { - initialize(); - } - - virtual void start() SWIFTEN_OVERRIDE { - if (readStream) { - session->startSending(readStream); - } - else { - session->startReceiving(writeStream); - } - } - - virtual void stop() SWIFTEN_OVERRIDE { - session->stop(); - } - - private: - void initialize() { - finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); - bytesSentConnection = session->onBytesSent.connect(boost::bind(boost::ref(onBytesSent), _1)); - } - - private: - boost::shared_ptr<T> session; - boost::shared_ptr<ReadBytestream> readStream; - boost::shared_ptr<WriteBytestream> writeStream; - - boost::bsignals::scoped_connection finishedConnection; - boost::bsignals::scoped_connection bytesSentConnection; - }; -} - DefaultFileTransferTransporter::DefaultFileTransferTransporter( const JID& initiator, const JID& responder, diff --git a/Swiften/FileTransfer/FailingTransportSession.h b/Swiften/FileTransfer/FailingTransportSession.h new file mode 100644 index 0000000..c197052 --- /dev/null +++ b/Swiften/FileTransfer/FailingTransportSession.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/FileTransfer/TransportSession.h> + +namespace Swift { + +class SWIFTEN_API FailingTransportSession : public TransportSession { + public: + virtual ~FailingTransportSession() { + } + + virtual void start() SWIFTEN_OVERRIDE { + assert(false); + onFinished(FileTransferError(FileTransferError::PeerError)); + } + + virtual void stop() SWIFTEN_OVERRIDE { + } +}; + +} diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.cpp b/Swiften/FileTransfer/IBBReceiveTransportSession.cpp new file mode 100644 index 0000000..4464946 --- /dev/null +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <boost/bind.hpp> + +#include <Swiften/FileTransfer/IBBReceiveTransportSession.h> + +namespace Swift { + +IBBReceiveTransportSession::IBBReceiveTransportSession(boost::shared_ptr<IBBReceiveSession> session) : session(session) { + finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); +} + +IBBReceiveTransportSession::~IBBReceiveTransportSession() { +} + +void IBBReceiveTransportSession::start() { + session->start(); +} + +void IBBReceiveTransportSession::stop() { + session->stop(); +} + +} diff --git a/Swiften/FileTransfer/IBBReceiveTransportSession.h b/Swiften/FileTransfer/IBBReceiveTransportSession.h new file mode 100644 index 0000000..5fca26a --- /dev/null +++ b/Swiften/FileTransfer/IBBReceiveTransportSession.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/FileTransfer/TransportSession.h> +#include <Swiften/FileTransfer/IBBReceiveSession.h> + +namespace Swift { + +class SWIFTEN_API IBBReceiveTransportSession : public TransportSession { + public: + IBBReceiveTransportSession(boost::shared_ptr<IBBReceiveSession> session); + virtual ~IBBReceiveTransportSession(); + + virtual void start() SWIFTEN_OVERRIDE; + virtual void stop() SWIFTEN_OVERRIDE; + + private: + boost::shared_ptr<IBBReceiveSession> session; + boost::bsignals::scoped_connection finishedConnection; + boost::bsignals::scoped_connection bytesSentConnection; +}; + +} diff --git a/Swiften/FileTransfer/IBBSendTransportSession.cpp b/Swiften/FileTransfer/IBBSendTransportSession.cpp new file mode 100644 index 0000000..b4d2467 --- /dev/null +++ b/Swiften/FileTransfer/IBBSendTransportSession.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <boost/bind.hpp> + +#include <Swiften/FileTransfer/IBBSendTransportSession.h> + +namespace Swift { + +IBBSendTransportSession::IBBSendTransportSession(boost::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)); +} + +IBBSendTransportSession::~IBBSendTransportSession() { +} + + void IBBSendTransportSession::start() { + session->start(); +} + +void IBBSendTransportSession::stop() { + session->stop(); +} + +} diff --git a/Swiften/FileTransfer/IBBSendTransportSession.h b/Swiften/FileTransfer/IBBSendTransportSession.h new file mode 100644 index 0000000..20abbd7 --- /dev/null +++ b/Swiften/FileTransfer/IBBSendTransportSession.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/FileTransfer/TransportSession.h> +#include <Swiften/FileTransfer/IBBSendSession.h> + +namespace Swift { + +class SWIFTEN_API IBBSendTransportSession : public TransportSession { + public: + IBBSendTransportSession(boost::shared_ptr<IBBSendSession> session); + virtual ~IBBSendTransportSession(); + + virtual void start() SWIFTEN_OVERRIDE; + virtual void stop() SWIFTEN_OVERRIDE; + + private: + boost::shared_ptr<IBBSendSession> session; + boost::bsignals::scoped_connection finishedConnection; + boost::bsignals::scoped_connection bytesSentConnection; +}; + +} diff --git a/Swiften/FileTransfer/S5BTransportSession.h b/Swiften/FileTransfer/S5BTransportSession.h new file mode 100644 index 0000000..234c491 --- /dev/null +++ b/Swiften/FileTransfer/S5BTransportSession.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <Swiften/Base/API.h> +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/FileTransfer/TransportSession.h> +#include <Swiften/FileTransfer/ReadBytestream.h> +#include <Swiften/FileTransfer/WriteBytestream.h> + +namespace Swift { + +template <typename T> +class SWIFTEN_API S5BTransportSession : public TransportSession { + public: + S5BTransportSession( + boost::shared_ptr<T> session, + boost::shared_ptr<ReadBytestream> readStream) : + session(session), + readStream(readStream) { + initialize(); + } + + S5BTransportSession( + boost::shared_ptr<T> session, + boost::shared_ptr<WriteBytestream> writeStream) : + session(session), + writeStream(writeStream) { + initialize(); + } + + virtual ~S5BTransportSession() { + } + + virtual void start() SWIFTEN_OVERRIDE { + if (readStream) { + session->startSending(readStream); + } + else { + session->startReceiving(writeStream); + } + } + + virtual void stop() SWIFTEN_OVERRIDE { + session->stop(); + } + + private: + void initialize() { + finishedConnection = session->onFinished.connect(boost::bind(boost::ref(onFinished), _1)); + bytesSentConnection = session->onBytesSent.connect(boost::bind(boost::ref(onBytesSent), _1)); + } + + private: + boost::shared_ptr<T> session; + boost::shared_ptr<ReadBytestream> readStream; + boost::shared_ptr<WriteBytestream> writeStream; + + boost::bsignals::scoped_connection finishedConnection; + boost::bsignals::scoped_connection bytesSentConnection; +}; + +} diff --git a/Swiften/FileTransfer/SConscript b/Swiften/FileTransfer/SConscript index 6c29ea6..88cfc00 100644 --- a/Swiften/FileTransfer/SConscript +++ b/Swiften/FileTransfer/SConscript @@ -23,6 +23,8 @@ sources = [ "FileWriteBytestream.cpp", "FileTransfer.cpp", "TransportSession.cpp", + "IBBSendTransportSession.cpp", + "IBBReceiveTransportSession.cpp", "SOCKS5BytestreamClientSession.cpp", "SOCKS5BytestreamServerInitializeRequest.cpp", "SOCKS5BytestreamServerManager.cpp", |