summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/ClientStateParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/ClientStateParser.cpp35
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&) {
+
+}
+
+}