soc.2008.vv: fd666962: Added better Farsight error handling.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Fri Jun 27 17:46:00 EDT 2008


-----------------------------------------------------------------
Revision: fd666962798759171d03709dc70a6bf3ecb52698
Ancestor: bd12501d3f5ff702be04d6aef2cc8e6fd255a8b2
Author: maiku at soc.pidgin.im
Date: 2008-06-27T21:39:56
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/fd666962798759171d03709dc70a6bf3ecb52698

Modified files:
        libpurple/media.c libpurple/media.h
        libpurple/protocols/jabber/jingle.c pidgin/gtkconv.c

ChangeLog: 

Added better Farsight error handling.

-------------- next part --------------
============================================================
--- libpurple/media.c	c2440167ccce5225d0d2f782b77b334cce0a5f8e
+++ libpurple/media.c	e74e7ebde3ec70bc1f403d01c3e62d2f3f76cb15
@@ -379,16 +379,31 @@ purple_media_add_session(PurpleMedia *me
 	g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session);
 }
 
+static gboolean
+purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session)
+{
+	return g_hash_table_remove(media->priv->sessions, session->id);
+}
+
 static FsParticipant *
 purple_media_add_participant(PurpleMedia *media, const gchar *name)
 {
 	FsParticipant *participant = purple_media_get_participant(media, name);
+	GError *err = NULL;
 
 	if (participant)
 		return participant;
 
-	participant = fs_conference_new_participant(media->priv->conference, g_strdup(name), NULL);
+	participant = fs_conference_new_participant(media->priv->conference,
+						    g_strdup(name), &err);
 
+	if (err) {
+		purple_debug_error("media", "Error creating participant: %s\n",
+				   err->message);
+		g_error_free(err);
+		return NULL;
+	}
+
 	if (!media->priv->participants) {
 		purple_debug_info("media", "Creating hash table for participants\n");
 		media->priv->participants = g_hash_table_new(g_str_hash, g_str_equal);
@@ -988,13 +1003,31 @@ purple_media_add_stream_internal(PurpleM
 		purple_media_add_session(media, session);
 	}
 
-	participant = purple_media_add_participant(media, who);
+	if (!(participant = purple_media_add_participant(media, who))) {
+		purple_media_remove_session(media, session);
+		g_free(session);
+		return FALSE;
+	}
 
 	stream = purple_media_session_get_stream(session, who);
 
 	if (!stream) {
+		GError *err = NULL;
+
 		stream = fs_session_new_stream(session->session, participant, 
-					       type_direction, transmitter, 0, NULL, NULL);
+					       type_direction, transmitter, 0,
+					       NULL, &err);
+
+		if (err) {
+			purple_debug_error("media", "Error creating stream: %s\n",
+					   err->message);
+			g_error_free(err);
+			g_object_unref(participant);
+			purple_media_remove_session(media, session);
+			g_free(session);
+			return FALSE;
+		}
+
 		purple_media_insert_stream(session, who, stream);
 		/* callback for new local candidate (new local candidate retreived) */
 		g_signal_connect(G_OBJECT(stream),
@@ -1091,8 +1124,16 @@ purple_media_add_remote_candidates(Purpl
 	PurpleMediaSession *session = purple_media_get_session(media, sess_id);
 	FsStream *stream = purple_media_session_get_stream(session, name);
 	GList *candidates = remote_candidates;
-	for (; candidates; candidates = candidates->next)
-		fs_stream_add_remote_candidate(stream, candidates->data, NULL);
+	for (; candidates; candidates = candidates->next) {
+		GError *err = NULL;
+		fs_stream_add_remote_candidate(stream, candidates->data, &err);
+
+		if (err) {
+			purple_debug_error("media", "Error adding remote candidate: %s\n",
+					   err->message);
+			g_error_free(err);
+		}
+	}
 }
 
 FsCandidate *
@@ -1109,12 +1150,22 @@ purple_media_get_remote_candidate(Purple
 	return session->remote_candidate;
 }
 
-void
+gboolean
 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, const gchar *name, GList *codecs)
 {
 	PurpleMediaSession *session = purple_media_get_session(media, sess_id);
 	FsStream *stream = purple_media_session_get_stream(session, name);
-	fs_stream_set_remote_codecs(stream, codecs, NULL);
+	GError *err = NULL;
+
+	fs_stream_set_remote_codecs(stream, codecs, &err);
+
+	if (err) {
+		purple_debug_error("media", "Error setting remote codecs: %s\n",
+				   err->message);
+		g_error_free(err);
+		return FALSE;
+	}
+	return TRUE;
 }
 
 gboolean
============================================================
--- libpurple/media.h	87fdbabf95c2d826f6f3966a23a8e71a704de998
+++ libpurple/media.h	a67d3d4e8d7930f42022f3275ebdc270b25694ef
@@ -134,7 +134,8 @@ FsCandidate *purple_media_get_remote_can
 GList *purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, const gchar *name);
 FsCandidate *purple_media_get_local_candidate(PurpleMedia *media, const gchar *sess_id, const gchar *name);
 FsCandidate *purple_media_get_remote_candidate(PurpleMedia *media, const gchar *sess_id, const gchar *name);
-void purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, const gchar *name, GList *codecs);
+gboolean purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id,
+					const gchar *name, GList *codecs);
 
 gboolean purple_media_candidates_prepared(PurpleMedia *media, const gchar *name);
 
