diff --git a/include/Swiften/Network/DummyConnectionServer.cpp b/include/Swiften/Network/DummyConnectionServer.cpp new file mode 100644 index 00000000..7250dce3 --- /dev/null +++ b/include/Swiften/Network/DummyConnectionServer.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include + +#include +#include +#include + +#include + +namespace Swift { + +DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) { +} + +void DummyConnectionServer::start() { +} + + +void DummyConnectionServer::stop() { + +} + +void DummyConnectionServer::acceptConnection(boost::shared_ptr connection) { + eventLoop->postEvent( + boost::bind(boost::ref(onNewConnection), connection), + shared_from_this()); +// connection->listen(); +} + + +HostAddressPort DummyConnectionServer::getAddressPort() const { + return HostAddressPort(); +} + +} diff --git a/include/Swiften/Network/DummyConnectionServer.h b/include/Swiften/Network/DummyConnectionServer.h new file mode 100644 index 00000000..0e2a141c --- /dev/null +++ b/include/Swiften/Network/DummyConnectionServer.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace Swift { + class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this { + public: + typedef boost::shared_ptr ref; + + enum Error { + Conflict, + UnknownError + }; + + static ref create(EventLoop* eventLoop) { + return ref(new DummyConnectionServer(eventLoop)); + } + + void acceptConnection(boost::shared_ptr connection); + + virtual void start(); + virtual void stop(); + + virtual HostAddressPort getAddressPort() const; + + + private: + DummyConnectionServer(EventLoop* eventLoop); + + + private: + HostAddress address_; + EventLoop* eventLoop; + }; +} diff --git a/include/Swiften/Network/DummyConnectionServerFactory.cpp b/include/Swiften/Network/DummyConnectionServerFactory.cpp new file mode 100644 index 00000000..4fbabbc2 --- /dev/null +++ b/include/Swiften/Network/DummyConnectionServerFactory.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2011 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include +#include + +namespace Swift { + +DummyConnectionServerFactory::DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) { +} + +boost::shared_ptr DummyConnectionServerFactory::createConnectionServer(int port) { + return DummyConnectionServer::create(eventLoop); +} + +boost::shared_ptr DummyConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) { + return DummyConnectionServer::create(eventLoop); +} + +} diff --git a/include/Swiften/Network/DummyConnectionServerFactory.h b/include/Swiften/Network/DummyConnectionServerFactory.h new file mode 100644 index 00000000..a4bdbfd2 --- /dev/null +++ b/include/Swiften/Network/DummyConnectionServerFactory.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2011 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include + +#include +#include + +namespace Swift { + class ConnectionServer; + + class DummyConnectionServerFactory : public ConnectionServerFactory { + public: + DummyConnectionServerFactory(EventLoop* eventLoop); + + virtual boost::shared_ptr createConnectionServer(int port); + + virtual boost::shared_ptr createConnectionServer(const Swift::HostAddress &hostAddress, int port); + + private: + EventLoop* eventLoop; + }; +}