]> crepu.dev Git - config.git/blame_incremental - djavu-asus/elpa/jabber-20230715.456/jabber-ping.el
Actualizado el Readme
[config.git] / djavu-asus / elpa / jabber-20230715.456 / jabber-ping.el
... / ...
CommitLineData
1;; jabber-ping.el - XMPP "Ping" by XEP-0199 -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2009 - Evgenii Terechkov - evg@altlinux.org
4
5;; This file is a part of jabber.el.
6
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 2 of the License, or
10;; (at your option) any later version.
11
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program; if not, write to the Free Software
19;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21(require 'jabber-iq)
22(require 'jabber-util)
23(require 'jabber-menu)
24(require 'jabber-disco)
25
26(add-to-list 'jabber-jid-info-menu
27 (cons "Ping" 'jabber-ping))
28
29(defun jabber-ping-send (jc to process-func on-success on-error)
30 "Send XEP-0199 ping IQ stanza.
31JC is connection to use, TO is full JID, PROCESS-FUNC is fucntion to call to
32process result, ON-SUCCESS and ON-ERROR is arg for this function depending on
33result."
34 (jabber-send-iq jc to "get"
35 '(ping ((xmlns . "urn:xmpp:ping")))
36 process-func on-success
37 process-func on-error))
38
39(defun jabber-ping (to)
40 "Ping XMPP entity.
41TO is full JID. All connected JIDs is used."
42 (interactive (list (jabber-read-jid-completing "Send ping to: " nil nil nil 'full)))
43 (dolist (jc jabber-connections)
44 (jabber-ping-send jc to 'jabber-silent-process-data 'jabber-process-ping "Ping is unsupported")))
45
46;; called by jabber-process-data
47(defun jabber-process-ping (jc xml-data)
48 "Handle results from ping requests.
49
50JC is the Jabber connection.
51XML-DATA is the parsed tree data from the stream (stanzas)
52obtained from `xml-parse-region'."
53 (let ((to (jabber-xml-get-attribute xml-data 'from)))
54 (format "%s is alive" to)))
55
56(add-to-list 'jabber-iq-get-xmlns-alist (cons "urn:xmpp:ping" 'jabber-pong))
57(jabber-disco-advertise-feature "urn:xmpp:ping")
58
59(defun jabber-pong (jc xml-data)
60 "Return pong as defined in XEP-0199.
61Sender and Id are determined from the incoming packet passed in XML-DATA.
62
63JC is the Jabber connection.
64XML-DATA is the parsed tree data from the stream (stanzas)
65obtained from `xml-parse-region'."
66 (let ((to (jabber-xml-get-attribute xml-data 'from))
67 (id (jabber-xml-get-attribute xml-data 'id)))
68 (jabber-send-iq jc to "result" nil nil nil nil nil id)))
69
70(provide 'jabber-ping)