changeset 26314:2ad89aff8d68

Remove ready-new from use.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 20 Mar 2009 01:48:28 +0000
parents 96ffb196d18d
children c0499eb4dd4d bd9fa96c47dc
files libpurple/media.c libpurple/media.h libpurple/protocols/jabber/google.c
diffstat 3 files changed, 46 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Fri Mar 20 00:24:06 2009 +0000
+++ b/libpurple/media.c	Fri Mar 20 01:48:28 2009 +0000
@@ -501,7 +501,7 @@
 	return candidate;
 }
 
-static PurpleMediaCandidate *
+PurpleMediaCandidate *
 purple_media_candidate_copy(PurpleMediaCandidate *candidate)
 {
 	PurpleMediaCandidate *new_candidate;
@@ -756,7 +756,7 @@
 	return codec;
 }
 
-static PurpleMediaCodec *
+PurpleMediaCodec *
 purple_media_codec_copy(PurpleMediaCodec *codec)
 {
 	PurpleMediaCodec *new_codec;
--- a/libpurple/media.h	Fri Mar 20 00:24:06 2009 +0000
+++ b/libpurple/media.h	Fri Mar 20 01:48:28 2009 +0000
@@ -207,6 +207,16 @@
 		const gchar *ip, guint port);
 
 /**
+ * Copies a PurpleMediaCandidate instance.
+ *
+ * @param candidate The candidate to copy
+ *
+ * @return The newly created PurpleMediaCandidate copy.
+ */
+PurpleMediaCandidate *purple_media_candidate_copy(
+		PurpleMediaCandidate *candidate);
+
+/**
  * Copies a GList of PurpleMediaCandidate and its contents.
  *
  * @param candidates The list of candidates to be copied.
@@ -243,6 +253,15 @@
 		PurpleMediaSessionType media_type, guint clock_rate);
 
 /**
+ * Copies a PurpleMediaCodec instance.
+ *
+ * @param codec The codec to copy
+ *
+ * @return The newly created PurpleMediaCodec copy.
+ */
+PurpleMediaCodec *purple_media_codec_copy(PurpleMediaCodec *codec);
+
+/**
  * Creates a string representation of the codec.
  *
  * @param codec The codec to create the string of.
--- a/libpurple/protocols/jabber/google.c	Fri Mar 20 00:24:06 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Fri Mar 20 01:48:28 2009 +0000
@@ -156,19 +156,29 @@
 }
 
 static void
-google_session_ready(PurpleMedia *media, gchar *id,
-		gchar *participant, GoogleSession *session)
+google_session_ready(GoogleSession *session)
 {
-	if (id == NULL && participant == NULL) {
+	PurpleMedia *media = session->media;
+	if (purple_media_codecs_ready(media, NULL) &&
+			purple_media_candidates_prepared(media, NULL, NULL)) {
 		gchar *me = g_strdup_printf("%s@%s/%s",
 				session->js->user->node,
 				session->js->user->domain,
 				session->js->user->resource);
-		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+		JabberIq *iq;
 		xmlnode *sess, *desc, *payload;
 		GList *codecs, *iter;
+		gboolean is_initiator = !strcmp(session->id.initiator, me);
 
-		if (!strcmp(session->id.initiator, me)) {
+		if (!is_initiator &&
+				!purple_media_accepted(media, NULL, NULL)) {
+			g_free(me);
+			return;
+		}
+
+		iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+
+		if (is_initiator) {
 			xmlnode_set_attrib(iq->node, "to", session->remote_jid);
 			xmlnode_set_attrib(iq->node, "from", session->id.initiator);
 			sess = google_session_create_xmlnode(session, "initiate");
@@ -309,7 +319,10 @@
 		return NULL;
 	}
 
-	g_signal_connect(G_OBJECT(session->media), "ready-new",
+	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);
@@ -369,7 +382,12 @@
 
 	purple_media_set_remote_codecs(session->media, "google-voice", session->remote_jid, codecs);
 
-	g_signal_connect(G_OBJECT(session->media), "ready-new",
+	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);