diff libgaim/protocols/jabber/jabber.c @ 14308:9ad313800b19

[gaim-migrate @ 16998] Make gaim_srv_resolve cancelable. Please test and let me know of any problems. I was unable to test the WIN32 method for this, since it actually uses Windows stuff. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 23 Aug 2006 08:02:05 +0000
parents 8342b39f975b
children 8a2b571f9990
line wrap: on
line diff
--- a/libgaim/protocols/jabber/jabber.c	Wed Aug 23 07:14:19 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.c	Wed Aug 23 08:02:05 2006 +0000
@@ -486,18 +486,10 @@
 
 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data)
 {
-	GaimConnection *gc;
 	JabberStream *js;
 
-	gc = data;
-	if (!GAIM_CONNECTION_IS_VALID(gc))
-	{
-		/* This connection has been closed */
-		g_free(resp);
-		return;
-	}
-
-	js = (JabberStream*)gc->proto_data;
+	js = data;
+	js->srv_query_data = NULL;
 
 	if(results) {
 		jabber_login_connect(js, resp->hostname, resp->port);
@@ -577,7 +569,8 @@
 		if(connect_server[0]) {
 			jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222));
 		} else {
-			gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, gc);
+			js->srv_query_data = gaim_srv_resolve("xmpp-client",
+					"tcp", js->user->domain, srv_resolved_cb, js);
 		}
 	}
 }
@@ -936,6 +929,9 @@
 	if (!gc->disconnect_timeout)
 		jabber_send_raw(js, "</stream:stream>", -1);
 
+	if (js->srv_query_data)
+		gaim_srv_cancel(js->srv_query_data);
+
 	if (js->connect_data)
 		gaim_proxy_connect_cancel(js->connect_data);