Skip to content
Snippets Groups Projects
Commit 07af0f43 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

[httpupload] Refactor error stanza handling

parent eddbe04b
No related branches found
No related tags found
No related merge requests found
......@@ -334,20 +334,26 @@ class Base(object):
progress_messages = Queue(8)
event = threading.Event()
progress_window = ProgressWindow(_('HTTP Upload'), _('Requesting HTTP Upload Slot...'), progress_messages, self.plugin, event)
def upload_file(stanza):
if stanza.getType() == 'error':
ErrorDialog(_('Could not request upload slot'),
stanza.getErrorMsg(),
transient_for=self.chat_control.parent_win.window)
log.error(stanza)
progress_window.close_dialog()
return
slot = stanza.getTag("slot")
if not slot:
if slot:
put = slot.getTag("put")
get = slot.getTag("get")
else:
progress_window.close_dialog()
log.error("got unexpected stanza: "+str(stanza))
error = stanza.getTag("error")
if error and error.getTag("text"):
ErrorDialog(_('Could not request upload slot'),
_('Got unexpected response from server: %s') % str(error.getTagData("text")),
transient_for=self.chat_control.parent_win.window)
else:
ErrorDialog(_('Could not request upload slot'),
_('Got unexpected response from server (protocol mismatch??)'),
transient_for=self.chat_control.parent_win.window)
log.error("got unexpected stanza: " + str(stanza))
ErrorDialog(_('Could not request upload slot'),
_('Got unexpected response from server (see log)'),
transient_for=self.chat_control.parent_win.window)
return
try:
......@@ -369,16 +375,6 @@ class Base(object):
transient_for=self.chat_control.parent_win.window)
raise # fill error log with useful information
put = slot.getTag("put")
get = slot.getTag("get")
if not put or not get:
progress_window.close_dialog()
log.error("got unexpected stanza: " + str(stanza))
ErrorDialog(_('Could not request upload slot'),
_('Got unexpected response from server (protocol mismatch??)'),
transient_for=self.chat_control.parent_win.window)
return
def upload_complete(response_code):
if isinstance(response_code, str):
# We got a error Message
......
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