comparison libpurple/protocols/jabber/ping.c @ 26917:6b0e150f2276

Stop trying to be clever with XMPP keepalive pings. djabberd is responding like this (note no 'from' on the reply. No, I haven't yet filed a bug with them): C: <iq type='get' id='purplefc9e10a4' to='livejournal.com'><ping xmlns='urn:xmpp:ping'/></iq> S: <iq to='Adium user' type='error' id='purplefc9e10a4'><ping xmlns='urn:xmpp:ping'/><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>This feature is not implemented yet in DJabberd.</text></error></iq> This fixes Adium#12124.
author Paul Aurich <paul@darkrain42.org>
date Wed, 20 May 2009 00:34:59 +0000
parents 6faa5d5b4f44
children 08f5c5b12e7c
comparison
equal deleted inserted replaced
26916:bf3ad70508f4 26917:6b0e150f2276
26 26
27 #include "jabber.h" 27 #include "jabber.h"
28 #include "ping.h" 28 #include "ping.h"
29 #include "iq.h" 29 #include "iq.h"
30 30
31 static void jabber_keepalive_pong_cb(JabberStream *js) 31 static void jabber_keepalive_pong_cb(JabberStream *js, const char *from,
32 JabberIqType type, const char *id,
33 xmlnode *packet, gpointer data)
32 { 34 {
33 if (js->keepalive_timeout >= 0) { 35 if (js->keepalive_timeout >= 0) {
34 purple_timeout_remove(js->keepalive_timeout); 36 purple_timeout_remove(js->keepalive_timeout);
35 js->keepalive_timeout = -1; 37 js->keepalive_timeout = -1;
36 } 38 }
55 57
56 static void jabber_ping_result_cb(JabberStream *js, const char *from, 58 static void jabber_ping_result_cb(JabberStream *js, const char *from,
57 JabberIqType type, const char *id, 59 JabberIqType type, const char *id,
58 xmlnode *packet, gpointer data) 60 xmlnode *packet, gpointer data)
59 { 61 {
60 if (purple_strequal(from, js->user->domain)) 62 if (type == JABBER_IQ_RESULT)
61 /* If the pong is from the server, assume it's a result of the 63 purple_debug_info("jabber", "PONG!\n");
62 * keepalive functions */ 64 else
63 jabber_keepalive_pong_cb(js); 65 purple_debug_info("jabber", "ping not supported\n");
64 else { 66 }
65 if (type == JABBER_IQ_RESULT) 67
66 purple_debug_info("jabber", "PONG!\n"); 68 void jabber_keepalive_ping(JabberStream *js)
67 else 69 {
68 purple_debug_info("jabber", "ping not supported\n"); 70 JabberIq *iq;
69 } 71 xmlnode *ping;
72
73 iq = jabber_iq_new(js, JABBER_IQ_GET);
74 ping = xmlnode_new_child(iq->node, "ping");
75 xmlnode_set_namespace(ping, "urn:xmpp:ping");
76
77 jabber_iq_set_callback(iq, jabber_keepalive_pong_cb, NULL);
78 jabber_iq_send(iq);
70 } 79 }
71 80
72 gboolean jabber_ping_jid(JabberStream *js, const char *jid) 81 gboolean jabber_ping_jid(JabberStream *js, const char *jid)
73 { 82 {
74 JabberIq *iq; 83 JabberIq *iq;