From 86844bd1818c389d471977303121b03fe15e992a Mon Sep 17 00:00:00 2001
From: HanzZ <hanzz.k@gmail.com>
Date: Sat, 18 Jun 2011 20:47:50 +0200
Subject: Send footer when finishing session

License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php

diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp
index 39fab14..cdb83d4 100644
--- a/Swiften/Session/Session.cpp
+++ b/Swiften/Session/Session.cpp
@@ -38,18 +38,26 @@ void Session::startSession() {
 }
 
 void Session::finishSession() {
+	if (finishing)
+		return;
 	finishing = true;
+	if (xmppLayer) {
+		xmppLayer->writeFooter();
+	}
 	connection->disconnect();
 	handleSessionFinished(boost::optional<SessionError>());
-	finishing = false;
 	onSessionFinished(boost::optional<SessionError>());
 }
 
 void Session::finishSession(const SessionError& error) {
+	if (finishing)
+		return;
 	finishing = true;
+	if (xmppLayer) {
+		xmppLayer->writeFooter();
+	}
 	connection->disconnect();
 	handleSessionFinished(boost::optional<SessionError>(error));
-	finishing = false;
 	onSessionFinished(boost::optional<SessionError>(error));
 }
 
-- 
cgit v0.10.2-6-g49f6