From 9c5568e53b09615bee4d516fd8ea29341383fbf7 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 2 Mar 2012 10:50:09 +0100 Subject: Revert "Stop approve StreamedMedia channels" This reverts commit c7dd14aef20e429135fba7c7a53a8d507b9579a3. --- src/empathy-event-manager.c | 86 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'src/empathy-event-manager.c') diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 75f2cb8ab..c6b3e29ed 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -407,7 +408,11 @@ reject_channel_claim_cb (GObject *source, goto out; } - if (TP_IS_CALL_CHANNEL (user_data)) + if (EMPATHY_IS_TP_STREAMED_MEDIA (user_data)) + { + empathy_tp_streamed_media_close (user_data); + } + else if (TP_IS_CALL_CHANNEL (user_data)) { tp_call_channel_hangup_async (user_data, TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, @@ -494,7 +499,13 @@ event_channel_process_voip_func (EventPriv *event) return; } - if (etype == EMPATHY_EVENT_TYPE_CALL) + if (etype == EMPATHY_EVENT_TYPE_VOIP) + { + EmpathyTpStreamedMedia *call; + call = EMPATHY_TP_STREAMED_MEDIA (event->approval->handler_instance); + video = empathy_tp_streamed_media_has_initial_video (call); + } + else if (etype == EMPATHY_EVENT_TYPE_CALL) { TpCallChannel *call; call = TP_CALL_CHANNEL (event->approval->handler_instance); @@ -736,6 +747,54 @@ event_manager_call_channel_got_contact_cb (TpConnection *connection, g_object_unref (window); } +static void +event_manager_media_channel_got_contact (EventManagerApproval *approval) +{ + EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager); + GtkWidget *window = empathy_roster_window_dup (); + gchar *header; + EmpathyTpStreamedMedia *call; + gboolean video; + + call = EMPATHY_TP_STREAMED_MEDIA (approval->handler_instance); + + video = empathy_tp_streamed_media_has_initial_video (call); + + header = g_strdup_printf ( + video ? _("Incoming video call from %s") :_("Incoming call from %s"), + empathy_contact_get_alias (approval->contact)); + + event_manager_add (approval->manager, NULL, + approval->contact, EMPATHY_EVENT_TYPE_VOIP, + video ? EMPATHY_IMAGE_VIDEO_CALL : EMPATHY_IMAGE_VOIP, + header, NULL, approval, + event_channel_process_voip_func, NULL); + + g_free (header); + + priv->ringing++; + if (priv->ringing == 1) + empathy_sound_manager_start_playing (priv->sound_mgr, window, + EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING); + + g_object_unref (window); +} + +static void +event_manager_media_channel_contact_changed_cb (EmpathyTpStreamedMedia *call, + GParamSpec *param, EventManagerApproval *approval) +{ + EmpathyContact *contact; + + g_object_get (G_OBJECT (call), "contact", &contact, NULL); + + if (contact == NULL) + return; + + approval->contact = contact; + event_manager_media_channel_got_contact (approval); +} + static void invite_dialog_response_cb (GtkDialog *dialog, gint response, @@ -1021,6 +1080,29 @@ approve_channels (TpSimpleApprover *approver, event_manager_chat_message_received_cb (tp_chat, msg, approval); } } + else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) + { + EmpathyContact *contact; + EmpathyTpStreamedMedia *call = empathy_tp_streamed_media_new (account, + channel); + + approval->handler_instance = G_OBJECT (call); + + g_object_get (G_OBJECT (call), "contact", &contact, NULL); + + if (contact == NULL) + { + g_signal_connect (call, "notify::contact", + G_CALLBACK (event_manager_media_channel_contact_changed_cb), + approval); + } + else + { + approval->contact = contact; + event_manager_media_channel_got_contact (approval); + } + + } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL) { TpCallChannel *call = TP_CALL_CHANNEL (channel); -- cgit v1.2.3