diff options
author | Tobias Markmann <tm@ayena.de> | 2013-03-28 09:06:07 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-03-31 11:42:49 (GMT) |
commit | dfa83363f4f8c8faa77be4c410d960a4cf39ec43 (patch) | |
tree | b025069ccfc8293b234d4a6f9808ada1b772c251 /Swift/Controllers/Chat | |
parent | cc502f8a172e24f407cad40a049334ff79ac952a (diff) | |
download | swift-dfa83363f4f8c8faa77be4c410d960a4cf39ec43.zip swift-dfa83363f4f8c8faa77be4c410d960a4cf39ec43.tar.bz2 |
Add blocking support for MUC 1-to-1 conversations.
Change-Id: I1cc138aecc6876609de4bdc4b22f1c98e3dd993f
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 25 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatController.h | 3 |
2 files changed, 25 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index f0de59c..68af288 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -30,6 +30,7 @@ #include <Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h> #include <Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h> #include <Swift/Controllers/UIEvents/ShowWhiteboardUIEvent.h> +#include <Swift/Controllers/UIEvents/RequestChangeBlockStateUIEvent.h> #include <Swiften/Elements/DeliveryReceipt.h> #include <Swiften/Elements/DeliveryReceiptRequest.h> #include <Swiften/Elements/Idle.h> @@ -86,6 +87,8 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ chatWindow_->onWhiteboardSessionAccept.connect(boost::bind(&ChatController::handleWhiteboardSessionAccept, this)); chatWindow_->onWhiteboardSessionCancel.connect(boost::bind(&ChatController::handleWhiteboardSessionCancel, this)); chatWindow_->onWhiteboardWindowShow.connect(boost::bind(&ChatController::handleWhiteboardWindowShow, this)); + chatWindow_->onBlockUserRequest.connect(boost::bind(&ChatController::handleBlockUserRequest, this)); + chatWindow_->onUnblockUserRequest.connect(boost::bind(&ChatController::handleUnblockUserRequest, this)); handleBareJIDCapsChanged(toJID_); settings_->onSettingChanged.connect(boost::bind(&ChatController::handleSettingChanged, this, _1)); @@ -233,7 +236,7 @@ void ChatController::checkForDisplayingDisplayReceiptsAlert() { void ChatController::handleBlockingStateChanged() { boost::shared_ptr<BlockList> blockList = clientBlockListManager_->getBlockList(); if (blockList->getState() == BlockList::Available) { - if (blockList->isBlocked(toJID_.toBare())) { + if (isInMUC_ ? blockList->isBlocked(toJID_) : blockList->isBlocked(toJID_.toBare())) { chatWindow_->setAlert(QT_TRANSLATE_NOOP("", "You've currently blocked this contact. To continue your conversation you have to unblock the contact first.")); chatWindow_->setInputEnabled(false); chatWindow_->setBlockingState(ChatWindow::IsBlocked); @@ -244,7 +247,7 @@ void ChatController::handleBlockingStateChanged() { } void ChatController::handleBlockingItemAdded(const JID& jid) { - if (jid == toJID_.toBare()) { + if (toJID_ == (isInMUC_ ? jid: jid.toBare())) { chatWindow_->setAlert(QT_TRANSLATE_NOOP("", "You've currently blocked this contact. To continue your conversation you have to unblock the contact first.")); chatWindow_->setInputEnabled(false); chatWindow_->setBlockingState(ChatWindow::IsBlocked); @@ -252,7 +255,7 @@ void ChatController::handleBlockingItemAdded(const JID& jid) { } void ChatController::handleBlockingItemRemoved(const JID& jid) { - if (jid == toJID_.toBare()) { + if (toJID_ == (isInMUC_ ? jid: jid.toBare())) { // FIXME: Support for different types of alerts. chatWindow_->cancelAlert(); chatWindow_->setInputEnabled(true); @@ -260,6 +263,22 @@ void ChatController::handleBlockingItemRemoved(const JID& jid) { } } +void ChatController::handleBlockUserRequest() { + if (isInMUC_) { + eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Blocked, toJID_)); + } else { + eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Blocked, toJID_.toBare())); + } +} + +void ChatController::handleUnblockUserRequest() { + if (isInMUC_) { + eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Unblocked, toJID_)); + } else { + eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Unblocked, toJID_.toBare())); + } +} + void ChatController::postSendMessage(const std::string& body, boost::shared_ptr<Stanza> sentStanza) { boost::shared_ptr<Replace> replace = sentStanza->getPayload<Replace>(); if (replace) { diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index 4322240..17bfdd0 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -73,6 +73,9 @@ namespace Swift { void handleBlockingItemAdded(const JID&); void handleBlockingItemRemoved(const JID&); + void handleBlockUserRequest(); + void handleUnblockUserRequest(); + private: NickResolver* nickResolver_; ChatStateNotifier* chatStateNotifier_; |