From 99981e57b892a04e32fa03249218f55e6fd7cfb2 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 26 Aug 2010 11:56:12 +0200 Subject: [PATCH] ability to send several files at the same time. We need to accept them all before transfer starts for the moment. --- src/common/jingle_ft.py | 3 ++- src/common/socks5.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py index 89c261e2e..4a612180b 100644 --- a/src/common/jingle_ft.py +++ b/src/common/jingle_ft.py @@ -188,7 +188,8 @@ class JingleFileTransfer(JingleContent): gajim.socks5queue.add_receiver(self.session.connection.name, receiver) streamhost_used['idx'] = receiver.queue_idx - gajim.socks5queue.on_success = self.transport._on_proxy_auth_ok + gajim.socks5queue.on_success[self.file_props['sid']] = \ + self.transport._on_proxy_auth_ok else: jid = gajim.get_jid_without_resource(self.session.ourjid) gajim.socks5queue.send_file(self.file_props, diff --git a/src/common/socks5.py b/src/common/socks5.py index 6dc70f955..f7bdc7884 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -81,8 +81,8 @@ class SocksQueue: self.complete_transfer_cb = complete_transfer_cb self.progress_transfer_cb = progress_transfer_cb self.error_cb = error_cb - self.on_success = None - self.on_failure = None + self.on_success = {} # {id: cb} + self.on_failure = {} # {id: cb} def start_listener(self, port, sha_str, sha_handler, sid, fingerprint=None): """ @@ -110,7 +110,7 @@ class SocksQueue: if 'proxyhosts' in file_props: for proxy in file_props['proxyhosts']: if proxy == streamhost: - self.on_success(streamhost) + self.on_success[file_props['sid']](streamhost) return 2 return 0 if 'streamhosts' in file_props: @@ -118,14 +118,14 @@ class SocksQueue: if streamhost['state'] == 1: return 0 streamhost['state'] = 1 - self.on_success(streamhost) + self.on_success[file_props['sid']](streamhost) return 1 return 0 def connect_to_hosts(self, account, sid, on_success=None, on_failure=None, fingerprint=None): - self.on_success = on_success - self.on_failure = on_failure + self.on_success[sid] = on_success + self.on_failure[sid] = on_failure file_props = self.files_props[account][sid] file_props['failure_cb'] = on_failure @@ -304,6 +304,8 @@ class SocksQueue: if account in self.files_props: fl_props = self.files_props[account] if sid in fl_props: + del self.on_success[sid] + del self.on_failure[sid] del(fl_props[sid]) if len(self.files_props) == 0: