diff 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
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0166/models.py	Tue Aug 08 23:59:24 2023 +0200
+++ b/libervia/backend/plugins/plugin_xep_0166/models.py	Wed Aug 09 00:07:37 2023 +0200
@@ -24,11 +24,37 @@
 from twisted.internet import defer
 from twisted.words.xish import domish
 
+from libervia.backend.core import exceptions
 from libervia.backend.core.core_types import SatXMPPEntity
 from libervia.backend.core.i18n import _
 
+class BaseApplicationHandler(abc.ABC):
 
-class BaseApplicationHandler(abc.ABC):
+    @abc.abstractmethod
+    async def jingle_preflight(
+        self,
+        client: SatXMPPEntity,
+        session: dict,
+        description_elt: domish.Element
+    ) -> None:
+        """Called when preparation steps are needed by a plugin
+
+        Notably used by XEP-0353 when a initiation message is received
+        """
+        pass
+
+    @abc.abstractmethod
+    async def jingle_preflight_cancel(
+        self,
+        client: SatXMPPEntity,
+        session: dict,
+        cancel_error: exceptions.CancelError
+    ) -> None:
+        """Called when preflight initiation is cancelled
+
+        Notably used by XEP-0353 when an initiation message is cancelled
+        """
+        pass
 
     @abc.abstractmethod
     def jingle_request_confirmation(
@@ -42,8 +68,7 @@
         Callable[..., Union[bool, defer.Deferred]],
         Callable[..., Awaitable[bool]]
     ]:
-        """
-        If present, it is called on when session must be accepted.
+        """If present, it is called on when session must be accepted.
         If not present, a generic accept dialog will be used.
 
         @param session: Jingle Session
@@ -64,8 +89,7 @@
         Callable[..., domish.Element],
         Callable[..., Awaitable[domish.Element]]
     ]:
-        """
-        Must return the domish.Element used for initial content.
+        """Must return the domish.Element used for initial content.
 
         @param client: SatXMPPEntity instance
         @param session: Jingle Session
@@ -86,8 +110,7 @@
         Callable[..., None],
         Callable[..., Awaitable[None]]
     ]:
-        """
-        Called on several actions to negotiate the application or transport.
+        """Called on several actions to negotiate the application or transport.
 
         @param client: SatXMPPEntity instance
         @param action: Jingle action
@@ -109,8 +132,7 @@
         Callable[..., None],
         Callable[..., Awaitable[None]]
     ]:
-        """
-        Called on session terminate, with reason_elt.
+        """Called on session terminate, with reason_elt.
         May be used to clean session.
 
         @param reason_elt: Reason element
@@ -131,8 +153,7 @@
         Callable[..., domish.Element],
         Callable[..., Awaitable[domish.Element]]
     ]:
-        """
-        Must return the domish.Element used for initial content.
+        """Must return the domish.Element used for initial content.
 
         @param client: SatXMPPEntity instance
         @param session: Jingle Session
@@ -153,8 +174,7 @@
         Callable[..., None],
         Callable[..., Awaitable[None]]
     ]:
-        """
-        Called on several actions to negotiate the application or transport.
+        """Called on several actions to negotiate the application or transport.
 
         @param client: SatXMPPEntity instance
         @param action: Jingle action