changeset 24992:d881fc5d907f

Remove PurpleMedias from JabberStream's list when a media session ends.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 04 Jan 2009 12:13:12 +0000
parents b0e6a64cbf2e
children 7d2e06b29f88
files libpurple/protocols/jabber/jingle/rtp.c
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/rtp.c	Sun Jan 04 11:12:47 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Sun Jan 04 12:13:12 2009 +0000
@@ -264,16 +264,12 @@
 }
 
 static void
-jingle_rtp_reject_cb(PurpleMedia *media, JingleSession *session)
-{
-	jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
-	g_object_unref(session);
-}
-
-static void
 jingle_rtp_hangup_cb(PurpleMedia *media, JingleSession *session)
 {
+	gchar *sid = jingle_session_get_sid(session);
 	jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
+	g_hash_table_remove(jingle_session_get_js(session)->medias, sid);
+	g_free(sid);
 	g_object_unref(session);
 }
 
@@ -361,7 +357,7 @@
 
 	/* connect callbacks */
 	g_signal_connect(G_OBJECT(media), "reject",
-				 G_CALLBACK(jingle_rtp_reject_cb), session);
+				 G_CALLBACK(jingle_rtp_hangup_cb), session);
 	g_signal_connect(G_OBJECT(media), "hangup",
 				 G_CALLBACK(jingle_rtp_hangup_cb), session);
 	g_signal_connect(G_OBJECT(media), "new-candidate",
@@ -602,7 +598,16 @@
 		}
 		case JINGLE_SESSION_TERMINATE: {
 			JingleSession *session = jingle_content_get_session(content);
-			purple_media_got_hangup(jingle_rtp_get_media(session));
+			PurpleMedia *media = jingle_rtp_get_media(session);
+
+			if (media != NULL) {
+				gchar *sid = jingle_session_get_sid(session);
+				purple_media_got_hangup(media);
+				g_hash_table_remove(jingle_session_get_js(
+						session)->medias, sid);
+				g_free(sid);
+			}
+
 			g_object_unref(session);
 			break;
 		}