summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Voicu <vladvoic@gmail.com>2011-04-29 18:13:05 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-04-30 08:35:40 (GMT)
commit09f61b624e99f69a9221ba46c15efa61892f475f (patch)
tree636be7dd1399a4cf97fda4343d6f849d9eac2e34 /Swiften/Serializer/PayloadSerializers
parentd4781a09b22013da45adf8e9e8b6484fd672a3ec (diff)
downloadswift-09f61b624e99f69a9221ba46c15efa61892f475f.zip
swift-09f61b624e99f69a9221ba46c15efa61892f475f.tar.bz2
Correct message feature using XEP-Correct
Uses Kev's not-yet-published protocol for correcting the last sent message. Release-Notes: You can now correct your previously sent message in a chat by pressing 'up' in the input field. License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp30
3 files changed, 54 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index 0f05580..a1f412b 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -41,6 +41,7 @@
#include "Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/NicknameSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h"
namespace Swift {
@@ -79,6 +80,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new InBandRegistrationPayloadSerializer());
serializers_.push_back(new NicknameSerializer());
serializers_.push_back(new SearchPayloadSerializer());
+ serializers_.push_back(new ReplaceSerializer());
foreach(PayloadSerializer* serializer, serializers_) {
addSerializer(serializer);
}
diff --git a/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h b/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h
new file mode 100644
index 0000000..303b2b8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/Serializer/GenericPayloadSerializer.h"
+#include "Swiften/Serializer/XML/XMLTextNode.h"
+#include "Swiften/Elements/Replace.h"
+
+namespace Swift {
+ class ReplaceSerializer : public GenericPayloadSerializer<Replace> {
+ public:
+ ReplaceSerializer() : GenericPayloadSerializer<Replace>() {}
+
+ virtual std::string serializePayload(boost::shared_ptr<Replace> replace) const {
+ return "<replace id = '" + replace->getId() + "' xmlns='http://swift.im/protocol/replace'/>";
+ }
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp
new file mode 100644
index 0000000..8fe96e5
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ReplaceSerializerTest.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/PayloadSerializers/ReplaceSerializer.h"
+
+using namespace Swift;
+
+class ReplaceSerializerTest: public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(ReplaceSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ ReplaceSerializerTest() {}
+
+ void testSerialize() {
+ ReplaceSerializer testling;
+ boost::shared_ptr<Replace> replace(new Replace());
+ replace->setId("bad1");
+ CPPUNIT_ASSERT_EQUAL(std::string("<replace id = 'bad1' xmlns='http://swift.im/protocol/replace'/>"), testling.serialize(replace));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ReplaceSerializerTest);