diff options
Diffstat (limited to 'Swiften/Serializer/MessageSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/MessageSerializer.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Serializer/MessageSerializer.cpp b/Swiften/Serializer/MessageSerializer.cpp new file mode 100644 index 0000000..a3cf2ad --- /dev/null +++ b/Swiften/Serializer/MessageSerializer.cpp @@ -0,0 +1,27 @@ +#include "Swiften/Serializer/MessageSerializer.h" +#include "Swiften/Serializer/XML/XMLElement.h" + +namespace Swift { + +MessageSerializer::MessageSerializer(PayloadSerializerCollection* payloadSerializers) : + GenericStanzaSerializer<Message>("message", payloadSerializers) { +} + +void MessageSerializer::setStanzaSpecificAttributesGeneric( + boost::shared_ptr<Message> message, + XMLElement& element) const { + if (message->getType() == Message::Chat) { + element.setAttribute("type", "chat"); + } + else if (message->getType() == Message::Groupchat) { + element.setAttribute("type", "groupchat"); + } + else if (message->getType() == Message::Headline) { + element.setAttribute("type", "headline"); + } + else if (message->getType() == Message::Error) { + element.setAttribute("type", "error"); + } +} + +} |