changeset 15294:4bcc40bd4e20

[gaim-migrate @ 18084] If the Jabber server does not support the server discovery info (http://jabber.org/protocol/disco#info) we still need to request the roster and send initial presence. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Mon, 08 Jan 2007 00:08:10 +0000
parents 0e8f0468a809
children e5c75076c6d1
files libgaim/protocols/jabber/disco.c
diffstat 1 files changed, 33 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/jabber/disco.c	Sun Jan 07 20:05:46 2007 +0000
+++ b/libgaim/protocols/jabber/disco.c	Mon Jan 08 00:08:10 2007 +0000
@@ -21,6 +21,7 @@
 
 #include "internal.h"
 #include "prefs.h"
+#include "debug.h"
 
 #include "buddy.h"
 #include "google.h"
@@ -214,27 +215,50 @@
 }
 
 static void
-jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_disco_finish_server_info_result_cb(JabberStream *js)
 {
 	GaimPresence *gpresence;
 	GaimStatus *status;
+
+	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);
+	}
+	
+	/* Send initial presence; this will trigger receipt of presence for contacts on the roster */
+	gpresence = gaim_account_get_presence(js->gc->account);
+	status = gaim_presence_get_active_status(gpresence);
+	jabber_presence_send(js->gc->account, status);	
+}
+
+static void
+jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+{
   	xmlnode *query, *child;
 	const char *from = xmlnode_get_attrib(packet, "from");
 	const char *type = xmlnode_get_attrib(packet, "type");
 
-	if(!from || !type)
+	if(!from || !type) {
 		return;
+	}
 
-	if(strcmp(from, js->user->domain))
+	if(strcmp(from, js->user->domain)) {
 		return;
+	}
 
-	if(strcmp(type, "result"))
+	if(strcmp(type, "result")) {
+		/* A common way to get here is for the server not to support xmlns http://jabber.org/protocol/disco#info */
+		jabber_disco_finish_server_info_result_cb(js);
 		return;
+	}
 
 	query = xmlnode_get_child(packet, "query");
-	
-	if (!query) return;
-	
+
+	if (!query) {
+		jabber_disco_finish_server_info_result_cb(js);
+		return;
+	}
+
 	for (child = xmlnode_get_child(query, "category"); child; 
 	     child = xmlnode_get_next_twin(child)) {
 		const char *category, *type, *name;
@@ -254,7 +278,7 @@
 		if (!strcmp(name, "Google Talk"))
 			js->googletalk = TRUE;
 	}
-	
+
 	for (child = xmlnode_get_child(query, "feature"); child; 
 	     child = xmlnode_get_next_twin(child)) {
 		const char *var;
@@ -271,12 +295,7 @@
 		}
 	}
 
-	if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER))
-		jabber_roster_request(js);
-
-	gpresence = gaim_account_get_presence(js->gc->account);
-	status = gaim_presence_get_active_status(gpresence);
-	jabber_presence_send(js->gc->account, status);	
+	jabber_disco_finish_server_info_result_cb(js);
 }
 
 static void