summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-02-20 09:06:33 (GMT)
committerTobias Markmann <tm@ayena.de>2015-02-20 16:51:51 (GMT)
commit88758e2b2a24372386b8d3d5fa5390414cc8ec0f (patch)
tree8bb7183c1cc7d47715a23a9be1b414cc9c09d90f /Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp
parent9b4314424ee2daff9031a0027f2d8de3a84ed48e (diff)
downloadswift-88758e2b2a24372386b8d3d5fa5390414cc8ec0f.zip
swift-88758e2b2a24372386b8d3d5fa5390414cc8ec0f.tar.bz2
Add elements/parsers/serializers/tests for Message Carbons (XEP-0280)
In addition this patch adds an element, a parser and a serializer for the <thread/> element from XMPP IM. Test-Information: Implemented unit tests pass as expected. Change-Id: I0a14c778c2c0bf65f4b405c9878c741449bfe142
Diffstat (limited to 'Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp b/Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp
new file mode 100644
index 0000000..b430249
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/CarbonsSentParser.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/CarbonsSentParser.h>
+
+namespace Swift {
+ CarbonsSentParser::CarbonsSentParser(PayloadParserFactoryCollection* factories) : GenericPayloadParser<CarbonsSent>(), factories_(factories), level_(TopLevel) {
+ }
+
+ CarbonsSentParser::~CarbonsSentParser() {
+ }
+
+ void CarbonsSentParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ if (level_ == PayloadLevel) {
+ if (element == "forwarded") {
+ forwardedParser_ = boost::dynamic_pointer_cast<ForwardedParser>(boost::make_shared<ForwardedParser>(factories_));
+ }
+ }
+ if (forwardedParser_) {
+ forwardedParser_->handleStartElement(element, ns, attributes);
+ }
+ ++level_;
+ }
+
+ void CarbonsSentParser::handleEndElement(const std::string& element, const std::string& ns) {
+ --level_;
+ if (forwardedParser_ && level_ >= PayloadLevel) {
+ forwardedParser_->handleEndElement(element, ns);
+ }
+ if (forwardedParser_ && level_ == PayloadLevel) {
+ /* done parsing nested stanza */
+ getPayloadInternal()->setForwarded(forwardedParser_->getPayloadInternal());
+ forwardedParser_.reset();
+ }
+ }
+
+ void CarbonsSentParser::handleCharacterData(const std::string& data) {
+ if (forwardedParser_) {
+ forwardedParser_->handleCharacterData(data);
+ }
+ }
+}