Mercurial > pidgin
diff libpurple/protocols/jabber/ping.c @ 25640:42dd7e591031
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 03 Feb 2009 17:39:14 +0000 |
parents | b5052c66701c |
children | ced3d4ab745a |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/ping.c Tue Feb 03 17:10:05 2009 +0000 +++ b/libpurple/protocols/jabber/ping.c Tue Feb 03 17:39:14 2009 +0000 @@ -23,12 +23,17 @@ #include "internal.h" #include "debug.h" -#include "xmlnode.h" #include "jabber.h" #include "ping.h" #include "iq.h" +static void jabber_keepalive_pong_cb(JabberStream *js) +{ + purple_timeout_remove(js->keepalive_timeout); + js->keepalive_timeout = -1; +} + void jabber_ping_parse(JabberStream *js, xmlnode *packet) { @@ -58,11 +63,19 @@ } static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, - gpointer data) + gpointer data) { const char *type = xmlnode_get_attrib(packet, "type"); + const char *from = xmlnode_get_attrib(packet, "from"); purple_debug_info("jabber", "jabber_ping_result_cb\n"); + + if (!from || !strcmp(from, js->user->domain)) { + /* If the pong is from our server, treat it as a return from the + * keepalive functions */ + jabber_keepalive_pong_cb(js); + } + if(type && !strcmp(type, "result")) { purple_debug_info("jabber", "PONG!\n"); } else { @@ -70,15 +83,16 @@ } } -gboolean jabber_ping_jid(PurpleConversation *conv, const char *jid) +gboolean jabber_ping_jid(JabberStream *js, const char *jid) { JabberIq *iq; xmlnode *ping; purple_debug_info("jabber", "jabber_ping_jid\n"); - iq = jabber_iq_new(conv->account->gc->proto_data, JABBER_IQ_GET); - xmlnode_set_attrib(iq->node, "to", jid); + iq = jabber_iq_new(js, JABBER_IQ_GET); + if (jid) + xmlnode_set_attrib(iq->node, "to", jid); ping = xmlnode_new_child(iq->node, "ping"); xmlnode_set_namespace(ping, "urn:xmpp:ping"); @@ -86,7 +100,5 @@ jabber_iq_set_callback(iq, jabber_ping_result_cb, NULL); jabber_iq_send(iq); - - return TRUE; }