summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-22 16:48:19 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-22 16:48:19 (GMT)
commitabbfb6f8c410104c883c54e6f483c8c37f954d56 (patch)
tree7dec68761b91b9ce36acc5b5edf4178730782f74 /Swiften/Serializer
parent706276e0fdffb0af86d8178973bbf5ae3722733d (diff)
downloadswift-contrib-abbfb6f8c410104c883c54e6f483c8c37f954d56.zip
swift-contrib-abbfb6f8c410104c883c54e6f483c8c37f954d56.tar.bz2
Added VCard-Update serializer.
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/Makefile.inc3
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc3
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp31
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp21
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h13
7 files changed, 72 insertions, 3 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index f9a0789..0f66b35 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -16,6 +16,7 @@
#include "Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/VCardSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h"
namespace Swift {
@@ -35,6 +36,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new SecurityLabelSerializer());
serializers_.push_back(new SecurityLabelsCatalogSerializer());
serializers_.push_back(new VCardSerializer());
+ serializers_.push_back(new VCardUpdateSerializer());
foreach(PayloadSerializer* serializer, serializers_) {
addSerializer(serializer);
}
diff --git a/Swiften/Serializer/PayloadSerializers/Makefile.inc b/Swiften/Serializer/PayloadSerializers/Makefile.inc
index 893da6c..9bfbeee 100644
--- a/Swiften/Serializer/PayloadSerializers/Makefile.inc
+++ b/Swiften/Serializer/PayloadSerializers/Makefile.inc
@@ -9,6 +9,7 @@ SWIFTEN_SOURCES += \
Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp \
Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp \
Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp \
- Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
+ Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp \
+ Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
include Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc b/Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc
index fce7ab9..73887a1 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/Makefile.inc
@@ -9,4 +9,5 @@ UNITTEST_SOURCES += \
Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp \
Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp \
Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp \
- Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp
+ Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp \
+ Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
new file mode 100644
index 0000000..fc7e442
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp
@@ -0,0 +1,31 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h"
+
+using namespace Swift;
+
+class VCardUpdateSerializerTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(VCardUpdateSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ VCardUpdateSerializerTest() {}
+
+ void testSerialize() {
+ VCardUpdateSerializer testling;
+ boost::shared_ptr<VCardUpdate> update(new VCardUpdate());
+ update->setPhotoHash("sha1-hash-of-image");
+
+ String expectedResult =
+ "<x xmlns=\"vcard-temp:x:update\">"
+ "<photo>sha1-hash-of-image</photo>"
+ "</x>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(update));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VCardUpdateSerializerTest);
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
index ce4e399..4e1a762 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
@@ -9,7 +9,7 @@ namespace Swift {
VCardSerializer::VCardSerializer() : GenericPayloadSerializer<VCard>() {
}
-String VCardSerializer::serializePayload(boost::shared_ptr<VCard> discoInfo) const {
+String VCardSerializer::serializePayload(boost::shared_ptr<VCard>) const {
XMLElement queryElement("vCard", "vcard-temp");
// TODO
return queryElement.serialize();
diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
new file mode 100644
index 0000000..540b48d
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
@@ -0,0 +1,21 @@
+#include "Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Serializer/XML/XMLElement.h"
+#include "Swiften/Serializer/XML/XMLTextNode.h"
+
+namespace Swift {
+
+VCardUpdateSerializer::VCardUpdateSerializer() : GenericPayloadSerializer<VCardUpdate>() {
+}
+
+String VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const {
+ XMLElement updateElement("x", "vcard-temp:x:update");
+ boost::shared_ptr<XMLElement> photoElement(new XMLElement("photo"));
+ photoElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcardUpdate->getPhotoHash())));
+ updateElement.addNode(photoElement);
+ return updateElement.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h
new file mode 100644
index 0000000..e1373a9
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "Swiften/Serializer/GenericPayloadSerializer.h"
+#include "Swiften/Elements/VCardUpdate.h"
+
+namespace Swift {
+ class VCardUpdateSerializer : public GenericPayloadSerializer<VCardUpdate> {
+ public:
+ VCardUpdateSerializer();
+
+ virtual String serializePayload(boost::shared_ptr<VCardUpdate>) const;
+ };
+}