Mercurial > pidgin.yaz
changeset 25643:befeece4dd48
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?
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 22 Mar 2008 09:17:34 +0000 |
parents | 10a76e4b0dc0 |
children | 52a753b67ebb |
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 |
diffstat | 8 files changed, 62 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntmedia.c Sat Mar 22 05:10:29 2008 +0000 +++ b/finch/gntmedia.c Sat Mar 22 09:17:34 2008 +0000 @@ -401,7 +401,7 @@ if (!media) return PURPLE_CMD_STATUS_FAILED; - purple_media_accept(media); + purple_media_wait(media); return PURPLE_CMD_STATUS_OK; }
--- a/libpurple/media.c Sat Mar 22 05:10:29 2008 +0000 +++ b/libpurple/media.c Sat Mar 22 09:17:34 2008 +0000 @@ -67,6 +67,7 @@ enum { READY, + WAIT, ACCEPTED, HANGUP, REJECT, @@ -189,6 +190,10 @@ 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 +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);
--- a/libpurple/media.h Sat Mar 22 05:10:29 2008 +0000 +++ b/libpurple/media.h Sat Mar 22 09:17:34 2008 +0000 @@ -86,6 +86,7 @@ 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);
--- a/libpurple/server.c Sat Mar 22 05:10:29 2008 +0000 +++ b/libpurple/server.c Sat Mar 22 09:17:34 2008 +0000 @@ -1050,12 +1050,12 @@ { 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);
--- a/pidgin/gtkconv.c Sat Mar 22 05:10:29 2008 +0000 +++ b/pidgin/gtkconv.c Sat Mar 22 09:17:34 2008 +0000 @@ -7629,43 +7629,22 @@ 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 @@ 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
--- a/pidgin/gtkconv.h Sat Mar 22 05:10:29 2008 +0000 +++ b/pidgin/gtkconv.h Sat Mar 22 09:17:34 2008 +0000 @@ -170,6 +170,7 @@ GtkListStore *infopane_model; GtkTreeIter infopane_iter; GtkWidget *topvbox; + GtkWidget *gtkmedia; /* Used when attaching a PidginConversation to a PurpleConversation * with message history */
--- a/pidgin/gtkmedia.c Sat Mar 22 05:10:29 2008 +0000 +++ b/pidgin/gtkmedia.c Sat Mar 22 09:17:34 2008 +0000 @@ -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_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 @@ 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 @@ 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 @@ 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 * -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 @@ 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 @@ 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; }
--- a/pidgin/gtkmedia.h Sat Mar 22 05:10:29 2008 +0000 +++ b/pidgin/gtkmedia.h Sat Mar 22 09:17:34 2008 +0000 @@ -46,7 +46,6 @@ typedef struct _PidginMedia PidginMedia; typedef struct _PidginMediaClass PidginMediaClass; typedef struct _PidginMediaPrivate PidginMediaPrivate; -typedef enum _PidginMediaState PidginMediaState; struct _PidginMediaClass { @@ -59,25 +58,9 @@ 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