diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-05-08 17:36:16 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-05-08 17:36:45 (GMT) |
commit | 73ad73d896664a75e30063a6b96ed18a3b856786 (patch) | |
tree | c60a625c2a70501972c9c4a4cb45e903772c9fe9 /Swiften/MUC/MUCBookmarkManager.cpp | |
parent | 09de88ddd4377a53a880b98d63bbe391eba982b9 (diff) | |
download | swift-contrib-73ad73d896664a75e30063a6b96ed18a3b856786.zip swift-contrib-73ad73d896664a75e30063a6b96ed18a3b856786.tar.bz2 |
Flush bookmarks.
Resolves: #335
Diffstat (limited to 'Swiften/MUC/MUCBookmarkManager.cpp')
-rw-r--r-- | Swiften/MUC/MUCBookmarkManager.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp index 3675635..cc1c8d6 100644 --- a/Swiften/MUC/MUCBookmarkManager.cpp +++ b/Swiften/MUC/MUCBookmarkManager.cpp @@ -10,6 +10,8 @@ #include <iostream> #include "Swiften/Queries/IQRouter.h" +#include "Swiften/Queries/Requests/GetPrivateStorageRequest.h" +#include "Swiften/Queries/Requests/SetPrivateStorageRequest.h" namespace Swift { @@ -29,16 +31,7 @@ void MUCBookmarkManager::handleBookmarksReceived(boost::shared_ptr<Storage> payl std::vector<MUCBookmark> receivedBookmarks; foreach (Storage::Room room, payload->getRooms()) { - String name = (!room.name.isEmpty()) ? room.name : room.jid.getNode(); - MUCBookmark bookmark(room.jid, name); - bookmark.setAutojoin(room.autoJoin); - if (!room.nick.isEmpty()) { - bookmark.setNick(room.nick); - } - if (!room.password.isEmpty()) { - bookmark.setPassword(room.password); - } - receivedBookmarks.push_back(bookmark); + receivedBookmarks.push_back(MUCBookmark(room)); } std::vector<MUCBookmark> newBookmarks; @@ -95,7 +88,17 @@ void MUCBookmarkManager::removeBookmark(const MUCBookmark& bookmark) { } void MUCBookmarkManager::flush() { - //FIXME: some code may be useful + // Update the storage element + storage->clearRooms(); + foreach(const MUCBookmark& bookmark, bookmarks_) { + storage->addRoom(bookmark.toStorage()); + } + + // Send an iq to save the storage element + boost::shared_ptr<SetPrivateStorageRequest<Storage> > request(new SetPrivateStorageRequest<Storage>(storage, iqRouter_)); + // FIXME: We should care about the result + //request->onResponse.connect(boost::bind(&MUCBookmarkManager::handleBookmarksSet, this, _1, _2)); + request->send(); } const std::vector<MUCBookmark>& MUCBookmarkManager::getBookmarks() const { |