pidgin.vv.yahoo.voice: ee6e5142: Handle ending media sessions from both s...

maiku at pidgin.im maiku at pidgin.im
Sat Aug 29 07:55:44 EDT 2009


-----------------------------------------------------------------
Revision: ee6e5142fd1d490fe5280d337a0d770b68d591d1
Ancestor: afa748458318b61b31b603424cd55699245c92f0
Author: maiku at pidgin.im
Date: 2009-08-29T08:08:16
Branch: im.pidgin.pidgin.vv.yahoo.voice
URL: http://d.pidgin.im/viewmtn/revision/info/ee6e5142fd1d490fe5280d337a0d770b68d591d1

Modified files:
        libpurple/protocols/yahoo/yahoo_sip.c

ChangeLog: 

Handle ending media sessions from both sides.

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo_sip.c	4006c0681e970444a80985f2e9283979fbbc83fd
+++ libpurple/protocols/yahoo/yahoo_sip.c	c1540db6c6c66bcf385cd1093f811eac76f755f3
@@ -199,7 +199,8 @@ yahoo_sip_state_changed_cb(PurpleMedia *
 yahoo_sip_state_changed_cb(PurpleMedia *media, PurpleMediaState state,
 		gchar *sid, gchar *name, nua_handle_t *nh)
 {
-	
+	if (state == PURPLE_MEDIA_STATE_END)
+		nua_handle_bind(nh, NULL);
 }
 
 static void
@@ -210,6 +211,12 @@ yahoo_sip_stream_info_cb(PurpleMedia *me
 	if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE &&
 			sid == NULL && name == NULL) {
 		yahoo_sip_ready(media, nh);
+	} else if ((type == PURPLE_MEDIA_INFO_HANGUP) &&
+			sid == NULL && name == NULL) {
+		nua_bye(nh, TAG_END());
+	} else if ((type == PURPLE_MEDIA_INFO_REJECT) &&
+			sid == NULL && name == NULL) {
+		nua_respond(nh, 603, "Decline", TAG_END());
 	}
 }
 
@@ -312,6 +319,7 @@ event_callback(nua_event_t event, int st
 		}
 
 		purple_media_set_prpl_data(media, nh);
+		nua_handle_bind(nh, media);
 
 		/* connect callbacks */
 		g_signal_connect(G_OBJECT(media), "candidates-prepared",
@@ -334,15 +342,13 @@ event_callback(nua_event_t event, int st
 		 * This has a phrase of "Trying" if not,
 		 * I need to add the check back.
 		 */
-		PurpleAccount *account = magic;
 		const sdp_session_t *sdp_session = NULL;
 		const sip_to_t *remote = nua_handle_remote(nh);
 		sdp_media_t *sdp_media;
 		sdp_rtpmap_t *codec_iter;
 		sdp_attribute_t *conn_iter;
 		GList *codecs = NULL, *candidates = NULL;
-		PurpleMedia *media = NULL;
-		GList *iter;
+		PurpleMedia *media = hmagic;
 
 		tl_gets(tags, SOATAG_REMOTE_SDP_REF(sdp_session), TAG_END());
 		if (!sdp_session) {
@@ -354,24 +360,7 @@ event_callback(nua_event_t event, int st
 		codec_iter = sdp_media->m_rtpmaps;
 		conn_iter = sdp_media->m_attributes;
 
-		/*
-		 * Find PurpleMedia associated with this handle.
-		 * Need to use a structure to hold this information.
-		 * Then this won't be necessary.
-		 */
-		iter = purple_media_manager_get_media_by_account(
-				purple_media_manager_get(), account);
-		for (; iter; iter = g_list_delete_link(iter, iter)) {
-			nua_handle_t *nh_media =
-					purple_media_get_prpl_data(iter->data);
-			if (nh_media == nh) {
-				media = iter->data;
-				break;
-			}
-		}
-		g_list_free(iter);
-
-		if (!media) {
+		if (!PURPLE_IS_MEDIA(media)) {
 			purple_debug_error("yahoo", "Couldn't find media "
 					"session associated with this SIP call.\n");
 			return;
@@ -424,6 +413,15 @@ event_callback(nua_event_t event, int st
 		purple_media_add_remote_candidates(media, "yahoo-voice",
 				remote->a_display, candidates);		
 		purple_media_codec_list_free(candidates);
+	} else if ((event == nua_i_bye || event == nua_i_cancel)
+			&& status >= 200) {
+		PurpleMedia *media = hmagic;
+		if (!PURPLE_IS_MEDIA(media)) {
+			purple_debug_warning("yahoo", "Got %s couldn't find "
+					"media session associated with it.\n", phrase);
+			return;
+		}
+		purple_media_end(media, NULL, NULL);
 	}
 }
 


More information about the Commits mailing list