pidgin.vv.ticket34: 15b32b84: Change a few things:

sadrul at pidgin.im sadrul at pidgin.im
Sat Mar 22 05:15:48 EDT 2008


-----------------------------------------------------------------
Revision: 15b32b8473cc77f98e14f53525b1eebb60c4eb84
Ancestor: d96f1fc768a9e4b4758f2b0bd7ca8d645cbab000
Author: sadrul at pidgin.im
Date: 2008-03-22T09:17:34
Branch: im.pidgin.pidgin.vv.ticket34
URL: http://d.pidgin.im/viewmtn/revision/info/15b32b8473cc77f98e14f53525b1eebb60c4eb84

Modified files:
        finch/gntmedia.c libpurple/media.c libpurple/media.h
        libpurple/server.c pidgin/gtkconv.c pidgin/gtkconv.h
        pidgin/gtkmedia.c pidgin/gtkmedia.h

ChangeLog: 

Change a few things:
 * call purple_media_wait to notify that we are waiting on a response from the
   remote end
 * fix the /call command in finch
 * keep track of the PidginMedia for a PidginConversation
 * fix the two-widget bug in pidgin.
We probably should have a way to get the PidginMedia from a PurpleMedia. Should
we use _set/_get_ui_data for this?

-------------- next part --------------
============================================================
--- finch/gntmedia.c	aafecb7c9022a1ce0c98703e93d1cf6048268c73
+++ finch/gntmedia.c	00688148251fd3a1d6acec510a4eb28e355118a0
@@ -401,7 +401,7 @@ call_cmd_cb(PurpleConversation *conv, co
 	if (!media)
 		return PURPLE_CMD_STATUS_FAILED;
 
-	purple_media_accept(media);
+	purple_media_wait(media);
 	return PURPLE_CMD_STATUS_OK;
 }
 
