From 9e1c5bcc741c19c1f3e7e5f534b8b572f4526961 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Wed, 7 Apr 2010 14:58:52 -0400
Subject: [PATCH] [#3045] Start/stop python glib mainloop for test suite

---
 tools/pysflphone/pysflphone_testdbus.py |  3 +++
 tools/pysflphone/sflphonectrlsimple.py  | 18 +++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tools/pysflphone/pysflphone_testdbus.py b/tools/pysflphone/pysflphone_testdbus.py
index d05da47a99..dc17f2bbc9 100644
--- a/tools/pysflphone/pysflphone_testdbus.py
+++ b/tools/pysflphone/pysflphone_testdbus.py
@@ -135,10 +135,13 @@ class SflPhoneTests():
         # Start Glib mainloop
         self.sflphone.start()
 
+        
+
 
     # SCENARIO 1 Test 4
     def test_ip2ip_recv_peer_hungup(self):
         """Wait for calls, answer, peer hangup"""
+
         # Add callback for this test
         self.sflphone.onIncomingCall_cb = acceptOnIncomingCall
 
diff --git a/tools/pysflphone/sflphonectrlsimple.py b/tools/pysflphone/sflphonectrlsimple.py
index 8de24706aa..cba2cf72da 100755
--- a/tools/pysflphone/sflphonectrlsimple.py
+++ b/tools/pysflphone/sflphonectrlsimple.py
@@ -71,9 +71,13 @@ class SflPhoneCtrlSimple(Thread):
 
 	self.loop = MainLoop()
 
+	self.isStop = False
+
 	self.test = test
 	self.onIncomingCall_cb = None
 	self.event = Event()
+
+	gobject.threads_init()
 	
 
 
@@ -83,6 +87,12 @@ class SflPhoneCtrlSimple(Thread):
 	self.loop.quit()
 
 
+    def stopThread(self):
+        print "Stop PySFLphone"
+        self.isStop = True
+	
+
+
     def register(self):
         if self.registered:
             return
@@ -614,9 +624,11 @@ class SflPhoneCtrlSimple(Thread):
 
     def run(self):
         """Processing method for this thread"""
-        gobject.threads_init()
-        # self.loop.run()
+
 	context = self.loop.get_context()
 
-	while 1:
+	while True:
             context.iteration(True)
+
+	    if self.isStop: 
+	        return
-- 
GitLab