diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
3 files changed, 66 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index f3e22d2..87dfbc3 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -24,6 +24,7 @@ #include <Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h> #include <Swiften/Serializer/PayloadSerializers/StatusSerializer.h> #include <Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h> @@ -74,6 +75,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new MUCPayloadSerializer()); serializers_.push_back(new MUCDestroyPayloadSerializer()); serializers_.push_back(new MUCAdminPayloadSerializer()); + serializers_.push_back(new MUCInvitationPayloadSerializer()); serializers_.push_back(new MUCOwnerPayloadSerializer(this)); serializers_.push_back(new MUCUserPayloadSerializer(this)); serializers_.push_back(new SoftwareVersionSerializer()); diff --git a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp new file mode 100644 index 0000000..24e30e6 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h> + +#include <boost/shared_ptr.hpp> +#include <boost/smart_ptr/make_shared.hpp> + +#include <Swiften/Base/foreach.h> +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLTextNode.h> +#include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h> + + +namespace Swift { + +MUCInvitationPayloadSerializer::MUCInvitationPayloadSerializer() : GenericPayloadSerializer<MUCInvitationPayload>() { +} + +std::string MUCInvitationPayloadSerializer::serializePayload(boost::shared_ptr<MUCInvitationPayload> payload) const { + XMLElement mucElement("x", "jabber:x:conference"); + if (payload->getIsContinuation()) { + mucElement.setAttribute("continue", "true"); + } + if (payload->getJID().isValid()) { + mucElement.setAttribute("jid", payload->getJID().toString()); + } + if (!payload->getPassword().empty()) { + mucElement.setAttribute("password", payload->getPassword()); + } + if (!payload->getReason().empty()) { + mucElement.setAttribute("reason", payload->getReason()); + } + if (!payload->getThread().empty()) { + mucElement.setAttribute("thread", payload->getThread()); + } + return mucElement.serialize(); +} + + +} diff --git a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h new file mode 100644 index 0000000..e60d5ca --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2011 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <Swiften/Serializer/GenericPayloadSerializer.h> +#include <Swiften/Elements/MUCInvitationPayload.h> + +namespace Swift { + class MUCInvitationPayloadSerializer : public GenericPayloadSerializer<MUCInvitationPayload> { + public: + MUCInvitationPayloadSerializer(); + + virtual std::string serializePayload(boost::shared_ptr<MUCInvitationPayload> version) const; + }; +} + |