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