Fixes jingleFT IBB fallback
This commit is contained in:
parent
f49f8163a6
commit
8fbaaba356
|
@ -138,6 +138,17 @@ class JingleContent(object):
|
|||
content = self.__content()
|
||||
content.addChild(node=self.transport.make_transport([candidate]))
|
||||
self.session.send_transport_info(content)
|
||||
|
||||
def send_error_candidate(self):
|
||||
"""
|
||||
Sends a candidate-error when we can't connect to a candidate.
|
||||
"""
|
||||
content = self.__content()
|
||||
tp = self.transport.make_transport()
|
||||
tp.addChild(name='candidate-error')
|
||||
content.addChild(node=tp)
|
||||
self.session.send_transport_info(content)
|
||||
|
||||
|
||||
def send_description_info(self):
|
||||
content = self.__content()
|
||||
|
|
|
@ -23,7 +23,6 @@ import gajim
|
|||
import xmpp
|
||||
from jingle_content import contents, JingleContent
|
||||
from jingle_transport import JingleTransportICEUDP, JingleTransportSocks5
|
||||
from jingle_transport import JingleTransportIBB
|
||||
from common import helpers
|
||||
from common.socks5 import Socks5Receiver
|
||||
from common.connection_handlers_events import FileRequestReceivedEvent
|
||||
|
@ -88,6 +87,7 @@ class JingleFileTransfer(JingleContent):
|
|||
|
||||
self.session = session
|
||||
self.media = 'file'
|
||||
|
||||
|
||||
def __on_session_initiate(self, stanza, content, error, action):
|
||||
gajim.nec.push_incoming_event(FileRequestReceivedEvent(None,
|
||||
|
@ -131,6 +131,9 @@ class JingleFileTransfer(JingleContent):
|
|||
|
||||
if not self.weinitiate: # proxy activated from initiator
|
||||
return
|
||||
if content.getTag('transport').getTag('candidate-error'):
|
||||
self.session.transport_replace()
|
||||
return
|
||||
streamhost_cid = content.getTag('transport').getTag('candidate-used').\
|
||||
getAttr('cid')
|
||||
streamhost_used = None
|
||||
|
@ -147,7 +150,7 @@ class JingleFileTransfer(JingleContent):
|
|||
if proxy['host'] == streamhost_used['host'] and \
|
||||
proxy['port'] == streamhost_used['port'] and \
|
||||
proxy['jid'] == streamhost_used['jid']:
|
||||
streamhost_used = proxy
|
||||
host_used = proxy
|
||||
break
|
||||
if 'streamhosts' not in self.file_props:
|
||||
self.file_props['streamhosts'] = []
|
||||
|
@ -238,6 +241,9 @@ class JingleFileTransfer(JingleContent):
|
|||
self.session.send_transport_info(content)
|
||||
|
||||
def _on_connect_error(self, to, _id, sid, code=404):
|
||||
if code == 404 and self.file_props['sid'] == sid:
|
||||
self.send_error_candidate()
|
||||
|
||||
log.info('connect error, sid=' + sid)
|
||||
|
||||
def _fill_content(self, content):
|
||||
|
|
|
@ -314,7 +314,7 @@ class JingleSession(object):
|
|||
self.__send_error(stanza, 'bad-request')
|
||||
return
|
||||
# FIXME: If we aren't initiated and it's not a session-initiate...
|
||||
if action != 'session-initiate' and self.state == JingleStates.ended:
|
||||
if action not in ['session-initiate','session-terminate'] and self.state == JingleStates.ended:
|
||||
self.__send_error(stanza, 'item-not-found', 'unknown-session')
|
||||
return
|
||||
else:
|
||||
|
@ -367,7 +367,7 @@ class JingleSession(object):
|
|||
self.__append_contents(jingle)
|
||||
self.__broadcast(stanza, jingle, None, 'transport-replace')
|
||||
self.connection.connection.send(stanza)
|
||||
#self.collect_iq_id(stanza.getID())
|
||||
self.state = JingleStates.pending
|
||||
|
||||
|
||||
def __on_transport_replace(self, stanza, jingle, error, action):
|
||||
|
@ -599,10 +599,6 @@ class JingleSession(object):
|
|||
|
||||
def __dispatch_error(self, error=None, text=None, type_=None):
|
||||
|
||||
if type_ == 'cancel' and error == 'item-not-found':
|
||||
# We coudln't connect with sock5stream, we fallback to IBB
|
||||
self.transport_replace()
|
||||
return
|
||||
if text:
|
||||
text = '%s (%s)' % (error, text)
|
||||
if type_ != 'modify':
|
||||
|
|
|
@ -128,7 +128,7 @@ class ConnectionBytestream:
|
|||
feature.addChild(node=_feature)
|
||||
field = _feature.setField('stream-method')
|
||||
field.setAttr('type', 'list-single')
|
||||
#field.addOption(xmpp.NS_BYTESTREAM)
|
||||
field.addOption(xmpp.NS_BYTESTREAM)
|
||||
field.addOption(xmpp.NS_IBB)
|
||||
self.connection.send(iq)
|
||||
|
||||
|
@ -795,8 +795,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
|||
if file_props['seq'] == 65536:
|
||||
file_props['seq'] = 0
|
||||
self.last_sent_ibb_id = self.connection.send(xmpp.Protocol('iq',
|
||||
file_props['direction'][1:], payload=[datanode,
|
||||
self._ampnode]))
|
||||
file_props['direction'][1:], 'set', payload=[datanode]))
|
||||
current_time = time.time()
|
||||
file_props['elapsed-time'] += current_time - file_props[
|
||||
'last-time']
|
||||
|
@ -871,7 +870,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
|||
# look in sending files
|
||||
if sid in self.files_props.keys():
|
||||
conn.send(stanza.buildReply('result'))
|
||||
gajim.socks5queue.complete_transfer_cb(self.name, file_props)
|
||||
gajim.socks5queue.complete_transfer_cb(self.name, self.files_props[sid])
|
||||
del self.files_props[sid]
|
||||
# look in receiving files
|
||||
elif gajim.socks5queue.get_file_props(self.name, sid):
|
||||
|
|
|
@ -209,7 +209,7 @@ class SocksQueue:
|
|||
return
|
||||
# failure_cb exists - this means that it has never been called
|
||||
if 'failure_cb' in file_props and file_props['failure_cb']:
|
||||
file_props['failure_cb'](streamhost['initiator'], streamhost['id'],
|
||||
file_props['failure_cb'](streamhost['initiator'], streamhost['idx'],
|
||||
file_props['sid'], code = 404)
|
||||
del(file_props['failure_cb'])
|
||||
|
||||
|
|
|
@ -36,11 +36,13 @@
|
|||
##
|
||||
|
||||
from common import demandimport
|
||||
|
||||
demandimport.enable()
|
||||
demandimport.ignore += ['gobject._gobject', 'libasyncns', 'i18n',
|
||||
'logging.NullHandler', 'dbus.glib', 'dbus.service',
|
||||
'command_system.implementation.standard', 'OpenSSL.SSL', 'OpenSSL.crypto',
|
||||
'common.sleepy', 'DLFCN', 'dl', 'xml.sax', 'xml.sax.handler', 'ic']
|
||||
'common.sleepy', 'DLFCN', 'dl', 'xml.sax', 'xml.sax.handler', 'ic'
|
||||
,'FileRequestReceivedEvent']
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
Loading…
Reference in New Issue