pidgin.vv: c1a9adfd: Stop sending multiple session-initiate p...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Fri Mar 20 04:35:58 EDT 2009


-----------------------------------------------------------------
Revision: c1a9adfd9a11efca29e7df4474c89d26bb1322c9
Ancestor: 51b5200c40771d0312386d5521a875dedbbe14a5
Author: maiku at soc.pidgin.im
Date: 2009-03-20T06:18:03
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/c1a9adfd9a11efca29e7df4474c89d26bb1322c9

Modified files:
        libpurple/protocols/jabber/jingle/rtp.c

ChangeLog: 

Stop sending multiple session-initiate packets.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	9516406594b252b294321ffee8f9d2382bd84d5d
+++ libpurple/protocols/jabber/jingle/rtp.c	ee185429e9e93592cda6aea76bf71655529cda27
@@ -335,15 +335,14 @@ jingle_rtp_transport_to_candidates(Jingl
 	}
 }
 
-static void jingle_rtp_send_initiate(JingleSession *session);
-static void jingle_rtp_send_accept(JingleSession *session);
+static void jingle_rtp_ready(JingleSession *session);
 
 static void
 jingle_rtp_accepted_cb(PurpleMedia *media, gchar *sid, gchar *name,
 		JingleSession *session)
 {
 	purple_debug_info("jingle-rtp", "jingle_rtp_accepted_cb\n");
-	jingle_rtp_send_accept(session);
+	jingle_rtp_ready(session);
 }
 
 static void
@@ -377,8 +376,7 @@ jingle_rtp_candidates_prepared_cb(Purple
 	jingle_content_set_pending_transport(content, transport);
 	jingle_content_accept_transport(content);
 
-	jingle_rtp_send_initiate(session);
-	jingle_rtp_send_accept(session);
+	jingle_rtp_ready(session);
 }
 
 static void
@@ -387,8 +385,7 @@ jingle_rtp_codecs_changed_cb(PurpleMedia
 {
 	purple_debug_info("jingle-rtp", "jingle_rtp_codecs_changed_cb: "
 			"session_id: %s jingle_session: %p\n", sid, session);
-	jingle_rtp_send_initiate(session);
-	jingle_rtp_send_accept(session);
+	jingle_rtp_ready(session);
 }
 
 static void
@@ -453,35 +450,33 @@ static void
 }
 
 static void
-jingle_rtp_send_initiate(JingleSession *session)
+jingle_rtp_ready(JingleSession *session)
 {
 	PurpleMedia *media = jingle_rtp_get_media(session);
 
-	if (jingle_session_is_initiator(session) == TRUE &&
+	if (purple_media_candidates_prepared(media, NULL, NULL) &&
 			purple_media_codecs_ready(media, NULL) &&
-			purple_media_candidates_prepared(media, NULL, NULL)) {
-		JabberIq *iq = jingle_session_to_packet(
-				session, JINGLE_SESSION_INITIATE);
-		jabber_iq_set_callback(iq,
-				jingle_rtp_initiate_ack_cb, session);
-		jabber_iq_send(iq);
-		g_signal_connect(G_OBJECT(media), "new-candidate",
-				G_CALLBACK(jingle_rtp_new_candidate_cb),
-				session);
-	}
-}
+			(jingle_session_is_initiator(session) == TRUE ||
+			purple_media_accepted(media, NULL, NULL))) {
+		if (jingle_session_is_initiator(session)) {
+			JabberIq *iq = jingle_session_to_packet(
+					session, JINGLE_SESSION_INITIATE);
+			jabber_iq_set_callback(iq,
+					jingle_rtp_initiate_ack_cb, session);
+			jabber_iq_send(iq);
+		} else {
+			jabber_iq_send(jingle_session_to_packet(session,
+					JINGLE_SESSION_ACCEPT));
+		}
 
-static void
-jingle_rtp_send_accept(JingleSession *session)
-{
-	PurpleMedia *media = jingle_rtp_get_media(session);
-
-	if (jingle_session_is_initiator(session) == FALSE &&
-			purple_media_codecs_ready(media, NULL) &&
-			purple_media_accepted(media, NULL, NULL) &&
-			purple_media_candidates_prepared(media, NULL, NULL)) {
-		jabber_iq_send(jingle_session_to_packet(session,
-				JINGLE_SESSION_ACCEPT));
+		g_signal_handlers_disconnect_by_func(G_OBJECT(media),
+				G_CALLBACK(jingle_rtp_accepted_cb), session);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(media),
+				G_CALLBACK(jingle_rtp_candidates_prepared_cb),
+				session);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(media),
+				G_CALLBACK(jingle_rtp_codecs_changed_cb),
+				session);
 		g_signal_connect(G_OBJECT(media), "new-candidate",
 				G_CALLBACK(jingle_rtp_new_candidate_cb),
 				session);
@@ -508,8 +503,9 @@ jingle_rtp_create_media(JingleContent *c
 	purple_media_set_prpl_data(media, session);
 
 	/* connect callbacks */
-	g_signal_connect(G_OBJECT(media), "accepted",
-				 G_CALLBACK(jingle_rtp_accepted_cb), session);
+	if (jingle_session_is_initiator(session) == FALSE)
+		g_signal_connect(G_OBJECT(media), "accepted",
+				G_CALLBACK(jingle_rtp_accepted_cb), session);
 	g_signal_connect(G_OBJECT(media), "candidates-prepared",
 				 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
 	g_signal_connect(G_OBJECT(media), "codecs-changed",


More information about the Commits mailing list