Commit 6b53f794 authored by Philipp Hörist's avatar Philipp Hörist

FileTransferProgress: Use cancel action

parent 69493b80
Pipeline #7086 passed with stages
in 7 minutes and 20 seconds
......@@ -58,8 +58,11 @@ def __init__(self, transfer):
self._ui.connect_signals(self)
def _on_transfer_state_change(self, transfer, _signal_name, state):
if self._destroyed:
return
if state.is_error:
ErrorDialog(_('Upload Failed'),
ErrorDialog(_('Error'),
transfer.error_text,
transient_for=app.interface.roster.window)
self.destroy()
......@@ -80,12 +83,12 @@ def _on_cancel_button_clicked(self, _widget):
self.destroy()
def _on_destroy(self, *args):
self._destroyed = True
if self._transfer.state.is_active:
client = app.get_client(self._transfer.account)
client.get_module('HTTPUpload').cancel_transfer(self._transfer)
self._transfer.cancel()
self._transfer = None
self._destroyed = True
if self._pulse is not None:
GLib.source_remove(self._pulse)
......
......@@ -878,6 +878,7 @@ def _send_httpupload(self, chat_control, path):
None, dialog_name='open-file-error2', args=error))
return
transfer.connect('cancel', self._on_cancel_upload)
transfer.connect('state-changed',
self._on_http_upload_state_changed)
FileTransferProgress(transfer)
......@@ -901,6 +902,11 @@ def _on_http_upload_state_changed(transfer, _signal_name, state):
client = app.get_client(transfer.account)
client.send_message(message)
@staticmethod
def _on_cancel_upload(transfer, _signal_name):
client = app.get_client(transfer.account)
client.get_module('HTTPUpload').cancel_transfer(transfer)
@staticmethod
def handle_event_metacontacts(obj):
app.contacts.define_metacontacts(obj.conn.name, obj.meta_list)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment