diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-03-26 11:22:06 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-03-26 11:22:06 (GMT) |
commit | fd6e929a54514d5c3f77956429d5ab5fb4271ff2 (patch) | |
tree | 59157c256de56e24f0aaf50efa50f2290afe4fee /Swiften/MUC | |
parent | 1e1e1f083b63769b019763c420ef8d556090459f (diff) | |
download | swift-contrib-fd6e929a54514d5c3f77956429d5ab5fb4271ff2.zip swift-contrib-fd6e929a54514d5c3f77956429d5ab5fb4271ff2.tar.bz2 |
Starting plumbing for MUC bookmarks
Diffstat (limited to 'Swiften/MUC')
-rw-r--r-- | Swiften/MUC/MUCBookmark.h | 28 | ||||
-rw-r--r-- | Swiften/MUC/MUCBookmarkManager.cpp | 37 | ||||
-rw-r--r-- | Swiften/MUC/MUCBookmarkManager.h | 27 |
3 files changed, 92 insertions, 0 deletions
diff --git a/Swiften/MUC/MUCBookmark.h b/Swiften/MUC/MUCBookmark.h new file mode 100644 index 0000000..439e716 --- /dev/null +++ b/Swiften/MUC/MUCBookmark.h @@ -0,0 +1,28 @@ +#pragma once + +#include <boost/optional.hpp> + +#include "Swiften/Base/String.h" +#include "Swiften/JID/JID.h" + +namespace Swift { + class MUCBookmark { + public: + MUCBookmark(const JID& room, const String& bookmarkName) : room_(room), name_(bookmarkName){}; + void setAutojoin(bool enabled) {autojoin_ = enabled;}; + void setNick(const boost::optional<String>& nick) {nick_ = nick;}; + void setPassword(const boost::optional<String>& password) {password_ = password;}; + bool getAutojoin() const {return autojoin_;}; + const boost::optional<String>& getNick() const {return nick_;}; + const boost::optional<String>& getPassword() const {return password_;}; + const String& getName() const {return name_;}; + const JID& getRoom() const {return room_;}; + private: + JID room_; + String name_; + boost::optional<String> nick_; + boost::optional<String> password_; + bool autojoin_; + }; +} + diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp new file mode 100644 index 0000000..f789300 --- /dev/null +++ b/Swiften/MUC/MUCBookmarkManager.cpp @@ -0,0 +1,37 @@ +#include "MUCBookmarkManager.h" + +#include "Swiften/Queries/IQRouter.h" + +namespace Swift { + +MUCBookmarkManager::MUCBookmarkManager(IQRouter* iqRouter) { + iqRouter_ = iqRouter; +} + +void MUCBookmarkManager::addBookmark(boost::shared_ptr<MUCBookmark> bookmark) { + bookmarks_.push_back(bookmark); + flush(); +} + + +void MUCBookmarkManager::removeBookmark(boost::shared_ptr<MUCBookmark> bookmark) { + std::vector<boost::shared_ptr<MUCBookmark> >::iterator it; + for (it = bookmarks_.begin(); it != bookmarks_.end(); it++) { + if ((*it).get() == bookmark.get()) { + bookmarks_.erase(it); + return; + } + } + assert(false); + flush(); +} + +void MUCBookmarkManager::flush() { + //FIXME: some code may be useful +} + +const std::vector<boost::shared_ptr<MUCBookmark> >& MUCBookmarkManager::getBookmarks() { + return bookmarks_; +} + +} diff --git a/Swiften/MUC/MUCBookmarkManager.h b/Swiften/MUC/MUCBookmarkManager.h new file mode 100644 index 0000000..e1f8708 --- /dev/null +++ b/Swiften/MUC/MUCBookmarkManager.h @@ -0,0 +1,27 @@ +#pragma once + +#include <vector> + +#include <boost/shared_ptr.hpp> +#include <boost/signals.hpp> + +#include "Swiften/MUC/MUCBookmark.h" + +namespace Swift { + class IQRouter; + class MUCBookmarkManager { + public: + MUCBookmarkManager(IQRouter* iqRouter); + void addBookmark(boost::shared_ptr<MUCBookmark> bookmark); + void removeBookmark(boost::shared_ptr<MUCBookmark> bookmark); + /** Call flush after editing an existing bookmark. */ + void flush(); + /** Returns pointers to the bookmarks. These can be edited, and then flush()ed.*/ + const std::vector<boost::shared_ptr<MUCBookmark> >& getBookmarks(); + boost::signal<void ()> onBookmarksChanged; + private: + + std::vector<boost::shared_ptr<MUCBookmark> > bookmarks_; + IQRouter* iqRouter_; + }; +} |