00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <vector>
00010
00011 #include <boost/shared_ptr.hpp>
00012 #include <Swiften/Base/boost_bsignals.h>
00013 #include <boost/optional.hpp>
00014
00015 #include <Swiften/Base/API.h>
00016 #include <Swiften/MUC/MUCBookmark.h>
00017 #include <Swiften/Elements/Storage.h>
00018 #include <Swiften/Elements/ErrorPayload.h>
00019
00020 namespace Swift {
00021 class IQRouter;
00022
00023 class SWIFTEN_API MUCBookmarkManager {
00024 public:
00025 MUCBookmarkManager(IQRouter* iqRouter);
00026
00027 void addBookmark(const MUCBookmark& bookmark);
00028 void removeBookmark(const MUCBookmark& bookmark);
00029 void replaceBookmark(const MUCBookmark& oldBookmark, const MUCBookmark& newBookmark);
00030
00031 const std::vector<MUCBookmark>& getBookmarks() const;
00032
00033 public:
00034 boost::signal<void (const MUCBookmark&)> onBookmarkAdded;
00035 boost::signal<void (const MUCBookmark&)> onBookmarkRemoved;
00039 boost::signal<void ()> onBookmarksReady;
00040
00041 private:
00042 bool containsEquivalent(const std::vector<MUCBookmark>& list, const MUCBookmark& bookmark);
00043 void handleBookmarksReceived(boost::shared_ptr<Storage> payload, ErrorPayload::ref error);
00044 void flush();
00045
00046 private:
00047 bool ready_;
00048 std::vector<MUCBookmark> bookmarks_;
00049 IQRouter* iqRouter_;
00050 boost::shared_ptr<Storage> storage;
00051 };
00052 }