Mercurial > libervia-backend
annotate libervia/cli/cmd_blocking.py @ 4240:79c8a70e1813
backend, frontend: prepare remote control:
This is a series of changes necessary to prepare the implementation of remote control
feature:
- XEP-0166: add a `priority` attribute to `ApplicationData`: this is needed when several
applications are working in a same session, to know which one must be handled first.
Will be used to make Remote Control have precedence over Call content.
- XEP-0166: `_call_plugins` is now async and is not used with `DeferredList` anymore: the
benefit to have methods called in parallels is very low, and it cause a lot of trouble
as we can't predict order. Methods are now called sequentially so workflow can be
predicted.
- XEP-0167: fix `senders` XMPP attribute <=> SDP mapping
- XEP-0234: preflight acceptance key is now `pre-accepted` instead of `file-accepted`, so
the same key can be used with other jingle applications.
- XEP-0167, XEP-0343: move some method to XEP-0167
- XEP-0353: use new `priority` feature to call preflight methods of applications according
to it.
- frontend (webrtc): refactor the sources/sink handling with a more flexible mechanism
based on Pydantic models. It is now possible to have has many Data Channel as necessary,
to have them in addition to A/V streams, to specify manually GStreamer sources and
sinks, etc.
- frontend (webrtc): rework of the pipeline to reduce latency.
- frontend: new `portal_desktop` method. Screenshare portal handling has been moved there,
and RemoteDesktop portal has been added.
- frontend (webrtc): fix `extract_ufrag_pwd` method.
rel 436
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 11 May 2024 13:52:41 +0200 |
parents | 47401850dec6 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3788 | 1 #!/usr/bin/env python3 |
2 | |
3 | |
4075
47401850dec6
refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents:
4074
diff
changeset
|
4 # Libervia CLI |
3788 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 import json | |
22 import os | |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
23 from libervia.backend.core.i18n import _ |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
24 from libervia.backend.tools.common import data_format |
4075
47401850dec6
refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents:
4074
diff
changeset
|
25 from libervia.cli import common |
47401850dec6
refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents:
4074
diff
changeset
|
26 from libervia.cli.constants import Const as C |
3788 | 27 from . import base |
28 | |
29 __commands__ = ["Blocking"] | |
30 | |
31 | |
32 class List(base.CommandBase): | |
33 def __init__(self, host): | |
34 super().__init__( | |
35 host, | |
36 "list", | |
37 use_output=C.OUTPUT_LIST, | |
38 help=_("list blocked entities"), | |
39 ) | |
40 | |
41 def add_parser_options(self): | |
42 pass | |
43 | |
44 async def start(self): | |
45 try: | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3788
diff
changeset
|
46 blocked_jids = await self.host.bridge.blocking_list( |
3788 | 47 self.profile, |
48 ) | |
49 except Exception as e: | |
50 self.disp(f"can't get blocked entities: {e}", error=True) | |
51 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
52 else: | |
53 await self.output(blocked_jids) | |
54 self.host.quit(C.EXIT_OK) | |
55 | |
56 | |
57 class Block(base.CommandBase): | |
58 def __init__(self, host): | |
59 super().__init__( | |
60 host, | |
61 "block", | |
62 help=_("block one or more entities"), | |
63 ) | |
64 | |
65 def add_parser_options(self): | |
66 self.parser.add_argument( | |
67 "entities", | |
68 nargs="+", | |
69 metavar="JID", | |
70 help=_("JIDs of entities to block"), | |
71 ) | |
72 | |
73 async def start(self): | |
74 try: | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3788
diff
changeset
|
75 await self.host.bridge.blocking_block( |
3788 | 76 self.args.entities, |
77 self.profile | |
78 ) | |
79 except Exception as e: | |
80 self.disp(f"can't block entities: {e}", error=True) | |
81 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
82 else: | |
83 self.host.quit(C.EXIT_OK) | |
84 | |
85 | |
86 class Unblock(base.CommandBase): | |
87 def __init__(self, host): | |
88 super().__init__( | |
89 host, | |
90 "unblock", | |
91 help=_("unblock one or more entities"), | |
92 ) | |
93 | |
94 def add_parser_options(self): | |
95 self.parser.add_argument( | |
96 "entities", | |
97 nargs="+", | |
98 metavar="JID", | |
99 help=_("JIDs of entities to unblock"), | |
100 ) | |
101 self.parser.add_argument( | |
102 "-f", | |
103 "--force", | |
104 action="store_true", | |
105 help=_('when "all" is used, unblock all entities without confirmation'), | |
106 ) | |
107 | |
108 async def start(self): | |
109 if self.args.entities == ["all"]: | |
110 if not self.args.force: | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3788
diff
changeset
|
111 await self.host.confirm_or_quit( |
3788 | 112 _("All entities will be unblocked, are you sure"), |
113 _("unblock cancelled") | |
114 ) | |
115 self.args.entities.clear() | |
116 elif self.args.force: | |
117 self.parser.error(_('--force is only allowed when "all" is used as target')) | |
118 | |
119 try: | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3788
diff
changeset
|
120 await self.host.bridge.blocking_unblock( |
3788 | 121 self.args.entities, |
122 self.profile | |
123 ) | |
124 except Exception as e: | |
125 self.disp(f"can't unblock entities: {e}", error=True) | |
126 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
127 else: | |
128 self.host.quit(C.EXIT_OK) | |
129 | |
130 | |
131 class Blocking(base.CommandBase): | |
132 subcommands = (List, Block, Unblock) | |
133 | |
134 def __init__(self, host): | |
135 super().__init__( | |
136 host, "blocking", use_profile=False, help=_("entities blocking") | |
137 ) |