Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0166/models.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 79c8a70e1813 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
26 | 26 |
27 from libervia.backend.core import exceptions | 27 from libervia.backend.core import exceptions |
28 from libervia.backend.core.core_types import SatXMPPEntity | 28 from libervia.backend.core.core_types import SatXMPPEntity |
29 from libervia.backend.core.i18n import _ | 29 from libervia.backend.core.i18n import _ |
30 | 30 |
31 | |
31 class BaseApplicationHandler(abc.ABC): | 32 class BaseApplicationHandler(abc.ABC): |
32 | 33 |
33 @abc.abstractmethod | 34 @abc.abstractmethod |
34 async def jingle_preflight( | 35 async def jingle_preflight( |
35 self, | 36 self, client: SatXMPPEntity, session: dict, description_elt: domish.Element |
36 client: SatXMPPEntity, | |
37 session: dict, | |
38 description_elt: domish.Element | |
39 ) -> None: | 37 ) -> None: |
40 """Called when preparation steps are needed by a plugin | 38 """Called when preparation steps are needed by a plugin |
41 | 39 |
42 Notably used by XEP-0353 when a initiation message is received | 40 Notably used by XEP-0353 when a initiation message is received |
43 """ | 41 """ |
47 async def jingle_preflight_info( | 45 async def jingle_preflight_info( |
48 self, | 46 self, |
49 client: SatXMPPEntity, | 47 client: SatXMPPEntity, |
50 session: dict, | 48 session: dict, |
51 info_type: str, | 49 info_type: str, |
52 info_data: dict|None = None | 50 info_data: dict | None = None, |
53 ) -> None: | 51 ) -> None: |
54 """Called when we have new information during preflight | 52 """Called when we have new information during preflight |
55 | 53 |
56 Notably used by XEP-0353 to signal ringing | 54 Notably used by XEP-0353 to signal ringing |
57 """ | 55 """ |
58 pass | 56 pass |
59 | 57 |
60 @abc.abstractmethod | 58 @abc.abstractmethod |
61 async def jingle_preflight_cancel( | 59 async def jingle_preflight_cancel( |
62 self, | 60 self, client: SatXMPPEntity, session: dict, cancel_error: exceptions.CancelError |
63 client: SatXMPPEntity, | |
64 session: dict, | |
65 cancel_error: exceptions.CancelError | |
66 ) -> None: | 61 ) -> None: |
67 """Called when preflight initiation is cancelled | 62 """Called when preflight initiation is cancelled |
68 | 63 |
69 Notably used by XEP-0353 when an initiation message is cancelled | 64 Notably used by XEP-0353 when an initiation message is cancelled |
70 """ | 65 """ |
77 action: str, | 72 action: str, |
78 session: dict, | 73 session: dict, |
79 content_name: str, | 74 content_name: str, |
80 desc_elt: domish.Element, | 75 desc_elt: domish.Element, |
81 ) -> Union[ | 76 ) -> Union[ |
82 Callable[..., Union[bool, defer.Deferred]], | 77 Callable[..., Union[bool, defer.Deferred]], Callable[..., Awaitable[bool]] |
83 Callable[..., Awaitable[bool]] | |
84 ]: | 78 ]: |
85 """If present, it is called on when session must be accepted. | 79 """If present, it is called on when session must be accepted. |
86 If not present, a generic accept dialog will be used. | 80 If not present, a generic accept dialog will be used. |
87 | 81 |
88 @param session: Jingle Session | 82 @param session: Jingle Session |
92 """ | 86 """ |
93 pass | 87 pass |
94 | 88 |
95 @abc.abstractmethod | 89 @abc.abstractmethod |
96 def jingle_session_init( | 90 def jingle_session_init( |
97 self, | 91 self, client: SatXMPPEntity, session: dict, content_name: str, *args, **kwargs |
98 client: SatXMPPEntity, | 92 ) -> Union[Callable[..., domish.Element], Callable[..., Awaitable[domish.Element]]]: |
99 session: dict, | |
100 content_name: str, | |
101 *args, **kwargs | |
102 ) -> Union[ | |
103 Callable[..., domish.Element], | |
104 Callable[..., Awaitable[domish.Element]] | |
105 ]: | |
106 """Must return the domish.Element used for initial content. | 93 """Must return the domish.Element used for initial content. |
107 | 94 |
108 @param client: SatXMPPEntity instance | 95 @param client: SatXMPPEntity instance |
109 @param session: Jingle Session | 96 @param session: Jingle Session |
110 @param content_name: Name of the content | 97 @param content_name: Name of the content |
117 self, | 104 self, |
118 client: SatXMPPEntity, | 105 client: SatXMPPEntity, |
119 action: str, | 106 action: str, |
120 session: dict, | 107 session: dict, |
121 content_name: str, | 108 content_name: str, |
122 transport_elt: domish.Element | 109 transport_elt: domish.Element, |
123 ) -> Union[ | 110 ) -> Union[Callable[..., None], Callable[..., Awaitable[None]]]: |
124 Callable[..., None], | |
125 Callable[..., Awaitable[None]] | |
126 ]: | |
127 """Called on several actions to negotiate the application or transport. | 111 """Called on several actions to negotiate the application or transport. |
128 | 112 |
129 @param client: SatXMPPEntity instance | 113 @param client: SatXMPPEntity instance |
130 @param action: Jingle action | 114 @param action: Jingle action |
131 @param session: Jingle Session | 115 @param session: Jingle Session |
139 self, | 123 self, |
140 client: SatXMPPEntity, | 124 client: SatXMPPEntity, |
141 action: str, | 125 action: str, |
142 session: dict, | 126 session: dict, |
143 content_name: str, | 127 content_name: str, |
144 reason_elt: domish.Element | 128 reason_elt: domish.Element, |
145 ) -> Union[ | 129 ) -> Union[Callable[..., None], Callable[..., Awaitable[None]]]: |
146 Callable[..., None], | |
147 Callable[..., Awaitable[None]] | |
148 ]: | |
149 """Called on session terminate, with reason_elt. | 130 """Called on session terminate, with reason_elt. |
150 May be used to clean session. | 131 May be used to clean session. |
151 | 132 |
152 @param reason_elt: Reason element | 133 @param reason_elt: Reason element |
153 """ | 134 """ |
168 """ | 149 """ |
169 return True | 150 return True |
170 | 151 |
171 @abc.abstractmethod | 152 @abc.abstractmethod |
172 def jingle_session_init( | 153 def jingle_session_init( |
173 self, | 154 self, client: SatXMPPEntity, session: dict, content_name: str, *args, **kwargs |
174 client: SatXMPPEntity, | 155 ) -> Union[Callable[..., domish.Element], Callable[..., Awaitable[domish.Element]]]: |
175 session: dict, | |
176 content_name: str, | |
177 *args, **kwargs | |
178 ) -> Union[ | |
179 Callable[..., domish.Element], | |
180 Callable[..., Awaitable[domish.Element]] | |
181 ]: | |
182 """Must return the domish.Element used for initial content. | 156 """Must return the domish.Element used for initial content. |
183 | 157 |
184 @param client: SatXMPPEntity instance | 158 @param client: SatXMPPEntity instance |
185 @param session: Jingle Session | 159 @param session: Jingle Session |
186 @param content_name: Name of the content | 160 @param content_name: Name of the content |
193 self, | 167 self, |
194 client: SatXMPPEntity, | 168 client: SatXMPPEntity, |
195 action: str, | 169 action: str, |
196 session: dict, | 170 session: dict, |
197 content_name: str, | 171 content_name: str, |
198 reason_elt: domish.Element | 172 reason_elt: domish.Element, |
199 ) -> Union[ | 173 ) -> Union[Callable[..., None], Callable[..., Awaitable[None]]]: |
200 Callable[..., None], | |
201 Callable[..., Awaitable[None]] | |
202 ]: | |
203 """Called on several actions to negotiate the application or transport. | 174 """Called on several actions to negotiate the application or transport. |
204 | 175 |
205 @param client: SatXMPPEntity instance | 176 @param client: SatXMPPEntity instance |
206 @param action: Jingle action | 177 @param action: Jingle action |
207 @param session: Jingle Session | 178 @param session: Jingle Session |