annotate libervia/backend/plugins/plugin_xep_0298.py @ 4292:dd0891d0b22b

plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation: This is the first draft of XEP-0298 implementation. The focus is to implement elements needed for A/V Conferences protoXEP. rel 447
author Goffi <goffi@goffi.org>
date Mon, 29 Jul 2024 03:31:13 +0200
parents
children a0ed5c976bf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4292
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Libervia plugin to handle events
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2022 Jérôme Poisson (goffi@goffi.org)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from urllib.parse import quote, unquote
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber import jid
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from libervia.backend.core.i18n import _
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from libervia.backend.core.constants import Const as C
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from libervia.backend.core.log import getLogger
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from wokkel import disco, iwokkel
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from zope.interface import implementer
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 log = getLogger(__name__)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 PLUGIN_INFO = {
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 C.PI_NAME: "Events",
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_IMPORT_NAME: "XEP-0298",
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_TYPE: "XEP",
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_MODES: C.PLUG_MODE_BOTH,
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_PROTOCOLS: [],
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_DEPENDENCIES: [],
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_MAIN: "XEP_0298",
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_HANDLER: "yes",
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_DESCRIPTION: _(
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 "Delivering Conference Information to Jingle Participants (Coin). This plugin "
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 "is used to associate metadata about uses an call states in multi-party calls."
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 ),
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 }
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 NS_COIN = "urn:xmpp:coin:1"
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 NS_CONFERENCE_INFO = "urn:ietf:params:xml:ns:conference-info"
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 class XEP_0298:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 namespace = NS_COIN
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 def __init__(self, host):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 log.info(f"plugin {PLUGIN_INFO[C.PI_NAME]!r} initialization")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 self.host = host
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def get_handler(self, client):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 return CoinHandler(self)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 def add_conference_info(
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 self, jingle_elt: domish.Element, is_focus: bool = False, **kwargs
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 ) -> domish.Element:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 """Create and return a <conference_info> element
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 @param jingle_elt: parent element
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 @param kwargs: attributes of the element.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 @return: created <conference-info> element.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 """
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 conference_info_elt = jingle_elt.addElement(
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 (NS_CONFERENCE_INFO, "conference-info"),
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 )
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 if is_focus:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 conference_info_elt["isfocus"] = C.BOOL_TRUE
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 conference_info_elt.attributes.update(kwargs)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 return conference_info_elt
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 def add_user(
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 self, conference_info_elt: domish.Element, entity: jid.JID
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 ) -> domish.Element:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 """Add an user to a cconference info element.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 If the parent <users> doesn't exist, it will be created.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 @param conference_info_elt: <conference-info> element where the <user> element
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 need to be added
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 @param entity: XMPP JID to use as entity.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 @return: created <user> element.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 """
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 try:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 users_elt = next(conference_info_elt.elements(NS_CONFERENCE_INFO, "users"))
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 except StopIteration:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 users_elt = conference_info_elt.addElement("users")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 user_elt = users_elt.addElement("user")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 user_elt["entity"] = f"xmpp:{quote(entity.userhost())}"
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 return user_elt
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
98
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 def parse(self, jingle_elt: domish.Element) -> dict:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 """Parse a Jingle element and return a dictionary with conference info if present.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 @param jingle_elt: Jingle element to parse.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 @return: Dictionary with "info" key if conference info is found.
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 """
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 try:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 conference_info_elt = next(
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 jingle_elt.elements((NS_CONFERENCE_INFO, "conference-info"))
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 )
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 except StopIteration:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 return {}
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 users = []
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 try:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 users_elt = next(conference_info_elt.elements(NS_CONFERENCE_INFO, "users"))
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 for user_elt in users_elt.elements(NS_CONFERENCE_INFO, "user"):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 entity = user_elt.getAttribute("entity")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 if entity.startswith("xmpp:"):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 try:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 entity = jid.JID(unquote(entity[5:]))
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 users.append(entity)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 except Exception as e:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 log.warning(f"Failed to parse entity {entity!r}: {e}")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 else:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 log.warning(f"Ignoring non-XMPP entity {entity!r}")
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 except StopIteration:
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 pass
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 return {"info": {"users": users}}
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 @implementer(iwokkel.IDisco)
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 class CoinHandler(XMPPHandler):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
133
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 def __init__(self, plugin_parent):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 self.plugin_parent = plugin_parent
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 return [
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 disco.DiscoFeature(NS_COIN),
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 ]
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
dd0891d0b22b plugin XEP-0298: Delivering Conference Information to Jingle Participants (Coin) implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 return []