============================================================
--- libpurple/media.c	1d1da79dd93657152fe1552477c84d328cc938dd
+++ libpurple/media.c	9119e05f4aca04bf2fc7105bdb03d856033c80cc
@@ -67,6 +67,7 @@ enum {
 
 enum {
 	READY,
+	WAIT,
 	ACCEPTED,
 	HANGUP,
 	REJECT,
@@ -189,6 +190,10 @@ purple_media_class_init (PurpleMediaClas
 				 	 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
+	purple_media_signals[WAIT] = g_signal_new("wait", G_TYPE_FROM_CLASS(klass),
+				 	 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
 	purple_media_signals[ACCEPTED] = g_signal_new("accepted", G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
@@ -441,6 +446,12 @@ void
 }
 
 void
+purple_media_wait(PurpleMedia *media)
+{
+	g_signal_emit(media, purple_media_signals[WAIT], 0);
+}
+
+void
 purple_media_accept(PurpleMedia *media)
 {
 	g_signal_emit(media, purple_media_signals[ACCEPTED], 0);
============================================================
--- libpurple/media.h	f122be5e7842ecc46526ff7118feeb3ad6f6b610
+++ libpurple/media.h	13db098c626e2dd8b7183d9b9a10dc7ea012f088
@@ -86,6 +86,7 @@ void purple_media_ready(PurpleMedia *med
 PurpleConnection *purple_media_get_connection(PurpleMedia *media);
 const char *purple_media_get_screenname(PurpleMedia *media);
 void purple_media_ready(PurpleMedia *media);
+void purple_media_wait(PurpleMedia *media);
 void purple_media_accept(PurpleMedia *media);
 void purple_media_reject(PurpleMedia *media);
 void purple_media_hangup(PurpleMedia *media);
============================================================
--- libpurple/server.c	1c73e257f3e79c482f9b1b9a1d9f12329c789e16
+++ libpurple/server.c	c92c992322b10f6624cbfe5027c03dc8f9440e4f
@@ -1050,12 +1050,12 @@ PurpleMedia *serv_initiate_media(PurpleC
 {
 	PurplePlugin *prpl = NULL;
 	PurplePluginProtocolInfo *prpl_info = NULL;
-	
+
 	if (gc)
 		prpl = purple_connection_get_prpl(gc);
 	if (prpl)
 		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	
+
 	if (prpl_info && prpl_info->initiate_media) {
 		/* should check that the protol supports this media type here.... */
 		return prpl_info->initiate_media(gc, who, type);
============================================================
--- pidgin/gtkconv.c	2aee2f05ec5f6bd773ea8b07ff79c598206ea23d
+++ pidgin/gtkconv.c	21b8de6c47773da000cdf41bc45b0c34c363d900
@@ -7629,43 +7629,22 @@ menu_initiate_voice_call_cb(gpointer dat
 menu_initiate_voice_call_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	PidginWindow *win = (PidginWindow *)data;
-	GtkWidget *gtkmedia = NULL;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
-	PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
-
 	PurpleConnection *gc = purple_conversation_get_gc(conv);
-	PurplePluginProtocolInfo *prpl = gc->prpl;
-	PurpleMediaManager *manager = purple_media_manager_get();
 
 	PurpleMedia *media =
 		serv_initiate_media(gc,
 							purple_conversation_get_name(conv),
 							PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
-	GstElement *sendbin, *src, *sendlevel;
-	GstElement *recvbin, *sink, *recvlevel;
-	GstPad *pad, *ghost;
 
-	purple_media_audio_init_src(&sendbin, &sendlevel);
-	purple_media_audio_init_recv(&recvbin, &recvlevel);
-
-	purple_media_set_audio_src(media, sendbin);
-	purple_media_set_audio_sink(media, recvbin);
-
-	gtkmedia = pidgin_media_new(media, PIDGIN_MEDIA_WAITING, sendlevel, recvlevel);
-
-	gtk_box_pack_start(GTK_BOX(gtkconv->topvbox), gtkmedia, FALSE, FALSE, 0);
-	gtk_widget_show(gtkmedia);
-	g_signal_connect(G_OBJECT(gtkmedia), "message",
-					 G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
-	/* need to setup handler for accept, reject and if we hangup here... */
+	purple_media_wait(media);
 }
 
 static void
 pidgin_conv_new_media_cb(PurpleMediaManager *manager, PurpleMedia *media, gpointer nul)
 {
-	GstElement *sendbin, *src, *sendlevel;
-	GstElement *recvbin, *sink, *recvlevel;
-	GstPad *pad, *ghost;
+	GstElement *sendbin, *sendlevel;
+	GstElement *recvbin, *recvlevel;
 
 	GtkWidget *gtkmedia;
 	PurpleConversation *conv;
@@ -7677,14 +7656,20 @@ pidgin_conv_new_media_cb(PurpleMediaMana
 	purple_media_set_audio_src(media, sendbin);
 	purple_media_set_audio_sink(media, recvbin);
 
-	gtkmedia = pidgin_media_new(media, PIDGIN_MEDIA_REQUESTED, sendlevel, recvlevel);
 	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
 				       purple_connection_get_account(purple_media_get_connection(media)),
 				       purple_media_get_screenname(media));
 	gtkconv = PIDGIN_CONVERSATION(conv);
+	if (gtkconv->gtkmedia)
+		gtk_widget_destroy(gtkconv->gtkmedia);
+
+	gtkmedia = pidgin_media_new(media, sendlevel, recvlevel);
 	gtk_box_pack_start(GTK_BOX(gtkconv->topvbox), gtkmedia, FALSE, FALSE, 0);
 	gtk_widget_show(gtkmedia);
 	g_signal_connect(G_OBJECT(gtkmedia), "message", G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
+
+	gtkconv->gtkmedia = gtkmedia;
+	g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(gtk_widget_destroyed), &(gtkconv->gtkmedia));
 }
 
 #endif
============================================================
--- pidgin/gtkconv.h	28e0d5dc1aaf571405596a25e2bb45b9cdff900a
+++ pidgin/gtkconv.h	5036f2250c314d599e0b25d73854487b0a05cd74
@@ -170,6 +170,7 @@ struct _PidginConversation
 	GtkListStore *infopane_model;
 	GtkTreeIter infopane_iter;
 	GtkWidget *topvbox;
+	GtkWidget *gtkmedia;
 
 	/* Used when attaching a PidginConversation to a PurpleConversation
 	 * with message history */
============================================================
--- pidgin/gtkmedia.c	ea8e54991d85383ff6c34fd65dd66f5147a5ddd4
+++ pidgin/gtkmedia.c	366ef2bdb32c73b6c1bb1dcc8d604a70249a8caa
@@ -34,6 +34,18 @@
 
 #include <farsight/farsight.h>
 
+typedef enum
+{
+	/* Waiting for response */
+	PIDGIN_MEDIA_WAITING = 1,
+	/* Got request */
+	PIDGIN_MEDIA_REQUESTED,
+	/* Accepted call */
+	PIDGIN_MEDIA_ACCEPTED,
+	/* Rejected call */
+	PIDGIN_MEDIA_REJECTED,
+} PidginMediaState;
+
 struct _PidginMediaPrivate
 {
 	PurpleMedia *media;
@@ -58,6 +70,7 @@ static void pidgin_media_set_property (G
 static void pidgin_media_finalize (GObject *object);
 static void pidgin_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
 static void pidgin_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void pidgin_media_set_state(PidginMedia *gtkmedia, PidginMediaState state);
 
 static GtkHBoxClass *parent_class = NULL;
 
@@ -164,15 +177,20 @@ pidgin_media_init (PidginMedia *media)
 	gtk_widget_show(media->priv->send_progress);
 	gtk_widget_show(media->priv->recv_progress);
 
-	/*
-	   gtk_widget_show_all(media->priv->accept);
-	   gtk_widget_show_all(media->priv->reject);
-	   */
+	gtk_widget_show_all(media->priv->accept);
+	gtk_widget_show_all(media->priv->reject);
 }
 
 static void
 pidgin_media_finalize (GObject *media)
 {
+	PidginMedia *gtkmedia = PIDGIN_MEDIA(media);
+	if (gtkmedia->priv->media)
+		g_object_unref(gtkmedia->priv->media);
+	if (gtkmedia->priv->send_level)
+		gst_object_unref(gtkmedia->priv->send_level);
+	if (gtkmedia->priv->recv_level)
+		gst_object_unref(gtkmedia->priv->recv_level);
 }
 
 static void
@@ -227,6 +245,12 @@ pidgin_media_ready_cb(PurpleMedia *media
 	printf("\n\nbus: %p\n", gst_pipeline_get_bus(GST_PIPELINE(element)));
 }
 
+static void
+pidgin_media_wait_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+{
+	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
@@ -281,6 +305,8 @@ pidgin_media_set_property (GObject *obje
 				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), "hangup",
 				G_CALLBACK(pidgin_media_hangup_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "reject",
@@ -333,17 +359,15 @@ GtkWidget *
 }
 
 GtkWidget *
-pidgin_media_new(PurpleMedia *media, PidginMediaState state,
-                 GstElement *sendlevel, GstElement *recvlevel)
+pidgin_media_new(PurpleMedia *media, GstElement *sendlevel, GstElement *recvlevel)
 {
 	PidginMedia *gtkmedia = g_object_new(pidgin_media_get_type(), "media", media,
 			"send-level", sendlevel,
 			"recv-level", recvlevel, NULL);
-	pidgin_media_set_state(gtkmedia, state);
 	return GTK_WIDGET(gtkmedia);
 }
 
-void
+static void
 pidgin_media_set_state(PidginMedia *gtkmedia, PidginMediaState state)
 {
 	gtkmedia->priv->state = state;
@@ -352,12 +376,12 @@ pidgin_media_set_state(PidginMedia *gtkm
 			gtk_widget_show(gtkmedia->priv->calling);
 			gtk_widget_hide(gtkmedia->priv->accept);
 			gtk_widget_hide(gtkmedia->priv->reject);
-			gtk_widget_hide(gtkmedia->priv->hangup);
+			gtk_widget_show(gtkmedia->priv->hangup);
 			break;
 		case PIDGIN_MEDIA_REQUESTED:
+			gtk_widget_hide(gtkmedia->priv->calling);
 			gtk_widget_show(gtkmedia->priv->accept);
 			gtk_widget_show(gtkmedia->priv->reject);
-			gtk_widget_hide(gtkmedia->priv->calling);
 			gtk_widget_hide(gtkmedia->priv->hangup);
 			break;
 		case PIDGIN_MEDIA_ACCEPTED:
@@ -366,12 +390,6 @@ pidgin_media_set_state(PidginMedia *gtkm
 			gtk_widget_hide(gtkmedia->priv->accept);
 			gtk_widget_hide(gtkmedia->priv->reject);
 			break;
-		case PIDGIN_MEDIA_REJECTED:
-			gtk_widget_hide(gtkmedia->priv->calling);
-			gtk_widget_hide(gtkmedia->priv->hangup);
-			gtk_widget_hide(gtkmedia->priv->accept);
-			gtk_widget_hide(gtkmedia->priv->reject);
-			break;
 		default:
 			break;
 	}
============================================================
--- pidgin/gtkmedia.h	6d53aae98f518afe254988b00345abc23adea610
+++ pidgin/gtkmedia.h	3e50ecb202f87961bb423d5d9bafc9aac5e96d5d
@@ -46,7 +46,6 @@ typedef struct _PidginMediaPrivate Pidgi
 typedef struct _PidginMedia PidginMedia;
 typedef struct _PidginMediaClass PidginMediaClass;
 typedef struct _PidginMediaPrivate PidginMediaPrivate;
-typedef enum _PidginMediaState PidginMediaState;
 
 struct _PidginMediaClass
 {
@@ -59,26 +58,10 @@ struct _PidginMedia
 	PidginMediaPrivate *priv;
 };
 
-enum _PidginMediaState
-{
-	/* Waiting for response */
-	PIDGIN_MEDIA_WAITING = 1,
-	/* Got request */
-	PIDGIN_MEDIA_REQUESTED,
-	/* Accepted call */
-	PIDGIN_MEDIA_ACCEPTED,
-	/* Rejected call */
-	PIDGIN_MEDIA_REJECTED,
-};
-
 GType pidgin_media_get_type(void);
 
-GtkWidget *pidgin_media_new(PurpleMedia *media, PidginMediaState state,
-                            GstElement *send_level, GstElement *recv_level);
-PidginMediaState pidgin_media_get_state(PidginMedia *gtkmedia);
-void pidgin_media_set_state(PidginMedia *gtkmedia, PidginMediaState state);
+GtkWidget *pidgin_media_new(PurpleMedia *media, GstElement *send_level, GstElement *recv_level);
 
-
 G_END_DECLS
 
 #endif  /* USE_FARSIGHT */


More information about the Commits mailing list