summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-14 16:17:30 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-14 19:48:53 (GMT)
commitef5a4dc3a5b0224628a225ef0dccc679287478be (patch)
tree126d8f752f18d3d5891cd32cacf2a21734ab0b92 /Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp
parent9ecba612d790c1f613dc959888f62e5d3575faae (diff)
downloadswift-ef5a4dc3a5b0224628a225ef0dccc679287478be.zip
swift-ef5a4dc3a5b0224628a225ef0dccc679287478be.tar.bz2
Add extended disco support to caps verifier.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp b/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp
index 81f2ce8..c47c703 100644
--- a/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp
+++ b/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp
@@ -5,13 +5,14 @@
*/
#include "Swiften/Parser/PayloadParsers/DiscoInfoParser.h"
+#include "Swiften/Parser/PayloadParsers/FormParser.h"
namespace Swift {
-DiscoInfoParser::DiscoInfoParser() : level_(TopLevel) {
+DiscoInfoParser::DiscoInfoParser() : level_(TopLevel), formParser_(NULL) {
}
-void DiscoInfoParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) {
+void DiscoInfoParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) {
if (level_ == PayloadLevel) {
if (element == "identity") {
getPayloadInternal()->addIdentity(DiscoInfo::Identity(attributes.getAttribute("name"), attributes.getAttribute("category"), attributes.getAttribute("type"), attributes.getAttribute("lang")));
@@ -19,15 +20,33 @@ void DiscoInfoParser::handleStartElement(const String& element, const String&, c
else if (element == "feature") {
getPayloadInternal()->addFeature(attributes.getAttribute("var"));
}
+ else if (element == "x" && ns == "jabber:x:data") {
+ assert(!formParser_);
+ formParser_ = new FormParser();
+ }
+ }
+ if (formParser_) {
+ formParser_->handleStartElement(element, ns, attributes);
}
++level_;
}
-void DiscoInfoParser::handleEndElement(const String&, const String&) {
+void DiscoInfoParser::handleEndElement(const String& element, const String& ns) {
--level_;
+ if (formParser_) {
+ formParser_->handleEndElement(element, ns);
+ }
+ if (level_ == PayloadLevel && formParser_) {
+ getPayloadInternal()->addExtension(formParser_->getPayloadInternal());
+ delete formParser_;
+ formParser_ = NULL;
+ }
}
-void DiscoInfoParser::handleCharacterData(const String&) {
+void DiscoInfoParser::handleCharacterData(const String& data) {
+ if (formParser_) {
+ formParser_->handleCharacterData(data);
+ }
}
}