Mercurial > libervia-backend
annotate sat/plugins/plugin_xep_0353.py @ 4063:e12936318177
tests (units): tests for plugin XEP-0294:
fix 438
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 May 2023 17:58:44 +0200 |
parents | 38819c69aa39 |
children |
rev | line source |
---|---|
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
3 # Libervia plugin for Jingle Message Initiation (XEP-0353) |
3479 | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 from twisted.internet import defer |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from twisted.internet import reactor |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
21 from twisted.words.protocols.jabber import error, jid |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
22 from twisted.words.protocols.jabber import xmlstream |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from twisted.words.xish import domish |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from wokkel import disco, iwokkel |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
25 from zope.interface import implementer |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
26 |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from sat.core import exceptions |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
28 from sat.core.constants import Const as C |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
29 from sat.core.core_types import SatXMPPEntity |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
30 from sat.core.i18n import D_, _ |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from sat.core.log import getLogger |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 from sat.tools import xml_tools |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 log = getLogger(__name__) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 NS_JINGLE_MESSAGE = "urn:xmpp:jingle-message:0" |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 PLUGIN_INFO = { |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 C.PI_NAME: "Jingle Message Initiation", |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 C.PI_IMPORT_NAME: "XEP-0353", |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 C.PI_TYPE: "XEP", |
3651 | 43 C.PI_MODES: [C.PLUG_MODE_CLIENT], |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 C.PI_PROTOCOLS: ["XEP-0353"], |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
45 C.PI_DEPENDENCIES: ["XEP-0166", "XEP-0334"], |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 C.PI_MAIN: "XEP_0353", |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 C.PI_HANDLER: "yes", |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 C.PI_DESCRIPTION: _("""Implementation of Jingle Message Initiation"""), |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 } |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
3517
8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
52 class XEP_0353: |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 def __init__(self, host): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 log.info(_("plugin {name} initialization").format(name=PLUGIN_INFO[C.PI_NAME])) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 self.host = host |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
56 host.register_namespace("jingle-message", NS_JINGLE_MESSAGE) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 self._j = host.plugins["XEP-0166"] |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
58 self._h = host.plugins["XEP-0334"] |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
59 host.trigger.add( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
60 "XEP-0166_initiate_elt_built", |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
61 self._on_initiate_trigger, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
62 # this plugin set the resource, we want it to happen first to other trigger |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
63 # can get the full peer JID |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
64 priority=host.trigger.MAX_PRIORITY, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
65 ) |
4051
c23cad65ae99
core: renamed `messageReceived` trigger to `message_received`
Goffi <goffi@goffi.org>
parents:
4044
diff
changeset
|
66 host.trigger.add("message_received", self._on_message_received) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
68 def get_handler(self, client): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 return Handler() |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
71 def profile_connecting(self, client): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 # mapping from session id to deferred used to wait for destinee answer |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 client._xep_0353_pending_sessions = {} |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
75 def build_message_data(self, client, peer_jid, verb, session_id): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 mess_data = { |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
77 "from": client.jid, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
78 "to": peer_jid, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
79 "uid": "", |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
80 "message": {}, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
81 "type": C.MESS_TYPE_CHAT, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
82 "subject": {}, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
83 "extra": {}, |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 } |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
85 client.generate_message_xml(mess_data) |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
86 message_elt = mess_data["xml"] |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
87 verb_elt = message_elt.addElement((NS_JINGLE_MESSAGE, verb)) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 verb_elt["id"] = session_id |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
89 self._h.add_hint_elements(message_elt, [self._h.HINT_STORE]) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 return mess_data |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
92 async def _on_initiate_trigger( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
93 self, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
94 client: SatXMPPEntity, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
95 session: dict, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
96 iq_elt: domish.Element, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
97 jingle_elt: domish.Element, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
98 ) -> bool: |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
99 peer_jid = session["peer_jid"] |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 if peer_jid.resource: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 |
3652
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
103 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
104 infos = await self.host.memory.disco.get_infos(client, peer_jid) |
3652
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
105 except error.StanzaError as e: |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
106 if e.condition == "service-unavailable": |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
107 categories = {} |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
108 else: |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
109 raise e |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
110 else: |
6e34307319c0
plugin XEP-0353: fix jingle initiation on disco "Service Unavailable" error:
Goffi <goffi@goffi.org>
parents:
3651
diff
changeset
|
111 categories = {c for c, __ in infos.identities} |
3517
8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
112 if "component" in categories: |
8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
113 # we don't use message initiation with components |
8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
114 return True |
8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
115 |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 if peer_jid.userhostJID() not in client.roster: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 # if the contact is not in our roster, we need to send a directed presence |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 # according to XEP-0353 §3.1 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 await client.presence.available(peer_jid) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
121 mess_data = self.build_message_data(client, peer_jid, "propose", session["id"]) |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
122 message_elt = mess_data["xml"] |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
123 for content_data in session["contents"].values(): |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
124 # we get the full element build by the application plugin |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
125 jingle_description_elt = content_data["application_data"]["desc_elt"] |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
126 # and copy it to only keep the root <description> element, no children |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
127 description_elt = domish.Element( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
128 (jingle_description_elt.uri, jingle_description_elt.name), |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
129 defaultUri=jingle_description_elt.defaultUri, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
130 attribs=jingle_description_elt.attributes, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
131 localPrefixes=jingle_description_elt.localPrefixes, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
132 ) |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
133 message_elt.propose.addChild(description_elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 response_d = defer.Deferred() |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 # we wait for 2 min before cancelling the session init |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
4042
diff
changeset
|
136 # FIXME: let's application decide timeout? |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
137 response_d.addTimeout(2 * 60, reactor) |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
138 client._xep_0353_pending_sessions[session["id"]] = response_d |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
139 await client.send_message_data(mess_data) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 try: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 accepting_jid = await response_d |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 except defer.TimeoutError: |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
143 log.warning( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
144 _("Message initiation with {peer_jid} timed out").format( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
145 peer_jid=peer_jid |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
146 ) |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
147 ) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 else: |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
149 if iq_elt["to"] != accepting_jid.userhost(): |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
150 raise exceptions.InternalError( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
151 f"<jingle> 'to' attribute ({iq_elt['to']!r}) must not differ " |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
152 f"from bare JID of the accepting entity ({accepting_jid!r}), this " |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
153 "may be a sign of an internal bug, a hack attempt, or a MITM attack!" |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
154 ) |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
155 iq_elt["to"] = accepting_jid.full() |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 session["peer_jid"] = accepting_jid |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
157 del client._xep_0353_pending_sessions[session["id"]] |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
160 async def _on_message_received(self, client, message_elt, post_treat): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 for elt in message_elt.elements(): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 if elt.uri == NS_JINGLE_MESSAGE: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 if elt.name == "propose": |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
164 return await self._handle_propose(client, message_elt, elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 elif elt.name == "retract": |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
166 return self._handle_retract(client, message_elt, elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 elif elt.name == "proceed": |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
168 return self._handle_proceed(client, message_elt, elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 elif elt.name == "accept": |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
170 return self._handle_accept(client, message_elt, elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 elif elt.name == "reject": |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
172 return self._handle_accept(client, message_elt, elt) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 else: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 log.warning(f"invalid element: {elt.toXml}") |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
178 async def _handle_propose(self, client, message_elt, elt): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 peer_jid = jid.JID(message_elt["from"]) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 session_id = elt["id"] |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 if peer_jid.userhostJID() not in client.roster: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 app_ns = elt.description.uri |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 try: |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
4042
diff
changeset
|
184 application = self._j.get_application(app_ns) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 human_name = getattr(application.handler, "human_name", application.name) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 except (exceptions.NotFound, AttributeError): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 if app_ns.startswith("urn:xmpp:jingle:apps:"): |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
188 human_name = app_ns[21:].split(":", 1)[0].replace("-", " ").title() |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 else: |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
190 splitted_ns = app_ns.split(":") |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 if len(splitted_ns) > 1: |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
192 human_name = splitted_ns[-2].replace("- ", " ").title() |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 else: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 human_name = app_ns |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 confirm_msg = D_( |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 "Somebody not in your contact list ({peer_jid}) wants to do a " |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 '"{human_name}" session with you, this would leak your presence and ' |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 "possibly you IP (internet localisation), do you accept?" |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 ).format(peer_jid=peer_jid, human_name=human_name) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 confirm_title = D_("Invitation from an unknown contact") |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
202 accept = await xml_tools.defer_confirm( |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
203 self.host, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
204 confirm_msg, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
205 confirm_title, |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
206 profile=client.profile, |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 action_extra={ |
4042
877145b4ba01
core: don't use `meta_` prefix anymore for `action_extra` in `action_new` signal.
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
208 "type": C.META_TYPE_NOT_IN_ROSTER_LEAK, |
877145b4ba01
core: don't use `meta_` prefix anymore for `action_extra` in `action_new` signal.
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
209 "session_id": session_id, |
877145b4ba01
core: don't use `meta_` prefix anymore for `action_extra` in `action_new` signal.
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
210 "from_jid": peer_jid.full(), |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
211 }, |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 ) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 if not accept: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
214 mess_data = self.build_message_data( |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
215 client, client.jid.userhostJID(), "reject", session_id |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
216 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
217 await client.send_message_data(mess_data) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 # we don't sent anything to sender, to avoid leaking presence |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 return False |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 else: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 await client.presence.available(peer_jid) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 session_id = elt["id"] |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
223 mess_data = self.build_message_data(client, peer_jid, "proceed", session_id) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
224 await client.send_message_data(mess_data) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
225 return False |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
227 def _handle_retract(self, client, message_elt, proceed_elt): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 log.warning("retract is not implemented yet") |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 return False |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
230 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
231 def _handle_proceed(self, client, message_elt, proceed_elt): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
232 try: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
233 session_id = proceed_elt["id"] |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
234 except KeyError: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
235 log.warning(f"invalid proceed element in message_elt: {message_elt}") |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
236 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
237 try: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 response_d = client._xep_0353_pending_sessions[session_id] |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 except KeyError: |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 log.warning( |
4055
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
241 _( |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
242 "no pending session found with id {session_id}, did it timed out?" |
38819c69aa39
plugin XEP-0353: update according to XEP changes + <description> fix:
Goffi <goffi@goffi.org>
parents:
4051
diff
changeset
|
243 ).format(session_id=session_id) |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
244 ) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 return True |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
247 response_d.callback(jid.JID(message_elt["from"])) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
248 return False |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
249 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
250 def _handle_accept(self, client, message_elt, accept_elt): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
251 pass |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3652
diff
changeset
|
253 def _handle_reject(self, client, message_elt, accept_elt): |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 pass |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
255 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
256 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 @implementer(iwokkel.IDisco) |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 class Handler(xmlstream.XMPPHandler): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 return [disco.DiscoFeature(NS_JINGLE_MESSAGE)] |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
261 |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
262 def getDiscoItems(self, requestor, target, nodeIdentifier=""): |
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
263 return [] |