# HG changeset patch # User Paul Aurich # Date 1242779952 0 # Node ID a6a4b440e5aed27dbb98c0ab4f8c63edbf706adf # Parent 65fadd6977b454b80789c6d99c364f92cec4b04b# Parent 6b0e150f2276e1aa208e41fc829c285066a1a57e merge of '53630753bb021f7391e8ad30abd709f73fe47c3d' and '90901b2c41b0b1a7856d9fb15fb2eb3b67383423' diff -r 65fadd6977b4 -r a6a4b440e5ae libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Tue May 19 21:35:08 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed May 20 00:39:12 2009 +0000 @@ -483,7 +483,7 @@ JabberStream *js = gc->proto_data; if (js->keepalive_timeout == -1) { - jabber_ping_jid(js, js->user->domain); + jabber_keepalive_ping(js); js->keepalive_timeout = purple_timeout_add_seconds(120, (GSourceFunc)(jabber_keepalive_timeout), gc); } diff -r 65fadd6977b4 -r a6a4b440e5ae libpurple/protocols/jabber/ping.c --- a/libpurple/protocols/jabber/ping.c Tue May 19 21:35:08 2009 +0000 +++ b/libpurple/protocols/jabber/ping.c Wed May 20 00:39:12 2009 +0000 @@ -28,7 +28,9 @@ #include "ping.h" #include "iq.h" -static void jabber_keepalive_pong_cb(JabberStream *js) +static void jabber_keepalive_pong_cb(JabberStream *js, const char *from, + JabberIqType type, const char *id, + xmlnode *packet, gpointer data) { if (js->keepalive_timeout >= 0) { purple_timeout_remove(js->keepalive_timeout); @@ -57,16 +59,23 @@ JabberIqType type, const char *id, xmlnode *packet, gpointer data) { - if (purple_strequal(from, js->user->domain)) - /* If the pong is from the server, assume it's a result of the - * keepalive functions */ - jabber_keepalive_pong_cb(js); - else { - if (type == JABBER_IQ_RESULT) - purple_debug_info("jabber", "PONG!\n"); - else - purple_debug_info("jabber", "ping not supported\n"); - } + if (type == JABBER_IQ_RESULT) + purple_debug_info("jabber", "PONG!\n"); + else + purple_debug_info("jabber", "ping not supported\n"); +} + +void jabber_keepalive_ping(JabberStream *js) +{ + JabberIq *iq; + xmlnode *ping; + + iq = jabber_iq_new(js, JABBER_IQ_GET); + ping = xmlnode_new_child(iq->node, "ping"); + xmlnode_set_namespace(ping, "urn:xmpp:ping"); + + jabber_iq_set_callback(iq, jabber_keepalive_pong_cb, NULL); + jabber_iq_send(iq); } gboolean jabber_ping_jid(JabberStream *js, const char *jid) diff -r 65fadd6977b4 -r a6a4b440e5ae libpurple/protocols/jabber/ping.h --- a/libpurple/protocols/jabber/ping.h Tue May 19 21:35:08 2009 +0000 +++ b/libpurple/protocols/jabber/ping.h Wed May 20 00:39:12 2009 +0000 @@ -29,5 +29,6 @@ void jabber_ping_parse(JabberStream *js, const char *from, JabberIqType, const char *id, xmlnode *child); gboolean jabber_ping_jid(JabberStream *js, const char *jid); +void jabber_keepalive_ping(JabberStream *js); #endif /* PURPLE_JABBER_PING_H_ */