changeset 28395:98d8c11e4937

Gracefully handle failures to create an FsStream. This was caused by Farsight 2's new "tos" property which isn't defaulting to 0 properly on some systems. This won't make calls on systems that are affected by this bug #10017 work, but it won't crash now. Fixes #10016
author maiku@pidgin.im
date Sat, 22 Aug 2009 02:55:18 +0000
parents 74958cad186d
children 0bf7defe41fd f0eaa57f58c3
files libpurple/media.c libpurple/protocols/jabber/google.c
diffstat 2 files changed, 30 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sat Aug 22 02:28:23 2009 +0000
+++ b/libpurple/media.c	Sat Aug 22 02:55:18 2009 +0000
@@ -2730,10 +2730,13 @@
 					num_params, params, &err);
 		}
 
-		if (err) {
-			purple_debug_error("media", "Error creating stream: %s\n",
-					   err->message);
-			g_error_free(err);
+		if (fsstream == NULL) {
+			purple_debug_error("media",
+					"Error creating stream: %s\n",
+					err && err->message ?
+					err->message : "NULL");
+			if (err)
+				g_error_free(err);
 			g_object_unref(participant);
 			g_hash_table_remove(media->priv->participants, who);
 			purple_media_remove_session(media, session);
--- a/libpurple/protocols/jabber/google.c	Sat Aug 22 02:28:23 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Sat Aug 22 02:55:18 2009 +0000
@@ -91,20 +91,6 @@
 }
 
 static void
-google_session_send_terminate(GoogleSession *session)
-{
-	xmlnode *sess;
-	JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
-
-	xmlnode_set_attrib(iq->node, "to", session->remote_jid);
-	sess = google_session_create_xmlnode(session, "terminate");
-	xmlnode_insert_child(iq->node, sess);
-
-	jabber_iq_send(iq);
-	google_session_destroy(session);
-}
-
-static void
 google_session_send_candidates(PurpleMedia *media, gchar *session_id,
 		gchar *participant, GoogleSession *session)
 {
@@ -398,6 +384,16 @@
 
 	purple_media_set_prpl_data(session->media, session);
 
+	g_signal_connect_swapped(G_OBJECT(session->media),
+			"candidates-prepared",
+			G_CALLBACK(google_session_ready), session);
+	g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
+			G_CALLBACK(google_session_ready), session);
+	g_signal_connect(G_OBJECT(session->media), "state-changed",
+			G_CALLBACK(google_session_state_changed_cb), session);
+	g_signal_connect(G_OBJECT(session->media), "stream-info",
+			G_CALLBACK(google_session_stream_info_cb), session);
+
 	params = jabber_google_session_get_params(js, &num_params);
 
 	if (purple_media_add_stream(session->media, "google-voice",
@@ -408,23 +404,11 @@
 			session->remote_jid, PURPLE_MEDIA_VIDEO,
 			TRUE, "nice", num_params, params) == FALSE)) {
 		purple_media_error(session->media, "Error adding stream.");
-		purple_media_stream_info(session->media,
-				PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
-		google_session_destroy(session);
+		purple_media_end(session->media, NULL, NULL);
 		g_free(params);
 		return FALSE;
 	}
 
-	g_signal_connect_swapped(G_OBJECT(session->media),
-			"candidates-prepared",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect(G_OBJECT(session->media), "state-changed",
-			G_CALLBACK(google_session_state_changed_cb), session);
-	g_signal_connect(G_OBJECT(session->media), "stream-info",
-			G_CALLBACK(google_session_stream_info_cb), session);
-
 	g_free(params);
 
 	return (session->media != NULL) ? TRUE : FALSE;
@@ -466,6 +450,16 @@
 
 	purple_media_set_prpl_data(session->media, session);
 
+	g_signal_connect_swapped(G_OBJECT(session->media),
+			"candidates-prepared",
+			G_CALLBACK(google_session_ready), session);
+	g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
+			G_CALLBACK(google_session_ready), session);
+	g_signal_connect(G_OBJECT(session->media), "state-changed",
+			G_CALLBACK(google_session_state_changed_cb), session);
+	g_signal_connect(G_OBJECT(session->media), "stream-info",
+			G_CALLBACK(google_session_stream_info_cb), session);
+
 	params = jabber_google_session_get_params(js, &num_params);
 
 	if (purple_media_add_stream(session->media, "google-voice",
@@ -477,8 +471,7 @@
 			FALSE, "nice", num_params, params) == FALSE)) {
 		purple_media_error(session->media, "Error adding stream.");
 		purple_media_stream_info(session->media,
-				PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
-		google_session_send_terminate(session);
+				PURPLE_MEDIA_INFO_REJECT, NULL, NULL, TRUE);
 		g_free(params);
 		return FALSE;
 	}
@@ -535,18 +528,6 @@
 	purple_media_codec_list_free(codecs);
 	purple_media_codec_list_free(video_codecs);
 
-	g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect_swapped(G_OBJECT(session->media),
-			"candidates-prepared",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect(G_OBJECT(session->media), "state-changed",
-			G_CALLBACK(google_session_state_changed_cb), session);
-	g_signal_connect(G_OBJECT(session->media), "stream-info",
-			G_CALLBACK(google_session_stream_info_cb), session);
-
 	result = jabber_iq_new(js, JABBER_IQ_RESULT);
 	jabber_iq_set_id(result, iq_id);
 	xmlnode_set_attrib(result->node, "to", session->remote_jid);
@@ -778,8 +759,7 @@
 	session->js = js;
 	session->remote_jid = g_strdup(session->id.initiator);
 
-	if (!google_session_handle_initiate(js, session, session_node, iq_id))
-		google_session_destroy(session);
+	google_session_handle_initiate(js, session, session_node, iq_id);
 }
 #endif /* USE_VV */