summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp7
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp13
-rw-r--r--Swiften/StreamStack/XMPPLayer.h13
3 files changed, 15 insertions, 18 deletions
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index f60c370..e284ba9 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -3,6 +3,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include "Swiften/Elements/ProtocolHeader.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Base/ByteArray.h"
#include "Swiften/StreamStack/XMPPLayer.h"
@@ -68,9 +69,11 @@ class XMPPLayerTest : public CppUnit::TestFixture
void testWriteHeader() {
testling_->onWriteData.connect(boost::bind(&XMPPLayerTest::handleWriteData, this, _1));
- testling_->writeHeader("example.com");
+ ProtocolHeader header;
+ header.setTo("example.com");
+ testling_->writeHeader(header);
- 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_);
+ CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" to=\"example.com\" version=\"1.0\">"), dataReceived_);
}
void testWriteElement() {
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index 73d763a..b87cb4a 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -1,6 +1,7 @@
#include "Swiften/StreamStack/XMPPLayer.h"
#include "Swiften/Parser/XMPPParser.h"
#include "Swiften/Serializer/XMPPSerializer.h"
+#include "Swiften/Elements/ProtocolHeader.h"
namespace Swift {
@@ -20,12 +21,8 @@ XMPPLayer::~XMPPLayer() {
delete xmppParser_;
}
-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::writeHeader(const ProtocolHeader& header) {
+ onWriteData(ByteArray(xmppSerializer_->serializeHeader(header)));
}
void XMPPLayer::writeFooter() {
@@ -60,8 +57,8 @@ void XMPPLayer::doResetParser() {
resetParserAfterParse_ = false;
}
-void XMPPLayer::handleStreamStart(const String& from, const String& to, const String& id) {
- onStreamStart(from, to, id);
+void XMPPLayer::handleStreamStart(const ProtocolHeader& header) {
+ onStreamStart(header);
}
void XMPPLayer::handleElement(boost::shared_ptr<Element> stanza) {
diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h
index 7437112..7974811 100644
--- a/Swiften/StreamStack/XMPPLayer.h
+++ b/Swiften/StreamStack/XMPPLayer.h
@@ -1,5 +1,4 @@
-#ifndef SWIFTEN_XMPPLAYER_H
-#define SWIFTEN_XMPPLAYER_H
+#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/signal.hpp>
@@ -10,6 +9,7 @@
#include "Swiften/Parser/XMPPParserClient.h"
namespace Swift {
+ class ProtocolHeader;
class XMPPParser;
class PayloadParserFactoryCollection;
class XMPPSerializer;
@@ -22,8 +22,7 @@ namespace Swift {
PayloadSerializerCollection* payloadSerializers);
~XMPPLayer();
- void writeHeader(const String& from, const String& id);
- void writeHeader(const String& to);
+ void writeHeader(const ProtocolHeader& header);
void writeFooter();
void writeElement(boost::shared_ptr<Element>);
void writeData(const String& data);
@@ -32,14 +31,14 @@ namespace Swift {
void resetParser();
public:
- boost::signal<void (const String& /* from */, const String& /* to */ , const String& /* id */)> onStreamStart;
+ boost::signal<void (const ProtocolHeader&)> 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&, const String&, const String&);
+ void handleStreamStart(const ProtocolHeader&);
void handleElement(boost::shared_ptr<Element>);
void handleStreamEnd();
@@ -54,5 +53,3 @@ namespace Swift {
bool inParser_;
};
}
-
-#endif