diff options
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r-- | Swiften/Serializer/XMPPSerializer.cpp | 15 | ||||
-rw-r--r-- | Swiften/Serializer/XMPPSerializer.h | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp index c43f9db..6139586 100644 --- a/Swiften/Serializer/XMPPSerializer.cpp +++ b/Swiften/Serializer/XMPPSerializer.cpp @@ -34,8 +34,19 @@ XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers) serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StreamFeaturesSerializer())); } -String XMPPSerializer::serializeHeader(const String& domain) const { - return "<?xml version='1.0'?><stream:stream to='" + domain + "' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' >"; +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 + "\""; + } + if (!to.isEmpty()) { + result += " to=\"" + to + "\""; + } + if (!id.isEmpty()) { + result += " id=\"" + id + "\""; + } + result += ">"; + return result; } String XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const { diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h index 1fc8b9d..f77e14b 100644 --- a/Swiften/Serializer/XMPPSerializer.h +++ b/Swiften/Serializer/XMPPSerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: XMPPSerializer(PayloadSerializerCollection*); - String serializeHeader(const String& domain) const; + String serializeHeader(const String& from, const String& to, const String& id = "") const; String serializeElement(boost::shared_ptr<Element> stanza) const; String serializeFooter() const; |