diff options
Diffstat (limited to 'Swift/Controllers/Chat/ChatsManager.cpp')
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index e11d14b..343f490 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp | |||
| @@ -748,11 +748,16 @@ ChatController* ChatsManager::getChatControllerIfExists(const JID &contact, bool | |||
| 748 | return NULL; | 748 | return NULL; |
| 749 | } | 749 | } |
| 750 | //Need to look for an unbound window to bind first | 750 | //Need to look for an unbound window to bind first |
| 751 | JID bare(contact.toBare()); | 751 | JID bare(contact.toBare()); |
| 752 | if (chatControllers_.find(bare) != chatControllers_.end()) { | 752 | if (chatControllers_.find(bare) != chatControllers_.end()) { |
| 753 | rebindControllerJID(bare, contact); | 753 | if (rebindIfNeeded) { |
| 754 | rebindControllerJID(bare, contact); | ||
| 755 | } | ||
| 756 | else { | ||
| 757 | return chatControllers_[bare]; | ||
| 758 | } | ||
| 754 | } else { | 759 | } else { |
| 755 | foreach (JIDChatControllerPair pair, chatControllers_) { | 760 | foreach (JIDChatControllerPair pair, chatControllers_) { |
| 756 | if (pair.first.toBare() == contact.toBare()) { | 761 | if (pair.first.toBare() == contact.toBare()) { |
| 757 | if (rebindIfNeeded) { | 762 | if (rebindIfNeeded) { |
| 758 | rebindControllerJID(pair.first, contact); | 763 | rebindControllerJID(pair.first, contact); |
| @@ -907,11 +912,19 @@ void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) { | |||
| 907 | } | 912 | } |
| 908 | 913 | ||
| 909 | //if not a mucroom | 914 | //if not a mucroom |
| 910 | if (!event->isReadable() && !isInvite && !isMediatedInvite) { | 915 | if (!event->isReadable() && !isInvite && !isMediatedInvite) { |
| 911 | /* Only route such messages if a window exists, don't open new windows for them.*/ | 916 | /* Only route such messages if a window exists, don't open new windows for them.*/ |
| 912 | ChatController* controller = getChatControllerIfExists(jid); | 917 | |
| 918 | // Do not bind a controller to a full JID, for delivery receipts or chat state notifications. | ||
| 919 | bool bindControllerToJID = false; | ||
| 920 | ChatState::ref chatState = message->getPayload<ChatState>(); | ||
| 921 | if (!message->getBody().empty() || (chatState && chatState->getChatState() == ChatState::Composing)) { | ||
| 922 | bindControllerToJID = true; | ||
| 923 | } | ||
| 924 | |||
| 925 | ChatController* controller = getChatControllerIfExists(jid, bindControllerToJID); | ||
| 913 | if (controller) { | 926 | if (controller) { |
| 914 | controller->handleIncomingMessage(event); | 927 | controller->handleIncomingMessage(event); |
| 915 | } | 928 | } |
| 916 | } else { | 929 | } else { |
| 917 | getChatControllerOrCreate(jid)->handleIncomingMessage(event); | 930 | getChatControllerOrCreate(jid)->handleIncomingMessage(event); |
Swift