summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser')
-rw-r--r--Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp30
-rw-r--r--Swiften/Parser/PayloadParsers/DiscoItemsParser.h29
-rw-r--r--Swiften/Parser/PayloadParsers/DiscoItemsParserFactory.h18
-rw-r--r--Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp2
-rw-r--r--Swiften/Parser/SConscript1
5 files changed, 80 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp b/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp
new file mode 100644
index 0000000..0900354
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Parser/PayloadParsers/DiscoItemsParser.h"
+
+namespace Swift {
+
+DiscoItemsParser::DiscoItemsParser() : level_(TopLevel) {
+}
+
+void DiscoItemsParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) {
+ if (level_ == PayloadLevel) {
+ if (element == "item") {
+ getPayloadInternal()->addItem(DiscoItems::Item(attributes.getAttribute("name"), JID(attributes.getAttribute("jid")), attributes.getAttribute("node")));
+ }
+ }
+ ++level_;
+}
+
+void DiscoItemsParser::handleEndElement(const String&, const String&) {
+ --level_;
+}
+
+void DiscoItemsParser::handleCharacterData(const String&) {
+}
+
+}
diff --git a/Swiften/Parser/PayloadParsers/DiscoItemsParser.h b/Swiften/Parser/PayloadParsers/DiscoItemsParser.h
new file mode 100644
index 0000000..e3da34e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/DiscoItemsParser.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/Elements/DiscoItems.h"
+#include "Swiften/Parser/GenericPayloadParser.h"
+
+namespace Swift {
+ class DiscoItemsParser : public GenericPayloadParser<DiscoItems> {
+ public:
+ DiscoItemsParser();
+
+ virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes);
+ virtual void handleEndElement(const String& element, const String&);
+ virtual void handleCharacterData(const String& data);
+
+ private:
+ enum Level {
+ TopLevel = 0,
+ PayloadLevel = 1
+ };
+ int level_;
+ };
+}
+
diff --git a/Swiften/Parser/PayloadParsers/DiscoItemsParserFactory.h b/Swiften/Parser/PayloadParsers/DiscoItemsParserFactory.h
new file mode 100644
index 0000000..5b53031
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/DiscoItemsParserFactory.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/Parser/GenericPayloadParserFactory.h"
+#include "Swiften/Parser/PayloadParsers/DiscoItemsParser.h"
+
+namespace Swift {
+ class DiscoItemsParserFactory : public GenericPayloadParserFactory<DiscoItemsParser> {
+ public:
+ DiscoItemsParserFactory() : GenericPayloadParserFactory<DiscoItemsParser>("query", "http://jabber.org/protocol/disco#items") {}
+ };
+}
+
diff --git a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
index b0e4eb2..8c570cb 100644
--- a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
+++ b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp
@@ -20,6 +20,7 @@
#include "Swiften/Parser/PayloadParsers/SoftwareVersionParserFactory.h"
#include "Swiften/Parser/PayloadParsers/StorageParserFactory.h"
#include "Swiften/Parser/PayloadParsers/DiscoInfoParserFactory.h"
+#include "Swiften/Parser/PayloadParsers/DiscoItemsParserFactory.h"
#include "Swiften/Parser/PayloadParsers/SecurityLabelParserFactory.h"
#include "Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParserFactory.h"
#include "Swiften/Parser/PayloadParsers/VCardUpdateParserFactory.h"
@@ -42,6 +43,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() {
factories_.push_back(shared_ptr<PayloadParserFactory>(new StorageParserFactory()));
factories_.push_back(shared_ptr<PayloadParserFactory>(new RosterParserFactory()));
factories_.push_back(shared_ptr<PayloadParserFactory>(new DiscoInfoParserFactory()));
+ factories_.push_back(shared_ptr<PayloadParserFactory>(new DiscoItemsParserFactory()));
factories_.push_back(shared_ptr<PayloadParserFactory>(new ResourceBindParserFactory()));
factories_.push_back(shared_ptr<PayloadParserFactory>(new StartSessionParserFactory()));
factories_.push_back(shared_ptr<PayloadParserFactory>(new SecurityLabelParserFactory()));
diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript
index 0d3aad2..77f50be 100644
--- a/Swiften/Parser/SConscript
+++ b/Swiften/Parser/SConscript
@@ -20,6 +20,7 @@ sources = [
"PayloadParsers/BodyParser.cpp",
"PayloadParsers/ChatStateParser.cpp",
"PayloadParsers/DiscoInfoParser.cpp",
+ "PayloadParsers/DiscoItemsParser.cpp",
"PayloadParsers/ErrorParser.cpp",
"PayloadParsers/FullPayloadParserFactoryCollection.cpp",
"PayloadParsers/PriorityParser.cpp",