diff libgaim/protocols/simple/simple.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 645598a4ec04
children 8ed6ef220b2d
line wrap: on
line diff
--- a/libgaim/protocols/simple/simple.c	Wed Aug 23 07:14:19 2006 +0000
+++ b/libgaim/protocols/simple/simple.c	Wed Aug 23 08:02:05 2006 +0000
@@ -1584,20 +1584,13 @@
 }
 
 static void srvresolved(GaimSrvResponse *resp, int results, gpointer data) {
-	GaimConnection *gc;
 	struct simple_account_data *sip;
 	gchar *hostname;
 	int port;
 
-	gc = data;
-	if (!GAIM_CONNECTION_IS_VALID(gc))
-	{
-		/* This connection has been closed */
-		g_free(resp);
-		return;
-	}
+	sip = data;
+	sip->srv_query_data = NULL;
 
-	sip = gc->proto_data;
 	port = gaim_account_get_int(sip->account, "port", 0);
 
 	/* find the host to connect to */
@@ -1682,12 +1675,8 @@
 		hosttoconnect = g_strdup(gaim_account_get_string(account, "proxy", sip->servername));
 	}
 
-	/* TCP case */
-	if(!sip->udp) {
-		gaim_srv_resolve("sip", "tcp", hosttoconnect, srvresolved, gc);
-	} else { /* UDP */
-		gaim_srv_resolve("sip", "udp", hosttoconnect, srvresolved, gc);
-	}
+	sip->srv_query_data = gaim_srv_resolve("sip",
+			sip->udp ? "udp" : "tcp", hosttoconnect, srvresolved, sip);
 	g_free(hosttoconnect);
 }
 
@@ -1703,6 +1692,9 @@
 		if (sip->query_data != NULL)
 			gaim_dnsquery_destroy(sip->query_data);
 
+		if (sip->srv_query_data != NULL)
+			gaim_srv_cancel(sip->srv_query_data);
+
 		if (sip->listen_data != NULL)
 			gaim_network_listen_cancel(sip->listen_data);