aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-call-window.c
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-09-07 20:19:24 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-09-08 19:26:25 +0800
commit3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99 (patch)
tree8e8c34a4eb131f36b094ecd41f26d0b89418b031 /src/empathy-call-window.c
parentee02c5c89132db72e5cd987cd443cd09202b6f5b (diff)
downloadgsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar.gz
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar.bz2
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar.lz
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar.xz
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.tar.zst
gsoc2013-empathy-3f30f0aac8ec4f21acb84e4b5b9afa6acd131b99.zip
CallWindow: display a dialog to accept or reject incoming calls
https://bugzilla.gnome.org/show_bug.cgi?id=580794
Diffstat (limited to 'src/empathy-call-window.c')
-rw-r--r--src/empathy-call-window.c72
1 files changed, 59 insertions, 13 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 81bee0596..c8d17c00e 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -188,6 +188,7 @@ struct _EmpathyCallWindowPriv
/* These are used to accept or reject an incoming call when the status
is RINGING. */
+ GtkWidget *incoming_call_dialog;
TpyCallChannel *pending_channel;
TpChannelDispatchOperation *pending_cdo;
TpAddDispatchOperationContext *pending_context;
@@ -1368,35 +1369,80 @@ empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage,
}
static void
+empathy_call_window_incoming_call_response_cb (GtkDialog *dialog,
+ gint response_id,
+ EmpathyCallWindow *self)
+{
+ switch (response_id)
+ {
+ case GTK_RESPONSE_ACCEPT:
+ tp_channel_dispatch_operation_handle_with_async (
+ self->priv->pending_cdo, EMPATHY_CALL_BUS_NAME, NULL, NULL);
+
+ tp_clear_object (&self->priv->pending_cdo);
+ tp_clear_object (&self->priv->pending_channel);
+ tp_clear_object (&self->priv->pending_context);
+
+ break;
+ case GTK_RESPONSE_CANCEL:
+ tp_channel_dispatch_operation_close_channels_async (
+ self->priv->pending_cdo, NULL, NULL);
+
+ empathy_call_window_status_message (self, _("Disconnected"));
+ self->priv->call_state = DISCONNECTED;
+ break;
+ default:
+ g_warn_if_reached ();
+ }
+}
+
+static void
empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
{
+ gboolean video;
+
g_assert (self->priv->call_state != CONNECTED);
+ video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
+
empathy_call_window_status_message (self, _("Incoming call"));
self->priv->call_state = RINGING;
-}
-static void
-empathy_call_window_stop_ringing (EmpathyCallWindow *self)
-{
- empathy_call_window_status_message (self, _("Disconnected"));
- self->priv->call_state = DISCONNECTED;
+ self->priv->incoming_call_dialog = gtk_message_dialog_new (
+ GTK_WINDOW (self), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ video ? _("Incoming video call from %s") : _("Incoming call from %s"),
+ empathy_contact_get_alias (self->priv->contact));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (self->priv->incoming_call_dialog),
+ _("Reject"), GTK_RESPONSE_CANCEL,
+ _("Answer"), GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ g_signal_connect (self->priv->incoming_call_dialog, "response",
+ G_CALLBACK (empathy_call_window_incoming_call_response_cb), self);
+ gtk_widget_show (self->priv->incoming_call_dialog);
}
static void
-empathy_call_window_incoming_channel_invalidated_cb (TpProxy *channel,
+empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
guint domain,
gint code,
gchar *message,
EmpathyCallWindow *self)
{
- tp_channel_dispatch_operation_destroy_channels_async (
- self->priv->pending_cdo, NULL, NULL);
- empathy_call_window_stop_ringing (self);
-
tp_clear_object (&self->priv->pending_cdo);
tp_clear_object (&self->priv->pending_channel);
tp_clear_object (&self->priv->pending_context);
+
+ /* We don't know if the incoming call has been accepted or not, so we
+ * assume it hasn't and if it has, we'll set the proper status when
+ * we get the new handler. */
+ empathy_call_window_status_message (self, _("Disconnected"));
+ self->priv->call_state = DISCONNECTED;
+
+ gtk_widget_destroy (self->priv->incoming_call_dialog);
+ self->priv->incoming_call_dialog = NULL;
}
void
@@ -1414,8 +1460,8 @@ empathy_call_window_start_ringing (EmpathyCallWindow *self,
self->priv->pending_context = g_object_ref (context);
self->priv->pending_cdo = g_object_ref (dispatch_operation);
- g_signal_connect (self->priv->pending_channel, "invalidated",
- G_CALLBACK (empathy_call_window_incoming_channel_invalidated_cb), self);
+ g_signal_connect (self->priv->pending_cdo, "invalidated",
+ G_CALLBACK (empathy_call_window_cdo_invalidated_cb), self);
empathy_call_window_set_state_ringing (self);
tp_add_dispatch_operation_context_accept (context);