summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h20
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp2
3 files changed, 58 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp
new file mode 100644
index 0000000..056c515
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Base/foreach.h"
+#include "Swiften/Serializer/XML/XMLElement.h"
+
+namespace Swift {
+
+DiscoItemsSerializer::DiscoItemsSerializer() : GenericPayloadSerializer<DiscoItems>() {
+}
+
+String DiscoItemsSerializer::serializePayload(boost::shared_ptr<DiscoItems> discoItems) const {
+ XMLElement queryElement("query", "http://jabber.org/protocol/disco#items");
+ if (!discoItems->getNode().isEmpty()) {
+ queryElement.setAttribute("node", discoItems->getNode());
+ }
+ foreach(const DiscoItems::Item& item, discoItems->getItems()) {
+ boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
+ itemElement->setAttribute("name", item.getName());
+ itemElement->setAttribute("jid", item.getJID());
+ if (!item.getNode().isEmpty()) {
+ itemElement->setAttribute("node", item.getNode());
+ }
+ queryElement.addNode(itemElement);
+ }
+ return queryElement.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h
new file mode 100644
index 0000000..8116e9b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h
@@ -0,0 +1,20 @@
+/*
+ * 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/Serializer/GenericPayloadSerializer.h"
+#include "Swiften/Elements/DiscoItems.h"
+
+namespace Swift {
+ class DiscoItemsSerializer : public GenericPayloadSerializer<DiscoItems> {
+ public:
+ DiscoItemsSerializer();
+
+ virtual String serializePayload(boost::shared_ptr<DiscoItems>) const;
+ };
+}
+
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index 8dc9d86..caf1d9c 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -17,6 +17,7 @@
#include "Swiften/Serializer/PayloadSerializers/StatusSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h"
@@ -42,6 +43,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new StatusSerializer());
serializers_.push_back(new StatusShowSerializer());
serializers_.push_back(new DiscoInfoSerializer());
+ serializers_.push_back(new DiscoItemsSerializer());
serializers_.push_back(new CapsInfoSerializer());
serializers_.push_back(new ResourceBindSerializer());
serializers_.push_back(new StartSessionSerializer());