diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-12 09:12:09 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-12 09:12:09 (GMT) |
commit | a5928fb2a77e4ba899ecd67aeb2412b70945058c (patch) | |
tree | 10bfd3db7a67338f1a298b17511b729a9f0a3db9 | |
parent | 81fe3113234c0610ce49de0299f43ae12d985a14 (diff) | |
download | swift-contrib-a5928fb2a77e4ba899ecd67aeb2412b70945058c.zip swift-contrib-a5928fb2a77e4ba899ecd67aeb2412b70945058c.tar.bz2 |
Don't re-associate a MUC PM with the bare JID when the target goes offline.
Resolves: #458
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 3 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 19 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 3 |
3 files changed, 4 insertions, 21 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 7b52fba..79221c4 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -97,9 +97,10 @@ String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presenc } void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> previousPresence) { - if (!(toJID_.isBare() && newPresence->getFrom().equals(toJID_, JID::WithoutResource)) && newPresence->getFrom() != toJID_) { + if (!toJID_.equals(newPresence->getFrom(), toJID_.isBare() ? JID::WithoutResource : JID::WithResource)) { return; } + chatStateTracker_->handlePresenceChange(newPresence, previousPresence); String newStatusChangeString = getStatusChangeString(newPresence); if (!previousPresence || newStatusChangeString != getStatusChangeString(previousPresence)) { diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 1ee501a..824c98d 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -114,6 +114,7 @@ void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> event) { * If a resource goes offline, release bound chatdialog to that resource. */ void ChatsManager::handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> /*lastPresence*/) { + if (isMUC(newPresence->getFrom().toBare())) return; if (newPresence->getType() != Presence::Unavailable) return; JID fullJID(newPresence->getFrom()); std::map<JID, ChatController*>::iterator it = chatControllers_.find(fullJID); @@ -128,23 +129,6 @@ void ChatsManager::setAvatarManager(AvatarManager* avatarManager) { avatarManager_ = avatarManager; } -// void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { -// { -// boost::shared_ptr<RequestChatUIEvent> event = boost::dynamic_pointer_cast<RequestChatUIEvent>(rawEvent); -// if (event != NULL) { -// handleChatRequest(event->getContact()); -// return; -// } -// } -// { -// boost::shared_ptr<JoinMUCUIEvent> event = boost::dynamic_pointer_cast<JoinMUCUIEvent>(rawEvent); -// if (event != NULL) { -// handleJoinMUCRequest(); -// } -// } -// } - - void ChatsManager::setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info) { serverDiscoInfo_ = info; foreach (JIDChatControllerPair pair, chatControllers_) { @@ -157,7 +141,6 @@ void ChatsManager::setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info) { void ChatsManager::setEnabled(bool enabled) { foreach (JIDChatControllerPair controllerPair, chatControllers_) { - //printf("Setting enabled on %d to %d\n", controllerPair.second, enabled); controllerPair.second->setEnabled(enabled); } foreach (JIDMUCControllerPair controllerPair, mucControllers_) { diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 9957891..9af7a70 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -43,6 +43,7 @@ namespace Swift { void setEnabled(bool enabled); void setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<Message> message); + virtual bool isMUC(const JID& muc) const; private: void handleChatRequest(const String& contact); void handleJoinMUCRequest(const JID& muc, const boost::optional<String>& nick); @@ -56,8 +57,6 @@ namespace Swift { ChatController* createNewChatController(const JID &contact); ChatController* getChatControllerOrCreate(const JID &contact); ChatController* getChatControllerIfExists(const JID &contact); - virtual bool isMUC(const JID& muc) const; - std::map<JID, MUCController*> mucControllers_; std::map<JID, ChatController*> chatControllers_; EventController* eventController_; |