summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser')
-rw-r--r--Swiften/Parser/UnitTest/XMPPParserTest.cpp22
-rw-r--r--Swiften/Parser/XMPPParser.cpp7
-rw-r--r--Swiften/Parser/XMPPParser.h5
3 files changed, 19 insertions, 15 deletions
diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
index dbee18a..f8d60f2 100644
--- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
@@ -14,6 +14,7 @@
#include <Swiften/Parser/ElementParser.h>
#include <Swiften/Parser/XMPPParserClient.h>
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
+#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/IQ.h>
#include <Swiften/Elements/Message.h>
@@ -38,7 +39,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
public:
void testParse_SimpleSession() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
CPPUNIT_ASSERT(testling.parse("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' >"));
@@ -57,7 +58,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_SimpleClientFromServerSession() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
CPPUNIT_ASSERT(testling.parse("<stream:stream from='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='aeab'>"));
@@ -70,7 +71,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
void testParse_Presence() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<presence/>"));
@@ -81,7 +82,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_IQ() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<iq/>"));
@@ -92,7 +93,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_Message() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<message/>"));
@@ -103,7 +104,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_StreamFeatures() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<stream:features/>"));
@@ -114,7 +115,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_UnknownElement() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<presence/>"));
@@ -132,7 +133,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_StrayCharacterData() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
CPPUNIT_ASSERT(testling.parse("<presence/>"));
@@ -145,13 +146,13 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
void testParse_InvalidStreamStart() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(!testling.parse("<tream>"));
}
void testParse_ElementEndAfterInvalidStreamStart() {
- XMPPParser testling(&client_, &factories_);
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
CPPUNIT_ASSERT(!testling.parse("<tream/>"));
}
@@ -189,6 +190,7 @@ class XMPPParserTest : public CppUnit::TestFixture {
std::vector<Event> events;
} client_;
PayloadParserFactoryCollection factories_;
+ PlatformXMLParserFactory xmlParserFactory_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(XMPPParserTest);
diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp
index 6779b86..069a5bd 100644
--- a/Swiften/Parser/XMPPParser.cpp
+++ b/Swiften/Parser/XMPPParser.cpp
@@ -12,7 +12,6 @@
#include <Swiften/Elements/ProtocolHeader.h>
#include <string>
#include <Swiften/Parser/XMLParser.h>
-#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Parser/XMPPParserClient.h>
#include <Swiften/Parser/XMPPParser.h>
#include <Swiften/Parser/ElementParser.h>
@@ -41,6 +40,7 @@
#include <Swiften/Parser/UnknownElementParser.h>
#include <Swiften/Parser/TLSProceedParser.h>
#include <Swiften/Parser/ComponentHandshakeParser.h>
+#include <Swiften/Parser/XMLParserFactory.h>
// TODO: Whenever an error occurs in the handlers, stop the parser by returing
// a bool value, and stopping the XML parser
@@ -49,14 +49,15 @@ namespace Swift {
XMPPParser::XMPPParser(
XMPPParserClient* client,
- PayloadParserFactoryCollection* payloadParserFactories) :
+ PayloadParserFactoryCollection* payloadParserFactories,
+ XMLParserFactory* xmlParserFactory) :
xmlParser_(0),
client_(client),
payloadParserFactories_(payloadParserFactories),
level_(0),
currentElementParser_(0),
parseErrorOccurred_(false) {
- xmlParser_ = PlatformXMLParserFactory().createXMLParser(this);
+ xmlParser_ = xmlParserFactory->createXMLParser(this);
}
XMPPParser::~XMPPParser() {
diff --git a/Swiften/Parser/XMPPParser.h b/Swiften/Parser/XMPPParser.h
index b5d6d24..6cce2bd 100644
--- a/Swiften/Parser/XMPPParser.h
+++ b/Swiften/Parser/XMPPParser.h
@@ -15,7 +15,7 @@
namespace Swift {
class XMLParser;
class XMPPParserClient;
-
+ class XMLParserFactory;
class ElementParser;
class PayloadParserFactoryCollection;
@@ -23,7 +23,8 @@ namespace Swift {
public:
XMPPParser(
XMPPParserClient* parserClient,
- PayloadParserFactoryCollection* payloadParserFactories);
+ PayloadParserFactoryCollection* payloadParserFactories,
+ XMLParserFactory* xmlParserFactory);
~XMPPParser();
bool parse(const std::string&);