diff options
Diffstat (limited to 'Swiften/Serializer')
3 files changed, 37 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp new file mode 100644 index 0000000..0507092 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp @@ -0,0 +1,22 @@ +#include "Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h" + +namespace Swift { + +ChatStateSerializer::ChatStateSerializer() : GenericPayloadSerializer<ChatState>() { +} + +String ChatStateSerializer::serializePayload(boost::shared_ptr<ChatState> chatState) const { + String result("<"); + switch (chatState->getChatState()) { + case ChatState::Active: result += "active"; break; + case ChatState::Composing: result += "composing"; break; + case ChatState::Paused: result += "paused"; break; + case ChatState::Inactive: result += "inactive"; break; + case ChatState::Gone: result += "gone"; break; + default: result += "gone"; break; + } + result += " xmlns=\"http://jabber.org/protocol/chatstates\"/>"; + return result; +} + +} diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h new file mode 100644 index 0000000..e99b8b6 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Swiften/Serializer/GenericPayloadSerializer.h" +#include "Swiften/Elements/ChatState.h" + +namespace Swift { + class ChatStateSerializer : public GenericPayloadSerializer<ChatState> { + public: + ChatStateSerializer(); + + virtual String serializePayload(boost::shared_ptr<ChatState> error) const; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index fc20018..accf6c6 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -2,6 +2,7 @@ #include "Swiften/Base/foreach.h" #include "Swiften/Serializer/PayloadSerializer.h" #include "Swiften/Serializer/PayloadSerializers/BodySerializer.h" +#include "Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h" #include "Swiften/Serializer/PayloadSerializers/PrioritySerializer.h" #include "Swiften/Serializer/PayloadSerializers/ErrorSerializer.h" #include "Swiften/Serializer/PayloadSerializers/RosterSerializer.h" @@ -25,6 +26,7 @@ namespace Swift { FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new BodySerializer()); + serializers_.push_back(new ChatStateSerializer()); serializers_.push_back(new PrioritySerializer()); serializers_.push_back(new ErrorSerializer()); serializers_.push_back(new RosterSerializer()); |