diff sat/plugins/plugin_xep_0353.py @ 4044:3900626bc100

plugin XEP-0166: refactoring, and various improvments: - add models for transport and applications handlers and linked data - split models into separate file - some type hints - some documentation comments - add actions to prepare confirmation, useful to do initial parsing of all contents - application arg/kwargs and some transport data can be initialised during Jingle `initiate` call, this is notably useful when a call is made with transport data (this is the call for A/V calls where codecs and ICE candidate can be specified when starting a call) - session data can be specified during Jingle `initiate` call - new `store_in_session` argument in `_parse_elements`, which can be used to avoid race-condition when a context element (<decription> or <transport>) is being parsed for an action while an other action happens (like `transport-info`) - don't sed `sid` in `transport_elt` during a `transport-info` action anymore in `build_action`: this is specific to Jingle File Transfer and has been moved there rel 419
author Goffi <goffi@goffi.org>
date Mon, 15 May 2023 16:23:11 +0200
parents 877145b4ba01
children c23cad65ae99
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0353.py	Mon May 15 16:20:58 2023 +0200
+++ b/sat/plugins/plugin_xep_0353.py	Mon May 15 16:23:11 2023 +0200
@@ -105,22 +105,30 @@
 
         mess_data = self.build_message_data(client, peer_jid, "propose", session['id'])
         for content in contents:
-            application, app_args, app_kwargs, content_name = self._j.get_content_data(
+            content_data = self._j.get_content_data(
                 content)
             try:
-                jingle_description_elt = application.handler.jingle_description_elt
+                jingle_description_elt = (
+                    content_data.application.handler.jingle_description_elt
+                )
             except AttributeError:
-                log.debug(f"no jingle_description_elt set for {application.handler}")
+                log.debug(
+                    "no jingle_description_elt set for "
+                    f"{content_data.application.handler}"
+                )
                 description_elt = domish.Element((content["app_ns"], "description"))
             else:
                 description_elt = await utils.as_deferred(
                     jingle_description_elt,
-                    client, session, content_name, *app_args, **app_kwargs
+                    client, session, content_data.content_name, *content_data.app_args,
+                    **content_data.app_kwargs
                 )
         mess_data["xml"].propose.addChild(description_elt)
         response_d = defer.Deferred()
         # we wait for 2 min before cancelling the session init
-        response_d.addTimeout(2*60, reactor)
+        # response_d.addTimeout(2*60, reactor)
+        # FIXME: let's application decide timeout?
+        response_d.addTimeout(2, reactor)
         client._xep_0353_pending_sessions[session['id']] = response_d
         await client.send_message_data(mess_data)
         try:
@@ -158,7 +166,7 @@
         if peer_jid.userhostJID() not in client.roster:
             app_ns = elt.description.uri
             try:
-                application = self._j.getApplication(app_ns)
+                application = self._j.get_application(app_ns)
                 human_name = getattr(application.handler, "human_name", application.name)
             except (exceptions.NotFound, AttributeError):
                 if app_ns.startswith("urn:xmpp:jingle:apps:"):
@@ -193,6 +201,7 @@
             else:
                 await client.presence.available(peer_jid)
         session_id = elt["id"]
+        # FIXME: accept is not used anymore in new specification, check it and remove it
         mess_data = self.build_message_data(
             client, client.jid.userhostJID(), "accept", session_id)
         await client.send_message_data(mess_data)