changeset 26032:2809a63dbadf

Convert PidginMedia to use the state-changed signal.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Tue, 13 Jan 2009 08:40:27 +0000
parents 7bbac147f276
children 366f68124622
files libpurple/media.c pidgin/gtkmedia.c
diffstat 2 files changed, 18 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Tue Jan 13 06:48:30 2009 +0000
+++ b/libpurple/media.c	Tue Jan 13 08:40:27 2009 +0000
@@ -1318,7 +1318,6 @@
 	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 			0, PURPLE_MEDIA_STATE_CHANGED_END,
 			NULL, NULL);
-	g_signal_emit(media, purple_media_signals[HANGUP], 0);
 }
 
 void
@@ -1330,7 +1329,6 @@
 	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 			0, PURPLE_MEDIA_STATE_CHANGED_END,
 			NULL, NULL);
-	g_signal_emit(media, purple_media_signals[REJECT], 0);
 }
 
 void
@@ -1345,7 +1343,6 @@
 	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 			0, PURPLE_MEDIA_STATE_CHANGED_END,
 			NULL, NULL);
-	g_signal_emit(media, purple_media_signals[GOT_HANGUP], 0);
 }
 
 void
--- a/pidgin/gtkmedia.c	Tue Jan 13 06:48:30 2009 +0000
+++ b/pidgin/gtkmedia.c	Tue Jan 13 08:40:27 2009 +0000
@@ -564,13 +564,6 @@
 }
 
 static void
-pidgin_media_hangup_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	pidgin_media_emit_message(gtkmedia, _("You have ended the call."));
-	gtk_widget_destroy(GTK_WIDGET(gtkmedia));
-}
-
-static void
 pidgin_media_got_request_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	PurpleMediaSessionType type = purple_media_get_overall_type(media);
@@ -594,17 +587,23 @@
 }
 
 static void
-pidgin_media_got_hangup_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+pidgin_media_state_changed_cb(PurpleMedia *media,
+		PurpleMediaStateChangedType type,
+		gchar *sid, gchar *name, PidginMedia *gtkmedia)
 {
-	pidgin_media_emit_message(gtkmedia, _("The call has been terminated."));
-	gtk_widget_destroy(GTK_WIDGET(gtkmedia));
-}
-
-static void
-pidgin_media_reject_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	pidgin_media_emit_message(gtkmedia, _("You have rejected the call."));
-	gtk_widget_destroy(GTK_WIDGET(gtkmedia));
+	purple_debug_info("gtkmedia", "type: %d sid: %s name: %s\n",
+			type, sid, name);
+	if (sid == NULL && name == NULL) {
+		if (type == PURPLE_MEDIA_STATE_CHANGED_END) {
+			pidgin_media_emit_message(gtkmedia,
+					_("The call has been terminated."));
+			gtk_widget_destroy(GTK_WIDGET(gtkmedia));
+			
+		} else if (type == PURPLE_MEDIA_STATE_CHANGED_REJECTED) {
+			pidgin_media_emit_message(gtkmedia,
+					_("You have rejected the call."));
+		}
+	}
 }
 
 static void
@@ -635,16 +634,12 @@
 				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), "hangup",
-				G_CALLBACK(pidgin_media_hangup_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media), "reject",
-				G_CALLBACK(pidgin_media_reject_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-hangup",
-				G_CALLBACK(pidgin_media_got_hangup_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)