From 84f6c22878d11ff4b0deed1a1c15b4db47177917 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Wed, 29 Feb 2012 09:27:52 +0000
Subject: Don't crash when trying to join MUCs offline

Resolves: #940

diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index a2b286f..557aef4 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -547,6 +547,10 @@ void ChatsManager::rebindControllerJID(const JID& from, const JID& to) {
 }
 
 void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<std::string>& password, const boost::optional<std::string>& nickMaybe, bool addAutoJoin, bool createAsReservedIfNew) {
+	if (!stanzaChannel_->isAvailable()) {
+		/* This is potentially not the optimal solution, but it will avoid consistency issues.*/
+		return;
+	}
 	if (addAutoJoin) {
 		MUCBookmark bookmark(mucJID, mucJID.getNode());
 		bookmark.setAutojoin(true);
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index 9bcb279..a52f552 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -59,7 +59,6 @@ void MUC::joinWithContextSince(const std::string &nick, const boost::posix_time:
 }
 
 void MUC::internalJoin(const std::string &nick) {
-	//TODO: password
 	//TODO: history request
 	joinComplete_ = false;
 	joinSucceeded_ = false;
-- 
cgit v0.10.2-6-g49f6