comparison libervia/backend/plugins/plugin_xep_0166/models.py @ 4112:bc60875cb3b8

plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI: - XEP-0166: add `jingle_preflight` and `jingle_preflight_cancel` methods to prepare a jingle session, principally used by XEP-0353 to create and cancel a session - XEP-0167: preflight methods implementation, workflow split in more methods/signals to handle UI and call events (e.g.: retract or reject a call) - XEP-0234: implementation of preflight methods as they are now mandatory - XEP-0353: handle various events using the new preflight methods rel 423
author Goffi <goffi@goffi.org>
date Wed, 09 Aug 2023 00:07:37 +0200
parents 4b842c1fb686
children 0da563780ffc
comparison
equal deleted inserted replaced
4111:a8ac5e1e5848 4112:bc60875cb3b8
22 from typing import Awaitable, Callable, Union 22 from typing import Awaitable, Callable, Union
23 23
24 from twisted.internet import defer 24 from twisted.internet import defer
25 from twisted.words.xish import domish 25 from twisted.words.xish import domish
26 26
27 from libervia.backend.core import exceptions
27 from libervia.backend.core.core_types import SatXMPPEntity 28 from libervia.backend.core.core_types import SatXMPPEntity
28 from libervia.backend.core.i18n import _ 29 from libervia.backend.core.i18n import _
29 30
30
31 class BaseApplicationHandler(abc.ABC): 31 class BaseApplicationHandler(abc.ABC):
32
33 @abc.abstractmethod
34 async def jingle_preflight(
35 self,
36 client: SatXMPPEntity,
37 session: dict,
38 description_elt: domish.Element
39 ) -> None:
40 """Called when preparation steps are needed by a plugin
41
42 Notably used by XEP-0353 when a initiation message is received
43 """
44 pass
45
46 @abc.abstractmethod
47 async def jingle_preflight_cancel(
48 self,
49 client: SatXMPPEntity,
50 session: dict,
51 cancel_error: exceptions.CancelError
52 ) -> None:
53 """Called when preflight initiation is cancelled
54
55 Notably used by XEP-0353 when an initiation message is cancelled
56 """
57 pass
32 58
33 @abc.abstractmethod 59 @abc.abstractmethod
34 def jingle_request_confirmation( 60 def jingle_request_confirmation(
35 self, 61 self,
36 client: SatXMPPEntity, 62 client: SatXMPPEntity,
40 desc_elt: domish.Element, 66 desc_elt: domish.Element,
41 ) -> Union[ 67 ) -> Union[
42 Callable[..., Union[bool, defer.Deferred]], 68 Callable[..., Union[bool, defer.Deferred]],
43 Callable[..., Awaitable[bool]] 69 Callable[..., Awaitable[bool]]
44 ]: 70 ]:
45 """ 71 """If present, it is called on when session must be accepted.
46 If present, it is called on when session must be accepted.
47 If not present, a generic accept dialog will be used. 72 If not present, a generic accept dialog will be used.
48 73
49 @param session: Jingle Session 74 @param session: Jingle Session
50 @param desc_elt: <description> element 75 @param desc_elt: <description> element
51 @return: True if the session is accepted. 76 @return: True if the session is accepted.
62 *args, **kwargs 87 *args, **kwargs
63 ) -> Union[ 88 ) -> Union[
64 Callable[..., domish.Element], 89 Callable[..., domish.Element],
65 Callable[..., Awaitable[domish.Element]] 90 Callable[..., Awaitable[domish.Element]]
66 ]: 91 ]:
67 """ 92 """Must return the domish.Element used for initial content.
68 Must return the domish.Element used for initial content.
69 93
70 @param client: SatXMPPEntity instance 94 @param client: SatXMPPEntity instance
71 @param session: Jingle Session 95 @param session: Jingle Session
72 @param content_name: Name of the content 96 @param content_name: Name of the content
73 @return: The domish.Element used for initial content 97 @return: The domish.Element used for initial content
84 transport_elt: domish.Element 108 transport_elt: domish.Element
85 ) -> Union[ 109 ) -> Union[
86 Callable[..., None], 110 Callable[..., None],
87 Callable[..., Awaitable[None]] 111 Callable[..., Awaitable[None]]
88 ]: 112 ]:
89 """ 113 """Called on several actions to negotiate the application or transport.
90 Called on several actions to negotiate the application or transport.
91 114
92 @param client: SatXMPPEntity instance 115 @param client: SatXMPPEntity instance
93 @param action: Jingle action 116 @param action: Jingle action
94 @param session: Jingle Session 117 @param session: Jingle Session
95 @param content_name: Name of the content 118 @param content_name: Name of the content
107 reason_elt: domish.Element 130 reason_elt: domish.Element
108 ) -> Union[ 131 ) -> Union[
109 Callable[..., None], 132 Callable[..., None],
110 Callable[..., Awaitable[None]] 133 Callable[..., Awaitable[None]]
111 ]: 134 ]:
112 """ 135 """Called on session terminate, with reason_elt.
113 Called on session terminate, with reason_elt.
114 May be used to clean session. 136 May be used to clean session.
115 137
116 @param reason_elt: Reason element 138 @param reason_elt: Reason element
117 """ 139 """
118 pass 140 pass
129 *args, **kwargs 151 *args, **kwargs
130 ) -> Union[ 152 ) -> Union[
131 Callable[..., domish.Element], 153 Callable[..., domish.Element],
132 Callable[..., Awaitable[domish.Element]] 154 Callable[..., Awaitable[domish.Element]]
133 ]: 155 ]:
134 """ 156 """Must return the domish.Element used for initial content.
135 Must return the domish.Element used for initial content.
136 157
137 @param client: SatXMPPEntity instance 158 @param client: SatXMPPEntity instance
138 @param session: Jingle Session 159 @param session: Jingle Session
139 @param content_name: Name of the content 160 @param content_name: Name of the content
140 @return: The domish.Element used for initial content 161 @return: The domish.Element used for initial content
151 reason_elt: domish.Element 172 reason_elt: domish.Element
152 ) -> Union[ 173 ) -> Union[
153 Callable[..., None], 174 Callable[..., None],
154 Callable[..., Awaitable[None]] 175 Callable[..., Awaitable[None]]
155 ]: 176 ]:
156 """ 177 """Called on several actions to negotiate the application or transport.
157 Called on several actions to negotiate the application or transport.
158 178
159 @param client: SatXMPPEntity instance 179 @param client: SatXMPPEntity instance
160 @param action: Jingle action 180 @param action: Jingle action
161 @param session: Jingle Session 181 @param session: Jingle Session
162 @param content_name: Name of the content 182 @param content_name: Name of the content