Forget all unused streamhosts when we use one of our proposed streamhosts

This commit is contained in:
Yann Leboulanger 2017-08-16 23:05:43 +02:00
parent 99b27b4484
commit 09bcbc0cef
3 changed files with 13 additions and 10 deletions

View File

@ -159,8 +159,7 @@ class StateTransfering(JingleFileTransferStates):
mode = 'server'
streamhost_used = self.jft.nominated_cand['peer-cand']
gajim.socks5queue.remove_client(self.jft.file_props.transport_sid)
# our_cand = self.jft.nominated_cand['our-cand']
# gajim.socks5queue.remove_receiver(our_cand['idx'])
gajim.socks5queue.remove_other_servers(streamhost_used['host'])
if streamhost_used['type'] == 'proxy':
self.jft.file_props.is_a_proxy = True
if self.jft.file_props.type_ == 's' and self.jft.weinitiate:

View File

@ -398,12 +398,11 @@ class SocksQueue:
sender = self.senders[key]
if do_disconnect:
sender.disconnect()
else:
self.idlequeue.unplug_idle(sender.fd)
self.idlequeue.remove_timeout(sender.fd)
del(self.senders[key])
if self.connected > 0:
self.connected -= 1
self.idlequeue.unplug_idle(sender.fd)
self.idlequeue.remove_timeout(sender.fd)
del(self.senders[key])
if self.connected > 0:
self.connected -= 1
def remove_receiver(self, idx, do_disconnect=True, remove_all=False):
"""
@ -448,6 +447,11 @@ class SocksQueue:
def remove_client(self, transport_sid, do_disconnect=True):
self.remove_by_mode(transport_sid, 'client')
def remove_other_servers(self, host_to_keep):
for (key, sock) in self.senders.copy().items():
if sock.host != host_to_keep and sock.mode == 'server':
self.remove_sender_by_key(key)
class Socks5(object):
def __init__(self, idlequeue, host, port, initiator, target, sid):
if host is not None:

View File

@ -212,8 +212,8 @@ class FileTransfersWindow:
sectext += recipient
if file_props.type_ == 'r':
sectext += '\n\t' + _('Saved in: %s') % file_path
dialog = dialogs.HigDialog(None, Gtk.MessageType.INFO, Gtk.ButtonsType.NONE,
_('File transfer completed'), sectext)
dialog = dialogs.HigDialog(gajim.interface.roster.window, Gtk.MessageType.INFO,
Gtk.ButtonsType.NONE, _('File transfer completed'), sectext)
if file_props.type_ == 'r':
button = Gtk.Button.new_with_mnemonic(_('Open _Containing Folder'))
button.connect('clicked', on_open, file_props)