blob: e44e30e9effa74b855f774bc172d7ecb8bf4af2b (
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
|
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h"
#include "Swiften/Base/foreach.h"
#include "Swiften/Serializer/XML/XMLElement.h"
#include "Swiften/Serializer/XML/XMLRawTextNode.h"
#include "Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h"
namespace Swift {
SecurityLabelsCatalogSerializer::SecurityLabelsCatalogSerializer() : GenericPayloadSerializer<SecurityLabelsCatalog>() {
}
String SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr<SecurityLabelsCatalog> catalog) const {
XMLElement element("catalog", "urn:xmpp:sec-label:catalog:0");
if (!catalog->getName().isEmpty()) {
element.setAttribute("name", catalog->getName());
}
if (catalog->getTo().isValid()) {
element.setAttribute("to", catalog->getTo());
}
if (!catalog->getDescription().isEmpty()) {
element.setAttribute("desc", catalog->getDescription());
}
foreach (const SecurityLabel& label, catalog->getLabels()) {
String serializedLabel = SecurityLabelSerializer().serialize(boost::shared_ptr<SecurityLabel>(new SecurityLabel(label)));
element.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializedLabel)));
}
return element.serialize();
}
}
|