diff options
Diffstat (limited to 'Swift/Controllers/Chat')
| -rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 6 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 17 |
2 files changed, 20 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 8c132d0..bedc427 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp | |||
| @@ -173,11 +173,15 @@ void ChatController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> me | |||
| 173 | } | 173 | } |
| 174 | boost::shared_ptr<Message> message = messageEvent->getStanza(); | 174 | boost::shared_ptr<Message> message = messageEvent->getStanza(); |
| 175 | JID from = message->getFrom(); | 175 | JID from = message->getFrom(); |
| 176 | if (!from.equals(toJID_, JID::WithResource)) { | 176 | if (!from.equals(toJID_, JID::WithResource)) { |
| 177 | if (toJID_.equals(from, JID::WithoutResource) && toJID_.isBare()){ | 177 | if (toJID_.equals(from, JID::WithoutResource) && toJID_.isBare()){ |
| 178 | setToJID(from); | 178 | // Bind controller to a full JID if message contains body text or is a typing chat state. |
| 179 | ChatState::ref chatState = message->getPayload<ChatState>(); | ||
| 180 | if (!message->getBody().empty() || (chatState && chatState->getChatState() == ChatState::Composing)) { | ||
| 181 | setToJID(from); | ||
| 182 | } | ||
| 179 | } | 183 | } |
| 180 | } | 184 | } |
| 181 | chatStateTracker_->handleMessageReceived(message); | 185 | chatStateTracker_->handleMessageReceived(message); |
| 182 | chatStateNotifier_->receivedMessageFromContact(!!message->getPayload<ChatState>()); | 186 | chatStateNotifier_->receivedMessageFromContact(!!message->getPayload<ChatState>()); |
| 183 | 187 | ||
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