annotate libervia/cli/cmd_call.py @ 4212:5f2d496c633f

core: get rid of `pickle`: Use of `pickle` to serialise data was a technical legacy that was causing trouble to store in database, to update (if a class was serialised, a change could break update), and to security (pickle can lead to code execution). This patch remove all use of Pickle in favour in JSON, notably: - for caching data, a Pydantic model is now used instead - for SQLAlchemy model, the LegacyPickle is replaced by JSON serialisation - in XEP-0373 a class `PublicKeyMetadata` was serialised. New method `from_dict` and `to_dict` method have been implemented to do serialisation. - new methods to (de)serialise data can now be specified with Identity data types. It is notably used to (de)serialise `path` of avatars. A migration script has been created to convert data (for upgrade or downgrade), with special care for XEP-0373 case. Depending of size of database, this migration script can be long to run. rel 443
author Goffi <goffi@goffi.org>
date Fri, 23 Feb 2024 13:31:04 +0100
parents 9218d4331bb2
children d01b8d002619
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Libervia CLI
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from functools import partial
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
22 import importlib
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 import logging
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from libervia.backend.core.i18n import _
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from libervia.backend.tools.common import data_format
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from libervia.cli.constants import Const as C
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
29 from libervia.frontends.tools import jid
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from . import base
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
32 from .call_webrtc import CallData, WebRTCCall
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 __commands__ = ["Call"]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 class Common(base.CommandBase):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
38
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
39
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
40 def __init__(self, *args, **kwargs):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
41 super().__init__(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
42 *args,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
43 use_output=C.OUTPUT_CUSTOM,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
44 extra_outputs={
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
45 #: automatically select best output for current platform
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
46 "default": self.auto_output,
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
47 #: simple output with GStreamer ``autovideosink``
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
48 "simple": partial(self.use_output, "simple"),
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
49 #: Qt GUI
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
50 "gui": partial(self.use_output, "gui"),
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
51 #: experimental TUI output
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
52 "tui": partial(self.use_output, "tui"),
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
53 },
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
54 **kwargs
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
55 )
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
56
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 self.parser.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 "--no-ui", action="store_true", help=_("disable user interface")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
61
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 root_logger = logging.getLogger()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 # we don't want any formatting for messages from webrtc
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 for handler in root_logger.handlers:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 handler.setFormatter(None)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 if self.verbosity == 0:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 root_logger.setLevel(logging.ERROR)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 if self.verbosity >= 1:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 root_logger.setLevel(logging.WARNING)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 if self.verbosity >= 2:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 root_logger.setLevel(logging.DEBUG)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
73
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
74 async def auto_output(self, call_data: CallData) -> None:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
75 """Make a guess on the best output to use on current platform"""
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
76 try:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
77 from .call_gui import AVCallUI
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
78 except ImportError:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
79 # we can't import GUI, we may have missing modules
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
80 await self.use_output("simple", call_data)
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
81 else:
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
82 if AVCallUI.can_run():
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
83 await self.use_output("gui", call_data)
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
84 else:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
85 await self.use_output("simple", call_data)
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
86
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
87 async def use_output(self, output_type, call_data: CallData):
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
88 try:
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
89 AVCall_module = importlib.import_module(f"libervia.cli.call_{output_type}")
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
90 AVCallUI = AVCall_module.AVCallUI
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
91 except Exception as e:
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
92 self.disp(f"Error starting {output_type.upper()} UI: {e}", error=True)
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
93 self.host.quit(C.EXIT_ERROR)
4210
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
94 else:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
95 try:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
96 await AVCallUI.run(self, call_data)
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
97 except Exception as e:
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
98 self.disp(f"Error running {output_type.upper()} UI: {e}", error=True)
9218d4331bb2 cli (call): `tui` output implementation:
Goffi <goffi@goffi.org>
parents: 4206
diff changeset
99 self.host.quit(C.EXIT_ERROR)
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
100
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
101
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 class Make(Common):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 super().__init__(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 host,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 "make",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 use_verbose=True,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 help=_("start a call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
110
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 super().add_parser_options()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 self.parser.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 "entity",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 metavar="JID",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 help=_("JIDs of entity to call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
118
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 await super().start()
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
121 await super().output(CallData(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
122 callee=jid.JID(self.args.entity),
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
123 ))
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
124
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
125
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 class Receive(Common):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 super().__init__(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 host,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 "receive",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 use_verbose=True,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 help=_("wait for a call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 super().add_parser_options()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 auto_accept_group = self.parser.add_mutually_exclusive_group()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 auto_accept_group.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 "-a",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 "--auto-accept",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 action="append",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 metavar="JID",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 default=[],
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 help=_("automatically accept call from this jid (can be used multiple times)")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 auto_accept_group.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 "--auto-accept-all",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 action="store_true",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 help=_("automatically accept call from anybody")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
151
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 async def on_action_new(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 self, action_data_s: str, action_id: str, security_limit: int, profile: str
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 ) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 if profile != self.profile:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 action_data = data_format.deserialise(action_data_s)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 if action_data.get("type") != C.META_TYPE_CALL:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 peer_jid = jid.JID(action_data["from_jid"]).bare
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 caller = peer_jid.bare
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 if (
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 not self.args.auto_accept_all
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 and caller not in self.args.auto_accept
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 and not await self.host.confirm(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 _("📞 Incoming call from {caller}, do you accept?").format(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 caller=caller
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 ):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 await self.host.bridge.action_launch(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 action_id, data_format.serialise({"cancelled": True}), profile
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
175
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 self.disp(_("✅ Incoming call from {caller} accepted.").format(caller=caller))
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
177
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
178 await super().output(CallData(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
179 callee=peer_jid,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
180 sid=action_data["session_id"],
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
181 action_id=action_id
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
182 ))
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
183
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 await super().start()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 self.host.bridge.register_signal("action_new", self.on_action_new, "core")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
187
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
188
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 class Call(base.CommandBase):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 subcommands = (Make, Receive)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
191
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 super().__init__(host, "call", use_profile=False, help=_("A/V calls and related"))