summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp13
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp45
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp40
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp44
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp111
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h28
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp39
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp35
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp35
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp45
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp42
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp51
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp48
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp37
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp45
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp39
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp45
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp38
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp37
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp34
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp35
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp51
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp43
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp38
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp38
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp39
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp69
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSerializer.h29
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp33
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp51
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp40
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp39
-rw-r--r--Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h31
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp94
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h19
-rw-r--r--Swiften/Serializer/XML/XMLElement.cpp4
82 files changed, 2956 insertions, 2 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index 3f45a7c..a57a74e 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -51,7 +51,12 @@
#include <Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/LastSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/IdleSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h>
@@ -111,6 +116,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new ReplaceSerializer());
serializers_.push_back(new LastSerializer());
serializers_.push_back(new WhiteboardSerializer());
+ serializers_.push_back(new UserLocationSerializer());
serializers_.push_back(new IdleSerializer());
serializers_.push_back(new StreamInitiationFileInfoSerializer());
@@ -124,6 +130,11 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new S5BProxyRequestSerializer());
serializers_.push_back(new DeliveryReceiptSerializer());
serializers_.push_back(new DeliveryReceiptRequestSerializer());
+
+ serializers_.push_back(new PubSubSerializer(this));
+ serializers_.push_back(new PubSubEventSerializer(this));
+ serializers_.push_back(new PubSubOwnerPubSubSerializer(this));
+ serializers_.push_back(new PubSubErrorSerializer());
foreach(PayloadSerializer* serializer, serializers_) {
addSerializer(serializer);
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp
new file mode 100644
index 0000000..d5d5ead
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubAffiliationSerializer::PubSubAffiliationSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubAffiliationSerializer::~PubSubAffiliationSerializer() {
+}
+
+std::string PubSubAffiliationSerializer::serializePayload(boost::shared_ptr<PubSubAffiliation> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliation", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("affiliation", serializeType(payload->getType()));
+ return element.serialize();
+}
+
+std::string PubSubAffiliationSerializer::serializeType(PubSubAffiliation::Type value) {
+ switch (value) {
+ case PubSubAffiliation::None: return "none";
+ case PubSubAffiliation::Member: return "member";
+ case PubSubAffiliation::Outcast: return "outcast";
+ case PubSubAffiliation::Owner: return "owner";
+ case PubSubAffiliation::Publisher: return "publisher";
+ case PubSubAffiliation::PublishOnly: return "publish-only";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h
new file mode 100644
index 0000000..f6722c8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubAffiliation.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubAffiliationSerializer : public GenericPayloadSerializer<PubSubAffiliation> {
+ public:
+ PubSubAffiliationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubAffiliationSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliation>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeType(PubSubAffiliation::Type);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp
new file mode 100644
index 0000000..25a0786
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubAffiliationsSerializer::PubSubAffiliationsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubAffiliationsSerializer::~PubSubAffiliationsSerializer() {
+}
+
+std::string PubSubAffiliationsSerializer::serializePayload(boost::shared_ptr<PubSubAffiliations> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliations", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ foreach(boost::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubAffiliationSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h
new file mode 100644
index 0000000..ba3c591
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubAffiliations.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubAffiliationsSerializer : public GenericPayloadSerializer<PubSubAffiliations> {
+ public:
+ PubSubAffiliationsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubAffiliationsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubAffiliations>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp
new file mode 100644
index 0000000..86a1ae8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubConfigureSerializer::PubSubConfigureSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubConfigureSerializer::~PubSubConfigureSerializer() {
+}
+
+std::string PubSubConfigureSerializer::serializePayload(boost::shared_ptr<PubSubConfigure> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configure", "http://jabber.org/protocol/pubsub");
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h
new file mode 100644
index 0000000..093fd35
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubConfigure.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubConfigureSerializer : public GenericPayloadSerializer<PubSubConfigure> {
+ public:
+ PubSubConfigureSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubConfigureSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubConfigure>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp
new file mode 100644
index 0000000..73b2703
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubCreateSerializer::PubSubCreateSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubCreateSerializer::~PubSubCreateSerializer() {
+}
+
+std::string PubSubCreateSerializer::serializePayload(boost::shared_ptr<PubSubCreate> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("create", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h
new file mode 100644
index 0000000..29c2393
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubCreate.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubCreateSerializer : public GenericPayloadSerializer<PubSubCreate> {
+ public:
+ PubSubCreateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubCreateSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubCreate>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp
new file mode 100644
index 0000000..d395c80
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubDefaultSerializer::PubSubDefaultSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubDefaultSerializer::~PubSubDefaultSerializer() {
+}
+
+std::string PubSubDefaultSerializer::serializePayload(boost::shared_ptr<PubSubDefault> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("default", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("type", serializeType(payload->getType()));
+ return element.serialize();
+}
+
+std::string PubSubDefaultSerializer::serializeType(PubSubDefault::Type value) {
+ switch (value) {
+ case PubSubDefault::None: return "none";
+ case PubSubDefault::Collection: return "collection";
+ case PubSubDefault::Leaf: return "leaf";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h
new file mode 100644
index 0000000..e7b8a6f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubDefault.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubDefaultSerializer : public GenericPayloadSerializer<PubSubDefault> {
+ public:
+ PubSubDefaultSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubDefaultSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubDefault>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeType(PubSubDefault::Type);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp
new file mode 100644
index 0000000..a25b71e
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+using namespace Swift;
+
+PubSubErrorSerializer::PubSubErrorSerializer() {
+}
+
+PubSubErrorSerializer::~PubSubErrorSerializer() {
+}
+
+std::string PubSubErrorSerializer::serializePayload(boost::shared_ptr<PubSubError> payload) const {
+ if (payload->getType() == PubSubError::UnknownType) {
+ return "";
+ }
+ XMLElement element(serializeType(payload->getType()), "http://jabber.org/protocol/pubsub#errors");
+ if (payload->getType() == PubSubError::Unsupported) {
+ if (payload->getUnsupportedFeatureType() != PubSubError::UnknownUnsupportedFeatureType) {
+ element.setAttribute("feature", serializeUnsupportedFeatureType(payload->getUnsupportedFeatureType()));
+ }
+ }
+ return element.serialize();
+}
+
+std::string PubSubErrorSerializer::serializeType(PubSubError::Type value) {
+ switch (value) {
+ case PubSubError::UnknownType: assert(false); return "";
+ case PubSubError::ClosedNode: return "closed-node";
+ case PubSubError::ConfigurationRequired: return "configuration-required";
+ case PubSubError::InvalidJID: return "invalid-jid";
+ case PubSubError::InvalidOptions: return "invalid-options";
+ case PubSubError::InvalidPayload: return "invalid-payload";
+ case PubSubError::InvalidSubscriptionID: return "invalid-subid";
+ case PubSubError::ItemForbidden: return "item-forbidden";
+ case PubSubError::ItemRequired: return "item-required";
+ case PubSubError::JIDRequired: return "jid-required";
+ case PubSubError::MaximumItemsExceeded: return "max-items-exceeded";
+ case PubSubError::MaximumNodesExceeded: return "max-nodes-exceeded";
+ case PubSubError::NodeIDRequired: return "nodeid-required";
+ case PubSubError::NotInRosterGroup: return "not-in-roster-group";
+ case PubSubError::NotSubscribed: return "not-subscribed";
+ case PubSubError::PayloadTooBig: return "payload-too-big";
+ case PubSubError::PayloadRequired: return "payload-required";
+ case PubSubError::PendingSubscription: return "pending-subscription";
+ case PubSubError::PresenceSubscriptionRequired: return "presence-subscription-required";
+ case PubSubError::SubscriptionIDRequired: return "subid-required";
+ case PubSubError::TooManySubscriptions: return "too-many-subscriptions";
+ case PubSubError::Unsupported: return "unsupported";
+ case PubSubError::UnsupportedAccessModel: return "unsupported-access-model";
+ }
+ assert(false);
+ return "";
+}
+
+std::string PubSubErrorSerializer::serializeUnsupportedFeatureType(PubSubError::UnsupportedFeatureType value) {
+ switch (value) {
+ case PubSubError::UnknownUnsupportedFeatureType: assert(false); return "";
+ case PubSubError::AccessAuthorize: return "access-authorize";
+ case PubSubError::AccessOpen: return "access-open";
+ case PubSubError::AccessPresence: return "access-presence";
+ case PubSubError::AccessRoster: return "access-roster";
+ case PubSubError::AccessWhitelist: return "access-whitelist";
+ case PubSubError::AutoCreate: return "auto-create";
+ case PubSubError::AutoSubscribe: return "auto-subscribe";
+ case PubSubError::Collections: return "collections";
+ case PubSubError::ConfigNode: return "config-node";
+ case PubSubError::CreateAndConfigure: return "create-and-configure";
+ case PubSubError::CreateNodes: return "create-nodes";
+ case PubSubError::DeleteItems: return "delete-items";
+ case PubSubError::DeleteNodes: return "delete-nodes";
+ case PubSubError::FilteredNotifications: return "filtered-notifications";
+ case PubSubError::GetPending: return "get-pending";
+ case PubSubError::InstantNodes: return "instant-nodes";
+ case PubSubError::ItemIDs: return "item-ids";
+ case PubSubError::LastPublished: return "last-published";
+ case PubSubError::LeasedSubscription: return "leased-subscription";
+ case PubSubError::ManageSubscriptions: return "manage-subscriptions";
+ case PubSubError::MemberAffiliation: return "member-affiliation";
+ case PubSubError::MetaData: return "meta-data";
+ case PubSubError::ModifyAffiliations: return "modify-affiliations";
+ case PubSubError::MultiCollection: return "multi-collection";
+ case PubSubError::MultiSubscribe: return "multi-subscribe";
+ case PubSubError::OutcastAffiliation: return "outcast-affiliation";
+ case PubSubError::PersistentItems: return "persistent-items";
+ case PubSubError::PresenceNotifications: return "presence-notifications";
+ case PubSubError::PresenceSubscribe: return "presence-subscribe";
+ case PubSubError::Publish: return "publish";
+ case PubSubError::PublishOptions: return "publish-options";
+ case PubSubError::PublishOnlyAffiliation: return "publish-only-affiliation";
+ case PubSubError::PublisherAffiliation: return "publisher-affiliation";
+ case PubSubError::PurgeNodes: return "purge-nodes";
+ case PubSubError::RetractItems: return "retract-items";
+ case PubSubError::RetrieveAffiliations: return "retrieve-affiliations";
+ case PubSubError::RetrieveDefault: return "retrieve-default";
+ case PubSubError::RetrieveItems: return "retrieve-items";
+ case PubSubError::RetrieveSubscriptions: return "retrieve-subscriptions";
+ case PubSubError::Subscribe: return "subscribe";
+ case PubSubError::SubscriptionOptions: return "subscription-options";
+ case PubSubError::SubscriptionNotifications: return "subscription-notifications";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h
new file mode 100644
index 0000000..3ee09ce
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubErrorSerializer.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubError.h>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubErrorSerializer : public GenericPayloadSerializer<PubSubError> {
+ public:
+ PubSubErrorSerializer();
+ virtual ~PubSubErrorSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubError>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeType(PubSubError::Type);
+ static std::string serializeUnsupportedFeatureType(PubSubError::UnsupportedFeatureType);
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp
new file mode 100644
index 0000000..1baf7e4
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubEventAssociateSerializer::PubSubEventAssociateSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventAssociateSerializer::~PubSubEventAssociateSerializer() {
+}
+
+std::string PubSubEventAssociateSerializer::serializePayload(boost::shared_ptr<PubSubEventAssociate> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("associate", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h
new file mode 100644
index 0000000..60cf9c7
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventAssociate.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventAssociateSerializer : public GenericPayloadSerializer<PubSubEventAssociate> {
+ public:
+ PubSubEventAssociateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventAssociateSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventAssociate>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp
new file mode 100644
index 0000000..b44acaa
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventAssociateSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubEventCollectionSerializer::PubSubEventCollectionSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventCollectionSerializer::~PubSubEventCollectionSerializer() {
+}
+
+std::string PubSubEventCollectionSerializer::serializePayload(boost::shared_ptr<PubSubEventCollection> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("collection", "http://jabber.org/protocol/pubsub#event");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventDisassociateSerializer(serializers).serialize(payload->getDisassociate())));
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventAssociateSerializer(serializers).serialize(payload->getAssociate())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h
new file mode 100644
index 0000000..ac5e7c4
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventCollection.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventCollectionSerializer : public GenericPayloadSerializer<PubSubEventCollection> {
+ public:
+ PubSubEventCollectionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventCollectionSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventCollection>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp
new file mode 100644
index 0000000..f478e4f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubEventConfigurationSerializer::PubSubEventConfigurationSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventConfigurationSerializer::~PubSubEventConfigurationSerializer() {
+}
+
+std::string PubSubEventConfigurationSerializer::serializePayload(boost::shared_ptr<PubSubEventConfiguration> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configuration", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h
new file mode 100644
index 0000000..6a73496
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventConfiguration.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventConfigurationSerializer : public GenericPayloadSerializer<PubSubEventConfiguration> {
+ public:
+ PubSubEventConfigurationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventConfigurationSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventConfiguration>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp
new file mode 100644
index 0000000..b45adb8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubEventDeleteSerializer::PubSubEventDeleteSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventDeleteSerializer::~PubSubEventDeleteSerializer() {
+}
+
+std::string PubSubEventDeleteSerializer::serializePayload(boost::shared_ptr<PubSubEventDelete> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("delete", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRedirectSerializer(serializers).serialize(payload->getRedirects())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h
new file mode 100644
index 0000000..10de3c3
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventDelete.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventDeleteSerializer : public GenericPayloadSerializer<PubSubEventDelete> {
+ public:
+ PubSubEventDeleteSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventDeleteSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventDelete>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp
new file mode 100644
index 0000000..60cc562
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubEventDisassociateSerializer::PubSubEventDisassociateSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventDisassociateSerializer::~PubSubEventDisassociateSerializer() {
+}
+
+std::string PubSubEventDisassociateSerializer::serializePayload(boost::shared_ptr<PubSubEventDisassociate> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("disassociate", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h
new file mode 100644
index 0000000..c7187c7
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventDisassociateSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventDisassociate.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventDisassociateSerializer : public GenericPayloadSerializer<PubSubEventDisassociate> {
+ public:
+ PubSubEventDisassociateSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventDisassociateSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventDisassociate>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp
new file mode 100644
index 0000000..2b8b08e
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubEventItemSerializer::PubSubEventItemSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventItemSerializer::~PubSubEventItemSerializer() {
+}
+
+std::string PubSubEventItemSerializer::serializePayload(boost::shared_ptr<PubSubEventItem> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("item", "http://jabber.org/protocol/pubsub#event");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ if (payload->getPublisher()) {
+ element.setAttribute("publisher", *payload->getPublisher());
+ }
+ foreach(boost::shared_ptr<Payload> item, payload->getData()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
+ }
+ if (payload->getID()) {
+ element.setAttribute("id", *payload->getID());
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h
new file mode 100644
index 0000000..93fa5b0
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventItem.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventItemSerializer : public GenericPayloadSerializer<PubSubEventItem> {
+ public:
+ PubSubEventItemSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventItemSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventItem>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp
new file mode 100644
index 0000000..099aa4b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubEventItemsSerializer::PubSubEventItemsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventItemsSerializer::~PubSubEventItemsSerializer() {
+}
+
+std::string PubSubEventItemsSerializer::serializePayload(boost::shared_ptr<PubSubEventItems> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("items", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubEventItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventItemSerializer(serializers).serialize(item)));
+ }
+ foreach(boost::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubEventRetractSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h
new file mode 100644
index 0000000..6e60ee4
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventItems.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventItemsSerializer : public GenericPayloadSerializer<PubSubEventItems> {
+ public:
+ PubSubEventItemsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventItemsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventItems>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp
new file mode 100644
index 0000000..1387848
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubEventPurgeSerializer::PubSubEventPurgeSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventPurgeSerializer::~PubSubEventPurgeSerializer() {
+}
+
+std::string PubSubEventPurgeSerializer::serializePayload(boost::shared_ptr<PubSubEventPurge> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("purge", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h
new file mode 100644
index 0000000..ab2d1d8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventPurge.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventPurgeSerializer : public GenericPayloadSerializer<PubSubEventPurge> {
+ public:
+ PubSubEventPurgeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventPurgeSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventPurge>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp
new file mode 100644
index 0000000..7134e58
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubEventRedirectSerializer::PubSubEventRedirectSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventRedirectSerializer::~PubSubEventRedirectSerializer() {
+}
+
+std::string PubSubEventRedirectSerializer::serializePayload(boost::shared_ptr<PubSubEventRedirect> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("redirect", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("uri", payload->getURI());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h
new file mode 100644
index 0000000..751ff19
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRedirectSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventRedirect.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventRedirectSerializer : public GenericPayloadSerializer<PubSubEventRedirect> {
+ public:
+ PubSubEventRedirectSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventRedirectSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventRedirect>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp
new file mode 100644
index 0000000..17d1a0f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubEventRetractSerializer::PubSubEventRetractSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventRetractSerializer::~PubSubEventRetractSerializer() {
+}
+
+std::string PubSubEventRetractSerializer::serializePayload(boost::shared_ptr<PubSubEventRetract> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("retract", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("id", payload->getID());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h
new file mode 100644
index 0000000..0d73ec8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventRetract.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventRetractSerializer : public GenericPayloadSerializer<PubSubEventRetract> {
+ public:
+ PubSubEventRetractSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventRetractSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventRetract>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp
new file mode 100644
index 0000000..da813cd
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventPurgeSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h>
+#include <Swiften/Base/foreach.h>
+
+using namespace Swift;
+
+PubSubEventSerializer::PubSubEventSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventSubscriptionSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventPurgeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventCollectionSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventDeleteSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventItemsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubEventConfigurationSerializer>(serializers));
+}
+
+PubSubEventSerializer::~PubSubEventSerializer() {
+}
+
+std::string PubSubEventSerializer::serializePayload(boost::shared_ptr<PubSubEvent> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("event", "http://jabber.org/protocol/pubsub#event");
+ boost::shared_ptr<PubSubEventPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ }
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h
new file mode 100644
index 0000000..85b5b90
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEvent.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventSerializer : public GenericPayloadSerializer<PubSubEvent> {
+ public:
+ PubSubEventSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEvent>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp
new file mode 100644
index 0000000..9b0a334
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/DateTime.h>
+
+using namespace Swift;
+
+PubSubEventSubscriptionSerializer::PubSubEventSubscriptionSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubEventSubscriptionSerializer::~PubSubEventSubscriptionSerializer() {
+}
+
+std::string PubSubEventSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubEventSubscription> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub#event");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ element.setAttribute("expiry", dateTimeToString(payload->getExpiry()));
+ return element.serialize();
+}
+
+std::string PubSubEventSubscriptionSerializer::serializeSubscriptionType(PubSubEventSubscription::SubscriptionType value) {
+ switch (value) {
+ case PubSubEventSubscription::None: return "none";
+ case PubSubEventSubscription::Pending: return "pending";
+ case PubSubEventSubscription::Subscribed: return "subscribed";
+ case PubSubEventSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h
new file mode 100644
index 0000000..3b613bd
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSubscriptionSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubEventSubscription.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubEventSubscriptionSerializer : public GenericPayloadSerializer<PubSubEventSubscription> {
+ public:
+ PubSubEventSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubEventSubscriptionSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubEventSubscription>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeSubscriptionType(PubSubEventSubscription::SubscriptionType);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
new file mode 100644
index 0000000..5a82b42
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubItemSerializer::PubSubItemSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubItemSerializer::~PubSubItemSerializer() {
+}
+
+std::string PubSubItemSerializer::serializePayload(boost::shared_ptr<PubSubItem> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("item", "http://jabber.org/protocol/pubsub");
+ foreach(boost::shared_ptr<Payload> item, payload->getData()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item)));
+ }
+ element.setAttribute("id", payload->getID());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
new file mode 100644
index 0000000..56f186d
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubItem.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubItemSerializer : public GenericPayloadSerializer<PubSubItem> {
+ public:
+ PubSubItemSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubItemSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubItem>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp
new file mode 100644
index 0000000..6bffa6a
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/lexical_cast.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubItemsSerializer::PubSubItemsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubItemsSerializer::~PubSubItemsSerializer() {
+}
+
+std::string PubSubItemsSerializer::serializePayload(boost::shared_ptr<PubSubItems> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("items", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ if (payload->getMaximumItems()) {
+ element.setAttribute("max_items", boost::lexical_cast<std::string>(*payload->getMaximumItems()));
+ }
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h
new file mode 100644
index 0000000..050e156
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubItems.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubItemsSerializer : public GenericPayloadSerializer<PubSubItems> {
+ public:
+ PubSubItemsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubItemsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubItems>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp
new file mode 100644
index 0000000..db983b9
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOptionsSerializer::PubSubOptionsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOptionsSerializer::~PubSubOptionsSerializer() {
+}
+
+std::string PubSubOptionsSerializer::serializePayload(boost::shared_ptr<PubSubOptions> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("options", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ element.setAttribute("jid", payload->getJID());
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h
new file mode 100644
index 0000000..258f1f2
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOptions.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOptionsSerializer : public GenericPayloadSerializer<PubSubOptions> {
+ public:
+ PubSubOptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOptionsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOptions>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp
new file mode 100644
index 0000000..3699b8e
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubOwnerAffiliationSerializer::PubSubOwnerAffiliationSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerAffiliationSerializer::~PubSubOwnerAffiliationSerializer() {
+}
+
+std::string PubSubOwnerAffiliationSerializer::serializePayload(boost::shared_ptr<PubSubOwnerAffiliation> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliation", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("affiliation", serializeType(payload->getType()));
+ return element.serialize();
+}
+
+std::string PubSubOwnerAffiliationSerializer::serializeType(PubSubOwnerAffiliation::Type value) {
+ switch (value) {
+ case PubSubOwnerAffiliation::None: return "none";
+ case PubSubOwnerAffiliation::Member: return "member";
+ case PubSubOwnerAffiliation::Outcast: return "outcast";
+ case PubSubOwnerAffiliation::Owner: return "owner";
+ case PubSubOwnerAffiliation::Publisher: return "publisher";
+ case PubSubOwnerAffiliation::PublishOnly: return "publish-only";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h
new file mode 100644
index 0000000..acea723
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerAffiliation.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerAffiliationSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliation> {
+ public:
+ PubSubOwnerAffiliationSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerAffiliationSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliation>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeType(PubSubOwnerAffiliation::Type);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp
new file mode 100644
index 0000000..c393bfb
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOwnerAffiliationsSerializer::PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerAffiliationsSerializer::~PubSubOwnerAffiliationsSerializer() {
+}
+
+std::string PubSubOwnerAffiliationsSerializer::serializePayload(boost::shared_ptr<PubSubOwnerAffiliations> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("affiliations", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubOwnerAffiliation> item, payload->getAffiliations()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerAffiliationSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h
new file mode 100644
index 0000000..3d20042
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerAffiliations.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerAffiliationsSerializer : public GenericPayloadSerializer<PubSubOwnerAffiliations> {
+ public:
+ PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerAffiliationsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerAffiliations>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp
new file mode 100644
index 0000000..154a370
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOwnerConfigureSerializer::PubSubOwnerConfigureSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerConfigureSerializer::~PubSubOwnerConfigureSerializer() {
+}
+
+std::string PubSubOwnerConfigureSerializer::serializePayload(boost::shared_ptr<PubSubOwnerConfigure> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("configure", "http://jabber.org/protocol/pubsub#owner");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h
new file mode 100644
index 0000000..41f2a9d
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerConfigure.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerConfigureSerializer : public GenericPayloadSerializer<PubSubOwnerConfigure> {
+ public:
+ PubSubOwnerConfigureSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerConfigureSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerConfigure>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp
new file mode 100644
index 0000000..7ce2e71
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOwnerDefaultSerializer::PubSubOwnerDefaultSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerDefaultSerializer::~PubSubOwnerDefaultSerializer() {
+}
+
+std::string PubSubOwnerDefaultSerializer::serializePayload(boost::shared_ptr<PubSubOwnerDefault> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("default", "http://jabber.org/protocol/pubsub#owner");
+ element.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(payload->getData())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h
new file mode 100644
index 0000000..02aefe8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerDefault.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerDefaultSerializer : public GenericPayloadSerializer<PubSubOwnerDefault> {
+ public:
+ PubSubOwnerDefaultSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerDefaultSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDefault>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp
new file mode 100644
index 0000000..010645c
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOwnerDeleteSerializer::PubSubOwnerDeleteSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerDeleteSerializer::~PubSubOwnerDeleteSerializer() {
+}
+
+std::string PubSubOwnerDeleteSerializer::serializePayload(boost::shared_ptr<PubSubOwnerDelete> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("delete", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerRedirectSerializer(serializers).serialize(payload->getRedirect())));
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h
new file mode 100644
index 0000000..d537a4f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerDelete.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerDeleteSerializer : public GenericPayloadSerializer<PubSubOwnerDelete> {
+ public:
+ PubSubOwnerDeleteSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerDeleteSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerDelete>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp
new file mode 100644
index 0000000..de7d5a5
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerDeleteSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h>
+#include <Swiften/Base/foreach.h>
+
+using namespace Swift;
+
+PubSubOwnerPubSubSerializer::PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerConfigureSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerSubscriptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDefaultSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerPurgeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerAffiliationsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOwnerDeleteSerializer>(serializers));
+}
+
+PubSubOwnerPubSubSerializer::~PubSubOwnerPubSubSerializer() {
+}
+
+std::string PubSubOwnerPubSubSerializer::serializePayload(boost::shared_ptr<PubSubOwnerPubSub> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("pubsub", "http://jabber.org/protocol/pubsub#owner");
+ boost::shared_ptr<PubSubOwnerPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ }
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h
new file mode 100644
index 0000000..9f5732b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerPubSub.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerPubSubSerializer : public GenericPayloadSerializer<PubSubOwnerPubSub> {
+ public:
+ PubSubOwnerPubSubSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerPubSubSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPubSub>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp
new file mode 100644
index 0000000..591cdf9
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubOwnerPurgeSerializer::PubSubOwnerPurgeSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerPurgeSerializer::~PubSubOwnerPurgeSerializer() {
+}
+
+std::string PubSubOwnerPurgeSerializer::serializePayload(boost::shared_ptr<PubSubOwnerPurge> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("purge", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h
new file mode 100644
index 0000000..51a086f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPurgeSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerPurge.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerPurgeSerializer : public GenericPayloadSerializer<PubSubOwnerPurge> {
+ public:
+ PubSubOwnerPurgeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerPurgeSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerPurge>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp
new file mode 100644
index 0000000..ea7d721
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubOwnerRedirectSerializer::PubSubOwnerRedirectSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerRedirectSerializer::~PubSubOwnerRedirectSerializer() {
+}
+
+std::string PubSubOwnerRedirectSerializer::serializePayload(boost::shared_ptr<PubSubOwnerRedirect> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("redirect", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("uri", payload->getURI());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h
new file mode 100644
index 0000000..e5d5af5
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerRedirectSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerRedirect.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerRedirectSerializer : public GenericPayloadSerializer<PubSubOwnerRedirect> {
+ public:
+ PubSubOwnerRedirectSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerRedirectSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerRedirect>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp
new file mode 100644
index 0000000..91bc00b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubOwnerSubscriptionSerializer::PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerSubscriptionSerializer::~PubSubOwnerSubscriptionSerializer() {
+}
+
+std::string PubSubOwnerSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubOwnerSubscription> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("jid", payload->getJID());
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ return element.serialize();
+}
+
+std::string PubSubOwnerSubscriptionSerializer::serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType value) {
+ switch (value) {
+ case PubSubOwnerSubscription::None: return "none";
+ case PubSubOwnerSubscription::Pending: return "pending";
+ case PubSubOwnerSubscription::Subscribed: return "subscribed";
+ case PubSubOwnerSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h
new file mode 100644
index 0000000..4cecca7
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerSubscription.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerSubscriptionSerializer : public GenericPayloadSerializer<PubSubOwnerSubscription> {
+ public:
+ PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerSubscriptionSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscription>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeSubscriptionType(PubSubOwnerSubscription::SubscriptionType);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp
new file mode 100644
index 0000000..c265662
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubOwnerSubscriptionsSerializer::PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubOwnerSubscriptionsSerializer::~PubSubOwnerSubscriptionsSerializer() {
+}
+
+std::string PubSubOwnerSubscriptionsSerializer::serializePayload(boost::shared_ptr<PubSubOwnerSubscriptions> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub#owner");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubOwnerSubscription> item, payload->getSubscriptions()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubOwnerSubscriptionSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h
new file mode 100644
index 0000000..d77bc99
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubOwnerSubscriptions.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubOwnerSubscriptionsSerializer : public GenericPayloadSerializer<PubSubOwnerSubscriptions> {
+ public:
+ PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubOwnerSubscriptionsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubOwnerSubscriptions>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp
new file mode 100644
index 0000000..5a150e0
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubPublishSerializer::PubSubPublishSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubPublishSerializer::~PubSubPublishSerializer() {
+}
+
+std::string PubSubPublishSerializer::serializePayload(boost::shared_ptr<PubSubPublish> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("publish", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h
new file mode 100644
index 0000000..9d53141
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubPublish.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubPublishSerializer : public GenericPayloadSerializer<PubSubPublish> {
+ public:
+ PubSubPublishSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubPublishSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubPublish>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp
new file mode 100644
index 0000000..3f1434b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubRetractSerializer::PubSubRetractSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubRetractSerializer::~PubSubRetractSerializer() {
+}
+
+std::string PubSubRetractSerializer::serializePayload(boost::shared_ptr<PubSubRetract> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("retract", "http://jabber.org/protocol/pubsub");
+ element.setAttribute("node", payload->getNode());
+ foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item)));
+ }
+ element.setAttribute("notify", payload->isNotify() ? "true" : "false");
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h
new file mode 100644
index 0000000..47a01af
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubRetract.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubRetractSerializer : public GenericPayloadSerializer<PubSubRetract> {
+ public:
+ PubSubRetractSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubRetractSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubRetract>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp
new file mode 100644
index 0000000..0e61331
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubCreateSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubOptionsSerializer.h>
+#include <Swiften/Base/foreach.h>
+
+using namespace Swift;
+
+PubSubSerializer::PubSubSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+ pubsubSerializers.push_back(boost::make_shared<PubSubItemsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubCreateSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubPublishSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubOptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubAffiliationsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubRetractSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubDefaultSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionsSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscribeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubUnsubscribeSerializer>(serializers));
+ pubsubSerializers.push_back(boost::make_shared<PubSubSubscriptionSerializer>(serializers));
+}
+
+PubSubSerializer::~PubSubSerializer() {
+}
+
+std::string PubSubSerializer::serializePayload(boost::shared_ptr<PubSub> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("pubsub", "http://jabber.org/protocol/pubsub");
+ boost::shared_ptr<PubSubPayload> p = payload->getPayload();
+ foreach(boost::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) {
+ if (serializer->canSerialize(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(p)));
+ if (boost::shared_ptr<PubSubCreate> create = boost::dynamic_pointer_cast<PubSubCreate>(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(create->getConfigure())));
+ }
+ if (boost::shared_ptr<PubSubSubscribe> subscribe = boost::dynamic_pointer_cast<PubSubSubscribe>(p)) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(boost::make_shared<PubSubConfigureSerializer>(serializers)->serialize(subscribe->getOptions())));
+ }
+ }
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h
new file mode 100644
index 0000000..7665800
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSub.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubSerializer : public GenericPayloadSerializer<PubSub> {
+ public:
+ PubSubSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSub>) const SWIFTEN_OVERRIDE;
+
+ private:
+ std::vector< boost::shared_ptr<PayloadSerializer> > pubsubSerializers;
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp
new file mode 100644
index 0000000..7a55228
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubSubscribeOptionsSerializer::PubSubSubscribeOptionsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubSubscribeOptionsSerializer::~PubSubSubscribeOptionsSerializer() {
+}
+
+std::string PubSubSubscribeOptionsSerializer::serializePayload(boost::shared_ptr<PubSubSubscribeOptions> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscribe-options", "http://jabber.org/protocol/pubsub");
+ element.addNode(payload->isRequired() ? boost::make_shared<XMLElement>("required", "") : boost::shared_ptr<XMLElement>());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h
new file mode 100644
index 0000000..6ffaac7
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubSubscribeOptions.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubSubscribeOptionsSerializer : public GenericPayloadSerializer<PubSubSubscribeOptions> {
+ public:
+ PubSubSubscribeOptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscribeOptionsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribeOptions>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp
new file mode 100644
index 0000000..83a73af
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubSubscribeSerializer::PubSubSubscribeSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubSubscribeSerializer::~PubSubSubscribeSerializer() {
+}
+
+std::string PubSubSubscribeSerializer::serializePayload(boost::shared_ptr<PubSubSubscribe> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscribe", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("jid", payload->getJID());
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h
new file mode 100644
index 0000000..b730a4d
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscribeSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubSubscribe.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubSubscribeSerializer : public GenericPayloadSerializer<PubSubSubscribe> {
+ public:
+ PubSubSubscribeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscribeSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscribe>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp
new file mode 100644
index 0000000..8a54afa
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscribeOptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubSubscriptionSerializer::PubSubSubscriptionSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubSubscriptionSerializer::~PubSubSubscriptionSerializer() {
+}
+
+std::string PubSubSubscriptionSerializer::serializePayload(boost::shared_ptr<PubSubSubscription> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscription", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ element.setAttribute("jid", payload->getJID());
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscribeOptionsSerializer(serializers).serialize(payload->getOptions())));
+ element.setAttribute("subscription", serializeSubscriptionType(payload->getSubscription()));
+ return element.serialize();
+}
+
+std::string PubSubSubscriptionSerializer::serializeSubscriptionType(PubSubSubscription::SubscriptionType value) {
+ switch (value) {
+ case PubSubSubscription::None: return "none";
+ case PubSubSubscription::Pending: return "pending";
+ case PubSubSubscription::Subscribed: return "subscribed";
+ case PubSubSubscription::Unconfigured: return "unconfigured";
+ }
+ assert(false);
+ return "";
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h
new file mode 100644
index 0000000..d03bb69
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubSubscription.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubSubscriptionSerializer : public GenericPayloadSerializer<PubSubSubscription> {
+ public:
+ PubSubSubscriptionSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscriptionSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscription>) const SWIFTEN_OVERRIDE;
+
+ private:
+ static std::string serializeSubscriptionType(PubSubSubscription::SubscriptionType);
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp
new file mode 100644
index 0000000..74f1123
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+#include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h>
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+
+using namespace Swift;
+
+PubSubSubscriptionsSerializer::PubSubSubscriptionsSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubSubscriptionsSerializer::~PubSubSubscriptionsSerializer() {
+}
+
+std::string PubSubSubscriptionsSerializer::serializePayload(boost::shared_ptr<PubSubSubscriptions> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ foreach(boost::shared_ptr<PubSubSubscription> item, payload->getSubscriptions()) {
+ element.addNode(boost::make_shared<XMLRawTextNode>(PubSubSubscriptionSerializer(serializers).serialize(item)));
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h
new file mode 100644
index 0000000..2b5d8fa
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubSubscriptions.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubSubscriptionsSerializer : public GenericPayloadSerializer<PubSubSubscriptions> {
+ public:
+ PubSubSubscriptionsSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubSubscriptionsSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubSubscriptions>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp
new file mode 100644
index 0000000..e0d6cd3
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma clang diagnostic ignored "-Wunused-private-field"
+
+#include <Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+
+#include <Swiften/Serializer/PayloadSerializerCollection.h>
+
+
+using namespace Swift;
+
+PubSubUnsubscribeSerializer::PubSubUnsubscribeSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+PubSubUnsubscribeSerializer::~PubSubUnsubscribeSerializer() {
+}
+
+std::string PubSubUnsubscribeSerializer::serializePayload(boost::shared_ptr<PubSubUnsubscribe> payload) const {
+ if (!payload) {
+ return "";
+ }
+ XMLElement element("unsubscribe", "http://jabber.org/protocol/pubsub");
+ if (payload->getNode()) {
+ element.setAttribute("node", *payload->getNode());
+ }
+ element.setAttribute("jid", payload->getJID());
+ if (payload->getSubscriptionID()) {
+ element.setAttribute("subid", *payload->getSubscriptionID());
+ }
+ return element.serialize();
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h
new file mode 100644
index 0000000..b4f6f62
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PubSubUnsubscribeSerializer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Base/API.h>
+#include <Swiften/Serializer/GenericPayloadSerializer.h>
+#include <Swiften/Elements/PubSubUnsubscribe.h>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+ class PayloadSerializerCollection;
+
+ class SWIFTEN_API PubSubUnsubscribeSerializer : public GenericPayloadSerializer<PubSubUnsubscribe> {
+ public:
+ PubSubUnsubscribeSerializer(PayloadSerializerCollection* serializers);
+ virtual ~PubSubUnsubscribeSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<PubSubUnsubscribe>) const SWIFTEN_OVERRIDE;
+
+ private:
+
+
+ private:
+ PayloadSerializerCollection* serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp
new file mode 100644
index 0000000..373276b
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include <Swiften/Base/foreach.h>
+#include <Swiften/Base/DateTime.h>
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+namespace Swift {
+
+UserLocationSerializer::UserLocationSerializer() {
+}
+
+std::string UserLocationSerializer::serializePayload(
+ boost::shared_ptr<UserLocation> payload) const {
+ XMLElement result("geoloc", "http://jabber.org/protocol/geoloc");
+ if (boost::optional<std::string> value = payload->getArea()) {
+ result.addNode(boost::make_shared<XMLElement>("area", "", *value));
+ }
+ else if (boost::optional<float> value = payload->getAltitude()) {
+ result.addNode(boost::make_shared<XMLElement>("alt", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<std::string> value = payload->getLocality()) {
+ result.addNode(boost::make_shared<XMLElement>("locality", "", *value));
+ }
+ else if (boost::optional<float> value = payload->getLatitude()) {
+ result.addNode(boost::make_shared<XMLElement>("lat", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<float> value = payload->getAccuracy()) {
+ result.addNode(boost::make_shared<XMLElement>("lon", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<std::string> value = payload->getDescription()) {
+ result.addNode(boost::make_shared<XMLElement>("description", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getCountryCode()) {
+ result.addNode(boost::make_shared<XMLElement>("countrycode", "", *value));
+ }
+ else if (boost::optional<boost::posix_time::ptime> value = payload->getTimestamp()) {
+ result.addNode(boost::make_shared<XMLElement>("timestamp", "", dateTimeToString(*value)));
+ }
+ else if (boost::optional<std::string> value = payload->getFloor()) {
+ result.addNode(boost::make_shared<XMLElement>("floor", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getBuilding()) {
+ result.addNode(boost::make_shared<XMLElement>("building", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getRoom()) {
+ result.addNode(boost::make_shared<XMLElement>("room", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getCountry()) {
+ result.addNode(boost::make_shared<XMLElement>("country", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getRegion()) {
+ result.addNode(boost::make_shared<XMLElement>("region", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getURI()) {
+ result.addNode(boost::make_shared<XMLElement>("uri", "", *value));
+ }
+ else if (boost::optional<float> value = payload->getLongitude()) {
+ result.addNode(boost::make_shared<XMLElement>("lon", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<float> value = payload->getError()) {
+ result.addNode(boost::make_shared<XMLElement>("error", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<std::string> value = payload->getPostalCode()) {
+ result.addNode(boost::make_shared<XMLElement>("postalcode", "", *value));
+ }
+ else if (boost::optional<float> value = payload->getBearing()) {
+ result.addNode(boost::make_shared<XMLElement>("bearing", "", boost::lexical_cast<std::string>(*value)));
+ }
+ else if (boost::optional<std::string> value = payload->getText()) {
+ result.addNode(boost::make_shared<XMLElement>("text", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getDatum()) {
+ result.addNode(boost::make_shared<XMLElement>("datum", "", *value));
+ }
+ else if (boost::optional<std::string> value = payload->getStreet()) {
+ result.addNode(boost::make_shared<XMLElement>("street", "", *value));
+ }
+ else if (boost::optional<float> value = payload->getSpeed()) {
+ result.addNode(boost::make_shared<XMLElement>("speed", "", boost::lexical_cast<std::string>(*value)));
+ }
+ return result.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h
new file mode 100644
index 0000000..28a5fe8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * 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/UserLocation.h>
+
+namespace Swift {
+ class UserLocationSerializer : public GenericPayloadSerializer<UserLocation> {
+ public:
+ UserLocationSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<UserLocation>) const;
+ };
+}
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp
index d39ec39..42b602a 100644
--- a/Swiften/Serializer/XML/XMLElement.cpp
+++ b/Swiften/Serializer/XML/XMLElement.cpp
@@ -52,7 +52,9 @@ void XMLElement::setAttribute(const std::string& attribute, const std::string& v
}
void XMLElement::addNode(boost::shared_ptr<XMLNode> node) {
- childNodes_.push_back(node);
+ if (node) {
+ childNodes_.push_back(node);
+ }
}
}