From 80b60a71936d0e029893958938df6e3d38cecf8b Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Fri, 3 Oct 2014 17:48:47 +0200
Subject: Do not send chat state notifications to blocked contacts.
Test-Information:
Started a chat session; then blocked the contact. Previously chat state
notifications were send when typing. Now they are not send anymore.
Change-Id: Id68f3faee4829e99cbfe1535f48346a8c27712d3
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 786b4e9..50d85a3 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -266,6 +266,10 @@ void ChatController::handleBlockingStateChanged() {
blockedContactAlert_ = chatWindow_->addAlert(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);
+
+ // disconnect typing events to prevent chat state notifciations to blocked contacts
+ chatWindow_->onUserTyping.disconnect(boost::bind(&ChatStateNotifier::setUserIsTyping, chatStateNotifier_));
+ chatWindow_->onUserCancelsTyping.disconnect(boost::bind(&ChatStateNotifier::userCancelledNewMessage, chatStateNotifier_));
} else {
if (blockedContactAlert_) {
chatWindow_->removeAlert(*blockedContactAlert_);
@@ -273,6 +277,9 @@ void ChatController::handleBlockingStateChanged() {
}
chatWindow_->setInputEnabled(true);
chatWindow_->setBlockingState(ChatWindow::IsUnblocked);
+
+ chatWindow_->onUserTyping.connect(boost::bind(&ChatStateNotifier::setUserIsTyping, chatStateNotifier_));
+ chatWindow_->onUserCancelsTyping.connect(boost::bind(&ChatStateNotifier::userCancelledNewMessage, chatStateNotifier_));
}
}
}
--
cgit v0.10.2-6-g49f6