diff options
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r-- | Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp | 10 | ||||
-rw-r--r-- | Swiften/StreamStack/XMPPLayer.cpp | 12 | ||||
-rw-r--r-- | Swiften/StreamStack/XMPPLayer.h | 7 |
3 files changed, 17 insertions, 12 deletions
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp index 2150f4d..f60c370 100644 --- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp +++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp @@ -48,9 +48,9 @@ class XMPPLayerTest : public CppUnit::TestFixture testling_->onElement.connect(boost::bind(&XMPPLayerTest::handleElement, this, _1)); testling_->onError.connect(boost::bind(&XMPPLayerTest::handleError, this)); - testling_->parseData("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' >"); + testling_->parseData("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >"); testling_->resetParser(); - testling_->parseData("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' >"); + testling_->parseData("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >"); testling_->parseData("<presence/>"); CPPUNIT_ASSERT_EQUAL(1, elementsReceived_); @@ -59,8 +59,8 @@ class XMPPLayerTest : public CppUnit::TestFixture void testResetParser_FromSlot() { testling_->onElement.connect(boost::bind(&XMPPLayerTest::handleElementAndReset, this, _1)); - testling_->parseData("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' ><presence/>"); - testling_->parseData("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' ><presence/>"); + testling_->parseData("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>"); + testling_->parseData("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>"); CPPUNIT_ASSERT_EQUAL(2, elementsReceived_); CPPUNIT_ASSERT_EQUAL(0, errorReceived_); @@ -70,7 +70,7 @@ class XMPPLayerTest : public CppUnit::TestFixture testling_->onWriteData.connect(boost::bind(&XMPPLayerTest::handleWriteData, this, _1)); testling_->writeHeader("example.com"); - CPPUNIT_ASSERT_EQUAL(String("<?xml version='1.0'?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' >"), dataReceived_); + CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\" to=\"example.com\">"), dataReceived_); } void testWriteElement() { diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp index 464d4b0..73d763a 100644 --- a/Swiften/StreamStack/XMPPLayer.cpp +++ b/Swiften/StreamStack/XMPPLayer.cpp @@ -20,8 +20,12 @@ XMPPLayer::~XMPPLayer() { delete xmppParser_; } -void XMPPLayer::writeHeader(const String& domain) { - onWriteData(ByteArray(xmppSerializer_->serializeHeader(domain))); +void XMPPLayer::writeHeader(const String& to) { + onWriteData(ByteArray(xmppSerializer_->serializeHeader("", to))); +} + +void XMPPLayer::writeHeader(const String& from, const String& id) { + onWriteData(ByteArray(xmppSerializer_->serializeHeader(from, "", id))); } void XMPPLayer::writeFooter() { @@ -56,8 +60,8 @@ void XMPPLayer::doResetParser() { resetParserAfterParse_ = false; } -void XMPPLayer::handleStreamStart(const String& domain) { - onStreamStart(domain); +void XMPPLayer::handleStreamStart(const String& from, const String& to, const String& id) { + onStreamStart(from, to, id); } void XMPPLayer::handleElement(boost::shared_ptr<Element> stanza) { diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h index e064d94..7437112 100644 --- a/Swiften/StreamStack/XMPPLayer.h +++ b/Swiften/StreamStack/XMPPLayer.h @@ -22,7 +22,8 @@ namespace Swift { PayloadSerializerCollection* payloadSerializers); ~XMPPLayer(); - void writeHeader(const String& domain); + void writeHeader(const String& from, const String& id); + void writeHeader(const String& to); void writeFooter(); void writeElement(boost::shared_ptr<Element>); void writeData(const String& data); @@ -31,14 +32,14 @@ namespace Swift { void resetParser(); public: - boost::signal<void (const String& domain)> onStreamStart; + boost::signal<void (const String& /* from */, const String& /* to */ , const String& /* id */)> onStreamStart; boost::signal<void (boost::shared_ptr<Element>)> onElement; boost::signal<void (const ByteArray&)> onWriteData; boost::signal<void (const ByteArray&)> onDataRead; boost::signal<void ()> onError; private: - void handleStreamStart(const String&); + void handleStreamStart(const String&, const String&, const String&); void handleElement(boost::shared_ptr<Element>); void handleStreamEnd(); |