summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client/BlockListImpl.cpp')
-rw-r--r--Swiften/Client/BlockListImpl.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/Swiften/Client/BlockListImpl.cpp b/Swiften/Client/BlockListImpl.cpp
index 02c1c18..4abaa37 100644
--- a/Swiften/Client/BlockListImpl.cpp
+++ b/Swiften/Client/BlockListImpl.cpp
@@ -1,34 +1,36 @@
/*
- * Copyright (c) 2011 Isode Limited.
+ * Copyright (c) 2011-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Client/BlockListImpl.h>
-#include <Swiften/Base/foreach.h>
-
#include <algorithm>
+#include <Swiften/Base/foreach.h>
+
using namespace Swift;
BlockListImpl::BlockListImpl() : state(Init) {
}
-void BlockListImpl::setItems(const std::vector<JID>& items) {
- foreach (const JID& jid, this->items) {
- if (std::find(items.begin(), items.end(), jid) != items.end()) {
+void BlockListImpl::setItems(const std::vector<JID>& newItems) {
+ // JIDs which are in the current list but not in the new list, are removed.
+ foreach (const JID& jid, items) {
+ if (std::find(newItems.begin(), newItems.end(), jid) == newItems.end()) {
onItemRemoved(jid);
}
}
- foreach (const JID& jid, items) {
- if (std::find(this->items.begin(), this->items.end(), jid) != this->items.end()) {
+ // JIDs which are in the new list but not in the current list, are added.
+ foreach (const JID& jid, newItems) {
+ if (std::find(items.begin(), items.end(), jid) == items.end()) {
onItemAdded(jid);
}
}
- this->items = items;
+ items = newItems;
}
void BlockListImpl::addItem(const JID& item) {