summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/Client/CoreClient.cpp2
-rw-r--r--Swiften/Client/CoreClient.h5
-rw-r--r--Swiften/Component/CoreComponent.cpp2
-rw-r--r--Swiften/Component/CoreComponent.h6
-rw-r--r--Swiften/Entity/Entity.cpp31
-rw-r--r--Swiften/Entity/Entity.h45
-rw-r--r--Swiften/Entity/SConscript6
-rw-r--r--Swiften/SConscript3
8 files changed, 90 insertions, 10 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index de0785f..c4e5225 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -75,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(), networkFactories->getTimerFactory()));
+ sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, getPayloadParserFactories(), getPayloadSerializers(), 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 d104148..146e219 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -21,6 +21,7 @@
#include "Swiften/Client/StanzaChannel.h"
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
+#include <Swiften/Entity/Entity.h>
#include "Swiften/Client/ClientSessionStanzaChannel.h"
@@ -46,7 +47,7 @@ namespace Swift {
* subclass provides more functionality and interfaces, and is better suited
* for most needs.
*/
- class CoreClient {
+ class CoreClient : public Entity {
public:
/**
* Constructs a client for the given JID with the given password.
@@ -211,8 +212,6 @@ namespace Swift {
IQRouter* iqRouter_;
Connector::ref connector_;
PlatformTLSFactories* tlsFactories;
- FullPayloadParserFactoryCollection payloadParserFactories_;
- FullPayloadSerializerCollection payloadSerializers_;
boost::shared_ptr<Connection> connection_;
boost::shared_ptr<BasicSessionStream> sessionStream_;
boost::shared_ptr<ClientSession> session_;
diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp
index 656f967..c3451de 100644
--- a/Swiften/Component/CoreComponent.cpp
+++ b/Swiften/Component/CoreComponent.cpp
@@ -62,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, networkFactories->getTimerFactory()));
+ sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ComponentStreamType, connection_, getPayloadParserFactories(), getPayloadSerializers(), 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 dd4c5fd..8ebf80f 100644
--- a/Swiften/Component/CoreComponent.h
+++ b/Swiften/Component/CoreComponent.h
@@ -20,8 +20,8 @@
#include "Swiften/Base/String.h"
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
-
#include "Swiften/Component/ComponentSessionStanzaChannel.h"
+#include <Swiften/Entity/Entity.h>
namespace Swift {
class IQRouter;
@@ -39,7 +39,7 @@ namespace Swift {
* subclass provides more functionality and interfaces, and is better suited
* for most needs.
*/
- class CoreComponent {
+ class CoreComponent : public Entity {
public:
CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret);
~CoreComponent();
@@ -94,8 +94,6 @@ namespace Swift {
ComponentSessionStanzaChannel* stanzaChannel_;
IQRouter* iqRouter_;
ComponentConnector::ref connector_;
- FullPayloadParserFactoryCollection payloadParserFactories_;
- FullPayloadSerializerCollection payloadSerializers_;
boost::shared_ptr<Connection> connection_;
boost::shared_ptr<BasicSessionStream> sessionStream_;
boost::shared_ptr<ComponentSession> session_;
diff --git a/Swiften/Entity/Entity.cpp b/Swiften/Entity/Entity.cpp
new file mode 100644
index 0000000..da2ecaf
--- /dev/null
+++ b/Swiften/Entity/Entity.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Entity/Entity.h"
+
+namespace Swift {
+
+Entity::~Entity() {
+}
+
+
+void Entity::addPayloadParserFactory(PayloadParserFactory* payloadParserFactory) {
+ payloadParserFactories.addFactory(payloadParserFactory);
+}
+
+void Entity::removePayloadParserFactory(PayloadParserFactory* payloadParserFactory) {
+ payloadParserFactories.removeFactory(payloadParserFactory);
+}
+
+void Entity::addPayloadSerializer(PayloadSerializer* payloadSerializer) {
+ payloadSerializers.addSerializer(payloadSerializer);
+}
+
+void Entity::removePayloadSerializer(PayloadSerializer* payloadSerializer) {
+ payloadSerializers.removeSerializer(payloadSerializer);
+}
+
+}
diff --git a/Swiften/Entity/Entity.h b/Swiften/Entity/Entity.h
new file mode 100644
index 0000000..20d02ba
--- /dev/null
+++ b/Swiften/Entity/Entity.h
@@ -0,0 +1,45 @@
+/*
+ * 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 <Swiften/Base/boost_bsignals.h>
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
+#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
+
+namespace Swift {
+ class PayloadParserFactory;
+ class PayloadSerializer;
+
+ /**
+ * The base class for XMPP entities (Clients, Components).
+ */
+ class Entity {
+ public:
+ virtual ~Entity();
+
+ void addPayloadParserFactory(PayloadParserFactory* payloadParserFactory);
+ void removePayloadParserFactory(PayloadParserFactory* payloadParserFactory);
+
+ void addPayloadSerializer(PayloadSerializer* payloadSerializer);
+ void removePayloadSerializer(PayloadSerializer* payloadSerializer);
+
+ protected:
+ PayloadParserFactoryCollection* getPayloadParserFactories() {
+ return &payloadParserFactories;
+ }
+
+ PayloadSerializerCollection* getPayloadSerializers() {
+ return &payloadSerializers;
+ }
+
+ private:
+ FullPayloadParserFactoryCollection payloadParserFactories;
+ FullPayloadSerializerCollection payloadSerializers;
+ };
+}
diff --git a/Swiften/Entity/SConscript b/Swiften/Entity/SConscript
new file mode 100644
index 0000000..78a298c
--- /dev/null
+++ b/Swiften/Entity/SConscript
@@ -0,0 +1,6 @@
+Import("swiften_env")
+
+objects = swiften_env.StaticObject([
+ "Entity.cpp",
+ ])
+swiften_env.Append(SWIFTEN_OBJECTS = [objects])
diff --git a/Swiften/SConscript b/Swiften/SConscript
index 11dec59..9827171 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -60,6 +60,7 @@ if env["SCONS_STAGE"] == "build" :
"Elements/RosterPayload.cpp",
"Elements/Stanza.cpp",
"Elements/VCard.cpp",
+ "Entity/Entity.cpp",
"MUC/MUC.cpp",
"MUC/MUCManager.cpp",
"MUC/MUCOccupant.cpp",
@@ -292,7 +293,7 @@ if env["SCONS_STAGE"] == "build" :
# Generate the Swiften header
swiften_header = "#pragma once\n"
top_path = env.Dir("..").abspath
- public_dirs = ["Avatars", "Base", "Chat", "Client", "Component", "Disco", "Elements", "JID", "MUC", "Network", "Presence", "Queries", "Roster", "StringCodecs", "TLS", "VCards"]
+ public_dirs = ["Avatars", "Base", "Chat", "Client", "Component", "Disco", "Entity", "Elements", "JID", "MUC", "Network", "Presence", "Queries", "Roster", "StringCodecs", "TLS", "VCards"]
for public_dir in public_dirs :
for root, dirs, files in os.walk(env.Dir(public_dir).abspath) :
if root.endswith("UnitTest") :