summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-09-14 18:57:59 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-09-14 19:15:45 (GMT)
commitb8201141afdbd4cab6fcda37cf8daad492b1f996 (patch)
treeab4908b05a7bb0b1fe97bc4609b68dd9c0b538a9 /Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
parent5e3ef73cc312d0d79504faa3e0adf4de9bf836c2 (diff)
downloadswift-contrib-b8201141afdbd4cab6fcda37cf8daad492b1f996.zip
swift-contrib-b8201141afdbd4cab6fcda37cf8daad492b1f996.tar.bz2
Added private storage element, parser, and serializer.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp')
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
new file mode 100644
index 0000000..999252c
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
@@ -0,0 +1,28 @@
+#include "Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Base/foreach.h"
+#include "Swiften/Serializer/XML/XMLElement.h"
+#include "Swiften/Serializer/XML/XMLTextNode.h"
+#include "Swiften/Serializer/XML/XMLRawTextNode.h"
+#include "Swiften/Serializer/PayloadSerializerCollection.h"
+
+namespace Swift {
+
+PrivateStorageSerializer::PrivateStorageSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
+}
+
+String PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const {
+ XMLElement storageElement("query", "jabber:iq:private");
+ boost::shared_ptr<Payload> payload = storage->getPayload();
+ if (payload) {
+ PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
+ if (serializer) {
+ storageElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(payload))));
+ }
+ }
+ return storageElement.serialize();
+}
+
+}