diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
commit | edd726abb1d0f7532218efbb8067a75a313e9e98 (patch) | |
tree | 7eec4f7912a59bb9a383a61c2c96616d5b5847b6 /Swiften/Serializer | |
parent | 6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad (diff) | |
download | swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.zip swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.tar.bz2 |
Improved whiteboard session handling
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp | 30 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h | 12 |
2 files changed, 34 insertions, 8 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp new file mode 100644 index 0000000..578b0ab --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h> +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLTextNode.h> + +namespace Swift { + std::string WhiteboardSerializer::serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const { + XMLElement element("wb"); + element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getData()))); + element.setAttribute("type", typeToString(payload->getType())); + return element.serialize(); + } + + std::string WhiteboardSerializer::typeToString(WhiteboardPayload::Type type) const { + if(type == WhiteboardPayload::Data) { + return ""; + } else if (type == WhiteboardPayload::SessionRequest) { + return "session-request"; + } else if (type == WhiteboardPayload::SessionAccept) { + return "session-accept"; + } else if (type == WhiteboardPayload::SessionTerminate) { + return "session-terminate"; + } + } +} diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h index 9b7f905..975d537 100644 --- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h @@ -12,13 +12,9 @@ namespace Swift { class WhiteboardSerializer : public GenericPayloadSerializer<WhiteboardPayload> { public: - std::string serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const { - XMLElement element("wb"); - element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getData()))); - if (payload->getType() == WhiteboardPayload::SessionRequest) { - element.setAttribute("type", "request"); - } - return element.serialize(); - } + std::string serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const; + + private: + std::string typeToString(WhiteboardPayload::Type type) const; }; } |