[Telepathy-commits] [mingle/master] Use Contact objest instead of FsParticipants where possible

Sjoerd Simons sjoerd at luon.net
Wed Nov 5 07:24:42 PST 2008


---
 jingle.py |   47 ++++++++++++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/jingle.py b/jingle.py
index 189f059..36d79f4 100644
--- a/jingle.py
+++ b/jingle.py
@@ -167,14 +167,19 @@ class JingleBaseTransport:
              'rtcp': farsight.COMPONENT_RTCP}.__getitem__),
         }
 
-    def prepare(self, fssession, participant):
-        self.fssession = fssession
-        self.fsstream = self.fssession.add_participant(participant,
-            self.transmitter, self.transmitter_params)
-        self.fsstream.newLocalCandidate.addCallback(False,
+    def got_stream(self, stream):
+        self.fsstream = stream
+        self.pending_candidates = stream.candidates[:]
+
+        stream.newLocalCandidate.addCallback(False,
             self.new_local_candidate)
         self.state = JingleBaseTransport.PREPARING
-        return defer.succeed(self)
+
+    def prepare(self, fssession, contact):
+        d =  self.content.session.conference.get_stream (fssession, contact)
+        d.addCallback (self.got_stream)
+
+        return d
 
     def add_transport(self, parent):
         return parent.addElement((self.namespace, 'transport'))
@@ -244,9 +249,8 @@ class JingleBaseTransport:
         self.pending_candidates = []
         map(self.send_candidate, candidates)
 
-
-    def got_initiate(self, fssession, participant, content):
-        self.prepare(fssession, participant)
+    def got_initiate(self, fssession, contact, content):
+        self.prepare(fssession, contact)
         self.initiate()
 
         self.transport_info(content)
@@ -325,8 +329,8 @@ class JingleRawudpTransport(JingleBaseTransport):
         # FIXME save somewhere
         candidate['id'] = make_sid()
 
-    def prepare(self, fssession, participant):
-        JingleBaseTransport.prepare(self, fssession, participant)
+    def prepare(self, fssession, contact):
+        JingleBaseTransport.prepare(self, fssession, contact)
         self.candidate_deferred = defer.Deferred()
         return self.candidate_deferred
 
@@ -353,7 +357,7 @@ class JingleContent:
         self.description = None
         self.transport = None
         self.initiator = initiator
-        self.accepted = False
+        self.session_accepted = False
         self.direction = farsight.DIRECTION_BOTH
 
     def transport_info(self, stanza):
@@ -394,7 +398,7 @@ class JingleContent:
         self.transport.add_transport(content)
 
     def accepted(self):
-        self.accepted = True
+        self.session_accepted = True
         self.description.accepted()
         self.description.change_direction(self.direction)
 
@@ -437,7 +441,7 @@ class JingleContent:
             return caps2desc[namespace](self, self.type)
 
     # Content part of the session initiatioe
-    def got_initiate(self, content, participant):
+    def got_initiate(self, content, contact):
         description = xpath.queryForNodes(
             '/content/description', content)[0]
         transport = xpath.queryForNodes(
@@ -463,7 +467,7 @@ class JingleContent:
             self.name, self.type)
 
         stream = self.transport.got_initiate(self.fssession,
-            participant, content)
+            contact, content)
         self.description.got_initiate(self.fssession, stream, content)
 
     def ready_for_accept(self):
@@ -507,16 +511,16 @@ class JingleContent:
             self.name, self.type)
 
         dtransport = self.transport.prepare(self.fssession,
-            self.remote_participant)
+            self.remote_contact)
         ddescription = self.description.prepare(self.fssession)
 
         d = defer.DeferredList([dtransport, ddescription])
         d.addCallback(lambda *args: self.prepare_deferred.callback(self))
 
-    def prepare(self, contact, participant):
+    def prepare(self, contact):
         # Prepare a description and transport for the contact, depending on
         # it's capabilities
-        self.remote_participant = participant
+        self.remote_contact = contact
         self.prepare_deferred = defer.Deferred()
         contact.get_capabilities().addCallback(self.prepare_got_caps)
 
@@ -615,14 +619,12 @@ class JingleBaseSession:
         self.initiator = JID(jingle['initiator'])
         self.sid = jingle['sid']
 
-        self.remote_participant = self.conference.get_participant(contact)
-
         contents = xpath.queryForNodes(
             '/iq/jingle[@xmlns="%s"]/content' % self.namespace, iq)
         for c in contents:
             content = JingleContent(self, c['name'], initiator = False)
             self.contents[content.name] = content
-            content.got_initiate(c, self.remote_participant)
+            content.got_initiate(c, contact)
 
         self.iq_handler_id = self.client.add_iq_handler('set',
             self.namespace, 'jingle', self.got_jingle_iq)
@@ -687,7 +689,6 @@ class JingleBaseSession:
         # Start initiating a new jingle to contact X
         self.initiating = True
         self.remote_jid = contact.jid
-        self.remote_participant = self.conference.get_participant(contact)
 
         assert self.contents == {}
 
@@ -703,7 +704,7 @@ class JingleBaseSession:
 
         deferreds = []
         for c in self.contents.copy().itervalues():
-            d = c.prepare(contact, self.remote_participant)
+            d = c.prepare(contact)
             d.addCallback(self.content_prepared)
             d.addErrback(self.content_preperation_failed, c)
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list