pidgin.vv: a7fd2120: Update Finch to new media API.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Tue Jan 13 08:46:29 EST 2009


-----------------------------------------------------------------
Revision: a7fd212070f9f469df9d0a908aad38d7a04753f5
Ancestor: a38c44e88ee54fa639c5d924a5100699df189a26
Author: maiku at soc.pidgin.im
Date: 2009-01-13T12:23:23
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/a7fd212070f9f469df9d0a908aad38d7a04753f5

Modified files:
        finch/gntmedia.c

ChangeLog: 

Update Finch to new media API.

-------------- next part --------------
============================================================
--- finch/gntmedia.c	84d3451a8d10da62f09729d75a16b4c8c46a7220
+++ finch/gntmedia.c	ff20efcb76a0f996b8c4f9f5a7b1e9f52fe7eea8
@@ -246,36 +246,37 @@ static void
 }
 
 static void
-finch_media_hangup_cb(PurpleMedia *media, FinchMedia *gntmedia)
+finch_media_state_changed_cb(PurpleMedia *media,
+		PurpleMediaStateChangedType type,
+		gchar *sid, gchar *name, FinchMedia *gntmedia)
 {
-	finch_media_emit_message(gntmedia, _("You have ended the call."));
-	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
-	gnt_widget_destroy(GNT_WIDGET(gntmedia));
-	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
-	g_object_unref(gntmedia);
+	purple_debug_info("gntmedia", "type: %d sid: %s name: %s\n",
+			type, sid, name);
+	if (sid == NULL && name == NULL) {
+		if (type == PURPLE_MEDIA_STATE_CHANGED_END) {
+			finch_media_emit_message(gntmedia,
+					_("The call has been terminated."));
+			finch_conversation_set_info_widget(
+					gntmedia->priv->conv, NULL);
+			gnt_widget_destroy(GNT_WIDGET(gntmedia));
+			/*
+			 * XXX: This shouldn't have to be here
+			 * to free the FinchMedia widget.
+			 */
+			g_object_unref(gntmedia);
+		} else if (type == PURPLE_MEDIA_STATE_CHANGED_REJECTED) {
+			finch_media_emit_message(gntmedia,
+					_("You have rejected the call."));
+		}
+	} else if (type == PURPLE_MEDIA_STATE_CHANGED_NEW
+			&& sid != NULL && name != NULL) {
+		finch_media_ready_cb(media, gntmedia);
+	} else if (type == PURPLE_MEDIA_STATE_CHANGED_CONNECTED) {
+		finch_media_accept_cb(media, gntmedia);
+	}
 }
 
 static void
-finch_media_got_hangup_cb(PurpleMedia *media, FinchMedia *gntmedia)
-{
-	finch_media_emit_message(gntmedia, _("The call has been terminated."));
-	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
-	gnt_widget_destroy(GNT_WIDGET(gntmedia));
-	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
-	g_object_unref(gntmedia);
-}
-
-static void
-finch_media_reject_cb(PurpleMedia *media, FinchMedia *gntmedia)
-{
-	finch_media_emit_message(gntmedia, _("You have rejected the call."));
-	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
-	gnt_widget_destroy(GNT_WIDGET(gntmedia));
-	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
-	g_object_unref(gntmedia);
-}
-
-static void
 finch_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
 	FinchMedia *media;
@@ -284,6 +285,8 @@ finch_media_set_property (GObject *objec
 	media = FINCH_MEDIA(object);
 	switch (prop_id) {
 		case PROP_MEDIA:
+		{
+			gboolean is_initiator;
 			if (media->priv->media)
 				g_object_unref(media->priv->media);
 			media->priv->media = g_value_get_object(value);
@@ -295,21 +298,15 @@ finch_media_set_property (GObject *objec
 			g_signal_connect_swapped(G_OBJECT(media->priv->hangup), "activate",
 				 G_CALLBACK(purple_media_hangup), media->priv->media);
 
-			g_signal_connect(G_OBJECT(media->priv->media), "accepted",
-				G_CALLBACK(finch_media_accept_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media) ,"ready",
-				G_CALLBACK(finch_media_ready_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "wait",
-				G_CALLBACK(finch_media_wait_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "hangup",
-				G_CALLBACK(finch_media_hangup_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "reject",
-				G_CALLBACK(finch_media_reject_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "got-hangup",
-				G_CALLBACK(finch_media_got_hangup_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "got-accept",
-				G_CALLBACK(finch_media_accept_cb), media);
+			g_object_get(G_OBJECT(media->priv->media), "initiator",
+					&is_initiator, NULL);
+			if (is_initiator == TRUE) {
+				finch_media_wait_cb(media->priv->media, media);
+			}
+			g_signal_connect(G_OBJECT(media->priv->media), "state-changed",
+				G_CALLBACK(finch_media_state_changed_cb), media);
 			break;
+		}
 		case PROP_SEND_LEVEL:
 			if (media->priv->send_level)
 				gst_object_unref(media->priv->send_level);


More information about the Commits mailing list