Mercurial > libervia-backend
changeset 4225:cd889f4771cb
cli (file/receive): handle `CONFIRM` dialog received in pre-flight.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 05 Mar 2024 17:31:56 +0100 |
parents | 8499b3ad5edb |
children | 3f7ca590a5da |
files | libervia/cli/cmd_file.py |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/cli/cmd_file.py Tue Mar 05 17:31:56 2024 +0100 +++ b/libervia/cli/cmd_file.py Tue Mar 05 17:31:56 2024 +0100 @@ -303,6 +303,7 @@ ) self._overwrite_refused = False # True when one overwrite as already been refused self.action_callbacks = { + C.META_TYPE_CONFIRM: self.on_confirm_action, C.META_TYPE_FILE: self.on_file_action, C.META_TYPE_OVERWRITE: self.on_overwrite_action, C.META_TYPE_NOT_IN_ROSTER_LEAK: self.on_not_in_roster_action, @@ -368,6 +369,23 @@ self.disp(_("Invalid XMLUI received"), error=True) return xmlui_id + async def on_confirm_action(self, action_data, action_id, security_limit, profile): + xmlui_id = self.get_xmlui_id(action_data) + if xmlui_id is None: + return self.host.quit_from_signal(1) + if action_data.get("subtype") != C.META_TYPE_FILE: + self.disp(_("Ignoring confirm dialog unrelated to file."), 1) + return + + # we always accept preflight confirmation dialog, as for now a second dialog is + # always sent + # FIXME: real confirmation should be done here, and second dialog should not be + # sent from backend + xmlui_data = {"answer": C.BOOL_TRUE} + await self.host.bridge.action_launch( + xmlui_id, data_format.serialise(xmlui_data), profile_key=profile + ) + async def on_file_action(self, action_data, action_id, security_limit, profile): xmlui_id = self.get_xmlui_id(action_data) if xmlui_id is None: @@ -429,7 +447,7 @@ except ValueError: self.disp( _('invalid "from_jid" value received, ignoring: {value}').format( - value=from_jid + value=action_data["from_jid"] ), error=True, ) @@ -459,7 +477,7 @@ self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids] self.path = os.path.abspath(self.args.path) if not os.path.isdir(self.path): - self.disp(_("Given path is not a directory !", error=True)) + self.disp(_("Given path is not a directory !"), error=True) self.host.quit(C.EXIT_BAD_ARG) if self.args.multiple: self.host.quit_on_progress_end = False