comparison libpurple/protocols/jabber/ping.c @ 25639:b5052c66701c

Jabber IQ handlers should handle non-query child nodes Historically, all IQ stanzas had a query child; this is no longer the case (XMPP Ping, Entity Time, etc). Instead, have the handlers use the first child of the IQ stanza. Also reduce some of the duplication in XMPP ping code (just use the one in ping.c)
author Paul Aurich <paul@darkrain42.org>
date Tue, 03 Feb 2009 17:10:05 +0000
parents 413103ddeaac
children 42dd7e591031
comparison
equal deleted inserted replaced
25638:a73791d35fcc 25639:b5052c66701c
30 #include "iq.h" 30 #include "iq.h"
31 31
32 void 32 void
33 jabber_ping_parse(JabberStream *js, xmlnode *packet) 33 jabber_ping_parse(JabberStream *js, xmlnode *packet)
34 { 34 {
35 JabberIq *iq; 35 const char *type, *id, *from;
36 36
37 type = xmlnode_get_attrib(packet, "type");
38 from = xmlnode_get_attrib(packet, "from");
39 id = xmlnode_get_attrib(packet, "id");
40
41 if (!type) {
42 purple_debug_warning("jabber", "jabber_ping with no type\n");
43 return;
44 }
45
37 purple_debug_info("jabber", "jabber_ping_parse\n"); 46 purple_debug_info("jabber", "jabber_ping_parse\n");
38 47
39 iq = jabber_iq_new(js, JABBER_IQ_RESULT); 48 if (!strcmp(type, "get")) {
49 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT);
40 50
41 xmlnode_set_attrib(iq->node, "to", xmlnode_get_attrib(packet, "from") ); 51 xmlnode_set_attrib(iq->node, "to", from);
52 xmlnode_set_attrib(iq->node, "id", id);
42 53
43 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); 54 jabber_iq_send(iq);
44 55 } else if (!strcmp(type, "set")) {
45 jabber_iq_send(iq); 56 /* XXX: error */
57 }
46 } 58 }
47 59
48 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, 60 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet,
49 gpointer data) 61 gpointer data)
50 { 62 {