Mercurial > pidgin
comparison libpurple/protocols/jabber/ping.c @ 25648:050052891c55
Pass IQ handlers type, from, id, and the child node
As QuLogic pointed out in 8a80f271, it's pointless for the handlers to re-get
the information from the IQ stanza. Additionally, instead of string-matching
the type everywhere, pass around a JabberIqType.
Last, 'child' cannot be NULL, but 'from' may be.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 08 Feb 2009 06:31:18 +0000 |
parents | ced3d4ab745a |
children | c8606917787a |
comparison
equal
deleted
inserted
replaced
25647:969c89c09ad7 | 25648:050052891c55 |
---|---|
33 purple_timeout_remove(js->keepalive_timeout); | 33 purple_timeout_remove(js->keepalive_timeout); |
34 js->keepalive_timeout = -1; | 34 js->keepalive_timeout = -1; |
35 } | 35 } |
36 | 36 |
37 void | 37 void |
38 jabber_ping_parse(JabberStream *js, xmlnode *packet) | 38 jabber_ping_parse(JabberStream *js, const char *from, |
39 JabberIqType type, const char *id, xmlnode *ping) | |
39 { | 40 { |
40 const char *type, *id, *from; | |
41 | |
42 type = xmlnode_get_attrib(packet, "type"); | |
43 from = xmlnode_get_attrib(packet, "from"); | |
44 id = xmlnode_get_attrib(packet, "id"); | |
45 | |
46 if (!type) { | |
47 purple_debug_warning("jabber", "jabber_ping with no type\n"); | |
48 return; | |
49 } | |
50 | |
51 purple_debug_info("jabber", "jabber_ping_parse\n"); | 41 purple_debug_info("jabber", "jabber_ping_parse\n"); |
52 | 42 |
53 if (!strcmp(type, "get")) { | 43 if (type == JABBER_IQ_GET) { |
54 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT); | 44 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
55 | 45 |
56 xmlnode_set_attrib(iq->node, "to", from); | 46 xmlnode_set_attrib(iq->node, "to", from); |
57 xmlnode_set_attrib(iq->node, "id", id); | 47 xmlnode_set_attrib(iq->node, "id", id); |
58 | 48 |
59 jabber_iq_send(iq); | 49 jabber_iq_send(iq); |
60 } else if (!strcmp(type, "set")) { | 50 } else if (type == JABBER_IQ_SET) { |
61 /* XXX: error */ | 51 /* XXX: error */ |
62 } | 52 } |
63 } | 53 } |
64 | 54 |
65 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, | 55 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, |