summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2014-01-19 11:46:51 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-01-19 16:49:19 (GMT)
commitcbd01a5368f0b761d2032d75c9f7dfde2bf61578 (patch)
tree5016505b1e977e84655cc3bba4435ef7cb80e811 /Swiften/Serializer
parent4083d6da47ac0e3b77da9c7c222a9439b3e1c04c (diff)
downloadswift-cbd01a5368f0b761d2032d75c9f7dfde2bf61578.zip
swift-cbd01a5368f0b761d2032d75c9f7dfde2bf61578.tar.bz2
Sluift: Add iTunes & PEP User Tune support
Change-Id: I25b3840bb40ce38531922cc737bc82828e026d3f
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp48
-rw-r--r--Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h19
3 files changed, 70 insertions, 1 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index a57a74e..16c79d5 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -52,6 +52,7 @@
#include <Swiften/Serializer/PayloadSerializers/LastSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/UserLocationSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/IdleSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/PubSubSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.h>
@@ -117,6 +118,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new LastSerializer());
serializers_.push_back(new WhiteboardSerializer());
serializers_.push_back(new UserLocationSerializer());
+ serializers_.push_back(new UserTuneSerializer());
serializers_.push_back(new IdleSerializer());
serializers_.push_back(new StreamInitiationFileInfoSerializer());
diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp
new file mode 100644
index 0000000..6c7799e
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Serializer/PayloadSerializers/UserTuneSerializer.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/Serializer/XML/XMLElement.h>
+
+namespace Swift {
+
+UserTuneSerializer::UserTuneSerializer() {
+}
+
+std::string UserTuneSerializer::serializePayload(
+ boost::shared_ptr<UserTune> payload) const {
+ XMLElement result("tune", "http://jabber.org/protocol/tune");
+ if (boost::optional<std::string> value = payload->getArtist()) {
+ result.addNode(boost::make_shared<XMLElement>("artist", "", *value));
+ }
+ if (boost::optional<unsigned int> value = payload->getLength()) {
+ result.addNode(boost::make_shared<XMLElement>("length", "", boost::lexical_cast<std::string>(*value)));
+ }
+ if (boost::optional<unsigned int> value = payload->getRating()) {
+ result.addNode(boost::make_shared<XMLElement>("rating", "", boost::lexical_cast<std::string>(*value)));
+ }
+ if (boost::optional<std::string> value = payload->getSource()) {
+ result.addNode(boost::make_shared<XMLElement>("source", "", *value));
+ }
+ if (boost::optional<std::string> value = payload->getTitle()) {
+ result.addNode(boost::make_shared<XMLElement>("title", "", *value));
+ }
+ if (boost::optional<std::string> value = payload->getTrack()) {
+ result.addNode(boost::make_shared<XMLElement>("track", "", *value));
+ }
+ if (boost::optional<std::string> value = payload->getURI()) {
+ result.addNode(boost::make_shared<XMLElement>("uri", "", *value));
+ }
+ return result.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h
new file mode 100644
index 0000000..8c20cbd
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2014 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/UserTune.h>
+
+namespace Swift {
+ class UserTuneSerializer : public GenericPayloadSerializer<UserTune> {
+ public:
+ UserTuneSerializer();
+
+ virtual std::string serializePayload(boost::shared_ptr<UserTune>) const;
+ };
+}