From 9d3b9903fcf830599c1b46fd1725f4d1d197e966 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sun, 24 Oct 2010 15:25:14 +0100
Subject: Rejoin MUCs on reconnect.

Resolves: #625
Release-Notes: MUCs will once again be rejoined on reconnect.

diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 26d29e7..614e2d2 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -296,9 +296,11 @@ void MainController::handleConnected() {
 
 	vcardManager_->requestOwnVCard();
 	
-	setManagersOnline(true);
-	//Send presence last to catch all the incoming presences.
+	rosterController_->setEnabled(true);
+	/* Send presence later to catch all the incoming presences. */
 	sendPresence(statusTracker_->getNextPresence());
+	/* Enable chats last of all, so rejoining MUCs has the right sent presence */
+	chatsManager_->setOnline(true);
 }
 
 void MainController::handleEventQueueLengthChange(int count) {
@@ -511,15 +513,15 @@ void MainController::logout() {
 		rosterController_->getWindow()->setMyStatusText("");
 		myStatusLooksOnline_ = false;
 	}
-	setManagersOnline(false);
+	setManagersOffline();
 }
 
-void MainController::setManagersOnline(bool enabled) {
+void MainController::setManagersOffline() {
 	if (chatsManager_) {
-		chatsManager_->setOnline(enabled);
+		chatsManager_->setOnline(false);
 	}
 	if (rosterController_) {
-		rosterController_->setEnabled(enabled);
+		rosterController_->setEnabled(false);
 	}
 }
 
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 2f01fd2..868f966 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -115,7 +115,7 @@ namespace Swift {
 	
 			void performLoginFromCachedCredentials();
 			void reconnectAfterError();
-			void setManagersOnline(bool enabled);
+			void setManagersOffline();
 			void handleNotificationClicked(const JID& jid);
 
 			VCardStorage* getVCardStorageForProfile(const JID& jid);
-- 
cgit v0.10.2-6-g49f6