diff libervia/desktop_kivy/plugins/plugin_wid_calls.py @ 514:d78728d7fd6a

plugin wid calls, core: implements WebRTC DataChannel file transfer: - Add a new "file" icon in call UI to send a file via WebRTC. - Handle new preflight mechanism, and WebRTC file transfer. - Native file chooser handling has been moved to new `core.file_chooser` module, and now supports "save" and "dir" modes (based on `plyer`). rel 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 13:37:27 +0200
parents 644a8d165e5a
children 11851162dd4c
line wrap: on
line diff
--- a/libervia/desktop_kivy/plugins/plugin_wid_calls.py	Thu Jan 18 23:46:31 2024 +0100
+++ b/libervia/desktop_kivy/plugins/plugin_wid_calls.py	Sat Apr 06 13:37:27 2024 +0200
@@ -6,6 +6,7 @@
 # from gi.repository import GLib
 from gi.repository import GObject, Gst, GstWebRTC, GstSdp
 from kivy.metrics import dp
+from libervia.desktop_kivy.core.file_chooser import FileChooser
 
 try:
     from gi.overrides import Gst as _
@@ -38,6 +39,7 @@
 from libervia.backend.tools.common import data_format
 from libervia.frontends.quick_frontend import quick_widgets
 from libervia.frontends.tools import aio, display_servers, jid, webrtc
+from libervia.frontends.tools.webrtc_file import WebRTCFileSender
 
 from libervia.desktop_kivy import G
 
@@ -431,6 +433,22 @@
     def on_desktop_sharing(self, instance, active: bool) -> None:
         self.webrtc.desktop_sharing = active
 
+    def on_file_btn_press(self) -> None:
+        aio.run_async(self.on_file_press())
+
+    async def on_file_press(self):
+        callee = self.webrtc.callee
+        if callee is None:
+            return
+        file_to_send = await FileChooser.a_open()
+        if file_to_send is None:
+            return
+        file_sender = WebRTCFileSender(
+            G.host.a_bridge,
+            self.profile
+        )
+        await file_sender.send_file_webrtc(file_to_send, self.webrtc.callee)
+
     def on_fullscreen(self, instance, fullscreen: bool) -> None:
         if fullscreen:
             G.host.app.show_head_widget(False, animation=False)