annotate libervia/backend/plugins/plugin_xep_0338.py @ 4272:89a0999884ac default tip @

cli (list/set): add "--comments" argument.
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2024 14:46:55 +0200
parents 0d7bb4df2343
children
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 )
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4123
diff changeset
58 host.trigger.add(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4123
diff changeset
59 "XEP-0167_jingle_session_init", self._jingle_session_init_trigger
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4123
diff changeset
60 )
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 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
62
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 def get_handler(self, client):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 return XEP_0338_handler()
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def _parse_sdp_a_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 attribute: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 parts: List[str],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 call_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 metadata: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 media_type: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 application_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 transport_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 """Parse "group" attributes"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 if attribute == "group":
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 semantics = parts[0]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 content_names = parts[1:]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 metadata.setdefault("group", {})[semantics] = content_names
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 def _generate_sdp_session_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 local: bool,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 sdp_lines: List[str],
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 """Generate "group" attributes"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 key = "metadata" if local else "peer_metadata"
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 group_data = session[key].get("group", {})
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 for semantics, content_names in group_data.items():
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 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
94
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4123
diff changeset
95 def parse_group_element(self, jingle_elt: domish.Element, session: dict) -> None:
4064
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
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4123
diff changeset
107 def add_group_element(self, jingle_elt: domish.Element, session: dict) -> None:
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 """Build the <group> and <content> elements if possible"""
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 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
110 # 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
111 # 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
112 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
113 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
114
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 group_elt["semantics"] = semantics
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 for content_name in content_names:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 content_elt = group_elt.addElement((NS_JINGLE_GROUPING, "content"))
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 content_elt["name"] = content_name
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 def _jingle_session_init_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 client: SatXMPPEntity,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 content_name: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 media: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 media_data: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 desc_elt: domish.Element,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 ) -> None:
4122
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
129 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
130 # 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
131 # content
52a89ddf3087 plugin XEP-0338: be sure to add the `<group>` element only once:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132 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
133 self.add_group_element(jingle_elt, session)
4064
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 def _jingle_handler_trigger(
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 self,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 client: SatXMPPEntity,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 action: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 session: dict,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 content_name: str,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 desc_elt: domish.Element,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 ) -> None:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 # 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
144 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
145 self._j.A_PREPARE_CONFIRMATION,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 self._j.A_SESSION_INITIATE,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self._j.A_PREPARE_INITIATOR,
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 ):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 jingle_elt = session["jingle_elt"]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 self.parse_group_element(jingle_elt, session)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 if action == self._j.A_SESSION_INITIATE:
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 self.add_group_element(jingle_elt, session)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 @implementer(iwokkel.IDisco)
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 class XEP_0338_handler(XMPPHandler):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 return [disco.DiscoFeature(NS_RFC_5888)]
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
08ee0e623e7e plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 return []