summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/BlockListController.cpp6
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.h3
-rw-r--r--Swift/Controllers/Roster/ItemOperations/SetBlockingState.h15
3 files changed, 18 insertions, 6 deletions
diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp
index e7bc45d..6bdb513 100644
--- a/Swift/Controllers/BlockListController.cpp
+++ b/Swift/Controllers/BlockListController.cpp
@@ -145,11 +145,13 @@ void BlockListController::handleBlockListChanged() {
blockListBeforeEdit = blockListManager_->getBlockList()->getItems();
foreach (const JID& jid, jidsToBlock) {
- blockListBeforeEdit.push_back(jid);
+ if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) {
+ blockListBeforeEdit.push_back(jid);
+ }
}
foreach (const JID& jid, jidsToUnblock) {
- blockListBeforeEdit.erase(std::remove(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid), blockListBeforeEdit.end());;
+ blockListBeforeEdit.erase(std::remove(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid), blockListBeforeEdit.end());
}
blockListEditorWidget_->setCurrentBlockList(blockListBeforeEdit);
diff --git a/Swift/Controllers/Roster/ContactRosterItem.h b/Swift/Controllers/Roster/ContactRosterItem.h
index d9ca8af..6de7909 100644
--- a/Swift/Controllers/Roster/ContactRosterItem.h
+++ b/Swift/Controllers/Roster/ContactRosterItem.h
@@ -36,7 +36,8 @@ class ContactRosterItem : public RosterItem {
enum BlockState {
BlockingNotSupported,
IsBlocked,
- IsUnblocked
+ IsUnblocked,
+ IsDomainBlocked
};
public:
diff --git a/Swift/Controllers/Roster/ItemOperations/SetBlockingState.h b/Swift/Controllers/Roster/ItemOperations/SetBlockingState.h
index a8eea09..ddb2c7a 100644
--- a/Swift/Controllers/Roster/ItemOperations/SetBlockingState.h
+++ b/Swift/Controllers/Roster/ItemOperations/SetBlockingState.h
@@ -17,13 +17,22 @@ class RosterItem;
class SetBlockingState : public RosterItemOperation {
public:
- SetBlockingState(const JID& jid, ContactRosterItem::BlockState state, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), jid_(jid), state_(state), compareType_(compareType) {
+ SetBlockingState(const JID& jid, ContactRosterItem::BlockState state, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(!jid.getNode().empty(), jid), jid_(jid), state_(state), compareType_(compareType) {
+ if (state_ == ContactRosterItem::IsBlocked && jid.getNode().empty()) {
+ state_ = ContactRosterItem::IsDomainBlocked;
+ }
}
virtual void operator() (RosterItem* item) const {
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (contact && contact->getJID().equals(jid_, compareType_)) {
- contact->setBlockState(state_);
+ if (jid_.getNode().empty()) {
+ if (contact && contact->getJID().getDomain() == jid_.getDomain()) {
+ contact->setBlockState(state_);
+ }
+ } else {
+ if (contact && contact->getJID().equals(jid_, compareType_)) {
+ contact->setBlockState(state_);
+ }
}
}