summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/XMPPSerializer.cpp20
-rw-r--r--Swiften/Serializer/XMPPSerializer.h8
2 files changed, 15 insertions, 13 deletions
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 6139586..660bb37 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -3,6 +3,7 @@
#include <boost/bind.hpp>
#include <iostream>
+#include "Swiften/Elements/ProtocolHeader.h"
#include "Swiften/Base/foreach.h"
#include "Swiften/Serializer/CompressRequestSerializer.h"
#include "Swiften/Serializer/CompressFailureSerializer.h"
@@ -34,16 +35,19 @@ XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers)
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StreamFeaturesSerializer()));
}
-String XMPPSerializer::serializeHeader(const String& from, const String& to, const String& id) const {
- String result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\"";
- if (!from.isEmpty()) {
- result += " from=\"" + from + "\"";
+String XMPPSerializer::serializeHeader(const ProtocolHeader& header) const {
+ String result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\"";
+ if (!header.getFrom().isEmpty()) {
+ result += " from=\"" + header.getFrom() + "\"";
}
- if (!to.isEmpty()) {
- result += " to=\"" + to + "\"";
+ if (!header.getTo().isEmpty()) {
+ result += " to=\"" + header.getTo() + "\"";
}
- if (!id.isEmpty()) {
- result += " id=\"" + id + "\"";
+ if (!header.getID().isEmpty()) {
+ result += " id=\"" + header.getID() + "\"";
+ }
+ if (!header.getVersion().isEmpty()) {
+ result += " version=\"" + header.getVersion() + "\"";
}
result += ">";
return result;
diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h
index f77e14b..38ba3ff 100644
--- a/Swiften/Serializer/XMPPSerializer.h
+++ b/Swiften/Serializer/XMPPSerializer.h
@@ -1,5 +1,4 @@
-#ifndef SWIFTEN_XMPPSERIALIZER_H
-#define SWIFTEN_XMPPSERIALIZER_H
+#pragma once
#include <boost/shared_ptr.hpp>
#include <vector>
@@ -11,12 +10,13 @@
namespace Swift {
class PayloadSerializerCollection;
class CompressRequestSerializer;
+ class ProtocolHeader;
class XMPPSerializer {
public:
XMPPSerializer(PayloadSerializerCollection*);
- String serializeHeader(const String& from, const String& to, const String& id = "") const;
+ String serializeHeader(const ProtocolHeader&) const;
String serializeElement(boost::shared_ptr<Element> stanza) const;
String serializeFooter() const;
@@ -24,5 +24,3 @@ namespace Swift {
std::vector< boost::shared_ptr<ElementSerializer> > serializers_;
};
}
-
-#endif