From 5234e42a28de708fe1ce30350e073226a8a561a2 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 26 Aug 2010 16:56:08 +0200 Subject: [PATCH] [Thibg] handle negociated variable correctly and use it for file transfer. --- src/common/jingle_content.py | 15 +++++++++++---- src/common/jingle_ft.py | 2 +- src/common/jingle_rtp.py | 12 ++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/common/jingle_content.py b/src/common/jingle_content.py index af94561c2..e2a5c9a28 100644 --- a/src/common/jingle_content.py +++ b/src/common/jingle_content.py @@ -55,14 +55,16 @@ class JingleContent(object): self.callbacks = { # these are called when *we* get stanzas - 'content-accept': [self.__on_transport_info], + 'content-accept': [self.__on_transport_info, + self.__on_content_accept], 'content-add': [self.__on_transport_info], 'content-modify': [], 'content-reject': [], 'content-remove': [], 'description-info': [], 'security-info': [], - 'session-accept': [self.__on_transport_info], + 'session-accept': [self.__on_transport_info, + self.__on_content_accept], 'session-info': [], 'session-initiate': [self.__on_transport_info], 'session-terminate': [], @@ -73,16 +75,21 @@ class JingleContent(object): 'iq-result': [], 'iq-error': [], # these are called when *we* sent these stanzas - 'content-accept-sent': [self.__fill_jingle_stanza], + 'content-accept-sent': [self.__fill_jingle_stanza, + self.__on_content_accept], 'content-add-sent': [self.__fill_jingle_stanza], 'session-initiate-sent': [self.__fill_jingle_stanza], - 'session-accept-sent': [self.__fill_jingle_stanza], + 'session-accept-sent': [self.__fill_jingle_stanza, + self.__on_content_accept], 'session-terminate-sent': [], } def is_ready(self): return self.accepted and not self.sent + def __on_content_accept(self, stanza, content, error, action): + self.on_negotiated() + def on_negotiated(self): if self.accepted: self.negotiated = True diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py index b8b7e0d19..697d24867 100644 --- a/src/common/jingle_ft.py +++ b/src/common/jingle_ft.py @@ -223,7 +223,7 @@ class JingleFileTransfer(JingleContent): # send error message, notify the user elif not self.weinitiate and self.state == STATE_NOT_STARTED: # session-accept iq-result - if not self.sent: + if not self.negotiated: return self.state = STATE_ACCEPTED if not gajim.socks5queue.get_file_props( diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index b32d0419b..6d738bc56 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -53,12 +53,8 @@ class JingleRTPContent(JingleContent): self.callbacks['session-initiate'] += [self.__on_remote_codecs] self.callbacks['content-add'] += [self.__on_remote_codecs] self.callbacks['description-info'] += [self.__on_remote_codecs] - self.callbacks['content-accept'] += [self.__on_remote_codecs, - self.__on_content_accept] - self.callbacks['session-accept'] += [self.__on_remote_codecs, - self.__on_content_accept] - self.callbacks['session-accept-sent'] += [self.__on_content_accept] - self.callbacks['content-accept-sent'] += [self.__on_content_accept] + self.callbacks['content-accept'] += [self.__on_remote_codecs] + self.callbacks['session-accept'] += [self.__on_remote_codecs] self.callbacks['session-terminate'] += [self.__stop] self.callbacks['session-terminate-sent'] += [self.__stop] @@ -234,14 +230,14 @@ class JingleRTPContent(JingleContent): def get_fallback_src(self): return gst.element_factory_make('fakesrc') - def __on_content_accept(self, stanza, content, error, action): + def on_negotiated(self): if self.accepted: if self.transport.remote_candidates: self.p2pstream.set_remote_candidates(self.transport.remote_candidates) self.transport.remote_candidates = [] # TODO: farsight.DIRECTION_BOTH only if senders='both' self.p2pstream.set_property('direction', farsight.DIRECTION_BOTH) - self.on_negotiated() + JingleContent.on_negotiated(self) def __on_remote_codecs(self, stanza, content, error, action): """