summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp32
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h1
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp1
3 files changed, 26 insertions, 8 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index e1a9adc..2fc5a43 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -39,16 +39,11 @@ ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRo
serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
presenceSender_ = presenceSender;
uiEventStream_ = uiEventStream;
- mucBookmarkManager_ = new MUCBookmarkManager(iqRouter);
- mucBookmarkManager_->onBookmarksReady.connect(boost::bind(&ChatsManager::handleBookmarksReady, this));
- mucBookmarkManager_->onBookmarkAdded.connect(boost::bind(&ChatsManager::handleMUCBookmarkAdded, this, _1));
- mucBookmarkManager_->onBookmarkRemoved.connect(boost::bind(&ChatsManager::handleMUCBookmarkRemoved, this, _1));
+ mucBookmarkManager_ = NULL;
presenceOracle_->onPresenceChange.connect(boost::bind(&ChatsManager::handlePresenceChange, this, _1));
uiEventConnection_ = uiEventStream_->onUIEvent.connect(boost::bind(&ChatsManager::handleUIEvent, this, _1));
chatListWindow_ = chatListWindowFactory->createWindow(uiEventStream_);
- if (chatListWindow_) {
- chatListWindow_->setBookmarksEnabled(false);
- }
+ setupBookmarks();
}
ChatsManager::~ChatsManager() {
@@ -61,6 +56,20 @@ ChatsManager::~ChatsManager() {
delete mucBookmarkManager_;
}
+void ChatsManager::setupBookmarks() {
+ if (!mucBookmarkManager_) {
+ mucBookmarkManager_ = new MUCBookmarkManager(iqRouter_);
+ mucBookmarkManager_->onBookmarksReady.connect(boost::bind(&ChatsManager::handleBookmarksReady, this));
+ mucBookmarkManager_->onBookmarkAdded.connect(boost::bind(&ChatsManager::handleMUCBookmarkAdded, this, _1));
+ mucBookmarkManager_->onBookmarkRemoved.connect(boost::bind(&ChatsManager::handleMUCBookmarkRemoved, this, _1));
+
+ if (chatListWindow_) {
+ chatListWindow_->setBookmarksEnabled(false);
+ chatListWindow_->clear();
+ }
+ }
+}
+
void ChatsManager::handleBookmarksReady() {
if (chatListWindow_) {
chatListWindow_->setBookmarksEnabled(true);
@@ -161,7 +170,14 @@ void ChatsManager::setOnline(bool enabled) {
controllerPair.second->rejoin();
}
}
- chatListWindow_->setBookmarksEnabled(enabled);
+ if (!enabled) {
+ delete mucBookmarkManager_;
+ mucBookmarkManager_ = NULL;
+ chatListWindow_->setBookmarksEnabled(false);
+ } else {
+ setupBookmarks();
+ }
+
}
void ChatsManager::handleChatRequest(const String &contact) {
diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h
index 6dab532..2b771eb 100644
--- a/Swift/Controllers/Chat/ChatsManager.h
+++ b/Swift/Controllers/Chat/ChatsManager.h
@@ -56,6 +56,7 @@ namespace Swift {
void handleMUCBookmarkRemoved(const MUCBookmark& bookmark);
void handleUserLeftMUC(MUCController* mucController);
void handleBookmarksReady();
+ void setupBookmarks();
ChatController* getChatControllerOrFindAnother(const JID &contact);
ChatController* createNewChatController(const JID &contact);
ChatController* getChatControllerOrCreate(const JID &contact);
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 6ac6a0c..975a2d2 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -284,6 +284,7 @@ String MUCController::roleToGroupName(MUCOccupant::Role role) {
void MUCController::setOnline(bool online) {
ChatControllerBase::setOnline(online);
if (!online) {
+ muc_->part();
parting_ = true;
processUserPart();
} else {