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 @@ -744,19 +744,24 @@ ChatController* ChatsManager::getChatControllerOrCreate(const JID &contact) { ChatController* ChatsManager::getChatControllerIfExists(const JID &contact, bool rebindIfNeeded) { if (chatControllers_.find(contact) == chatControllers_.end()) { if (mucRegistry_->isMUC(contact.toBare())) { return NULL; } //Need to look for an unbound window to bind first JID bare(contact.toBare()); if (chatControllers_.find(bare) != chatControllers_.end()) { - rebindControllerJID(bare, contact); + if (rebindIfNeeded) { + rebindControllerJID(bare, contact); + } + else { + return chatControllers_[bare]; + } } else { foreach (JIDChatControllerPair pair, chatControllers_) { if (pair.first.toBare() == contact.toBare()) { if (rebindIfNeeded) { rebindControllerJID(pair.first, contact); return chatControllers_[contact]; } else { return pair.second; } @@ -903,19 +908,27 @@ void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) { } else { handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true); return; } } //if not a mucroom if (!event->isReadable() && !isInvite && !isMediatedInvite) { /* Only route such messages if a window exists, don't open new windows for them.*/ - ChatController* controller = getChatControllerIfExists(jid); + + // Do not bind a controller to a full JID, for delivery receipts or chat state notifications. + bool bindControllerToJID = false; + ChatState::ref chatState = message->getPayload<ChatState>(); + if (!message->getBody().empty() || (chatState && chatState->getChatState() == ChatState::Composing)) { + bindControllerToJID = true; + } + + ChatController* controller = getChatControllerIfExists(jid, bindControllerToJID); if (controller) { controller->handleIncomingMessage(event); } } else { getChatControllerOrCreate(jid)->handleIncomingMessage(event); } } void ChatsManager::handleMUCSelectedAfterSearch(const JID& muc) { |
Swift