diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2017-03-22 09:18:20 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-03-23 21:07:53 (GMT) |
commit | cc873b3f00db4cd0a778bc2ec04f8748d70a92f9 (patch) | |
tree | 818b12d322fae76631668d8b64de082c6e20163e /Swiften/Parser/PayloadParsers/ClientStateParser.cpp | |
parent | 9bc6492fa3da165e0e3b9bb09b8f913d02275d11 (diff) | |
download | swift-cc873b3f00db4cd0a778bc2ec04f8748d70a92f9.zip swift-cc873b3f00db4cd0a778bc2ec04f8748d70a92f9.tar.bz2 |
Add Client State Indication Element, its Parser and Serializer
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Adds tests for Client State Parser and Serializer, which passes.
Tests performed on Ubuntu 16.04 LTS.
Change-Id: I60c63f63e1c0fdd55600ef42faa95989ca5ab75b
Diffstat (limited to 'Swiften/Parser/PayloadParsers/ClientStateParser.cpp')
-rw-r--r-- | Swiften/Parser/PayloadParsers/ClientStateParser.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/ClientStateParser.cpp b/Swiften/Parser/PayloadParsers/ClientStateParser.cpp new file mode 100644 index 0000000..8a6cc9c --- /dev/null +++ b/Swiften/Parser/PayloadParsers/ClientStateParser.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Tarun Gupta. + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/Parser/PayloadParsers/ClientStateParser.h> + +namespace Swift { + +ClientStateParser::ClientStateParser() { +} + +void ClientStateParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { + if (level_ == 0) { + auto state = ClientState::ClientStateType::Active; + if (element == "active") { + state = ClientState::ClientStateType::Active; + } else if (element == "inactive") { + state = ClientState::ClientStateType::Inactive; + } + getPayloadInternal()->setClientState(state); + } + ++level_; +} + +void ClientStateParser::handleEndElement(const std::string&, const std::string&) { + --level_; +} + +void ClientStateParser::handleCharacterData(const std::string&) { + +} + +} |