changeset 1516:a3ca1bab6eb1

server, restricted bridge: add new methods and signals to prepare calls implementation: rel 422
author Goffi <goffi@goffi.org>
date Thu, 01 Jun 2023 20:44:57 +0200
parents 73c848c2f41e
children b8ed9726525b
files libervia/server/restricted_bridge.py libervia/server/server.py
diffstat 2 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/restricted_bridge.py	Mon May 22 11:57:49 2023 +0200
+++ b/libervia/server/restricted_bridge.py	Thu Jun 01 20:44:57 2023 +0200
@@ -39,9 +39,40 @@
                 "This action is not allowed for service profile"
             )
 
+    async def action_launch(
+        self, callback_id: str, data_s: str, profile: str
+    ) -> str:
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "action_launch", callback_id, data_s, profile
+        )
+
+    async def call_start(self, entity: str, call_data_s: str, profile: str) -> None:
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "call_start", entity, call_data_s, profile
+        )
+
+    async def call_end(self, session_id: str, call_data: str, profile: str) -> None:
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "call_end", session_id, call_data, profile
+        )
+
     async def contacts_get(self, profile):
         return await self.host.bridge_call("contacts_get", profile)
 
+    async def external_disco_get(self, entity, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "external_disco_get", entity, profile)
+
+    async def ice_candidates_add(self, session_id, media_ice_data_s, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "ice_candidates_add", session_id, media_ice_data_s, profile
+        )
+
     async def identity_get(self, entity, metadata_filter, use_cache, profile):
         return await self.host.bridge_call(
             "identity_get", entity, metadata_filter, use_cache, profile)
--- a/libervia/server/server.py	Mon May 22 11:57:49 2023 +0200
+++ b/libervia/server/server.py	Thu Jun 01 20:44:57 2023 +0200
@@ -573,6 +573,18 @@
         self.bridge.register_signal(
             "message_new", partial(self.on_signal, "message_new")
         )
+        self.bridge.register_signal(
+            "call_accepted", partial(self.on_signal, "call_accepted"), "plugin"
+        )
+        self.bridge.register_signal(
+            "call_ended", partial(self.on_signal, "call_ended"), "plugin"
+        )
+        self.bridge.register_signal(
+            "ice_candidates_new", partial(self.on_signal, "ice_candidates_new"), "plugin"
+        )
+        self.bridge.register_signal(
+            "action_new", self.action_new_handler,
+        )
 
         # libervia applications handling
         self.bridge.register_signal(
@@ -694,6 +706,22 @@
         getattr(self.bridge, method_name)(*args, **kwargs)
         return d
 
+    def action_new_handler(
+        self,
+        action_data_s: str,
+        action_id: str,
+        security_limit: int,
+        profile: str
+    ) -> None:
+        if security_limit > C.SECURITY_LIMIT:
+            log.debug(
+                f"ignoring action {action_id} due to security limit"
+            )
+        else:
+            self.on_signal(
+                "action_new", action_data_s, action_id, security_limit, profile
+            )
+
     def on_signal(self, signal_name, *args):
         profile = args[-1]
         if not profile: