From f4fa70576b044fc60a309d7db70472d1ac2434e2 Mon Sep 17 00:00:00 2001 From: Jefry Lagrange <jefry.reyes@gmail.com> Date: Thu, 21 Jun 2012 13:56:15 -0400 Subject: [PATCH] fix connect error --- src/common/protocol/bytestream.py | 26 ++++++++++++++++---------- src/filetransfers_window.py | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/common/protocol/bytestream.py b/src/common/protocol/bytestream.py index fc928f89be..51b3e3d24b 100644 --- a/src/common/protocol/bytestream.py +++ b/src/common/protocol/bytestream.py @@ -549,34 +549,40 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): file_props.hash_ = hash_id 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 connection is rejected """ if not self.connection or self.connected < 2: 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 = { 404: 'Could not connect to given hosts', 405: 'Cancel', 406: 'Not acceptable', } 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.setAttr('id', _id) + iq.setAttr('id', file_props.session_sid) err = iq.setTag('error') err.setAttr('code', unicode(code)) err.setData(msg) self.connection.send(iq) if code == 404: - file_props = FilesProp.getFileProp(self.name, sid) - if file_props is not None: - self.disconnect_transfer(file_props) - file_props.error = -3 - from common.connection_handlers_events import \ - FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, - conn=self, jid=to, file_props=file_props, error_msg=msg)) + self.disconnect_transfer(file_props) + file_props.error = -3 + from common.connection_handlers_events import \ + FileRequestErrorEvent + gajim.nec.push_incoming_event(FileRequestErrorEvent(None, + conn=self, jid=to, file_props=file_props, error_msg=msg)) def _proxy_auth_ok(self, proxy): """ diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 89d407291b..a0e36e644c 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -553,6 +553,8 @@ class FileTransfersWindow: def _remove_transfer(self, iter_, sid, file_props): self.model.remove(iter_) + if not file_props: + return if file_props.tt_account: # file transfer is set account = file_props.tt_account -- GitLab