summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-10-07 18:09:30 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-10-07 18:09:30 (GMT)
commit6b98253a4127c975bd59b6a49ddb203337a8c32b (patch)
tree546a24e1687f50e403215152d65e21971568f166 /Swiften/StreamStack
parentb2f58c4f3eb93e3a32062670df5eb6682aed273a (diff)
downloadswift-6b98253a4127c975bd59b6a49ddb203337a8c32b.zip
swift-6b98253a4127c975bd59b6a49ddb203337a8c32b.tar.bz2
Hoist XML parser factory creation out of Swiften.
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp4
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp7
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp6
-rw-r--r--Swiften/StreamStack/XMPPLayer.h3
4 files changed, 15 insertions, 5 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index d3c0a7c..213948a 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -19,6 +19,7 @@
#include <Swiften/StreamStack/LowLayer.h>
#include <Swiften/StreamStack/XMPPLayer.h>
#include <Swiften/StreamStack/StreamLayer.h>
+#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
@@ -38,7 +39,7 @@ class StreamStackTest : public CppUnit::TestFixture {
public:
void setUp() {
physicalStream_ = new TestLowLayer();
- xmppStream_ = new XMPPLayer(&parserFactories_, &serializers_, ClientStreamType);
+ xmppStream_ = new XMPPLayer(&parserFactories_, &serializers_, &xmlParserFactory_, ClientStreamType);
elementsReceived_ = 0;
dataWriteReceived_ = 0;
}
@@ -172,6 +173,7 @@ class StreamStackTest : public CppUnit::TestFixture {
FullPayloadParserFactoryCollection parserFactories_;
FullPayloadSerializerCollection serializers_;
TestLowLayer* physicalStream_;
+ PlatformXMLParserFactory xmlParserFactory_;
XMPPLayer* xmppStream_;
int elementsReceived_;
int dataWriteReceived_;
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index bb0ce61..8123c00 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -14,6 +14,7 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/StreamStack/XMPPLayer.h>
#include <Swiften/StreamStack/LowLayer.h>
+#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
@@ -32,7 +33,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
public:
void setUp() {
lowLayer_ = new DummyLowLayer();
- testling_ = new XMPPLayerExposed(&parserFactories_, &serializers_, ClientStreamType);
+ testling_ = new XMPPLayerExposed(&parserFactories_, &serializers_, &xmlParserFactory_, ClientStreamType);
testling_->setChildLayer(lowLayer_);
elementsReceived_ = 0;
errorReceived_ = 0;
@@ -112,7 +113,8 @@ class XMPPLayerTest : public CppUnit::TestFixture {
XMPPLayerExposed(
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
- StreamType streamType) : XMPPLayer(payloadParserFactories, payloadSerializers, streamType) {}
+ XMLParserFactory* xmlParserFactory,
+ StreamType streamType) : XMPPLayer(payloadParserFactories, payloadSerializers, xmlParserFactory, streamType) {}
using XMPPLayer::handleDataRead;
using HighLayer::setChildLayer;
@@ -131,6 +133,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
FullPayloadSerializerCollection serializers_;
DummyLowLayer* lowLayer_;
XMPPLayerExposed* testling_;
+ PlatformXMLParserFactory xmlParserFactory_;
int elementsReceived_;
int errorReceived_;
};
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index 1dcd84f..94afcf9 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -14,12 +14,14 @@ namespace Swift {
XMPPLayer::XMPPLayer(
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
+ XMLParserFactory* xmlParserFactory,
StreamType streamType) :
payloadParserFactories_(payloadParserFactories),
payloadSerializers_(payloadSerializers),
+ xmlParserFactory_(xmlParserFactory),
resetParserAfterParse_(false),
inParser_(false) {
- xmppParser_ = new XMPPParser(this, payloadParserFactories_);
+ xmppParser_ = new XMPPParser(this, payloadParserFactories_, xmlParserFactory);
xmppSerializer_ = new XMPPSerializer(payloadSerializers_, streamType);
}
@@ -68,7 +70,7 @@ void XMPPLayer::handleDataRead(const SafeByteArray& data) {
void XMPPLayer::doResetParser() {
delete xmppParser_;
- xmppParser_ = new XMPPParser(this, payloadParserFactories_);
+ xmppParser_ = new XMPPParser(this, payloadParserFactories_, xmlParserFactory_);
resetParserAfterParse_ = false;
}
diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h
index 54bdd42..9be00b2 100644
--- a/Swiften/StreamStack/XMPPLayer.h
+++ b/Swiften/StreamStack/XMPPLayer.h
@@ -22,12 +22,14 @@ namespace Swift {
class PayloadParserFactoryCollection;
class XMPPSerializer;
class PayloadSerializerCollection;
+ class XMLParserFactory;
class XMPPLayer : public XMPPParserClient, public HighLayer, boost::noncopyable {
public:
XMPPLayer(
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
+ XMLParserFactory* xmlParserFactory,
StreamType streamType);
~XMPPLayer();
@@ -60,6 +62,7 @@ namespace Swift {
PayloadParserFactoryCollection* payloadParserFactories_;
XMPPParser* xmppParser_;
PayloadSerializerCollection* payloadSerializers_;
+ XMLParserFactory* xmlParserFactory_;
XMPPSerializer* xmppSerializer_;
bool resetParserAfterParse_;
bool inParser_;