summaryrefslogtreecommitdiffstats
blob: 616d41a1c2d814f43393b998ce3bb49e298683ec (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
/*
 * Copyright (c) 2014 Kevin Smith and Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <Swiften/Base/DateTime.h>
#include <Swiften/Parser/PayloadParserFactory.h>
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
#include <Swiften/Parser/PayloadParsers/MAMArchivedParser.h>

using namespace Swift;

MAMArchivedParser::MAMArchivedParser() : level_(TopLevel) {
}

void MAMArchivedParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) {
	if (level_ == TopLevel) {
		boost::optional<std::string> attributeValue;
		if ((attributeValue = attributes.getAttributeValue("by"))) {
			getPayloadInternal()->setBy(*attributeValue);
		}
		if ((attributeValue = attributes.getAttributeValue("id"))) {
			getPayloadInternal()->setID(*attributeValue);
		}
	}

	++level_;
}

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

void MAMArchivedParser::handleCharacterData(const std::string&) {
}