blob: 818d9b4fafba0f0018edb21c664bf6dcf923e4b3 (
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
|
/*
* Copyright (c) 2013 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <Swiften/JID/JID.h>
#include <Swift/Controllers/Roster/ContactRosterItem.h>
#include <Swift/Controllers/Roster/ItemOperations/RosterItemOperation.h>
namespace Swift {
class RosterItem;
class SetBlockingState : public RosterItemOperation {
public:
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 (jid_.getNode().empty()) {
if (contact && contact->getJID().getDomain() == jid_.getDomain()) {
contact->setBlockState(state_);
}
} else {
if (contact && contact->getJID().equals(jid_, compareType_)) {
contact->setBlockState(state_);
}
}
}
private:
JID jid_;
ContactRosterItem::BlockState state_;
JID::CompareType compareType_;
};
}
|