diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-18 19:04:32 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-18 20:40:56 (GMT) |
commit | 4457bc810a326de8d7895b3f2ff36ade5f1ae1a0 (patch) | |
tree | 1556c4b0190453897d4799d23b05e651b0bb8a32 /Swiften/Serializer | |
parent | 4052a822acd9da9dab6a8e2343c6170fb08dd8d6 (diff) | |
download | swift-contrib-4457bc810a326de8d7895b3f2ff36ade5f1ae1a0.zip swift-contrib-4457bc810a326de8d7895b3f2ff36ade5f1ae1a0.tar.bz2 |
Implement incoming linklocal connections.
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r-- | Swiften/Serializer/XMPPSerializer.cpp | 20 | ||||
-rw-r--r-- | Swiften/Serializer/XMPPSerializer.h | 8 |
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 |