send correct error message when we decline a FT, and print error message when we get it. Fixes #2330
This commit is contained in:
parent
5764374e5d
commit
e18e1079a9
|
@ -90,7 +90,7 @@ class ConnectionBytestream:
|
|||
if contact.jid == receiver_jid:
|
||||
file_props['error'] = -5
|
||||
self.remove_transfer(file_props)
|
||||
self.dispatch('FILE_REQUEST_ERROR', (contact.jid, file_props))
|
||||
self.dispatch('FILE_REQUEST_ERROR', (contact.jid, file_props, ''))
|
||||
sender_jid = unicode(file_props['sender']).split('/')[0]
|
||||
if contact.jid == sender_jid:
|
||||
file_props['error'] = -3
|
||||
|
@ -179,7 +179,8 @@ class ConnectionBytestream:
|
|||
sha_str, self._result_socks5_sid, file_props['sid'])
|
||||
if listener == None:
|
||||
file_props['error'] = -5
|
||||
self.dispatch('FILE_REQUEST_ERROR', (unicode(receiver), file_props))
|
||||
self.dispatch('FILE_REQUEST_ERROR', (unicode(receiver), file_props,
|
||||
''))
|
||||
self._connect_error(unicode(receiver), file_props['sid'],
|
||||
file_props['sid'], code = 406)
|
||||
return
|
||||
|
@ -221,8 +222,8 @@ class ConnectionBytestream:
|
|||
iq = common.xmpp.Protocol(name = 'iq',
|
||||
to = unicode(file_props['sender']), typ = 'error')
|
||||
iq.setAttr('id', file_props['request-id'])
|
||||
err = common.xmpp.ErrorNode(code = '406', typ = 'auth', name =
|
||||
'not-acceptable')
|
||||
err = common.xmpp.ErrorNode(code = '403', typ = 'cancel', name =
|
||||
'forbidden', text = 'Offer Declined')
|
||||
iq.addChild(node=err)
|
||||
self.connection.send(iq)
|
||||
|
||||
|
@ -314,8 +315,8 @@ class ConnectionBytestream:
|
|||
if file_props is not None:
|
||||
self.disconnect_transfer(file_props)
|
||||
file_props['error'] = -3
|
||||
self.dispatch('FILE_REQUEST_ERROR', (to, file_props))
|
||||
|
||||
self.dispatch('FILE_REQUEST_ERROR', (to, file_props, msg))
|
||||
|
||||
def _proxy_auth_ok(self, proxy):
|
||||
'''cb, called after authentication to proxy server '''
|
||||
file_props = self.files_props[proxy['sid']]
|
||||
|
@ -344,7 +345,7 @@ class ConnectionBytestream:
|
|||
return
|
||||
file_props = self.files_props[id]
|
||||
file_props['error'] = -4
|
||||
self.dispatch('FILE_REQUEST_ERROR', (jid, file_props))
|
||||
self.dispatch('FILE_REQUEST_ERROR', (jid, file_props, ''))
|
||||
raise common.xmpp.NodeProcessed
|
||||
|
||||
def _bytestreamSetCB(self, con, iq_obj):
|
||||
|
@ -561,7 +562,7 @@ class ConnectionBytestream:
|
|||
return
|
||||
jid = helpers.get_jid_from_iq(iq_obj)
|
||||
file_props['error'] = -3
|
||||
self.dispatch('FILE_REQUEST_ERROR', (jid, file_props))
|
||||
self.dispatch('FILE_REQUEST_ERROR', (jid, file_props, ''))
|
||||
raise common.xmpp.NodeProcessed
|
||||
|
||||
class ConnectionDisco:
|
||||
|
@ -1133,7 +1134,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
|||
raise common.xmpp.NodeProcessed
|
||||
|
||||
def _ErrorCB(self, con, iq_obj):
|
||||
errmsg = iq_obj.getError()
|
||||
errmsg = iq_obj.getErrorMsg()
|
||||
errcode = iq_obj.getErrorCode()
|
||||
jid_from = helpers.get_full_jid_from_iq(iq_obj)
|
||||
id = unicode(iq_obj.getID())
|
||||
|
|
|
@ -348,6 +348,13 @@ class Protocol(Node):
|
|||
for tag in errtag.getChildren():
|
||||
if tag.getName()<>'text': return tag.getName()
|
||||
return errtag.getData()
|
||||
def getErrorMsg(self):
|
||||
""" Return the textual description of the error (if present) or the error condition """
|
||||
errtag=self.getTag('error')
|
||||
if errtag:
|
||||
for tag in errtag.getChildren():
|
||||
if tag.getName()=='text': return tag.getData()
|
||||
return self.getError()
|
||||
def getErrorCode(self):
|
||||
""" Return the error code. Obsolette. """
|
||||
return self.getTagAttr('error','code')
|
||||
|
|
|
@ -213,7 +213,7 @@ class FileTransfersWindow:
|
|||
_('Connection with peer cannot be established.'))
|
||||
self.tree.get_selection().unselect_all()
|
||||
|
||||
def show_stopped(self, jid, file_props):
|
||||
def show_stopped(self, jid, file_props, error_msg = ''):
|
||||
self.window.present()
|
||||
self.window.window.focus()
|
||||
if file_props['type'] == 'r':
|
||||
|
@ -222,6 +222,8 @@ _('Connection with peer cannot be established.'))
|
|||
file_name = file_props['name']
|
||||
sectext = '\t' + _('Filename: %s') % file_name
|
||||
sectext += '\n\t' + _('Recipient: %s') % jid
|
||||
if error_msg:
|
||||
sectext += '\n\t' + _('Error message: %s') % error_msg
|
||||
dialogs.ErrorDialog(_('File transfer stopped by the contact of the other side'), \
|
||||
sectext)
|
||||
self.tree.get_selection().unselect_all()
|
||||
|
|
10
src/gajim.py
10
src/gajim.py
|
@ -273,7 +273,7 @@ class Interface:
|
|||
on_response_no = (response, account, data[3], 'no'))
|
||||
|
||||
def handle_event_error_answer(self, account, array):
|
||||
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
||||
#('ERROR_ANSWER', account, (id, jid_from, errmsg, errcode))
|
||||
id, jid_from, errmsg, errcode = array
|
||||
if unicode(errcode) in ('403', '406') and id:
|
||||
# show the error dialog
|
||||
|
@ -285,7 +285,7 @@ class Interface:
|
|||
file_props = ft.files_props['s'][sid]
|
||||
file_props['error'] = -4
|
||||
self.handle_event_file_request_error(account,
|
||||
(jid_from, file_props))
|
||||
(jid_from, file_props, errmsg))
|
||||
conn = gajim.connections[account]
|
||||
conn.disconnect_transfer(file_props)
|
||||
return
|
||||
|
@ -1169,15 +1169,15 @@ class Interface:
|
|||
self.roster.draw_contact(jid, account)
|
||||
|
||||
def handle_event_file_request_error(self, account, array):
|
||||
jid = array[0]
|
||||
file_props = array[1]
|
||||
# ('FILE_REQUEST_ERROR', account, (jid, file_props, error_msg))
|
||||
jid, file_props, errmsg = array
|
||||
ft = self.instances['file_transfers']
|
||||
ft.set_status(file_props['type'], file_props['sid'], 'stop')
|
||||
errno = file_props['error']
|
||||
|
||||
if helpers.allow_popup_window(account):
|
||||
if errno in (-4, -5):
|
||||
ft.show_stopped(jid, file_props)
|
||||
ft.show_stopped(jid, file_props, errmsg)
|
||||
else:
|
||||
ft.show_request_error(file_props)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue