diff options
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp (renamed from Swift/QtUI/Whiteboard/Window.cpp) | 0 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.h (renamed from Swift/QtUI/Whiteboard/Window.h) | 0 | ||||
-rw-r--r-- | Swiften/Elements/WhiteboardPayload.h | 30 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp | 2 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 26 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.h | 24 | ||||
-rw-r--r-- | Swiften/Parser/SConscript | 1 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp | 2 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h | 21 |
9 files changed, 106 insertions, 0 deletions
diff --git a/Swift/QtUI/Whiteboard/Window.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp index 4423d17..4423d17 100644 --- a/Swift/QtUI/Whiteboard/Window.cpp +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp diff --git a/Swift/QtUI/Whiteboard/Window.h b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h index 4423f7c..4423f7c 100644 --- a/Swift/QtUI/Whiteboard/Window.h +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h diff --git a/Swiften/Elements/WhiteboardPayload.h b/Swiften/Elements/WhiteboardPayload.h new file mode 100644 index 0000000..8d40d9d --- /dev/null +++ b/Swiften/Elements/WhiteboardPayload.h @@ -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. + */ + +#pragma once + +#include <string> + +#include <Swiften/Elements/Payload.h> + +namespace Swift { + class WhiteboardPayload : public Payload { + public: + WhiteboardPayload() { + } + + void setData(const std::string &data) { + data_ = data; + } + + std::string getData() const { + return data_; + } + + private: + std::string data_; + }; +} diff --git a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp index 01addf5..f8f68ff 100644 --- a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp +++ b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp @@ -66,6 +66,7 @@ #include <Swiften/Parser/PayloadParsers/JingleFileTransferDescriptionParser.h> #include <Swiften/Parser/PayloadParsers/DeliveryReceiptParserFactory.h> #include <Swiften/Parser/PayloadParsers/DeliveryReceiptRequestParserFactory.h> +#include <Swiften/Parser/PayloadParsers/WhiteboardParser.h> using namespace boost; @@ -123,6 +124,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() { factories_.push_back(boost::make_shared<GenericPayloadParserFactory<JingleFileTransferReceivedParser> >("received", "urn:xmpp:jingle:apps:file-transfer:3")); factories_.push_back(boost::make_shared<GenericPayloadParserFactory<JingleFileTransferHashParser> >("checksum")); factories_.push_back(boost::make_shared<GenericPayloadParserFactory<S5BProxyRequestParser> >("query", "http://jabber.org/protocol/bytestreams")); + factories_.push_back(boost::make_shared<GenericPayloadParserFactory<WhiteboardParser> >("wb")); factories_.push_back(boost::make_shared<DeliveryReceiptParserFactory>()); factories_.push_back(boost::make_shared<DeliveryReceiptRequestParserFactory>()); diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp new file mode 100644 index 0000000..77e5c2c --- /dev/null +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/WhiteboardParser.h> + +namespace Swift { + WhiteboardParser::WhiteboardParser() : level_(0) { + } + void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { + ++level_; + } + + void WhiteboardParser::handleEndElement(const std::string& element, const std::string&) { + --level_; + if(level_ == 0) { + getPayloadInternal()->setData(data_); + } + } + + void WhiteboardParser::handleCharacterData(const std::string& data) { + data_ += data; + } +} diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h new file mode 100644 index 0000000..265e12d --- /dev/null +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/Elements/WhiteboardPayload.h> +#include <Swiften/Parser/GenericPayloadParser.h> + +namespace Swift { + class WhiteboardParser : public Swift::GenericPayloadParser<WhiteboardPayload> { + public: + WhiteboardParser(); + + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); + private: + int level_; + std::string data_; + }; +} diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript index e4c2778..64e9eb9 100644 --- a/Swiften/Parser/SConscript +++ b/Swiften/Parser/SConscript @@ -72,6 +72,7 @@ sources = [ "PayloadParsers/S5BProxyRequestParser.cpp", "PayloadParsers/DeliveryReceiptParser.cpp", "PayloadParsers/DeliveryReceiptRequestParser.cpp", + "PayloadParsers/WhiteboardParser.cpp", "PlatformXMLParserFactory.cpp", "PresenceParser.cpp", "SerializingParser.cpp", diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index 93fd70f..b4822cd 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -50,6 +50,7 @@ #include <Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h> #include <Swiften/Serializer/PayloadSerializers/LastSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h> #include <Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h> #include <Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h> @@ -108,6 +109,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new SearchPayloadSerializer()); serializers_.push_back(new ReplaceSerializer()); serializers_.push_back(new LastSerializer()); + serializers_.push_back(new WhiteboardSerializer()); serializers_.push_back(new StreamInitiationFileInfoSerializer()); serializers_.push_back(new JingleContentPayloadSerializer()); diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h new file mode 100644 index 0000000..a7d04f1 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/Elements/WhiteboardPayload.h> +#include <Swiften/Serializer/GenericPayloadSerializer.h> + +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()))); + return element.serialize(); + } + }; +} |