pidgin: 40130e07: jabber: Roster Versioning support.

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat Dec 5 19:55:57 EST 2009


-----------------------------------------------------------------
Revision: 40130e07f40440b64aa3c2e3c05e928b89937780
Ancestor: 6a644d7b82c3a286d122cd2d4beb1aa92125588a
Author: darkrain42 at pidgin.im
Date: 2009-12-06T00:52:10
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/40130e07f40440b64aa3c2e3c05e928b89937780

Modified files:
        ChangeLog libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/jabber.h
        libpurple/protocols/jabber/namespaces.h
        libpurple/protocols/jabber/roster.c

ChangeLog: 

jabber: Roster Versioning support.

-------------- next part --------------
============================================================
--- ChangeLog	540fa01787c4bd127fe59fa904496a8936d86689
+++ ChangeLog	fe4f1c8727b488618342e4708d9fb8a7010a8361
@@ -5,12 +5,13 @@ version 2.6.5 (??/??/20??):
 	* Build-time fixes for Solaris.  (Paul Townsend)
 
 	XMPP:
-	* Added support for the SCRAM-SHA-1 SASL mechanism.  This support is only
+	* Added support for the SCRAM-SHA-1 SASL mechanism.  This is only
 	  available when built without Cyrus SASL support.
 	* When getting info on a domain-only (server) JID, show uptime
 	  (when given by the result of the "last query") and don't show status as
 	  offline.
 	* Do not crash when attempting to register for a new account on Windows.
+	* Added support for Roster Versioning (XEP-0237).
 
 version 2.6.4 (11/29/2009):
 	libpurple:
============================================================
--- libpurple/protocols/jabber/jabber.c	b68799f681041cfe9f7688573ee77523615dd27c
+++ libpurple/protocols/jabber/jabber.c	2c89b601a78832cf5745521b1bf8c6ca09d65bdf
@@ -229,6 +229,8 @@ void jabber_stream_features_parse(Jabber
 		jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL);
 
 		jabber_iq_send(iq);
+	} else if (xmlnode_get_child_with_namespace(packet, "ver", NS_ROSTER_VERSIONING)) {
+		js->server_caps |= JABBER_CAP_ROSTER_VERSIONING;
 	} else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ {
 		/* If we get an empty stream:features packet, or we explicitly get
 		 * an auth feature with namespace http://jabber.org/features/iq-auth
============================================================
--- libpurple/protocols/jabber/jabber.h	c24c5eda55230bd1e490927fa1b89e03950fe714
+++ libpurple/protocols/jabber/jabber.h	75485219b30094f6a1dff07499d5433a539acb90
@@ -47,6 +47,7 @@ typedef enum {
 	JABBER_CAP_BLOCKING       = 1 << 13,
 
 	JABBER_CAP_ITEMS          = 1 << 14,
+	JABBER_CAP_ROSTER_VERSIONING = 1 << 15,
 
 	JABBER_CAP_RETRIEVED      = 1 << 31
 } JabberCapabilities;
============================================================
--- libpurple/protocols/jabber/namespaces.h	5f7ae06cbc1020cf121a48cc1718caeccbddf5f2
+++ libpurple/protocols/jabber/namespaces.h	652c3c497120c07d61c8ee359f0e586f0385b11f
@@ -85,6 +85,9 @@
 /* XEP-0231 BoB (Bits of Binary) */
 #define NS_BOB "urn:xmpp:bob"
 
+/* XEP-0237 Roster Versioning */
+#define NS_ROSTER_VERSIONING "urn:xmpp:features:rosterver"
+
 /* Google extensions */
 #define NS_GOOGLE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1"
 #define NS_GOOGLE_VIDEO "http://www.google.com/xmpp/protocol/video/v1"
============================================================
--- libpurple/protocols/jabber/roster.c	d92234368a5e19b64ed543ee74d5f766653068ab
+++ libpurple/protocols/jabber/roster.c	1cc52c519ce49474687a4ab156d632114b33a971
@@ -47,11 +47,47 @@ static gchar *roster_groups_join(GSList 
 	return g_string_free(out, FALSE);
 }
 
+static void roster_request_cb(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *packet, gpointer data)
+{
+	xmlnode *query;
+
+	if (type == JABBER_IQ_ERROR) {
+		/*
+		 * This shouldn't happen in any real circumstances and
+		 * likely constitutes a server-side misconfiguration (i.e.
+		 * explicitly not loading mod_roster...)
+		 */
+		purple_debug_error("jabber", "Error retrieving roster!?\n");
+		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
+		return;
+	}
+
+	query = xmlnode_get_child(packet, "query");
+	if (query == NULL) {
+		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
+		return;
+	}
+
+	jabber_roster_parse(js, from, type, id, query);
+	jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
+}
+
 void jabber_roster_request(JabberStream *js)
 {
+	PurpleAccount *account;
+	const char *ver;
 	JabberIq *iq;
+	xmlnode *query;
 
+	account = purple_connection_get_account(js->gc);
+	ver = purple_account_get_string(account, "roster_ver", "");
+
 	iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
+	query = xmlnode_get_child(iq->node, "query");
+	xmlnode_set_attrib(query, "ver", ver);
+	jabber_iq_set_callback(iq, roster_request_cb, NULL);
 
 	jabber_iq_send(iq);
 }
@@ -155,6 +191,7 @@ void jabber_roster_parse(JabberStream *j
                          JabberIqType type, const char *id, xmlnode *query)
 {
 	xmlnode *item, *group;
+	const char *ver;
 
 	if (!jabber_is_own_account(js, from)) {
 		purple_debug_warning("jabber", "Received bogon roster push from %s\n",
@@ -227,13 +264,13 @@ void jabber_roster_parse(JabberStream *j
 		}
 	}
 
-	js->currently_parsing_roster_push = FALSE;
+	ver = xmlnode_get_attrib(query, "ver");
+	if (ver) {
+		 PurpleAccount *account = purple_connection_get_account(js->gc);
+		 purple_account_set_string(account, "roster_ver", ver);
+	}
 
-	/* if we're just now parsing the roster for the first time,
-	 * then now would be the time to declare ourselves connected.
-	 */
-	if (js->state != JABBER_STREAM_CONNECTED)
-		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
+	js->currently_parsing_roster_push = FALSE;
 }
 
 /* jabber_roster_update frees the GSList* passed in */


More information about the Commits mailing list