From 70e395802de55b1d2eb9f92ad86349cd2d0d0575 Mon Sep 17 00:00:00 2001
From: dknn <yoann.blein@free.fr>
Date: Sun, 15 Jul 2012 15:45:23 +0200
Subject: Add signal disconnects


diff --git a/Swiften/Examples/SConscript b/Swiften/Examples/SConscript
index fb568fc..11238ff 100644
--- a/Swiften/Examples/SConscript
+++ b/Swiften/Examples/SConscript
@@ -10,4 +10,5 @@ SConscript(dirs = [
 	"NetworkTool",
 	"ParserTester",
 	"BenchTool",
+	"ScreenSharing",
 ])
diff --git a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
index 77226c5..ec0a39c 100644
--- a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
+++ b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
@@ -28,11 +28,12 @@ OutgoingScreenSharing::OutgoingScreenSharing(boost::shared_ptr<JingleSession> se
 	  timerFactory(timerFactory), contentID(JingleContentID(idGenerator.generateID(), JingleContentPayload::InitiatorCreator)),
 	  canceled(false), sessionAccepted(false), socketConnected(false), encoder(0), packetizer(0)
 {
-	session->onSessionAcceptReceived.connect(boost::bind(&OutgoingScreenSharing::handleSessionAcceptReceived, this, _1, _2, _3));
+	jingleSession->onSessionAcceptReceived.connect(boost::bind(&OutgoingScreenSharing::handleSessionAcceptReceived, this, _1, _2, _3));
 }
 
 OutgoingScreenSharing::~OutgoingScreenSharing()
 {
+	jingleSession->onSessionAcceptReceived.disconnect(boost::bind(&OutgoingScreenSharing::handleSessionAcceptReceived, this, _1, _2, _3));
 	delete rtpSession;
 	delete encoder;
 	delete packetizer;
@@ -64,7 +65,6 @@ void OutgoingScreenSharing::start(unsigned int width, unsigned int height)
 	jingleSession->sendInitiate(contentID, desc, transport);
 	onStateChange(ScreenSharing::WaitingForAccept);
 
-	serverSocket->onConnected.connect(boost::bind(&OutgoingScreenSharing::handleSocketConnected, this));
 	serverSocket->connectToFirstIncoming();
 }
 
@@ -79,6 +79,8 @@ void OutgoingScreenSharing::handleSocketConnected()
 		return;
 	SWIFT_LOG(debug) << "Screen sharing: UDP socket connected" << std::endl;
 
+	serverSocket->onConnected.disconnect(boost::bind(&OutgoingScreenSharing::handleSocketConnected, this));
+
 	socketConnected = true;
 	if (sessionAccepted)
 		startRTPSession();
@@ -107,6 +109,8 @@ void OutgoingScreenSharing::handleConnectionFailed()
 {
 	SWIFT_LOG(debug) << "Screen sharing: unable to connect" << std::endl;
 
+	connectionTimer->onTick.disconnect(boost::bind(&OutgoingScreenSharing::handleConnectionFailed, this));
+
 	jingleSession->sendTerminate(JinglePayload::Reason::ConnectivityError);
 	canceled = true;
 
diff --git a/Swiften/ScreenSharing/RTPSession.cpp b/Swiften/ScreenSharing/RTPSession.cpp
deleted file mode 100644
index 3a22326..0000000
--- a/Swiften/ScreenSharing/RTPSession.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2012 Yoann Blein
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#include <Swiften/ScreenSharing/RTPSession.h>
-
-namespace Swift {
-
-RTPSession::~RTPSession()
-{
-}
-
-}
diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp
index eede971..be3c8ab 100644
--- a/Swiften/ScreenSharing/ScreenSharing.cpp
+++ b/Swiften/ScreenSharing/ScreenSharing.cpp
@@ -21,11 +21,12 @@ namespace Swift {
 ScreenSharing::ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory)
 	: rtpSession(0), jingleSession(session), udpSocketFactory(udpSocketFactory)
 {
-	session->onSessionTerminateReceived.connect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1));
+	jingleSession->onSessionTerminateReceived.connect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1));
 }
 
 ScreenSharing::~ScreenSharing()
 {
+	jingleSession->onSessionTerminateReceived.disconnect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1));
 }
 
 void ScreenSharing::stop()
-- 
cgit v0.10.2-6-g49f6