annotate libervia/backend/plugins/plugin_xep_0199.py @ 4146:60d107f2178a

frontends (tools/webrtc): fix `SINKS_APP` condition check.
author Goffi <goffi@goffi.org>
date Fri, 03 Nov 2023 15:32:17 +0100
parents 4b842c1fb686
children 0d7bb4df2343
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
3
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for Delayed Delivery (XEP-0199)
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
7
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # (at your option) any later version.
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
12
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
17
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
20
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
21 from libervia.backend.core.i18n import _, D_
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
22 from libervia.backend.core.log import getLogger
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
23
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
24 log = getLogger(__name__)
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
25 from libervia.backend.core.constants import Const as C
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from wokkel import disco, iwokkel
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from twisted.words.protocols.jabber import xmlstream, jid
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
28 from zope.interface import implementer
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
29 import time
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
30
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
31
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
32 PLUGIN_INFO = {
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
33 C.PI_NAME: "XMPP PING",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
34 C.PI_IMPORT_NAME: "XEP-0199",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
35 C.PI_TYPE: "XEP",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
36 C.PI_PROTOCOLS: ["XEP-199"],
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_MAIN: "XEP_0199",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
38 C.PI_HANDLER: "yes",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
39 C.PI_DESCRIPTION: D_("""Implementation of XMPP Ping"""),
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
40 }
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
41
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
42 NS_PING = "urn:xmpp:ping"
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
43 PING_REQUEST = C.IQ_GET + '/ping[@xmlns="' + NS_PING + '"]'
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
44
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
45
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
46 class XEP_0199(object):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
47
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def __init__(self, host):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
49 log.info(_("XMPP Ping plugin initialization"))
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self.host = host
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
51 host.bridge.add_method(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
52 "ping", ".plugin", in_sign='ss', out_sign='d', method=self._ping, async_=True)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
53 try:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
54 self.text_cmds = self.host.plugins[C.TEXT_CMDS]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
55 except KeyError:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
56 log.info(_("Text commands not available"))
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
57 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
58 self.text_cmds.register_text_commands(self)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
59
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
60 def get_handler(self, client):
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
61 return XEP_0199_handler(self)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
62
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
63 def _ping_raise_if_failure(self, pong):
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
64 """If ping didn't succeed, raise the failure, else return pong delay"""
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
65 if pong[0] != "PONG":
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
66 raise pong[0]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
67 return pong[1]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
68
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
69 def _ping(self, jid_s, profile):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
70 client = self.host.get_client(profile)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
71 entity_jid = jid.JID(jid_s)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
72 d = self.ping(client, entity_jid)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
73 d.addCallback(self._ping_raise_if_failure)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
74 return d
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
75
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
76 def _ping_cb(self, iq_result, send_time):
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
77 receive_time = time.time()
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
78 return ("PONG", receive_time - send_time)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
79
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
80 def _ping_eb(self, failure_, send_time):
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
81 receive_time = time.time()
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
82 return (failure_.value, receive_time - send_time)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
83
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
84 def ping(self, client, entity_jid):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
85 """Ping an XMPP entity
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
86
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
87 @param entity_jid(jid.JID): entity to ping
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
88 @return (tuple[(unicode,failure), float]): pong data:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
89 - either u"PONG" if it was successful, or failure
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
90 - delay between sending time and reception time
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
91 """
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
92 iq_elt = client.IQ("get")
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
93 iq_elt["to"] = entity_jid.full()
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
94 iq_elt.addElement((NS_PING, "ping"))
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
95 d = iq_elt.send()
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
96 send_time = time.time()
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
97 d.addCallback(self._ping_cb, send_time)
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
98 d.addErrback(self._ping_eb, send_time)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
99 return d
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
100
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def _cmd_ping_fb(self, pong, client, mess_data):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
102 """Send feedback to client when pong data is received"""
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
103 txt_cmd = self.host.plugins[C.TEXT_CMDS]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
104
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
105 if pong[0] == "PONG":
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
106 txt_cmd.feed_back(client, "PONG ({time} s)".format(time=pong[1]), mess_data)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
107 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
108 txt_cmd.feed_back(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
109 client, _("ping error ({err_msg}). Response time: {time} s")
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
110 .format(err_msg=pong[0], time=pong[1]), mess_data)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
111
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
112 def cmd_ping(self, client, mess_data):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
113 """ping an entity
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
114
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
115 @command (all): [JID]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
116 - JID: jid of the entity to ping
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
117 """
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
118 if mess_data["unparsed"].strip():
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
119 try:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
120 entity_jid = jid.JID(mess_data["unparsed"].strip())
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
121 except RuntimeError:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
122 txt_cmd = self.host.plugins[C.TEXT_CMDS]
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
123 txt_cmd.feed_back(client, _('Invalid jid: "{entity_jid}"').format(
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
124 entity_jid=mess_data["unparsed"].strip()), mess_data)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
125 return False
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
126 else:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
127 entity_jid = mess_data["to"]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
128 d = self.ping(client, entity_jid)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
129 d.addCallback(self._cmd_ping_fb, client, mess_data)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
130
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
131 return False
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
132
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
133 def on_ping_request(self, iq_elt, client):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
134 log.info(_("XMPP PING received from {from_jid} [{profile}]").format(
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
135 from_jid=iq_elt["from"], profile=client.profile))
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
136 iq_elt.handled = True
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
137 iq_result_elt = xmlstream.toResponse(iq_elt, "result")
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
138 client.send(iq_result_elt)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
139
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
140
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
141 @implementer(iwokkel.IDisco)
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
142 class XEP_0199_handler(xmlstream.XMPPHandler):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
143
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
144 def __init__(self, plugin_parent):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
145 self.plugin_parent = plugin_parent
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
146
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
147 def connectionInitialized(self):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
148 self.xmlstream.addObserver(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
149 PING_REQUEST, self.plugin_parent.on_ping_request, client=self.parent
2689
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
150 )
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
151
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
152 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
153 return [disco.DiscoFeature(NS_PING)]
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
154
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
155 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
156 return []