diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-02-16 09:05:37 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-02-17 08:05:08 (GMT) |
commit | 5a334fd9b676564a8915baad312d92bd86358eec (patch) | |
tree | aaecbbccd9cddcb843c126b8c022f1d1e667efde /Swiften/Serializer | |
parent | 231c2cb6d00061e70860626467107f4c63f359a0 (diff) | |
download | swift-5a334fd9b676564a8915baad312d92bd86358eec.zip swift-5a334fd9b676564a8915baad312d92bd86358eec.tar.bz2 |
Preliminary Chat State Notifications support.
Only covers Active and Composing (Which is very possibly all we care about).
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()); |