Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0338.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | c8b19a32f5c0 |
children | b4b4ea8c5c87 |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
53 self._j = host.plugins["XEP-0166"] | 53 self._j = host.plugins["XEP-0166"] |
54 host.trigger.add("XEP-0167_parse_sdp_a", self._parse_sdp_a_trigger) | 54 host.trigger.add("XEP-0167_parse_sdp_a", self._parse_sdp_a_trigger) |
55 host.trigger.add( | 55 host.trigger.add( |
56 "XEP-0167_generate_sdp_session", self._generate_sdp_session_trigger | 56 "XEP-0167_generate_sdp_session", self._generate_sdp_session_trigger |
57 ) | 57 ) |
58 host.trigger.add("XEP-0167_jingle_session_init", self._jingle_session_init_trigger) | 58 host.trigger.add( |
59 "XEP-0167_jingle_session_init", self._jingle_session_init_trigger | |
60 ) | |
59 host.trigger.add("XEP-0167_jingle_handler", self._jingle_handler_trigger) | 61 host.trigger.add("XEP-0167_jingle_handler", self._jingle_handler_trigger) |
60 | 62 |
61 def get_handler(self, client): | 63 def get_handler(self, client): |
62 return XEP_0338_handler() | 64 return XEP_0338_handler() |
63 | 65 |
88 group_data = session[key].get("group", {}) | 90 group_data = session[key].get("group", {}) |
89 | 91 |
90 for semantics, content_names in group_data.items(): | 92 for semantics, content_names in group_data.items(): |
91 sdp_lines.append(f"a=group:{semantics} {' '.join(content_names)}") | 93 sdp_lines.append(f"a=group:{semantics} {' '.join(content_names)}") |
92 | 94 |
93 def parse_group_element( | 95 def parse_group_element(self, jingle_elt: domish.Element, session: dict) -> None: |
94 self, jingle_elt: domish.Element, session: dict | |
95 ) -> None: | |
96 """Parse the <group> and <content> elements""" | 96 """Parse the <group> and <content> elements""" |
97 for group_elt in jingle_elt.elements(NS_JINGLE_GROUPING, "group"): | 97 for group_elt in jingle_elt.elements(NS_JINGLE_GROUPING, "group"): |
98 try: | 98 try: |
99 metadata = session["peer_metadata"] | 99 metadata = session["peer_metadata"] |
100 semantics = group_elt["semantics"] | 100 semantics = group_elt["semantics"] |
102 for content_elt in group_elt.elements(NS_JINGLE_GROUPING, "content"): | 102 for content_elt in group_elt.elements(NS_JINGLE_GROUPING, "content"): |
103 group_content.append(content_elt["name"]) | 103 group_content.append(content_elt["name"]) |
104 except KeyError as e: | 104 except KeyError as e: |
105 log.warning(f"Error while parsing <group>: {e}\n{group_elt.toXml()}") | 105 log.warning(f"Error while parsing <group>: {e}\n{group_elt.toXml()}") |
106 | 106 |
107 def add_group_element( | 107 def add_group_element(self, jingle_elt: domish.Element, session: dict) -> None: |
108 self, jingle_elt: domish.Element, session: dict | |
109 ) -> None: | |
110 """Build the <group> and <content> elements if possible""" | 108 """Build the <group> and <content> elements if possible""" |
111 for semantics, content_names in session["metadata"].get("group", {}).items(): | 109 for semantics, content_names in session["metadata"].get("group", {}).items(): |
112 # always add the <group> element as first child of <jingle> element to work | 110 # always add the <group> element as first child of <jingle> element to work |
113 # around https://github.com/movim/movim/issues/1233 | 111 # around https://github.com/movim/movim/issues/1233 |
114 group_elt = domish.Element((NS_JINGLE_GROUPING, "group")) | 112 group_elt = domish.Element((NS_JINGLE_GROUPING, "group")) |