[Telepathy-commits] [mingle/master] Add ability to remove participant and terminate jingle sessions

Sjoerd Simons sjoerd at luon.net
Tue Nov 11 11:01:17 PST 2008


---
 jingle.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/jingle.py b/jingle.py
index af6e22f..f818aaa 100644
--- a/jingle.py
+++ b/jingle.py
@@ -568,6 +568,7 @@ class JingleBaseSession:
             'transport-info': self.action_transport_info,
             'session-accept': self.action_session_accept,
             'content-modify': self.action_content_modify,
+            'session-terminate': self.action_session_terminate,
         }
 
     def add_jingle_stanza(self, iq, action):
@@ -598,6 +599,17 @@ class JingleBaseSession:
            self.contents[c['name']].transport_info(c)
         return make_iq_result(iq)
 
+    def action_session_terminate(self, iq, jingle):
+        # FIXME Cancel all outstanding deferreds
+        self.terminate()
+
+        return make_iq_result(iq)
+
+    def terminate(self):
+        part = self.conference.get_participant (
+            self.client.get_contact (self.remote_jid))
+        self.conference.remove_participant(part)
+
     def send_transport_info(self, content):
         iq = IQ(self.client.stream, 'set')
         iq['to'] = self.remote_jid.full()
@@ -775,6 +787,24 @@ class JingleConference(fs2.Conference):
 
         return session
 
+    def remove_participant(self, participant):
+        for session in self.streams.itervalues():
+            if session.has_key(participant):
+                stream = session.pop(participant)
+                self.remove_stream(stream.fsstream)
+
+        key = None
+        for (key, value) in self.participants.iteritems():
+            if value == participant:
+                break
+        self.participants.pop(key)
+
+        f = participant._fsparticipant
+        participant._fsparticipant = None
+        del f
+        del participant
+
+
     def create_stream(self, session, participant, namespace):
         transmitters = {
             ns.GOOGLE_TRANSPORT_P2P: ("nice", { 'compatibility-mode':  1 }),
-- 
1.5.6.5




More information about the Telepathy-commits mailing list