annotate sat/plugins/plugin_xep_0199.py @ 3895:eb0a77bea363

plugin XEP-0103: URL Address Information implementation: rel 379
author Goffi <goffi@goffi.org>
date Wed, 21 Sep 2022 22:26:48 +0200
parents be6d91572633
children 524856bd7b19
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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.i18n import _, D_
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.log import getLogger
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__)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.core.constants import Const as C
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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
51 host.bridge.addMethod(
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:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
58 self.text_cmds.registerTextCommands(self)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
59
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
60 def getHandler(self, client):
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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
63 def _pingRaiseIfFailure(self, pong):
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):
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
70 client = self.host.getClient(profile)
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)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
73 d.addCallback(self._pingRaiseIfFailure)
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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
76 def _pingCb(self, iq_result, send_time):
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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
80 def _pingEb(self, failure_, send_time):
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()
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
97 d.addCallback(self._pingCb, send_time)
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
98 d.addErrback(self._pingEb, send_time)
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":
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
106 txt_cmd.feedBack(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:
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
108 txt_cmd.feedBack(
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]
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
123 txt_cmd.feedBack(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
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
133 def onPingRequest(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(
d715d912afac plugin XEP-0199: implementation of XMPP Ping
Goffi <goffi@goffi.org>
parents:
diff changeset
149 PING_REQUEST, self.plugin_parent.onPingRequest, client=self.parent
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 []