summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-05-06 18:50:32 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-05-06 18:52:52 (GMT)
commita49e2a1d4d17c36fad6ac1d1313fac955f675a54 (patch)
tree5403d40ffcd2ec6d3a858db6f9e3320f64c6af87 /Swiften/Serializer/PayloadSerializers
parent0cec4698efdb9fa0072e5d8cbccd6cb806b940e9 (diff)
downloadswift-a49e2a1d4d17c36fad6ac1d1313fac955f675a54.zip
swift-a49e2a1d4d17c36fad6ac1d1313fac955f675a54.tar.bz2
Completed storage bookmark parser & serializer.
Added URI element.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r--Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp9
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp5
2 files changed, 14 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
index f7beecd..b4a2a49 100644
--- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
@@ -19,6 +19,7 @@ StorageSerializer::StorageSerializer() : GenericPayloadSerializer<Storage>() {
String StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) const {
XMLElement storageElement("storage", "storage:bookmarks");
+
foreach(const Storage::Conference& conference, storage->getConferences()) {
boost::shared_ptr<XMLElement> conferenceElement(new XMLElement("conference"));
conferenceElement->setAttribute("name", conference.name);
@@ -36,6 +37,14 @@ String StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) c
}
storageElement.addNode(conferenceElement);
}
+
+ foreach(const Storage::URL& url, storage->getURLs()) {
+ boost::shared_ptr<XMLElement> urlElement(new XMLElement("url"));
+ urlElement->setAttribute("name", url.name);
+ urlElement->setAttribute("url", url.url);
+ storageElement.addNode(urlElement);
+ }
+
return storageElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
index 714de42..5888731 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
@@ -31,6 +31,10 @@ class StorageSerializerTest : public CppUnit::TestFixture {
conference.nick = "Puck";
conference.password = "MyPass";
storage->addConference(conference);
+ Storage::URL url;
+ url.name = "Complete Works of Shakespeare";
+ url.url = "http://the-tech.mit.edu/Shakespeare/";
+ storage->addURL(url);
CPPUNIT_ASSERT_EQUAL(String(
"<storage xmlns=\"storage:bookmarks\">"
@@ -41,6 +45,7 @@ class StorageSerializerTest : public CppUnit::TestFixture {
"<nick>Puck</nick>"
"<password>MyPass</password>"
"</conference>"
+ "<url name=\"Complete Works of Shakespeare\" url=\"http://the-tech.mit.edu/Shakespeare/\"/>"
"</storage>"), serializer.serialize(storage));
}