summaryrefslogtreecommitdiffstats
blob: 3a5ba3b79c1b6ccb43916ec577ea7c6191570d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "Swiften/Parser/PayloadParsers/ChatStateParser.h"

namespace Swift {

ChatStateParser::ChatStateParser() : level_(0) {
}

void ChatStateParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap&) {
	if (level_ == 0) {
		ChatState::ChatStateType state = ChatState::Active;
		if (element == "active") {
			state = ChatState::Active;
		} else if (element == "composing") {
			state = ChatState::Composing;
		} else if (element == "inactive") {
			state = ChatState::Inactive;
		} else if (element == "paused") {
			state = ChatState::Paused;
		} else if (element == "gone") {
			state = ChatState::Gone;
		}
		getPayloadInternal()->setChatState(state);
	}
	++level_;
}

void ChatStateParser::handleEndElement(const std::string&, const std::string&) {
	--level_;
}

void ChatStateParser::handleCharacterData(const std::string&) {

}

}