diff options
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/BOSHConnectionFactory.cpp | 26 | ||||
-rw-r--r-- | Swiften/Network/BOSHConnectionFactory.h | 43 | ||||
-rw-r--r-- | Swiften/Network/BOSHConnectionPool.cpp | 13 | ||||
-rw-r--r-- | Swiften/Network/BOSHConnectionPool.h | 9 | ||||
-rw-r--r-- | Swiften/Network/SConscript | 1 | ||||
-rw-r--r-- | Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp | 10 |
6 files changed, 18 insertions, 84 deletions
diff --git a/Swiften/Network/BOSHConnectionFactory.cpp b/Swiften/Network/BOSHConnectionFactory.cpp deleted file mode 100644 index 7b83034..0000000 --- a/Swiften/Network/BOSHConnectionFactory.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2011 Thilo Cestonaro - * Licensed under the simplified BSD license. - * See Documentation/Licenses/BSD-simplified.txt for more information. - */ - -/* - * Copyright (c) 2011 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include <Swiften/Network/BOSHConnectionFactory.h> -#include <Swiften/Network/BOSHConnection.h> - -namespace Swift { - -BOSHConnectionFactory::BOSHConnectionFactory(const URL& boshURL, ConnectionFactory* connectionFactory, XMLParserFactory* xmlParserFactory, TLSContextFactory* tlsFactory) : boshURL(boshURL), connectionFactory(connectionFactory), xmlParserFactory(xmlParserFactory), tlsFactory(tlsFactory) { - -} - -boost::shared_ptr<Connection> BOSHConnectionFactory::createConnection(ConnectionFactory* overrideFactory) { - return BOSHConnection::create(boshURL, overrideFactory != NULL ? overrideFactory : connectionFactory, xmlParserFactory, tlsFactory); -} - -} diff --git a/Swiften/Network/BOSHConnectionFactory.h b/Swiften/Network/BOSHConnectionFactory.h deleted file mode 100644 index 3750057..0000000 --- a/Swiften/Network/BOSHConnectionFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 Thilo Cestonaro - * Licensed under the simplified BSD license. - * See Documentation/Licenses/BSD-simplified.txt for more information. - */ - -/* - * Copyright (c) 2011 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <string> - -#include <Swiften/Network/ConnectionFactory.h> -#include <Swiften/Network/HostAddressPort.h> -#include <Swiften/TLS/TLSContextFactory.h> -#include <Swiften/Base/URL.h> - -namespace Swift { - -class XMLParserFactory; - -class BOSHConnectionFactory { - public: - BOSHConnectionFactory(const URL& boshURL, ConnectionFactory* connectionFactory, XMLParserFactory* xmlParserFactory, TLSContextFactory* tlsFactory); - - /** - * @param overrideFactory If non-NULL, creates a connection over the given factory instead. - */ - boost::shared_ptr<Connection> createConnection(ConnectionFactory* overrideFactory); - ConnectionFactory* getRawConnectionFactory() {return connectionFactory;} - TLSContextFactory* getTLSContextFactory() {return tlsFactory;} - private: - URL boshURL; - ConnectionFactory* connectionFactory; - XMLParserFactory* xmlParserFactory; - TLSContextFactory* tlsFactory; -}; - -} diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp index 6c3ba7e..4886ede 100644 --- a/Swiften/Network/BOSHConnectionPool.cpp +++ b/Swiften/Network/BOSHConnectionPool.cpp @@ -16,8 +16,11 @@ #include <Swiften/Network/HTTPConnectProxiedConnectionFactory.h> namespace Swift { -BOSHConnectionPool::BOSHConnectionPool(boost::shared_ptr<BOSHConnectionFactory> connectionFactory, const std::string& to, long initialRID, const URL& boshHTTPConnectProxyURL, const SafeString& boshHTTPConnectProxyAuthID, const SafeString& boshHTTPConnectProxyAuthPassword) - : connectionFactory(connectionFactory), +BOSHConnectionPool::BOSHConnectionPool(const URL& boshURL, ConnectionFactory* connectionFactory, XMLParserFactory* parserFactory, TLSContextFactory* tlsFactory, const std::string& to, long initialRID, const URL& boshHTTPConnectProxyURL, const SafeString& boshHTTPConnectProxyAuthID, const SafeString& boshHTTPConnectProxyAuthPassword) : + boshURL(boshURL), + connectionFactory(connectionFactory), + xmlParserFactory(parserFactory), + tlsFactory(tlsFactory), rid(initialRID), pendingTerminate(false), to(to), @@ -29,9 +32,9 @@ BOSHConnectionPool::BOSHConnectionPool(boost::shared_ptr<BOSHConnectionFactory> connectProxyFactory = NULL; } else { - ConnectionFactory* rawFactory = connectionFactory->getRawConnectionFactory(); + ConnectionFactory* rawFactory = connectionFactory; if (boshHTTPConnectProxyURL.getScheme() == "https") { - tlsConnectionFactory = new TLSConnectionFactory(connectionFactory->getTLSContextFactory(), rawFactory); + tlsConnectionFactory = new TLSConnectionFactory(tlsFactory, rawFactory); rawFactory = tlsConnectionFactory; } connectProxyFactory = new HTTPConnectProxiedConnectionFactory(rawFactory, HostAddressPort(HostAddress(boshHTTPConnectProxyURL.getHost()), boshHTTPConnectProxyURL.getPort()), boshHTTPConnectProxyAuthID, boshHTTPConnectProxyAuthPassword); @@ -206,7 +209,7 @@ void BOSHConnectionPool::handleConnectionDisconnected(const boost::optional<Conn } boost::shared_ptr<BOSHConnection> BOSHConnectionPool::createConnection() { - BOSHConnection::ref connection = boost::dynamic_pointer_cast<BOSHConnection>(connectionFactory->createConnection(connectProxyFactory)); + BOSHConnection::ref connection = BOSHConnection::create(boshURL, connectProxyFactory ? connectProxyFactory : connectionFactory, xmlParserFactory, tlsFactory); connection->onXMPPDataRead.connect(boost::bind(&BOSHConnectionPool::handleDataRead, this, _1)); connection->onSessionStarted.connect(boost::bind(&BOSHConnectionPool::handleSessionStarted, this, _1, _2)); connection->onBOSHDataRead.connect(boost::bind(&BOSHConnectionPool::handleBOSHDataRead, this, _1)); diff --git a/Swiften/Network/BOSHConnectionPool.h b/Swiften/Network/BOSHConnectionPool.h index 85e598d..2264c90 100644 --- a/Swiften/Network/BOSHConnectionPool.h +++ b/Swiften/Network/BOSHConnectionPool.h @@ -10,15 +10,15 @@ #include <vector> #include <Swiften/Base/SafeString.h> -#include <Swiften/Network/BOSHConnectionFactory.h> #include <Swiften/Network/BOSHConnection.h> namespace Swift { class HTTPConnectProxiedConnectionFactory; class TLSConnectionFactory; + class BOSHConnectionPool : public boost::bsignals::trackable { public: - BOSHConnectionPool(boost::shared_ptr<BOSHConnectionFactory> factory, const std::string& to, long initialRID, const URL& boshHTTPConnectProxyURL, const SafeString& boshHTTPConnectProxyAuthID, const SafeString& boshHTTPConnectProxyAuthPassword); + BOSHConnectionPool(const URL& boshURL, ConnectionFactory* connectionFactory, XMLParserFactory* parserFactory, TLSContextFactory* tlsFactory, const std::string& to, long initialRID, const URL& boshHTTPConnectProxyURL, const SafeString& boshHTTPConnectProxyAuthID, const SafeString& boshHTTPConnectProxyAuthPassword); ~BOSHConnectionPool(); void write(const SafeByteArray& data); void writeFooter(); @@ -48,7 +48,10 @@ namespace Swift { BOSHConnection::ref getSuitableConnection(); private: - boost::shared_ptr<BOSHConnectionFactory> connectionFactory; + URL boshURL; + ConnectionFactory* connectionFactory; + XMLParserFactory* xmlParserFactory; + TLSContextFactory* tlsFactory; std::vector<BOSHConnection::ref> connections; std::string sid; unsigned long rid; diff --git a/Swiften/Network/SConscript b/Swiften/Network/SConscript index 4a5370f..6975fe6 100644 --- a/Swiften/Network/SConscript +++ b/Swiften/Network/SConscript @@ -17,7 +17,6 @@ sourceList = [ "BoostIOServiceThread.cpp", "BOSHConnection.cpp", "BOSHConnectionPool.cpp", - "BOSHConnectionFactory.cpp", "ConnectionFactory.cpp", "ConnectionServer.cpp", "ConnectionServerFactory.cpp", diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp index 978bf3b..1bfee10 100644 --- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp +++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp @@ -19,7 +19,6 @@ #include <Swiften/Network/Connection.h> #include <Swiften/Network/ConnectionFactory.h> #include <Swiften/Network/BOSHConnection.h> -#include <Swiften/Network/BOSHConnectionFactory.h> #include <Swiften/Network/BOSHConnectionPool.h> #include <Swiften/Network/HostAddressPort.h> #include <Swiften/EventLoop/DummyEventLoop.h> @@ -58,7 +57,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { "xmlns='http://jabber.org/protocol/httpbind'/>"; eventLoop = new DummyEventLoop(); connectionFactory = new MockConnectionFactory(eventLoop); - factory = boost::make_shared<BOSHConnectionFactory>(URL("http", to, 5280, path), connectionFactory, &parserFactory, static_cast<TLSContextFactory*>(NULL)); + boshURL = URL("http", to, 5280, path); sessionTerminated = 0; sessionStarted = 0; initialRID = 2349876; @@ -216,8 +215,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { void testSession() { to = "prosody.doomsong.co.uk"; path = "http-bind/"; - factory = boost::make_shared<BOSHConnectionFactory>(URL("http", to, 5280, path), connectionFactory, &parserFactory, static_cast<TLSContextFactory*>(NULL)); - + boshURL = URL("http", to, 5280, path); PoolRef testling = createTestling(); CPPUNIT_ASSERT_EQUAL(st(1), connectionFactory->connections.size()); @@ -281,7 +279,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { private: PoolRef createTestling() { - PoolRef pool = boost::make_shared<BOSHConnectionPool>(factory, to, initialRID, URL(), "", ""); + PoolRef pool = boost::make_shared<BOSHConnectionPool>(boshURL, connectionFactory, &parserFactory, static_cast<TLSContextFactory*>(NULL), to, initialRID, URL(), "", ""); pool->onXMPPDataRead.connect(boost::bind(&BOSHConnectionPoolTest::handleXMPPDataRead, this, _1)); pool->onBOSHDataRead.connect(boost::bind(&BOSHConnectionPoolTest::handleBOSHDataRead, this, _1)); pool->onBOSHDataWritten.connect(boost::bind(&BOSHConnectionPoolTest::handleBOSHDataWritten, this, _1)); @@ -401,6 +399,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { } private: + URL boshURL; DummyEventLoop* eventLoop; MockConnectionFactory* connectionFactory; std::vector<std::string> xmppDataRead; @@ -413,7 +412,6 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { std::string sid; std::string initial; long initialRID; - boost::shared_ptr<BOSHConnectionFactory> factory; int sessionStarted; int sessionTerminated; |