2 * purple - Jabber Protocol Plugin
4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
33 static void jabber_keepalive_pong_cb(JabberStream
*js
, const char *from
,
34 JabberIqType type
, const char *id
,
35 PurpleXmlNode
*packet
, gpointer data
)
37 if (js
->keepalive_timeout
!= 0) {
38 g_source_remove(js
->keepalive_timeout
);
39 js
->keepalive_timeout
= 0;
44 jabber_ping_parse(JabberStream
*js
, const char *from
,
45 JabberIqType type
, const char *id
, PurpleXmlNode
*ping
)
47 if (type
== JABBER_IQ_GET
) {
48 JabberIq
*iq
= jabber_iq_new(js
, JABBER_IQ_RESULT
);
51 purple_xmlnode_set_attrib(iq
->node
, "to", from
);
52 purple_xmlnode_set_attrib(iq
->node
, "id", id
);
55 } else if (type
== JABBER_IQ_SET
) {
60 static void jabber_ping_result_cb(JabberStream
*js
, const char *from
,
61 JabberIqType type
, const char *id
,
62 PurpleXmlNode
*packet
, gpointer data
)
64 if (type
== JABBER_IQ_RESULT
)
65 purple_debug_info("jabber", "PONG!\n");
67 purple_debug_info("jabber", "ping not supported\n");
70 void jabber_keepalive_ping(JabberStream
*js
)
75 iq
= jabber_iq_new(js
, JABBER_IQ_GET
);
76 ping
= purple_xmlnode_new_child(iq
->node
, "ping");
77 purple_xmlnode_set_namespace(ping
, NS_PING
);
79 jabber_iq_set_callback(iq
, jabber_keepalive_pong_cb
, NULL
);
83 gboolean
jabber_ping_jid(JabberStream
*js
, const char *jid
)
88 iq
= jabber_iq_new(js
, JABBER_IQ_GET
);
90 purple_xmlnode_set_attrib(iq
->node
, "to", jid
);
92 ping
= purple_xmlnode_new_child(iq
->node
, "ping");
93 purple_xmlnode_set_namespace(ping
, NS_PING
);
95 jabber_iq_set_callback(iq
, jabber_ping_result_cb
, NULL
);