summaryrefslogtreecommitdiffstats
blob: dfaaaf15f3fc1392eb92d82005199ef377aed3c1 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2011 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include <Swiften/Client/BlockListImpl.h>

#include <Swiften/Base/foreach.h>

using namespace Swift;

BlockListImpl::BlockListImpl() {

}

void BlockListImpl::setItems(const std::vector<JID>& items) {
	this->items = std::set<JID>(items.begin(), items.end());
}

void BlockListImpl::addItem(const JID& item) {
	if (items.insert(item).second) {
		onItemAdded(item);
	}
}

void BlockListImpl::removeItem(const JID& item) {
	if (items.erase(item)) {
		onItemRemoved(item);
	}
}

void BlockListImpl::setState(State state) {
	if (this->state != state) {
		onStateChanged();
	}
}

void BlockListImpl::addItems(const std::vector<JID>& items) {
	foreach (const JID& item, items) {
		addItem(item);
	}
}

void BlockListImpl::removeItems(const std::vector<JID>& items) {
	foreach (const JID& item, items) {
		removeItem(item);
	}
}

void BlockListImpl::removeAllItems() {
	foreach (const JID& item, items) {
		removeItem(item);
	}
}