pidgin: d158db08: jabber: The google roster request code w...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Dec 6 17:46:01 EST 2009


-----------------------------------------------------------------
Revision: d158db08540b0a2514b515d40ec33d941dd41dc4
Ancestor: f645adcdf3bac174129b9be57256238cb53c4312
Author: darkrain42 at pidgin.im
Date: 2009-12-06T22:44:20
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d158db08540b0a2514b515d40ec33d941dd41dc4

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

ChangeLog: 

jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/disco.c	12f8057571663f481d70ed663f277cdf8b2893b3
+++ libpurple/protocols/jabber/disco.c	a6bd8650006e651c876566a6f9a6d7aed4a4bc3f
@@ -370,10 +370,8 @@ jabber_disco_finish_server_info_result_c
 	if (js->pep)
 		jabber_avatar_fetch_mine(js);
 
-	if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) {
-		/* If the server supports JABBER_CAP_GOOGLE_ROSTER; we will have already requested it */
-		jabber_roster_request(js);
-	}
+	/* Yes, please! */
+	jabber_roster_request(js);
 
 	if (js->server_caps & JABBER_CAP_ADHOC) {
 		/* The server supports ad-hoc commands, so let's request the list */
@@ -555,9 +553,8 @@ jabber_disco_server_info_result_cb(Jabbe
 		if (!strcmp(NS_GOOGLE_MAIL_NOTIFY, var)) {
 			js->server_caps |= JABBER_CAP_GMAIL_NOTIFY;
 			jabber_gmail_init(js);
-		} else if (!strcmp("google:roster", var)) {
+		} else if (!strcmp(NS_GOOGLE_ROSTER, var)) {
 			js->server_caps |= JABBER_CAP_GOOGLE_ROSTER;
-			jabber_google_roster_init(js);
 		} else if (!strcmp("http://jabber.org/protocol/commands", var)) {
 			js->server_caps |= JABBER_CAP_ADHOC;
 		} else if (!strcmp(NS_SIMPLE_BLOCKING, var)) {
============================================================
--- libpurple/protocols/jabber/google.c	10422c32c921719c3e97be6fab05ac124662993e
+++ libpurple/protocols/jabber/google.c	d8e5d4bcd36352e3becbb456d302f7e4f25ce7ce
@@ -950,33 +950,6 @@ void jabber_gmail_init(JabberStream *js)
 	jabber_iq_send(iq);
 }
 
-static void
-roster_init_cb(JabberStream *js, const char *from, JabberIqType type,
-               const char *id, xmlnode *packet, gpointer data)
-{
-	xmlnode *query = xmlnode_get_child(packet, "query");
-
-	if (type == JABBER_IQ_RESULT && query)
-		jabber_roster_parse(js, from, type, id, query);
-
-	jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
-}
-
-void jabber_google_roster_init(JabberStream *js)
-{
-	JabberIq *iq;
-	xmlnode *query;
-
-	iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
-	query = xmlnode_get_child(iq->node, "query");
-
-	xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
-	xmlnode_set_attrib(query, "gr:ext", "2");
-
-	jabber_iq_set_callback(iq, roster_init_cb, NULL);
-	jabber_iq_send(iq);
-}
-
 void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item)
 {
 	PurpleAccount *account = purple_connection_get_account(js->gc);
@@ -986,7 +959,7 @@ void jabber_google_roster_outgoing(Jabbe
 
 	while (list) {
 		if (!strcmp(jid_norm, (char*)list->data)) {
-			xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
+			xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
 			xmlnode_set_attrib(query, "gr:ext", "2");
 			xmlnode_set_attrib(item, "gr:t", "B");
 			return;
@@ -1003,7 +976,7 @@ gboolean jabber_google_roster_incoming(J
 
 	char *jid_norm;
 
-	const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster");
+	const char *grt = xmlnode_get_attrib_with_namespace(item, "t", NS_GOOGLE_ROSTER);
 	const char *subscription = xmlnode_get_attrib(item, "subscription");
 	const char *ask = xmlnode_get_attrib(item, "ask");
 
@@ -1088,7 +1061,7 @@ void jabber_google_roster_add_deny(Jabbe
 	xmlnode_set_attrib(item, "jid", who);
 	xmlnode_set_attrib(item, "name", balias ? balias : "");
 	xmlnode_set_attrib(item, "gr:t", "B");
-	xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
+	xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
 	xmlnode_set_attrib(query, "gr:ext", "2");
 
 	jabber_iq_send(iq);
@@ -1147,7 +1120,7 @@ void jabber_google_roster_rem_deny(Jabbe
 	balias = purple_buddy_get_local_buddy_alias(b);
 	xmlnode_set_attrib(item, "jid", who);
 	xmlnode_set_attrib(item, "name", balias ? balias : "");
-	xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
+	xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
 	xmlnode_set_attrib(query, "gr:ext", "2");
 
 	jabber_iq_send(iq);
============================================================
--- libpurple/protocols/jabber/google.h	43aa22fc05a7a6333b84674eb8cbb4c8a639fe01
+++ libpurple/protocols/jabber/google.h	64feaa50857685e9df9d4639d0d9c81d487314a2
@@ -32,7 +32,6 @@ void jabber_gmail_poke(JabberStream *js,
 void jabber_gmail_poke(JabberStream *js, const char *from, JabberIqType type,
                        const char *id, xmlnode *new_mail);
 
-void jabber_google_roster_init(JabberStream *js);
 void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item);
 
 /* Returns FALSE if this should short-circuit processing of this roster item, or TRUE
============================================================
--- libpurple/protocols/jabber/namespaces.h	652c3c497120c07d61c8ee359f0e586f0385b11f
+++ libpurple/protocols/jabber/namespaces.h	c0b1b20e6c5d24f6d5c088d01ebfcfdd1702baf8
@@ -95,6 +95,7 @@
 #define NS_GOOGLE_JINGLE_INFO "google:jingleinfo"
 
 #define NS_GOOGLE_MAIL_NOTIFY "google:mail:notify"
+#define NS_GOOGLE_ROSTER "google:roster"
 
 #define NS_GOOGLE_PROTOCOL_SESSION "http://www.google.com/xmpp/protocol/session"
 #define NS_GOOGLE_SESSION "http://www.google.com/session"
============================================================
--- libpurple/protocols/jabber/roster.c	1cc52c519ce49474687a4ab156d632114b33a971
+++ libpurple/protocols/jabber/roster.c	153d1d579b17c98eeb1d0cd271b441ec2f957c90
@@ -87,8 +87,13 @@ void jabber_roster_request(JabberStream 
 	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);
 
+	if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) {
+		xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
+		xmlnode_set_attrib(query, "gr:ext", "2");
+	}
+
+	jabber_iq_set_callback(iq, roster_request_cb, NULL);
 	jabber_iq_send(iq);
 }
 
@@ -334,7 +339,7 @@ static void jabber_roster_update(JabberS
 
 	if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) {
 		jabber_google_roster_outgoing(js, query, item);
-		xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
+		xmlnode_set_attrib(query, "xmlns:gr", NS_GOOGLE_ROSTER);
 		xmlnode_set_attrib(query, "gr:ext", "2");
 	}
 	jabber_iq_send(iq);


More information about the Commits mailing list