Skip to content
Snippets Groups Projects
Commit 9baa857a authored by Marc Schink's avatar Marc Schink
Browse files

[httpupload] Use 'max-file-size' value for error message

If a file is too large, use the 'max-file-size' value to generate an
error message rather than using the error message provided by the XMPP
server. This enables easy i18n of the error message and a
human-readable file size.
parent 4e3c9841
No related branches found
No related tags found
No related merge requests found
......@@ -248,12 +248,24 @@ class Base(object):
IQ_CALLBACK[id_] = lambda stanza: self.received_slot(stanza, file)
app.connections[self.account].connection.send(iq)
@staticmethod
def get_slot_error_message(stanza):
tmp = stanza.getTag('error').getTag('file-too-large')
if tmp is not None:
max_file_size = int(tmp.getTag('max-file-size').getData())
return _('File is too large, maximum allowed file size is: %s') % \
GLib.format_size_full(max_file_size,
GLib.FormatSizeFlags.IEC_UNITS)
return stanza.getErrorMsg()
def received_slot(self, stanza, file):
log.info("Received slot")
if stanza.getType() == 'error':
file.progress.close_dialog()
ErrorDialog(_('Could not request upload slot'),
stanza.getErrorMsg(),
self.get_slot_error_message(stanza),
transient_for=file.control.parent_win.window)
log.error(stanza)
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment