diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index fb7092c..9b35952 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -19,29 +19,29 @@ SecurityLabelSerializer::SecurityLabelSerializer() : GenericPayloadSerializer<Se } std::string SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel> label) const { - XMLElement element("securitylabel", "urn:xmpp:sec-label:0"); - if (!label->getDisplayMarking().empty()) { - boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking")); - if (!label->getForegroundColor().empty()) { - displayMarking->setAttribute("fgcolor", label->getForegroundColor()); - } - if (!label->getBackgroundColor().empty()) { - displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); - } - displayMarking->addNode(boost::make_shared<XMLTextNode>(label->getDisplayMarking())); - element.addNode(displayMarking); - } - - boost::shared_ptr<XMLElement> labelElement(new XMLElement("label")); - labelElement->addNode(boost::make_shared<XMLRawTextNode>(label->getLabel())); - element.addNode(labelElement); - - foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { - boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel")); - equivalentLabelElement->addNode(boost::make_shared<XMLRawTextNode>(equivalentLabel)); - element.addNode(equivalentLabelElement); - } - return element.serialize(); + XMLElement element("securitylabel", "urn:xmpp:sec-label:0"); + if (!label->getDisplayMarking().empty()) { + boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking")); + if (!label->getForegroundColor().empty()) { + displayMarking->setAttribute("fgcolor", label->getForegroundColor()); + } + if (!label->getBackgroundColor().empty()) { + displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); + } + displayMarking->addNode(boost::make_shared<XMLTextNode>(label->getDisplayMarking())); + element.addNode(displayMarking); + } + + boost::shared_ptr<XMLElement> labelElement(new XMLElement("label")); + labelElement->addNode(boost::make_shared<XMLRawTextNode>(label->getLabel())); + element.addNode(labelElement); + + foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { + boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel")); + equivalentLabelElement->addNode(boost::make_shared<XMLRawTextNode>(equivalentLabel)); + element.addNode(equivalentLabelElement); + } + return element.serialize(); } } |