Mercurial > libervia-backend
annotate sat/plugins/plugin_xep_0338.py @ 4064:08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
rel 440
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 May 2023 17:59:20 +0200 |
parents | |
children |
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 |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from sat.core.constants import Const as C |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from sat.core.i18n import _ |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from sat.core.log import getLogger |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from sat.core.core_types import SatXMPPEntity |
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(): |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 group_elt = jingle_elt.addElement((NS_JINGLE_GROUPING, "group")) |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 group_elt["semantics"] = semantics |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 for content_name in content_names: |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 content_elt = group_elt.addElement((NS_JINGLE_GROUPING, "content")) |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 content_elt["name"] = content_name |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 def _jingle_session_init_trigger( |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 self, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 client: SatXMPPEntity, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 session: dict, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 content_name: str, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 media: str, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 media_data: dict, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 desc_elt: domish.Element, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 ) -> None: |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 jingle_elt = session["jingle_elt"] |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 self.add_group_element(jingle_elt, session) |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 def _jingle_handler_trigger( |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 self, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 client: SatXMPPEntity, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 action: str, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 session: dict, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 content_name: str, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 desc_elt: domish.Element, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 ) -> None: |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 # 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
|
139 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
|
140 self._j.A_PREPARE_CONFIRMATION, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 self._j.A_SESSION_INITIATE, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 self._j.A_PREPARE_INITIATOR, |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 ): |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 jingle_elt = session["jingle_elt"] |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 self.parse_group_element(jingle_elt, session) |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 if action == self._j.A_SESSION_INITIATE: |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 self.add_group_element(jingle_elt, session) |
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 |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 @implementer(iwokkel.IDisco) |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 class XEP_0338_handler(XMPPHandler): |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 return [disco.DiscoFeature(NS_RFC_5888)] |
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 def getDiscoItems(self, requestor, target, nodeIdentifier=""): |
08ee0e623e7e
plugin XEP-0338: "Jingle Grouping Framework" implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 return [] |