Mercurial > libervia-backend
annotate libervia/backend/plugins/plugin_xep_0166/models.py @ 4180:b86912d3fd33
plugin IP: fix use of legacy URL + coroutine use:
An https:/salut-a-toi.org URL was used to retrieve external IP, but it's not valid
anymore, resulting in an exception. This feature is currently disabled.
Also moved several methods from legacy inline callbacks to coroutines.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 09 Dec 2023 14:30:54 +0100 |
parents | 0da563780ffc |
children | e11b13418ba6 |
rev | line source |
---|---|
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # Libervia plugin for Jingle (XEP-0166) |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 import abc |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from dataclasses import dataclass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from typing import Awaitable, Callable, Union |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from twisted.internet import defer |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from twisted.words.xish import domish |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
27 from libervia.backend.core import exceptions |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4052
diff
changeset
|
28 from libervia.backend.core.core_types import SatXMPPEntity |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4052
diff
changeset
|
29 from libervia.backend.core.i18n import _ |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
31 class BaseApplicationHandler(abc.ABC): |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
33 @abc.abstractmethod |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
34 async def jingle_preflight( |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
35 self, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
36 client: SatXMPPEntity, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
37 session: dict, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
38 description_elt: domish.Element |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
39 ) -> None: |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
40 """Called when preparation steps are needed by a plugin |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
41 |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
42 Notably used by XEP-0353 when a initiation message is received |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
43 """ |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
44 pass |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
45 |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
46 @abc.abstractmethod |
4115
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
47 async def jingle_preflight_info( |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
48 self, |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
49 client: SatXMPPEntity, |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
50 session: dict, |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
51 info_type: str, |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
52 info_data: dict|None = None |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
53 ) -> None: |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
54 """Called when we have new information during preflight |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
55 |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
56 Notably used by XEP-0353 to signal ringing |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
57 """ |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
58 pass |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
59 |
0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents:
4112
diff
changeset
|
60 @abc.abstractmethod |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
61 async def jingle_preflight_cancel( |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
62 self, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
63 client: SatXMPPEntity, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
64 session: dict, |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
65 cancel_error: exceptions.CancelError |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
66 ) -> None: |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
67 """Called when preflight initiation is cancelled |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
68 |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
69 Notably used by XEP-0353 when an initiation message is cancelled |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
70 """ |
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
71 pass |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 def jingle_request_confirmation( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 self, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 client: SatXMPPEntity, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 action: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 session: dict, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 content_name: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 desc_elt: domish.Element, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 Callable[..., Union[bool, defer.Deferred]], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 Callable[..., Awaitable[bool]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
85 """If present, it is called on when session must be accepted. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 If not present, a generic accept dialog will be used. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 @param session: Jingle Session |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 @param desc_elt: <description> element |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 @return: True if the session is accepted. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 A Deferred can be returned. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 def jingle_session_init( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 self, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 client: SatXMPPEntity, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 session: dict, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 content_name: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 *args, **kwargs |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 Callable[..., domish.Element], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 Callable[..., Awaitable[domish.Element]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
106 """Must return the domish.Element used for initial content. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 @param client: SatXMPPEntity instance |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 @param session: Jingle Session |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 @param content_name: Name of the content |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 @return: The domish.Element used for initial content |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 def jingle_handler( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 self, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 client: SatXMPPEntity, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 action: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 session: dict, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 content_name: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 transport_elt: domish.Element |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 Callable[..., None], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 Callable[..., Awaitable[None]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
127 """Called on several actions to negotiate the application or transport. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 @param client: SatXMPPEntity instance |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 @param action: Jingle action |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 @param session: Jingle Session |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 @param content_name: Name of the content |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 @param transport_elt: Transport element |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 def jingle_terminate( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 self, |
4052
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
140 client: SatXMPPEntity, |
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
141 action: str, |
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
142 session: dict, |
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
143 content_name: str, |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 reason_elt: domish.Element |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 Callable[..., None], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 Callable[..., Awaitable[None]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
149 """Called on session terminate, with reason_elt. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 May be used to clean session. |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 @param reason_elt: Reason element |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 class BaseTransportHandler(abc.ABC): |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 def jingle_session_init( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 self, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 client: SatXMPPEntity, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 session: dict, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 content_name: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 *args, **kwargs |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 Callable[..., domish.Element], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 Callable[..., Awaitable[domish.Element]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
170 """Must return the domish.Element used for initial content. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 @param client: SatXMPPEntity instance |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 @param session: Jingle Session |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 @param content_name: Name of the content |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 @return: The domish.Element used for initial content |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 @abc.abstractmethod |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 def jingle_handler( |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 self, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 client: SatXMPPEntity, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 action: str, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 session: dict, |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 content_name: str, |
4052
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
186 reason_elt: domish.Element |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 ) -> Union[ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 Callable[..., None], |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 Callable[..., Awaitable[None]] |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 ]: |
4112
bc60875cb3b8
plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
191 """Called on several actions to negotiate the application or transport. |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 @param client: SatXMPPEntity instance |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 @param action: Jingle action |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 @param session: Jingle Session |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 @param content_name: Name of the content |
4052
2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
197 @param reason_elt: <reason> element |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 """ |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 pass |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 @dataclass(frozen=True) |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 class ApplicationData: |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 namespace: str |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
205 handler: BaseApplicationHandler |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 @dataclass(frozen=True) |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
209 class TransportData: |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 namespace: str |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 handler: BaseTransportHandler |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 priority: int |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 @dataclass(frozen=True) |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 class ContentData: |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 application: ApplicationData |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 app_args: list |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 app_kwargs: dict |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 transport_data: dict |
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 content_name: str |