summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster')
-rw-r--r--Swiften/Roster/RosterFileStorage.cpp18
-rw-r--r--Swiften/Roster/RosterFileStorage.h7
2 files changed, 11 insertions, 14 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);
}
diff --git a/Swiften/Roster/RosterFileStorage.h b/Swiften/Roster/RosterFileStorage.h
index dc91c27..cb00969 100644
--- a/Swiften/Roster/RosterFileStorage.h
+++ b/Swiften/Roster/RosterFileStorage.h
@@ -15,15 +15,10 @@ namespace Swift {
public:
RosterFileStorage(const boost::filesystem::path& path);
- // FIXME
- virtual boost::shared_ptr<RosterPayload> getRoster() const {
- return roster;
- }
-
+ virtual boost::shared_ptr<RosterPayload> getRoster() const;
virtual void setRoster(boost::shared_ptr<RosterPayload>);
private:
boost::filesystem::path path;
- boost::shared_ptr<RosterPayload> roster;
};
}