[Thibg] handle negociated variable correctly and use it for file transfer.

This commit is contained in:
Yann Leboulanger 2010-08-26 16:56:08 +02:00
parent 164a3891ba
commit 5234e42a28
3 changed files with 16 additions and 13 deletions

View File

@ -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

View File

@ -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(

View File

@ -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):
"""