summaryrefslogtreecommitdiffstats
blob: f9295e276cec8e83f211e8b4fd157de86156dc43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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();
	onBookmarkAdded(bookmark);
}


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);
			onBookmarkRemoved(bookmark);
			return;
		}
	}
	assert(false);
	flush();
}

void MUCBookmarkManager::flush() {
	//FIXME: some code may be useful
}

const std::vector<boost::shared_ptr<MUCBookmark> >& MUCBookmarkManager::getBookmarks() {
	return bookmarks_;
}

}