summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-13 07:17:57 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-13 07:18:39 (GMT)
commit6ca206b0d0645e50a8a2c59ebd134f9c0f164b9b (patch)
tree1c4d785f79941b07e7c7d7473fe98d09229b5fa6 /Swiften/StreamStack
parent72858ab262a16aa8db209c2898ab0d3c951a9829 (diff)
downloadswift-6ca206b0d0645e50a8a2c59ebd134f9c0f164b9b.zip
swift-6ca206b0d0645e50a8a2c59ebd134f9c0f164b9b.tar.bz2
Server stream header support.
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp10
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp12
-rw-r--r--Swiften/StreamStack/XMPPLayer.h7
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();