diff options
Diffstat (limited to 'Swiften/Client')
-rw-r--r-- | Swiften/Client/Client.cpp | 2 | ||||
-rw-r--r-- | Swiften/Client/Client.h | 2 | ||||
-rw-r--r-- | Swiften/Client/CoreClient.cpp | 15 | ||||
-rw-r--r-- | Swiften/Client/CoreClient.h | 6 |
4 files changed, 9 insertions, 16 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index 3b2c102..dcc8a79 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -27,7 +27,7 @@ namespace Swift { -Client::Client(EventLoop* eventLoop, const JID& jid, const String& password, Storages* storages) : CoreClient(eventLoop, jid, password), storages(storages) { +Client::Client(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& password, Storages* storages) : CoreClient(eventLoop, networkFactories, jid, password), storages(storages) { memoryStorages = new MemoryStorages(); softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h index fa45fdd..61d9e32 100644 --- a/Swiften/Client/Client.h +++ b/Swiften/Client/Client.h @@ -46,7 +46,7 @@ namespace Swift { * this is NULL, * all data will be stored in memory (and be lost on shutdown) */ - Client(EventLoop* eventLoop, const JID& jid, const String& password, Storages* storages = NULL); + Client(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& password, Storages* storages = NULL); ~Client(); diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index 66fe23e..de0785f 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -8,14 +8,11 @@ #include <boost/bind.hpp> -#include "Swiften/Network/MainBoostIOServiceThread.h" -#include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Client/ClientSession.h" #include "Swiften/TLS/PlatformTLSFactories.h" #include "Swiften/TLS/CertificateVerificationError.h" #include "Swiften/Network/Connector.h" -#include "Swiften/Network/BoostConnectionFactory.h" -#include "Swiften/Network/BoostTimerFactory.h" +#include "Swiften/Network/NetworkFactories.h" #include "Swiften/TLS/PKCS12Certificate.h" #include "Swiften/Session/BasicSessionStream.h" #include "Swiften/Queries/IQRouter.h" @@ -24,7 +21,7 @@ namespace Swift { -CoreClient::CoreClient(EventLoop* eventLoop, const JID& jid, const String& password) : resolver_(eventLoop), jid_(jid), password_(password), eventLoop(eventLoop), disconnectRequested_(false), certificateTrustChecker(NULL) { +CoreClient::CoreClient(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& password) : resolver_(eventLoop), jid_(jid), password_(password), eventLoop(eventLoop), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) { stanzaChannel_ = new ClientSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -32,8 +29,6 @@ CoreClient::CoreClient(EventLoop* eventLoop, const JID& jid, const String& passw stanzaChannel_->onAvailableChanged.connect(boost::bind(&CoreClient::handleStanzaChannelAvailableChanged, this, _1)); iqRouter_ = new IQRouter(stanzaChannel_); - connectionFactory_ = new BoostConnectionFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); - timerFactory_ = new BoostTimerFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); tlsFactories = new PlatformTLSFactories(); } @@ -42,8 +37,6 @@ CoreClient::~CoreClient() { std::cerr << "Warning: Client not disconnected properly" << std::endl; } delete tlsFactories; - delete timerFactory_; - delete connectionFactory_; delete iqRouter_; stanzaChannel_->onAvailableChanged.disconnect(boost::bind(&CoreClient::handleStanzaChannelAvailableChanged, this, _1)); @@ -65,7 +58,7 @@ void CoreClient::connect(const JID& jid) { void CoreClient::connect(const String& host) { disconnectRequested_ = false; assert(!connector_); - connector_ = Connector::create(host, &resolver_, connectionFactory_, timerFactory_); + connector_ = Connector::create(host, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory()); connector_->onConnectFinished.connect(boost::bind(&CoreClient::handleConnectorFinished, this, _1)); connector_->setTimeoutMilliseconds(60*1000); connector_->start(); @@ -82,7 +75,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio connection_ = connection; assert(!sessionStream_); - sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, tlsFactories->getTLSContextFactory(), timerFactory_)); + sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, tlsFactories->getTLSContextFactory(), networkFactories->getTimerFactory())); if (!certificate_.isEmpty()) { sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_)); } diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h index 628ced0..d104148 100644 --- a/Swiften/Client/CoreClient.h +++ b/Swiften/Client/CoreClient.h @@ -34,6 +34,7 @@ namespace Swift { class EventLoop; class PlatformTLSFactories; class CertificateTrustChecker; + class NetworkFactories; /** * The central class for communicating with an XMPP server. @@ -51,7 +52,7 @@ namespace Swift { * Constructs a client for the given JID with the given password. * The given eventLoop will be used to post events to. */ - CoreClient(EventLoop* eventLoop, const JID& jid, const String& password); + CoreClient(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& password); ~CoreClient(); void setCertificate(const String& certificate); @@ -205,11 +206,10 @@ namespace Swift { JID jid_; String password_; EventLoop* eventLoop; + NetworkFactories* networkFactories; ClientSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; Connector::ref connector_; - ConnectionFactory* connectionFactory_; - TimerFactory* timerFactory_; PlatformTLSFactories* tlsFactories; FullPayloadParserFactoryCollection payloadParserFactories_; FullPayloadSerializerCollection payloadSerializers_; |