comparison libervia/backend/plugins/plugin_xep_0234.py @ 4240:79c8a70e1813

backend, frontend: prepare remote control: This is a series of changes necessary to prepare the implementation of remote control feature: - XEP-0166: add a `priority` attribute to `ApplicationData`: this is needed when several applications are working in a same session, to know which one must be handled first. Will be used to make Remote Control have precedence over Call content. - XEP-0166: `_call_plugins` is now async and is not used with `DeferredList` anymore: the benefit to have methods called in parallels is very low, and it cause a lot of trouble as we can't predict order. Methods are now called sequentially so workflow can be predicted. - XEP-0167: fix `senders` XMPP attribute <=> SDP mapping - XEP-0234: preflight acceptance key is now `pre-accepted` instead of `file-accepted`, so the same key can be used with other jingle applications. - XEP-0167, XEP-0343: move some method to XEP-0167 - XEP-0353: use new `priority` feature to call preflight methods of applications according to it. - frontend (webrtc): refactor the sources/sink handling with a more flexible mechanism based on Pydantic models. It is now possible to have has many Data Channel as necessary, to have them in addition to A/V streams, to specify manually GStreamer sources and sinks, etc. - frontend (webrtc): rework of the pipeline to reduce latency. - frontend: new `portal_desktop` method. Screenshare portal handling has been moved there, and RemoteDesktop portal has been added. - frontend (webrtc): fix `extract_ufrag_pwd` method. rel 436
author Goffi <goffi@goffi.org>
date Sat, 11 May 2024 13:52:41 +0200
parents e11b13418ba6
children 0d7bb4df2343
comparison
equal deleted inserted replaced
4239:a38559e6d6e2 4240:79c8a70e1813
546 546
547 @raises exceptions.CancelError: If the user doesn't accept the incoming call. 547 @raises exceptions.CancelError: If the user doesn't accept the incoming call.
548 """ 548 """
549 session_id = session["id"] 549 session_id = session["id"]
550 peer_jid = session["peer_jid"] 550 peer_jid = session["peer_jid"]
551 # FIXME: has been moved from XEP-0353, but it doesn't handle correctly file
552 # transfer (metadata are not used). We must check with other clients what is
553 # actually send, and if XEP-0353 is used, and do a better integration.
554 551
555 try: 552 try:
556 file_elt = next(description_elt.elements(NS_JINGLE_FT, "file")) 553 file_elt = next(description_elt.elements(NS_JINGLE_FT, "file"))
557 except StopIteration: 554 except StopIteration:
558 file_data = {} 555 file_data = {}
562 is_in_roster, confirm_msg, confirm_title = self._get_confirm_msg( 559 is_in_roster, confirm_msg, confirm_title = self._get_confirm_msg(
563 client, peer_jid, file_data 560 client, peer_jid, file_data
564 ) 561 )
565 if is_in_roster: 562 if is_in_roster:
566 action_type = C.META_TYPE_CONFIRM 563 action_type = C.META_TYPE_CONFIRM
567 action_subtype = C.META_TYPE_FILE
568 else: 564 else:
569 action_type = C.META_TYPE_NOT_IN_ROSTER_LEAK 565 action_type = C.META_TYPE_NOT_IN_ROSTER_LEAK
570 action_subtype = None
571 566
572 action_extra = { 567 action_extra = {
573 "type": action_type, 568 "type": action_type,
574 "session_id": session_id, 569 "session_id": session_id,
575 "from_jid": peer_jid.full(), 570 "from_jid": peer_jid.full(),
576 "file_data": file_data 571 "file_data": file_data
577 } 572 }
578 if action_subtype is not None: 573 action_extra["subtype"] = C.META_TYPE_FILE
579 action_extra["subtype"] = action_subtype
580 accepted = await xml_tools.defer_confirm( 574 accepted = await xml_tools.defer_confirm(
581 self.host, 575 self.host,
582 confirm_msg, 576 confirm_msg,
583 confirm_title, 577 confirm_title,
584 profile=client.profile, 578 profile=client.profile,
585 action_extra=action_extra 579 action_extra=action_extra
586 ) 580 )
587 if accepted: 581 if accepted:
588 session["file_accepted"] = True 582 session["pre_accepted"] = True
589 return accepted 583 return accepted
590 584
591 async def jingle_preflight_info( 585 async def jingle_preflight_info(
592 self, 586 self,
593 client: SatXMPPEntity, 587 client: SatXMPPEntity,
750 ) -> bool: 744 ) -> bool:
751 """parse file_elt, and handle user permission/file opening""" 745 """parse file_elt, and handle user permission/file opening"""
752 transport_data = content_data["transport_data"] 746 transport_data = content_data["transport_data"]
753 webrtc = transport_data.get("webrtc", False) 747 webrtc = transport_data.get("webrtc", False)
754 # file may have been already accepted in preflight 748 # file may have been already accepted in preflight
755 file_accepted = session.get("file_accepted", False) 749 pre_accepted = session.get("pre_accepted", False)
756 file_data = await self.parse_file_element(client, file_elt, file_data, given=True) 750 file_data = await self.parse_file_element(client, file_elt, file_data, given=True)
757 # FIXME: looks redundant with code done in self.parse_file_element 751 # FIXME: looks redundant with code done in self.parse_file_element
758 try: 752 try:
759 hash_algo, file_data["given_file_hash"] = self._hash.parse_hash_elt(file_elt) 753 hash_algo, file_data["given_file_hash"] = self._hash.parse_hash_elt(file_elt)
760 except exceptions.NotFound: 754 except exceptions.NotFound:
771 __, confirm_msg, confirm_title = self._get_confirm_msg( 765 __, confirm_msg, confirm_title = self._get_confirm_msg(
772 client, peer_jid, file_data 766 client, peer_jid, file_data
773 ) 767 )
774 action_extra = { 768 action_extra = {
775 "webrtc": webrtc, 769 "webrtc": webrtc,
776 "file_accepted": file_accepted, 770 "pre_accepted": pre_accepted,
777 "type": C.META_TYPE_FILE, 771 "type": C.META_TYPE_FILE,
778 "session_id": session["id"], 772 "session_id": session["id"],
779 "from_jid": peer_jid.full(), 773 "from_jid": peer_jid.full(),
780 "file_data": file_data, 774 "file_data": file_data,
781 "progress_id": file_data["progress_id"], 775 "progress_id": file_data["progress_id"],