summaryrefslogtreecommitdiffstats
blob: 75ec699cd800f5446d507a504ff359e10738b43b (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 Isode Limited.
 * All rights reserved.
 * See the COPYING file 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&) {

}

}