summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-01 17:13:40 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-01 17:13:40 (GMT)
commite8ab1af885ff61715ab0350c3cb22ed6988a082a (patch)
treeabfd1f18bf6bda8865c1269c1ecb4a1b4ff802d0 /Swiften/Parser/PayloadParsers
parent4f9ad66f222d4bf1cb740a9e1b4b4496cfbc0910 (diff)
downloadswift-contrib-e8ab1af885ff61715ab0350c3cb22ed6988a082a.zip
swift-contrib-e8ab1af885ff61715ab0350c3cb22ed6988a082a.tar.bz2
Added simple whiteboard payload and it's parser and serializer
Diffstat (limited to 'Swiften/Parser/PayloadParsers')
-rw-r--r--Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp26
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.h24
3 files changed, 52 insertions, 0 deletions
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_;
+ };
+}