diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-09-07 22:54:29 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-09-08 19:26:25 +0800 |
commit | ee02c5c89132db72e5cd987cd443cd09202b6f5b (patch) | |
tree | 183b2e2e378e63ba453f2ef8ff756a0b2ffa840e /src/empathy-call-window.c | |
parent | d5136f90339362d53d780700808dc055fc0a7121 (diff) | |
download | gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar.gz gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar.bz2 gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar.lz gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar.xz gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.tar.zst gsoc2013-empathy-ee02c5c89132db72e5cd987cd443cd09202b6f5b.zip |
Let the existing call window know about new 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.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index af06b6251..81bee0596 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -43,6 +43,7 @@ #include <libempathy/empathy-camera-monitor.h> #include <libempathy/empathy-gsettings.h> #include <libempathy/empathy-tp-contact-factory.h> +#include <libempathy/empathy-request-util.h> #include <libempathy/empathy-utils.h> #include <libempathy-gtk/empathy-avatar-image.h> @@ -103,6 +104,7 @@ enum { }; typedef enum { + RINGING, CONNECTING, CONNECTED, HELD, @@ -184,6 +186,12 @@ struct _EmpathyCallWindowPriv easilly repack everything when toggling fullscreen */ GtkWidget *content_hbox; + /* These are used to accept or reject an incoming call when the status + is RINGING. */ + TpyCallChannel *pending_channel; + TpChannelDispatchOperation *pending_cdo; + TpAddDispatchOperationContext *pending_context; + gulong video_output_motion_handler_id; guint bus_message_source_id; @@ -1360,6 +1368,60 @@ empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage, } static void +empathy_call_window_set_state_ringing (EmpathyCallWindow *self) +{ + g_assert (self->priv->call_state != CONNECTED); + + 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; +} + +static void +empathy_call_window_incoming_channel_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); +} + +void +empathy_call_window_start_ringing (EmpathyCallWindow *self, + TpyCallChannel *channel, + TpChannelDispatchOperation *dispatch_operation, + TpAddDispatchOperationContext *context) +{ + g_assert (self->priv->pending_channel == NULL); + g_assert (self->priv->pending_context == NULL); + g_assert (self->priv->pending_cdo == NULL); + + /* Start ringing and delay until the user answers or hangs. */ + self->priv->pending_channel = g_object_ref (channel); + 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); + + empathy_call_window_set_state_ringing (self); + tp_add_dispatch_operation_context_accept (context); +} + +static void empathy_call_window_init (EmpathyCallWindow *self) { EmpathyCallWindowPriv *priv; |