summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-03-04 10:56:07 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-03-04 10:58:16 (GMT)
commit37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1 (patch)
treee6455b4f21b3a5ba716526916a67cfd4b7e55051 /Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
parent12024229138787d7df91cb8101d0986996880e3d (diff)
downloadswift-37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1.zip
swift-37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1.tar.bz2
Upgrade XEP-0258 support to match 0.6.
Resolves: #183 Release-Notes: Security labels (XEP-0258) support has been updated to match the latest version of the specification.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
index 1f2a6bc..a08cd11 100644
--- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
+++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
@@ -15,6 +15,7 @@ SecurityLabelsCatalogParser::SecurityLabelsCatalogParser() : level_(TopLevel), l
}
SecurityLabelsCatalogParser::~SecurityLabelsCatalogParser() {
+ //delete currentLabel_;
delete labelParserFactory_;
}
@@ -25,6 +26,11 @@ void SecurityLabelsCatalogParser::handleStartElement(const std::string& element,
getPayloadInternal()->setName(attributes.getAttribute("name"));
getPayloadInternal()->setDescription(attributes.getAttribute("desc"));
}
+ else if (level_ == ItemLevel && element == "item" && ns == "urn:xmpp:sec-label:catalog:2") {
+ currentItem_ = boost::shared_ptr<SecurityLabelsCatalog::Item>(new SecurityLabelsCatalog::Item());
+ currentItem_->setSelector(attributes.getAttribute("selector"));
+ currentItem_->setIsDefault(attributes.getBoolAttribute("default", false));
+ }
else if (level_ == LabelLevel) {
assert(!labelParser_);
if (labelParserFactory_->canParse(element, ns, attributes)) {
@@ -42,13 +48,19 @@ void SecurityLabelsCatalogParser::handleEndElement(const std::string& element, c
if (labelParser_) {
labelParser_->handleEndElement(element, ns);
}
- if (level_ == LabelLevel && labelParser_) {
- SecurityLabel* label = dynamic_cast<SecurityLabel*>(labelParser_->getPayload().get());
- assert(label);
- getPayloadInternal()->addLabel(SecurityLabel(*label));
+ if (level_ == LabelLevel && labelParser_ && currentItem_) {
+ boost::shared_ptr<SecurityLabel> currentLabel = labelParser_->getLabelPayload();
+ assert(currentLabel);
+ currentItem_->setLabel(currentLabel);
delete labelParser_;
labelParser_ = 0;
}
+ else if (level_ == ItemLevel && element == "item" && ns == "urn:xmpp:sec-label:catalog:2") {
+ if (currentItem_) {
+ getPayloadInternal()->addItem(SecurityLabelsCatalog::Item(*currentItem_));
+ currentItem_.reset();
+ }
+ }
--level_;
}