annotate libervia/backend/plugins/plugin_xep_0338.py @ 4236:f59e9421a650

test (unit/cli): Add a file send/receive test for WebRTC: fix 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 15:21:00 +0200
parents c8b19a32f5c0
children 0d7bb4df2343
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia plugin
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from typing import List
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from wokkel import disco, iwokkel
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from zope.interface import implementer
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4064
diff changeset
26 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4064
diff changeset
27 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4064
diff changeset
28 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4064
diff changeset
29 from libervia.backend.core.core_types import SatXMPPEntity
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 log = getLogger(__name__)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 NS_JINGLE_GROUPING = "urn:xmpp:jingle:apps:grouping:0"
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 NS_RFC_5888 = "urn:ietf:rfc:5888"
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 PLUGIN_INFO = {
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_NAME: "Jingle Grouping Framework",
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_IMPORT_NAME: "XEP-0338",
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_TYPE: "XEP",
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_MODES: C.PLUG_MODE_BOTH,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_PROTOCOLS: ["XEP-0338"],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_DEPENDENCIES: ["XEP-0166", "XEP-0167"],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 C.PI_RECOMMENDATIONS: [],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 C.PI_MAIN: "XEP_0338",
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 C.PI_HANDLER: "yes",
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 C.PI_DESCRIPTION: _("""Jingle mapping of RFC 5888 SDP Grouping Framework"""),
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 }
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 class XEP_0338:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 def __init__(self, host):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 log.info(f"plugin {PLUGIN_INFO[C.PI_NAME]!r} initialization")
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self._j = host.plugins["XEP-0166"]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 host.trigger.add("XEP-0167_parse_sdp_a", self._parse_sdp_a_trigger)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 host.trigger.add(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 "XEP-0167_generate_sdp_session", self._generate_sdp_session_trigger
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 )
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 host.trigger.add("XEP-0167_jingle_session_init", self._jingle_session_init_trigger)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 host.trigger.add("XEP-0167_jingle_handler", self._jingle_handler_trigger)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 def get_handler(self, client):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 return XEP_0338_handler()
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 def _parse_sdp_a_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 attribute: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 parts: List[str],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 call_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 metadata: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 media_type: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 application_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 transport_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 """Parse "group" attributes"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 if attribute == "group":
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 semantics = parts[0]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 content_names = parts[1:]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 metadata.setdefault("group", {})[semantics] = content_names
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 def _generate_sdp_session_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 local: bool,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 sdp_lines: List[str],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 """Generate "group" attributes"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 key = "metadata" if local else "peer_metadata"
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 group_data = session[key].get("group", {})
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 for semantics, content_names in group_data.items():
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 sdp_lines.append(f"a=group:{semantics} {' '.join(content_names)}")
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 def parse_group_element(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 self, jingle_elt: domish.Element, session: dict
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 """Parse the <group> and <content> elements"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 for group_elt in jingle_elt.elements(NS_JINGLE_GROUPING, "group"):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 try:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 metadata = session["peer_metadata"]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 semantics = group_elt["semantics"]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 group_content = metadata.setdefault("group", {})[semantics] = []
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 for content_elt in group_elt.elements(NS_JINGLE_GROUPING, "content"):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 group_content.append(content_elt["name"])
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 except KeyError as e:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 log.warning(f"Error while parsing <group>: {e}\n{group_elt.toXml()}")
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 def add_group_element(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 self, jingle_elt: domish.Element, session: dict
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 """Build the <group> and <content> elements if possible"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 for semantics, content_names in session["metadata"].get("group", {}).items():
4123
c8b19a32f5c0 plugin XEP-0338: always add `<group>` element as first <jingle> child:
Goffi <goffi@goffi.org>
parents: 4122
diff changeset
112 # always add the <group> element as first child of <jingle> element to work
c8b19a32f5c0 plugin XEP-0338: always add `<group>` element as first <jingle> child:
Goffi <goffi@goffi.org>
parents: 4122
diff changeset
113 # around https://github.com/movim/movim/issues/1233
c8b19a32f5c0 plugin XEP-0338: always add `<group>` element as first <jingle> child:
Goffi <goffi@goffi.org>
parents: 4122
diff changeset
114 group_elt = domish.Element((NS_JINGLE_GROUPING, "group"))
c8b19a32f5c0 plugin XEP-0338: always add `<group>` element as first <jingle> child:
Goffi <goffi@goffi.org>
parents: 4122
diff changeset
115 jingle_elt.children.insert(0, group_elt)
c8b19a32f5c0 plugin XEP-0338: always add `<group>` element as first <jingle> child:
Goffi <goffi@goffi.org>
parents: 4122
diff changeset
116
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 group_elt["semantics"] = semantics
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 for content_name in content_names:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 content_elt = group_elt.addElement((NS_JINGLE_GROUPING, "content"))
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 content_elt["name"] = content_name
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 def _jingle_session_init_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 client: SatXMPPEntity,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 content_name: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 media: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 media_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 desc_elt: domish.Element,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 ) -> None:
4122
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
131 if content_name == next(iter(session["contents"])):
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132 # the <group> element must be added only once, so we do it only for the first
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
133 # content
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
134 jingle_elt = session["jingle_elt"]
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
135 self.add_group_element(jingle_elt, session)
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def _jingle_handler_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 client: SatXMPPEntity,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 action: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 content_name: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 desc_elt: domish.Element,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 # this is a session metadata, so we only generate it on the first content
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 if content_name == next(iter(session["contents"])) and action in (
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self._j.A_PREPARE_CONFIRMATION,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 self._j.A_SESSION_INITIATE,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 self._j.A_PREPARE_INITIATOR,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 ):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 jingle_elt = session["jingle_elt"]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 self.parse_group_element(jingle_elt, session)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 if action == self._j.A_SESSION_INITIATE:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 self.add_group_element(jingle_elt, session)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 @implementer(iwokkel.IDisco)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 class XEP_0338_handler(XMPPHandler):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 return [disco.DiscoFeature(NS_RFC_5888)]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 return []