summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser')
-rw-r--r--Swiften/Parser/UnitTest/XMPPParserTest.cpp5
-rw-r--r--Swiften/Parser/XMPPParser.cpp8
-rw-r--r--Swiften/Parser/XMPPParserClient.h8
3 files changed, 13 insertions, 8 deletions
diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
index a8b805e..ecdd565 100644
--- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
@@ -2,6 +2,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <vector>
+#include "Swiften/Elements/ProtocolHeader.h"
#include "Swiften/Base/String.h"
#include "Swiften/Parser/XMPPParser.h"
#include "Swiften/Parser/ElementParser.h"
@@ -165,8 +166,8 @@ class XMPPParserTest : public CppUnit::TestFixture
Client() {}
- void handleStreamStart(const String& from, const String& to, const String& id) {
- events.push_back(Event(StreamStart, from, to, id));
+ void handleStreamStart(const ProtocolHeader& header) {
+ events.push_back(Event(StreamStart, header.getFrom(), header.getTo(), header.getID()));
}
void handleElement(boost::shared_ptr<Element> element) {
diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp
index 0f04cca..f97bed8 100644
--- a/Swiften/Parser/XMPPParser.cpp
+++ b/Swiften/Parser/XMPPParser.cpp
@@ -3,6 +3,7 @@
#include <iostream>
#include <cassert>
+#include "Swiften/Elements/ProtocolHeader.h"
#include "Swiften/Base/String.h"
#include "Swiften/Parser/XMLParser.h"
#include "Swiften/Parser/PlatformXMLParserFactory.h"
@@ -54,7 +55,12 @@ bool XMPPParser::parse(const String& data) {
void XMPPParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) {
if (!inStream()) {
if (element == "stream" && ns == "http://etherx.jabber.org/streams") {
- client_->handleStreamStart(attributes.getAttribute("from"), attributes.getAttribute("to"), attributes.getAttribute("id"));
+ ProtocolHeader header;
+ header.setFrom(attributes.getAttribute("from"));
+ header.setTo(attributes.getAttribute("to"));
+ header.setID(attributes.getAttribute("id"));
+ header.setVersion(attributes.getAttribute("version"));
+ client_->handleStreamStart(header);
}
else {
parseErrorOccurred_ = true;
diff --git a/Swiften/Parser/XMPPParserClient.h b/Swiften/Parser/XMPPParserClient.h
index fb81df8..b8f8e46 100644
--- a/Swiften/Parser/XMPPParserClient.h
+++ b/Swiften/Parser/XMPPParserClient.h
@@ -1,5 +1,4 @@
-#ifndef SWIFTEN_XMPPPARSERCLIENT_H
-#define SWIFTEN_XMPPPARSERCLIENT_H
+#pragma once
#include <boost/shared_ptr.hpp>
@@ -7,15 +6,14 @@
namespace Swift {
class String;
+ class ProtocolHeader;
class XMPPParserClient {
public:
virtual ~XMPPParserClient();
- virtual void handleStreamStart(const String& from, const String& to, const String& id) = 0;
+ virtual void handleStreamStart(const ProtocolHeader&) = 0;
virtual void handleElement(boost::shared_ptr<Element>) = 0;
virtual void handleStreamEnd() = 0;
};
}
-
-#endif