summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-04-09 07:54:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:41 (GMT)
commite3d2137622cea23298f203801bc698eff08e0ea1 (patch)
treee8d02f3334a6422e25ca5f30606850d960b27cc7 /Swiften/Roster/RosterFileStorage.cpp
parent01385d84f07466550fff702079555c65963463a8 (diff)
downloadswift-contrib-e3d2137622cea23298f203801bc698eff08e0ea1.zip
swift-contrib-e3d2137622cea23298f203801bc698eff08e0ea1.tar.bz2
Factor out payload persisting into utility classes.
Diffstat (limited to 'Swiften/Roster/RosterFileStorage.cpp')
-rw-r--r--Swiften/Roster/RosterFileStorage.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/Swiften/Roster/RosterFileStorage.cpp b/Swiften/Roster/RosterFileStorage.cpp
index de7b442..31b6c5e 100644
--- a/Swiften/Roster/RosterFileStorage.cpp
+++ b/Swiften/Roster/RosterFileStorage.cpp
@@ -6,19 +6,21 @@
#include <Swiften/Roster/RosterFileStorage.h>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <Swiften/Entity/GenericPayloadPersister.h>
+#include <Swiften/Serializer/PayloadSerializers/RosterSerializer.h>
+#include <Swiften/Parser/PayloadParsers/RosterParser.h>
-namespace Swift {
+using namespace Swift;
+
+typedef GenericPayloadPersister<RosterPayload, RosterParser, RosterSerializer> RosterPersister;
RosterFileStorage::RosterFileStorage(const boost::filesystem::path& path) : path(path) {
}
-// FIXME
-void RosterFileStorage::setRoster(boost::shared_ptr<RosterPayload> r) {
- roster.reset();
- if (r) {
- roster = boost::make_shared<RosterPayload>(*r);
- }
+boost::shared_ptr<RosterPayload> RosterFileStorage::getRoster() const {
+ return RosterPersister().loadPayloadGeneric(path);
}
+void RosterFileStorage::setRoster(boost::shared_ptr<RosterPayload> roster) {
+ RosterPersister().savePayload(roster, path);
}