diff options
Diffstat (limited to 'Swiften/Component')
-rw-r--r-- | Swiften/Component/Component.cpp | 2 | ||||
-rw-r--r-- | Swiften/Component/Component.h | 2 | ||||
-rw-r--r-- | Swiften/Component/CoreComponent.cpp | 15 | ||||
-rw-r--r-- | Swiften/Component/CoreComponent.h | 8 |
4 files changed, 9 insertions, 18 deletions
diff --git a/Swiften/Component/Component.cpp b/Swiften/Component/Component.cpp index 579bca9..f3e2b81 100644 --- a/Swiften/Component/Component.cpp +++ b/Swiften/Component/Component.cpp @@ -10,7 +10,7 @@ namespace Swift { -Component::Component(EventLoop* eventLoop, const JID& jid, const String& secret) : CoreComponent(eventLoop, jid, secret) { +Component::Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : CoreComponent(eventLoop, networkFactories, jid, secret) { softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); softwareVersionResponder->start(); } diff --git a/Swiften/Component/Component.h b/Swiften/Component/Component.h index b880725..1a04272 100644 --- a/Swiften/Component/Component.h +++ b/Swiften/Component/Component.h @@ -19,7 +19,7 @@ namespace Swift { */ class Component : public CoreComponent { public: - Component(EventLoop* eventLoop, const JID& jid, const String& secret); + Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); ~Component(); /** diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index 2821dd2..656f967 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -8,12 +8,9 @@ #include <boost/bind.hpp> -#include "Swiften/Network/MainBoostIOServiceThread.h" -#include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Component/ComponentSession.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" @@ -22,7 +19,7 @@ namespace Swift { -CoreComponent::CoreComponent(EventLoop* eventLoop, const JID& jid, const String& secret) : eventLoop(eventLoop), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { +CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { stanzaChannel_ = new ComponentSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -30,16 +27,12 @@ CoreComponent::CoreComponent(EventLoop* eventLoop, const JID& jid, const String& iqRouter_ = new IQRouter(stanzaChannel_); iqRouter_->setFrom(jid); - connectionFactory_ = new BoostConnectionFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); - timerFactory_ = new BoostTimerFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); } CoreComponent::~CoreComponent() { if (session_ || connection_) { std::cerr << "Warning: Component not disconnected properly" << std::endl; } - delete timerFactory_; - delete connectionFactory_; delete iqRouter_; stanzaChannel_->onAvailableChanged.disconnect(boost::bind(&CoreComponent::handleStanzaChannelAvailableChanged, this, _1)); @@ -50,7 +43,7 @@ CoreComponent::~CoreComponent() { void CoreComponent::connect(const String& host, int port) { assert(!connector_); - connector_ = ComponentConnector::create(host, port, &resolver_, connectionFactory_, timerFactory_); + connector_ = ComponentConnector::create(host, port, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory()); connector_->onConnectFinished.connect(boost::bind(&CoreComponent::handleConnectorFinished, this, _1)); connector_->setTimeoutMilliseconds(60*1000); connector_->start(); @@ -69,7 +62,7 @@ void CoreComponent::handleConnectorFinished(boost::shared_ptr<Connection> connec connection_ = connection; assert(!sessionStream_); - sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ComponentStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, NULL, timerFactory_)); + sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ComponentStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, NULL, networkFactories->getTimerFactory())); sessionStream_->onDataRead.connect(boost::bind(&CoreComponent::handleDataRead, this, _1)); sessionStream_->onDataWritten.connect(boost::bind(&CoreComponent::handleDataWritten, this, _1)); sessionStream_->initialize(); diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h index 59466f7..dd4c5fd 100644 --- a/Swiften/Component/CoreComponent.h +++ b/Swiften/Component/CoreComponent.h @@ -25,8 +25,7 @@ namespace Swift { class IQRouter; - class ConnectionFactory; - class TimerFactory; + class NetworkFactories; class ComponentSession; class BasicSessionStream; @@ -42,7 +41,7 @@ namespace Swift { */ class CoreComponent { public: - CoreComponent(EventLoop* eventLoop, const JID& jid, const String& secret); + CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); ~CoreComponent(); void connect(const String& host, int port); @@ -88,14 +87,13 @@ namespace Swift { private: EventLoop* eventLoop; + NetworkFactories* networkFactories; PlatformDomainNameResolver resolver_; JID jid_; String secret_; ComponentSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; ComponentConnector::ref connector_; - ConnectionFactory* connectionFactory_; - TimerFactory* timerFactory_; FullPayloadParserFactoryCollection payloadParserFactories_; FullPayloadSerializerCollection payloadSerializers_; boost::shared_ptr<Connection> connection_; |