diff options
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r-- | Swiften/Serializer/EnableSessionManagementSerializer.h | 25 | ||||
-rw-r--r-- | Swiften/Serializer/SessionManagementEnabledSerializer.h | 25 | ||||
-rw-r--r-- | Swiften/Serializer/SessionManagementFailedSerializer.h | 25 | ||||
-rw-r--r-- | Swiften/Serializer/StanzaAckRequestSerializer.h | 25 | ||||
-rw-r--r-- | Swiften/Serializer/StanzaAckSerializer.h | 30 | ||||
-rw-r--r-- | Swiften/Serializer/XMPPSerializer.cpp | 10 |
6 files changed, 140 insertions, 0 deletions
diff --git a/Swiften/Serializer/EnableSessionManagementSerializer.h b/Swiften/Serializer/EnableSessionManagementSerializer.h new file mode 100644 index 0000000..0820cdf --- /dev/null +++ b/Swiften/Serializer/EnableSessionManagementSerializer.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Elements/EnableSessionManagement.h" +#include "Swiften/Serializer/GenericElementSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + class EnableSessionManagementSerializer : public GenericElementSerializer<EnableSessionManagement> { + public: + EnableSessionManagementSerializer() : GenericElementSerializer<EnableSessionManagement>() { + } + + virtual String serialize(boost::shared_ptr<Element>) const { + return XMLElement("enable", "urn:xmpp:sm:2").serialize(); + } + }; +} diff --git a/Swiften/Serializer/SessionManagementEnabledSerializer.h b/Swiften/Serializer/SessionManagementEnabledSerializer.h new file mode 100644 index 0000000..4c492b7 --- /dev/null +++ b/Swiften/Serializer/SessionManagementEnabledSerializer.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Elements/SessionManagementEnabled.h" +#include "Swiften/Serializer/GenericElementSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + class SessionManagementEnabledSerializer : public GenericElementSerializer<SessionManagementEnabled> { + public: + SessionManagementEnabledSerializer() : GenericElementSerializer<SessionManagementEnabled>() { + } + + virtual String serialize(boost::shared_ptr<Element>) const { + return XMLElement("enabled", "urn:xmpp:sm:2").serialize(); + } + }; +} diff --git a/Swiften/Serializer/SessionManagementFailedSerializer.h b/Swiften/Serializer/SessionManagementFailedSerializer.h new file mode 100644 index 0000000..ecc0cb8 --- /dev/null +++ b/Swiften/Serializer/SessionManagementFailedSerializer.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Elements/SessionManagementFailed.h" +#include "Swiften/Serializer/GenericElementSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + class SessionManagementFailedSerializer : public GenericElementSerializer<SessionManagementFailed> { + public: + SessionManagementFailedSerializer() : GenericElementSerializer<SessionManagementFailed>() { + } + + virtual String serialize(boost::shared_ptr<Element>) const { + return XMLElement("failed", "urn:xmpp:sm:2").serialize(); + } + }; +} diff --git a/Swiften/Serializer/StanzaAckRequestSerializer.h b/Swiften/Serializer/StanzaAckRequestSerializer.h new file mode 100644 index 0000000..26d015d --- /dev/null +++ b/Swiften/Serializer/StanzaAckRequestSerializer.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Elements/StanzaAckRequest.h" +#include "Swiften/Serializer/GenericElementSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + class StanzaAckRequestSerializer : public GenericElementSerializer<StanzaAckRequest> { + public: + StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() { + } + + virtual String serialize(boost::shared_ptr<Element>) const { + return XMLElement("r", "urn:xmpp:sm:2").serialize(); + } + }; +} diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h new file mode 100644 index 0000000..eb957b9 --- /dev/null +++ b/Swiften/Serializer/StanzaAckSerializer.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> +#include <boost/lexical_cast.hpp> + +#include "Swiften/Elements/StanzaAck.h" +#include "Swiften/Serializer/GenericElementSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + class StanzaAckSerializer : public GenericElementSerializer<StanzaAck> { + public: + StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() { + } + + virtual String serialize(boost::shared_ptr<Element> element) const { + StanzaAck::ref stanzaAck = StanzaAck::cast(element); + assert(stanzaAck->isValid()); + XMLElement result("a", "urn:xmpp:sm:2"); + result.setAttribute("h", String(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount()))); + return result.serialize(); + } + }; +} diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp index c55600d..b619cae 100644 --- a/Swiften/Serializer/XMPPSerializer.cpp +++ b/Swiften/Serializer/XMPPSerializer.cpp @@ -19,6 +19,11 @@ #include "Swiften/Serializer/AuthSuccessSerializer.h" #include "Swiften/Serializer/AuthChallengeSerializer.h" #include "Swiften/Serializer/AuthResponseSerializer.h" +#include "Swiften/Serializer/EnableSessionManagementSerializer.h" +#include "Swiften/Serializer/SessionManagementEnabledSerializer.h" +#include "Swiften/Serializer/SessionManagementFailedSerializer.h" +#include "Swiften/Serializer/StanzaAckSerializer.h" +#include "Swiften/Serializer/StanzaAckRequestSerializer.h" #include "Swiften/Serializer/StartTLSRequestSerializer.h" #include "Swiften/Serializer/StartTLSFailureSerializer.h" #include "Swiften/Serializer/TLSProceedSerializer.h" @@ -43,6 +48,11 @@ XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers) serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StartTLSFailureSerializer())); serializers_.push_back(boost::shared_ptr<ElementSerializer>(new TLSProceedSerializer())); serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StreamFeaturesSerializer())); + serializers_.push_back(boost::shared_ptr<ElementSerializer>(new EnableSessionManagementSerializer())); + serializers_.push_back(boost::shared_ptr<ElementSerializer>(new SessionManagementEnabledSerializer())); + serializers_.push_back(boost::shared_ptr<ElementSerializer>(new SessionManagementFailedSerializer())); + serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StanzaAckSerializer())); + serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StanzaAckRequestSerializer())); } String XMPPSerializer::serializeHeader(const ProtocolHeader& header) const { |