changeset 18109:3d7129ac1de9

respond to XEP-0199 queries (XMPP ping)
author Nathan Walp <nwalp@pidgin.im>
date Sat, 16 Jun 2007 03:17:13 +0000
parents c0cd4d84ba52
children 463aba76c5b6 69febfa6d307
files libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/iq.c
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/disco.c	Sat Jun 16 02:21:13 2007 +0000
+++ b/libpurple/protocols/jabber/disco.c	Sat Jun 16 03:17:13 2007 +0000
@@ -96,6 +96,7 @@
 			SUPPORT_FEATURE("http://jabber.org/protocol/si")
 			SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer")
 			SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im")
+			SUPPORT_FEATURE("urn:xmpp:ping")
 		} else {
 			xmlnode *error, *inf;
 
--- a/libpurple/protocols/jabber/iq.c	Sat Jun 16 02:21:13 2007 +0000
+++ b/libpurple/protocols/jabber/iq.c	Sat Jun 16 03:17:13 2007 +0000
@@ -201,6 +201,25 @@
 		xmlnode_insert_data(xmlnode_new_child(query, "display"), date, -1);
 
 		jabber_iq_send(iq);
+	} else {
+		/* XXX: error */
+	}
+}
+
+static void urn_xmpp_ping_parse(JabberStream *js, xmlnode *packet)
+{
+	const char *type, *from, *id;
+	JabberIq *iq;
+	xmlnode *query;
+
+	if(type && !strcmp(type, "get")) {
+		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "urn:xmpp:ping");
+
+		jabber_iq_set_id(iq, id);
+
+		jabber_iq_send(iq);
+	} else {
+		/* XXX: error */
 	}
 }
 
@@ -328,6 +347,7 @@
 	jabber_iq_register_handler("http://jabber.org/protocol/disco#info", jabber_disco_info_parse);
 	jabber_iq_register_handler("http://jabber.org/protocol/disco#items", jabber_disco_items_parse);
 	jabber_iq_register_handler("jabber:iq:register", jabber_register_parse);
+	jabber_iq_register_handler("urn:xmpp:ping", urn_xmpp_ping_parse);
 }
 
 void jabber_iq_uninit(void)