summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-26 13:42:19 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-26 13:42:19 (GMT)
commit42cf17e614f0c490ea214e36ac4e7ded2d0495b7 (patch)
treed29dd06d1942c89a9e7cfb2243359b4460df01af /Swift/Controllers/Chat/ChatsManager.cpp
parentfd6e929a54514d5c3f77956429d5ab5fb4271ff2 (diff)
downloadswift-42cf17e614f0c490ea214e36ac4e7ded2d0495b7.zip
swift-42cf17e614f0c490ea214e36ac4e7ded2d0495b7.tar.bz2
Remove MUCs from the ChatsManager's list once you leave them.
Resolves: #292
Diffstat (limited to 'Swift/Controllers/Chat/ChatsManager.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index ac03f8a..104df22 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -56,6 +56,17 @@ void ChatsManager::handleMUCBookmarksChanged() {
}
}
+void ChatsManager::handleUserLeftMUC(MUCController* mucController) {
+ std::map<JID, MUCController*>::iterator it;
+ for (it = mucControllers_.begin(); it != mucControllers_.end(); it++) {
+ if ((*it).second == mucController) {
+ mucControllers_.erase(it);
+ delete mucController;
+ return;
+ }
+ }
+}
+
void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> event) {
boost::shared_ptr<RequestChatUIEvent> chatEvent = boost::dynamic_pointer_cast<RequestChatUIEvent>(event);
if (chatEvent) {
@@ -150,8 +161,10 @@ void ChatsManager::handleJoinMUCRequest(const JID &muc, const String &nick) {
if (it != mucControllers_.end()) {
//FIXME: What's correct behaviour here?
} else {
- mucControllers_[muc] = new MUCController(jid_, muc, nick, stanzaChannel_, presenceSender_, iqRouter_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_);
- mucControllers_[muc]->setAvailableServerFeatures(serverDiscoInfo_);
+ MUCController* controller = new MUCController(jid_, muc, nick, stanzaChannel_, presenceSender_, iqRouter_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_);
+ mucControllers_[muc] = controller;
+ controller->setAvailableServerFeatures(serverDiscoInfo_);
+ controller->onUserLeft.connect(boost::bind(&ChatsManager::handleUserLeftMUC, this, controller));
}
mucControllers_[muc]->activateChatWindow();
}