summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-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));
}