pidgin.vv: 35c21b92: Convert more PidginMedia signals to the ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Tue Jan 13 06:35:54 EST 2009


-----------------------------------------------------------------
Revision: 35c21b92337345a511b36a989a534f2744c58dd4
Ancestor: c4a6cbd29e988622dcec3545e731f03b7ffcd06a
Author: maiku at soc.pidgin.im
Date: 2009-01-13T09:50:13
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/35c21b92337345a511b36a989a534f2744c58dd4

Modified files:
        pidgin/gtkmedia.c

ChangeLog: 

Convert more PidginMedia signals to the newer API.

-------------- next part --------------
============================================================
--- pidgin/gtkmedia.c	f85b325dc1aa272dc8be817089bd45571e5ddd78
+++ pidgin/gtkmedia.c	306f9e6fd117718825bbdee318f399d8c2ffe18b
@@ -543,27 +543,7 @@ pidgin_media_wait_cb(PurpleMedia *media,
 	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_WAITING);
 }
 
-/* maybe we should have different callbacks for when we received the accept
-    and we accepted ourselves */
 static void
-pidgin_media_accept_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	GstElement *audiosendbin = NULL;
-	GstElement *audiorecvbin = NULL;
-	GstElement *videosendbin = NULL;
-	GstElement *videorecvbin = NULL;
-
-	pidgin_media_emit_message(gtkmedia, _("Call in progress."));
-	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED);
-
-	purple_media_get_elements(media, &audiosendbin, &audiorecvbin,
-				  &videosendbin, &videorecvbin);
-
-	if (audiorecvbin || audiosendbin || videorecvbin || videosendbin)
-		gtk_widget_show(gtkmedia->priv->display);
-}
-
-static void
 pidgin_media_got_request_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	PurpleMediaSessionType type = purple_media_get_overall_type(media);
@@ -603,6 +583,18 @@ pidgin_media_state_changed_cb(PurpleMedi
 			pidgin_media_emit_message(gtkmedia,
 					_("You have rejected the call."));
 		}
+	} else if (type == PURPLE_MEDIA_STATE_CHANGED_CONNECTED) {
+		GstElement *audiosendbin = NULL, *audiorecvbin = NULL;
+		GstElement *videosendbin = NULL, *videorecvbin = NULL;
+
+		pidgin_media_emit_message(gtkmedia, _("Call in progress."));
+		pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED);
+
+		purple_media_get_elements(media, &audiosendbin, &audiorecvbin,
+					  &videosendbin, &videorecvbin);
+
+		if (audiorecvbin || audiosendbin || videorecvbin || videosendbin)
+			gtk_widget_show(gtkmedia->priv->display);
 	}
 }
 
@@ -615,10 +607,20 @@ pidgin_media_set_property (GObject *obje
 	media = PIDGIN_MEDIA(object);
 	switch (prop_id) {
 		case PROP_MEDIA:
+		{
+			gboolean initiator;
 			if (media->priv->media)
 				g_object_unref(media->priv->media);
 			media->priv->media = g_value_get_object(value);
 			g_object_ref(media->priv->media);
+
+			g_object_get(G_OBJECT(media->priv->media),
+					"initiator", &initiator, NULL);
+			if (initiator == TRUE)
+				pidgin_media_set_state(media, PIDGIN_MEDIA_WAITING);
+			else
+				pidgin_media_set_state(media, PIDGIN_MEDIA_REQUESTED);
+
 			g_signal_connect_swapped(G_OBJECT(media->priv->accept), "clicked", 
 				 G_CALLBACK(purple_media_accept), media->priv->media);
 			g_signal_connect_swapped(G_OBJECT(media->priv->reject), "clicked",
@@ -628,19 +630,14 @@ pidgin_media_set_property (GObject *obje
 
 			g_signal_connect(G_OBJECT(media->priv->media), "error",
 				G_CALLBACK(pidgin_media_error_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "accepted",
-				G_CALLBACK(pidgin_media_accept_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media) ,"ready",
 				G_CALLBACK(pidgin_media_ready_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media) ,"wait",
-				G_CALLBACK(pidgin_media_wait_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "got-request",
 				G_CALLBACK(pidgin_media_got_request_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "got-accept",
-				G_CALLBACK(pidgin_media_accept_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "state-changed",
 				G_CALLBACK(pidgin_media_state_changed_cb), media);
 			break;
+		}
 		case PROP_SCREENNAME:
 			if (media->priv->screenname)
 				g_free(media->priv->screenname);


More information about the Commits mailing list