summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-14 20:14:08 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-14 20:14:08 (GMT)
commitcb32ea0954558da4bec9d4e9f13710a7f1a17d5a (patch)
tree91cf3495f6cfe4955c193b1b4d9badaebd854d03 /Swiften/Serializer/PayloadSerializers
parenteb788bf484f4d11f524473986bf19d1a80f522bc (diff)
downloadswift-cb32ea0954558da4bec9d4e9f13710a7f1a17d5a.zip
swift-cb32ea0954558da4bec9d4e9f13710a7f1a17d5a.tar.bz2
Added User Nickname element, serializer, and parser.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp25
-rw-r--r--Swiften/Serializer/PayloadSerializers/NicknameSerializer.h21
3 files changed, 48 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index d63c723..8598f17 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -34,6 +34,7 @@
#include "Swiften/Serializer/PayloadSerializers/DelaySerializer.h"
#include "Swiften/Serializer/PayloadSerializers/FormSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/CommandSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/NicknameSerializer.h"
namespace Swift {
@@ -65,6 +66,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new FormSerializer());
serializers_.push_back(new PrivateStorageSerializer(this));
serializers_.push_back(new CommandSerializer());
+ serializers_.push_back(new NicknameSerializer());
foreach(PayloadSerializer* serializer, serializers_) {
addSerializer(serializer);
}
diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
new file mode 100644
index 0000000..55d5bb6
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Serializer/PayloadSerializers/NicknameSerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Serializer/XML/XMLElement.h"
+#include "Swiften/Serializer/XML/XMLTextNode.h"
+
+namespace Swift {
+
+NicknameSerializer::NicknameSerializer() : GenericPayloadSerializer<Nickname>() {
+}
+
+String NicknameSerializer::serializePayload(boost::shared_ptr<Nickname> nick) const {
+ XMLElement nickElement("nick", "http://jabber.org/protocol/nick");
+ nickElement.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(nick->getNickname())));
+ return nickElement.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h
new file mode 100644
index 0000000..e296ffd
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010 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/Nickname.h"
+
+namespace Swift {
+ class NicknameSerializer : public GenericPayloadSerializer<Nickname> {
+ public:
+ NicknameSerializer();
+
+ virtual String serializePayload(boost::shared_ptr<Nickname>) const;
+ };
+}
+
+