============================================================
--- libpurple/protocols/jabber/jingle.c	1c72fb1782aacb1ee127774ab6d4765598148945
+++ libpurple/protocols/jabber/jingle.c	6c9041596ef3ea79815e9d33a0edab736666e872
@@ -253,8 +253,10 @@ jabber_jingle_session_destroy(JingleSess
 	GList *contents = g_hash_table_get_values(sess->contents);
 	g_hash_table_remove(sess->js->sessions, sess->id);
 	g_free(sess->id);
-	g_object_unref(sess->media);
 
+	if (sess->media)
+		g_object_unref(sess->media);
+
 	for (; contents; contents = contents->next)
 		jabber_jingle_session_destroy_content(contents->data);
 
@@ -1187,10 +1189,13 @@ jabber_jingle_session_handle_session_acc
 
 		purple_debug_info("jingle", "Setting remote codecs on stream\n");
 
-		purple_media_set_remote_codecs(session->media,
-					       xmlnode_get_attrib(content, "name"),
-					       jabber_jingle_session_get_remote_jid(session),
-					       remote_codecs);
+		if (!purple_media_set_remote_codecs(session->media,
+						    xmlnode_get_attrib(content, "name"),
+						    jabber_jingle_session_get_remote_jid(session),
+						    remote_codecs)) {
+			purple_media_reject(jabber_jingle_session_get_media(session));
+			return;
+		}
 
 		codec_intersection = purple_media_get_negotiated_codecs(session->media,
 									xmlnode_get_attrib(content, "name"));
============================================================
--- pidgin/gtkconv.c	fed2952775fd089743ef6608de76eaea6b80177b
+++ pidgin/gtkconv.c	ca8c89c834c116037a46d41bfb6d922cb4e1d5df
@@ -7707,7 +7707,8 @@ menu_initiate_video_call_cb(gpointer dat
 				    purple_conversation_get_name(conv),
 				    PURPLE_MEDIA_VIDEO);
 
-	purple_media_wait(media);
+	if (media)
+		purple_media_wait(media);
 }
 
 static void
@@ -7722,7 +7723,8 @@ menu_initiate_audio_video_call_cb(gpoint
 				    purple_conversation_get_name(conv),
 				    PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
 
-	purple_media_wait(media);
+	if (media)
+		purple_media_wait(media);
 }
 
 static void


More information about the Commits mailing list