diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2017-07-07 21:09:17 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-07-18 15:05:09 (GMT) |
commit | f0db4d39912e773208e9db2a3da3b68ac92ba17b (patch) | |
tree | cb6a455ba7b21d2218b3f9f2040af3bf30a39004 /Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp | |
parent | f21c9448c5187493fd08574962d88c2db1405512 (diff) | |
download | swift-f0db4d39912e773208e9db2a3da3b68ac92ba17b.zip swift-f0db4d39912e773208e9db2a3da3b68ac92ba17b.tar.bz2 |
Add MIXUpdateSubscription Element, its Parser and Serializer
Updates MIXJoin Element list of subscriptions to an unordered_set.
Remove redundant MIXSubscribe Element.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Added tests for MIXUpdateSubscription Parser and Serializer based on examples in XEP 0369, which passes.
Tested on Ubuntu 16.04 LTS.
Change-Id: Ied06269cf329b4fdffdde4ace67ebffa4089fbde
Diffstat (limited to 'Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp')
-rw-r--r-- | Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp new file mode 100644 index 0000000..d530e49 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/MIXUpdateSubscriptionParser.h> + +#include <boost/optional.hpp> + +#include <Swiften/Parser/PayloadParserFactory.h> +#include <Swiften/Parser/PayloadParsers/FormParser.h> + +namespace Swift { + +MIXUpdateSubscriptionParser::MIXUpdateSubscriptionParser() : level_(0) { +} + +MIXUpdateSubscriptionParser::~MIXUpdateSubscriptionParser() { +} + +void MIXUpdateSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { + if (level_ == 0) { + if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) { + if (boost::optional<JID> jid = JID::parse(*attributeValue)) { + getPayloadInternal()->setJID(*jid); + } + } + } + + if (level_ == 1) { + if (element == "subscribe" && ns == "urn:xmpp:mix:0") { + if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { + getPayloadInternal()->addSubscription(*attributeValue); + } + } + } + + ++level_; +} + +void MIXUpdateSubscriptionParser::handleEndElement(const std::string&, const std::string&) { + --level_; +} + +void MIXUpdateSubscriptionParser::handleCharacterData(const std::string&) { +} + +} |