fix connect error

This commit is contained in:
Jefry Lagrange 2012-06-21 13:56:15 -04:00
parent 1c895779ce
commit f4fa70576b
2 changed files with 18 additions and 10 deletions

View file

@ -549,28 +549,34 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
file_props.hash_ = hash_id file_props.hash_ = hash_id
return return
def _connect_error(self, to, _id, sid, code=404): def _connect_error(self,sid, code=404):
""" """
Called when there is an error establishing BS connection, or when Called when there is an error establishing BS connection, or when
connection is rejected connection is rejected
""" """
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
file_props = FilesProp.getFileProp(self.name, sid)
if file_props is None:
log.error('can not send iq error on failed transfer')
return
msg_dict = { msg_dict = {
404: 'Could not connect to given hosts', 404: 'Could not connect to given hosts',
405: 'Cancel', 405: 'Cancel',
406: 'Not acceptable', 406: 'Not acceptable',
} }
msg = msg_dict[code] msg = msg_dict[code]
if file_props.type_ == 's':
to = file_props.receiver
else:
to = file_props.sender
iq = xmpp.Iq(to=to, typ='error') iq = xmpp.Iq(to=to, typ='error')
iq.setAttr('id', _id) iq.setAttr('id', file_props.session_sid)
err = iq.setTag('error') err = iq.setTag('error')
err.setAttr('code', unicode(code)) err.setAttr('code', unicode(code))
err.setData(msg) err.setData(msg)
self.connection.send(iq) self.connection.send(iq)
if code == 404: if code == 404:
file_props = FilesProp.getFileProp(self.name, sid)
if file_props is not None:
self.disconnect_transfer(file_props) self.disconnect_transfer(file_props)
file_props.error = -3 file_props.error = -3
from common.connection_handlers_events import \ from common.connection_handlers_events import \

View file

@ -553,6 +553,8 @@ class FileTransfersWindow:
def _remove_transfer(self, iter_, sid, file_props): def _remove_transfer(self, iter_, sid, file_props):
self.model.remove(iter_) self.model.remove(iter_)
if not file_props:
return
if file_props.tt_account: if file_props.tt_account:
# file transfer is set # file transfer is set
account = file_props.tt_account account = file_props.tt_account