Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/ping.c @ 25940:c2cb082f5f2f
Reduce the debug log spam from the ping code and fix a logic error.
The response will come from our own bare JID (or have no 'from' attributes)
for the keepalive pings.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 08 Feb 2009 16:50:58 +0000 |
parents | c8606917787a |
children | ae41d8e827e3 |
comparison
equal
deleted
inserted
replaced
25939:150282919040 | 25940:c2cb082f5f2f |
---|---|
36 | 36 |
37 void | 37 void |
38 jabber_ping_parse(JabberStream *js, const char *from, | 38 jabber_ping_parse(JabberStream *js, const char *from, |
39 JabberIqType type, const char *id, xmlnode *ping) | 39 JabberIqType type, const char *id, xmlnode *ping) |
40 { | 40 { |
41 purple_debug_info("jabber", "jabber_ping_parse\n"); | |
42 | |
43 if (type == JABBER_IQ_GET) { | 41 if (type == JABBER_IQ_GET) { |
44 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT); | 42 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
45 | 43 |
46 if (from) | 44 if (from) |
47 xmlnode_set_attrib(iq->node, "to", from); | 45 xmlnode_set_attrib(iq->node, "to", from); |
56 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, | 54 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, |
57 gpointer data) | 55 gpointer data) |
58 { | 56 { |
59 const char *type = xmlnode_get_attrib(packet, "type"); | 57 const char *type = xmlnode_get_attrib(packet, "type"); |
60 const char *from = xmlnode_get_attrib(packet, "from"); | 58 const char *from = xmlnode_get_attrib(packet, "from"); |
59 char *own_bare_jid = g_strdup_printf("%s@%s", js->user->node, | |
60 js->user->domain); | |
61 | 61 |
62 purple_debug_info("jabber", "jabber_ping_result_cb\n"); | 62 if (!from || !strcmp(from, own_bare_jid)) { |
63 | 63 /* If the pong is from our bare JID, treat it as a return from the |
64 if (!from || !strcmp(from, js->user->domain)) { | |
65 /* If the pong is from our server, treat it as a return from the | |
66 * keepalive functions */ | 64 * keepalive functions */ |
67 jabber_keepalive_pong_cb(js); | 65 jabber_keepalive_pong_cb(js); |
68 } | 66 } |
67 g_free(own_bare_jid); | |
69 | 68 |
70 if(type && !strcmp(type, "result")) { | 69 if(type && !strcmp(type, "result")) { |
71 purple_debug_info("jabber", "PONG!\n"); | 70 purple_debug_info("jabber", "PONG!\n"); |
72 } else { | 71 } else { |
73 purple_debug_info("jabber", "(not supported)\n"); | 72 purple_debug_info("jabber", "(not supported)\n"); |
77 gboolean jabber_ping_jid(JabberStream *js, const char *jid) | 76 gboolean jabber_ping_jid(JabberStream *js, const char *jid) |
78 { | 77 { |
79 JabberIq *iq; | 78 JabberIq *iq; |
80 xmlnode *ping; | 79 xmlnode *ping; |
81 | 80 |
82 purple_debug_info("jabber", "jabber_ping_jid\n"); | |
83 | |
84 iq = jabber_iq_new(js, JABBER_IQ_GET); | 81 iq = jabber_iq_new(js, JABBER_IQ_GET); |
85 if (jid) | 82 if (jid) |
86 xmlnode_set_attrib(iq->node, "to", jid); | 83 xmlnode_set_attrib(iq->node, "to", jid); |
87 | 84 |
88 ping = xmlnode_new_child(iq->node, "ping"); | 85 ping = xmlnode_new_child(iq->node, "ping"); |