From 6e87ef3a842094483105df4e6333c90964a69a47 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Mon, 27 Oct 2014 16:31:32 +0100
Subject: Only call MUC::onJoinComplete signal once per MUC join.

Old versions of Prosody do not support instant rooms, i.e. do not respond to the
data form submit. It also pretends all rooms exist all the time and thus will
never send status 201.
This change will mark the room join as complete if we didn't receive status 201
but the join was otherwise successful.

Test-Information:

Tested this change against M-Link, Prosody nightly (which behaves according to
XEP-0045), Prosody 0.9 (which eats the data form submit for instant rooms), and
Openfire with Swift.

Change-Id: I63f5488433110231ca7d0a6834161a2acd2cfc73

diff --git a/Swiften/MUC/MUCImpl.cpp b/Swiften/MUC/MUCImpl.cpp
index 778c290..16e7421 100644
--- a/Swiften/MUC/MUCImpl.cpp
+++ b/Swiften/MUC/MUCImpl.cpp
@@ -266,7 +266,6 @@ void MUCImpl::handleIncomingPresence(Presence::ref presence) {
 					ownMUCJID = presence->getFrom();
 					presenceSender->addDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::AndSendPresence);
 				}
-				onJoinComplete(getOwnNick());
 			}
 			// MUC status 201: a new room has been created
 			if (status.code == 201) {
@@ -293,6 +292,9 @@ void MUCImpl::handleIncomingPresence(Presence::ref presence) {
 				}
 			}
 		}
+		if (joinComplete_ && !isLocked) {
+			onJoinComplete(getOwnNick());
+		}
 		if (!isLocked && !isUnlocked_ && (presence->getFrom() == ownMUCJID)) {
 			isUnlocked_ = true;
 			onUnlocked();
-- 
cgit v0.10.2-6-g49f6