summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-03-08 15:17:30 (GMT)
committerTobias Markmann <tm@ayena.de>2013-03-27 14:12:26 (GMT)
commit497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04 (patch)
treedc81e56199f54cf20f834c78bda7fc26ffbc38f9 /Swiften/Client/ClientBlockListManager.cpp
parent20ead0a84fdd8c9e870e98ee6a2712bfa263d7fb (diff)
downloadswift-497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04.zip
swift-497b647fe034a3d2cdc6d75ce0ff70e3df3aaf04.tar.bz2
Adding support for Blocking Command (XEP-0191) to Swift(-en).
Change-Id: I7c92518dc389474d520d4cf96f96a11459f73d26 License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swiften/Client/ClientBlockListManager.cpp')
-rw-r--r--Swiften/Client/ClientBlockListManager.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/Swiften/Client/ClientBlockListManager.cpp b/Swiften/Client/ClientBlockListManager.cpp
index 7222cea..6646a5c 100644
--- a/Swiften/Client/ClientBlockListManager.cpp
+++ b/Swiften/Client/ClientBlockListManager.cpp
@@ -66,11 +66,14 @@ namespace {
}
ClientBlockListManager::ClientBlockListManager(IQRouter* iqRouter) : iqRouter(iqRouter) {
+
}
ClientBlockListManager::~ClientBlockListManager() {
- unblockResponder->stop();
- blockResponder->stop();
+ if (blockList && blockList->getState() == BlockList::Available) {
+ unblockResponder->stop();
+ blockResponder->stop();
+ }
if (getRequest) {
getRequest->onResponse.disconnect(boost::bind(&ClientBlockListManager::handleBlockListReceived, this, _1, _2));
}
@@ -88,13 +91,36 @@ boost::shared_ptr<BlockList> ClientBlockListManager::getBlockList() {
return blockList;
}
+GenericRequest<BlockPayload>::ref ClientBlockListManager::createBlockJIDRequest(const JID& jid) {
+ return createBlockJIDsRequest(std::vector<JID>(1, jid));
+}
+
+GenericRequest<BlockPayload>::ref ClientBlockListManager::createBlockJIDsRequest(const std::vector<JID>& jids) {
+ boost::shared_ptr<BlockPayload> payload = boost::make_shared<BlockPayload>(jids);
+ return boost::make_shared< GenericRequest<BlockPayload> >(IQ::Set, JID(), payload, iqRouter);
+}
+
+GenericRequest<UnblockPayload>::ref ClientBlockListManager::createUnblockJIDRequest(const JID& jid) {
+ return createUnblockJIDsRequest(std::vector<JID>(1, jid));
+}
+
+GenericRequest<UnblockPayload>::ref ClientBlockListManager::createUnblockJIDsRequest(const std::vector<JID>& jids) {
+ boost::shared_ptr<UnblockPayload> payload = boost::make_shared<UnblockPayload>(jids);
+ return boost::make_shared< GenericRequest<UnblockPayload> >(IQ::Set, JID(), payload, iqRouter);
+}
+
+GenericRequest<UnblockPayload>::ref ClientBlockListManager::createUnblockAllRequest() {
+ return createUnblockJIDsRequest(std::vector<JID>());
+}
+
+
void ClientBlockListManager::handleBlockListReceived(boost::shared_ptr<BlockListPayload> payload, ErrorPayload::ref error) {
if (error || !payload) {
blockList->setState(BlockList::Error);
}
else {
- blockList->setState(BlockList::Available);
blockList->setItems(payload->getItems());
+ blockList->setState(BlockList::Available);
blockResponder = boost::make_shared<BlockResponder>(blockList, iqRouter);
blockResponder->start();
unblockResponder = boost::make_shared<UnblockResponder>(blockList, iqRouter);