summaryrefslogtreecommitdiffstats
blob: 3ee0772021e40efb5ae3aa28a26dde21fff66b6d (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
/*
 * Copyright (c) 2010-2014 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <Swiften/Serializer/StreamManagementEnabledSerializer.h>

#include <boost/shared_ptr.hpp>

#include <Swiften/Elements/StreamManagementEnabled.h>
#include <Swiften/Serializer/XML/XMLElement.h>

using namespace Swift;

StreamManagementEnabledSerializer::StreamManagementEnabledSerializer() : GenericElementSerializer<StreamManagementEnabled>() {
}

SafeByteArray StreamManagementEnabledSerializer::serialize(boost::shared_ptr<ToplevelElement> el) const {
	boost::shared_ptr<StreamManagementEnabled> e(boost::dynamic_pointer_cast<StreamManagementEnabled>(el));
	XMLElement element("enabled", "urn:xmpp:sm:2");
	if (!e->getResumeID().empty()) {
		element.setAttribute("id", e->getResumeID());
	}
	if (e->getResumeSupported()) {
		element.setAttribute("resume", "true");
	}
	return createSafeByteArray(element.serialize());
}