fixed logic errors in FT and proxies

This commit is contained in:
Dimitur Kirov 2005-08-09 11:38:11 +00:00
parent 31365c33ab
commit 2bc8bcf482
3 changed files with 38 additions and 23 deletions

View File

@ -541,27 +541,29 @@ class Connection:
raise common.xmpp.NodeProcessed
jid = streamhost.getAttr('jid')
id = real_id[3:]
if not self.files_props.has_key(id):
file_props = gajim.socks5queue.get_file_props(self.name, id)
gajim.socks5queue.get_file_from_sender(file_props, self.name)
raise common.xmpp.NodeProcessed
file_props = None
if self.files_props.has_key(id):
file_props = self.files_props[id]
else:
raise common.xmpp.NodeProcessed
file_props['type']
if file_props.has_key('streamhost-used') and \
file_props['streamhost-used'] is True:
raise common.xmpp.NodeProcessed
if real_id[:3] == 'au_':
gajim.socks5queue.send_file(file_props, self.name)
raise common.xmpp.NodeProcessed
proxy = None
if file_props.has_key('proxyhosts'):
for proxyhost in file_props['proxyhosts']:
if proxyhost['jid'] == jid:
proxy = proxyhost
if real_id[:3] == 'au_':
gajim.socks5queue.send_file(file_props, self.name)
raise common.xmpp.NodeProcessed
if proxy != None:
file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'):
file_props['streamhosts'] =[]
file_props['streamhosts'] = []
file_props['streamhosts'].append(proxy)
file_props['is_a_proxy'] = True
receiver = socks5.Socks5Receiver(proxy, file_props['sid'], file_props)
@ -569,16 +571,15 @@ class Connection:
proxy['idx'] = receiver.queue_idx
gajim.socks5queue.on_success = self.proxy_auth_ok
raise common.xmpp.NodeProcessed
elif not file_props.has_key('connected') or \
file_props['connected'] is False:
else:
gajim.socks5queue.send_file(file_props, self.name)
if file_props.has_key('fast'):
fasts = file_props['fast']
if len(fasts) > 0:
self._connect_error(str(iq_obj.getFrom()), fasts[0]['id'],
code = 406)
raise common.xmpp.NodeProcessed
def proxy_auth_ok(self, proxy):

View File

@ -54,9 +54,17 @@ class SocksQueue:
return self.listener
def send_success_reply(self, file_props, streamhost):
if file_props.has_key('streamhost-used') and \
file_props['streamhost-used'] is True:
if file_props.has_key('proxyhosts'):
for proxy in file_props['proxyhosts']:
if proxy == streamhost:
self.on_success(streamhost)
return True
return False
if file_props.has_key('streamhosts'):
for streamhost in file_props['streamhosts']:
if streamhost['state'] == 1:
for host in file_props['streamhosts']:
if streamhost['state'] == 1 and host != streamhost:
return False
streamhost['state'] = 1
self.on_success(streamhost)
@ -74,24 +82,27 @@ class SocksQueue:
file_props = self.files_props[account][sid]
file_props['success_cb'] = on_success
file_props['failure_cb'] = on_failure
# add streamhosts to the queue
for streamhost in file_props['streamhosts']:
receiver = Socks5Receiver(streamhost, sid, file_props)
self.add_receiver(account, receiver)
streamhost['idx'] = receiver.queue_idx
def _socket_connected(self, streamhost, file_props):
streamhost['state'] = 0
for host in file_props['streamhosts']:
if host != streamhost and host.has_key('idx'):
host['state'] = -1
if host['state'] == 1:
self.remove_receiver(streamhost['idx'])
return
else:
host['state'] = -1
self.remove_receiver(host['idx'])
pass
streamhost
def _connection_refused(self, streamhost, file_props, idx):
if file_props is None:
return
streamhost['state'] = -1
self.remove_receiver(idx)
if file_props['failure_cb']:
@ -120,9 +131,10 @@ class SocksQueue:
def get_file_from_sender(self, file_props, account):
if file_props is None:
return
file_props['hash']
if file_props.has_key('hash') and \
self.senders.has_key(file_props['hash']):
sender = self.senders[file_props['hash']]
sender.account = account
result = get_file_contents(0)
@ -137,6 +149,7 @@ class SocksQueue:
if file_props.has_key('hash') and \
self.senders.has_key(file_props['hash']):
sender = self.senders[file_props['hash']]
file_props['streamhost-used'] = True
sender.account = account
if file_props['type'] == 's':
sender.file_props = file_props

View File

@ -1698,12 +1698,13 @@ _('You are unable to connect to remote host. He may be behind a NAT.')).get_resp
def set_status(self, typ, sid, status):
iter = self.get_iter_by_sid(typ, sid)
if iter is None:
return
if status == 'stop':
sid = self.model[iter][4]
file_props = self.files_props[sid[0]][sid[1:]]
file_props['stopped'] = True
if iter is not None:
self.model.set(iter, 0, self.images[status])
self.model.set(iter, 0, self.images[status])
def set_progress(self, typ, sid, transfered_size, iter = None):
if not self.files_props[typ].has_key(sid):