diff libpurple/protocols/jabber/jabber.c @ 30941:2702ca44d963

propagate from branch 'im.pidgin.pidgin' (head 8c322571bfb4f2d00c9126e59746445f877be296) to branch 'im.pidgin.cpw.malu.xmpp.google_relay' (head b2d2119891f9d6708b7b60c858a25b7944558f84)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 03 Nov 2009 18:26:29 +0000
parents c3be1de8abde 093c79fa01c7
children 0712ce23901e
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Tue Nov 03 07:46:01 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Tue Nov 03 18:26:29 2009 +0000
@@ -844,6 +844,9 @@
 	js->stun_ip = NULL;
 	js->stun_port = 0;
 	js->stun_query = NULL;
+	js->google_relay_token = NULL;
+	js->google_relay_host = NULL;
+	js->google_relay_requests = NULL;
 
 	/* if we are idle, set idle-ness on the stream (this could happen if we get
 		disconnected and the reconnects while being idle. I don't think it makes
@@ -1545,6 +1548,21 @@
 		js->stun_query = NULL;
 	}
 
+	/* remove Google relay-related stuff */
+	g_free(js->google_relay_token);
+	g_free(js->google_relay_host);
+	if (js->google_relay_requests) {
+		while (js->google_relay_requests) {
+			PurpleUtilFetchUrlData *url_data =
+				(PurpleUtilFetchUrlData *) js->google_relay_requests->data;
+			purple_util_fetch_url_cancel(url_data);
+			g_free(url_data);
+			js->google_relay_requests = 
+				g_list_delete_link(js->google_relay_requests, 
+					js->google_relay_requests);
+		}
+	}
+
 	g_free(js);
 
 	gc->proto_data = NULL;
@@ -3005,10 +3023,11 @@
 		jbr = jabber_buddy_find_resource(jb, resource);
 		g_free(resource);
 
-		if (type & PURPLE_MEDIA_AUDIO &&
-				!jabber_resource_has_capability(jbr,
-				JINGLE_APP_RTP_SUPPORT_AUDIO) &&
-				jabber_resource_has_capability(jbr,
+		/* if we are on a Google Talk connection and the remote supports
+		 Google Jingle, we will go with that */
+		if ((js->googletalk || 
+		     !jabber_resource_has_capability(jbr, JINGLE_APP_RTP_SUPPORT_AUDIO))
+		    && type & PURPLE_MEDIA_AUDIO && jabber_resource_has_capability(jbr,
 				GOOGLE_VOICE_CAP))
 			return jabber_google_session_initiate(js, who, type);
 		else