#define NOTIFICATION_TIMEOUT 2 /* seconds */
+#define ACCEPT_WITHOUT_VIDEO 1
+
/* The time interval in milliseconds between 2 incoming rings */
#define MS_BETWEEN_RING 500
event->public.header = g_strdup (header);
event->public.message = g_strdup (message);
event->public.must_ack = (func != NULL);
+ if (approval != NULL)
+ event->public.handler_instance = approval->handler_instance;
event->inhibit = FALSE;
event->func = func;
event->user_data = user_data;
g_object_unref (user_data);
}
-static void
-reject_auth_channel_claim_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- TpChannelDispatchOperation *cdo = TP_CHANNEL_DISPATCH_OPERATION (source);
- GError *error = NULL;
-
- if (!tp_channel_dispatch_operation_claim_with_finish (cdo, result, &error))
- {
- DEBUG ("Failed to claim channel: %s", error->message);
-
- g_error_free (error);
- return;
- }
-
- tp_cli_channel_call_close (TP_CHANNEL (user_data), -1,
- NULL, NULL, NULL, NULL);
-}
-
static void
reject_approval (EventManagerApproval *approval)
{
else if (tp_channel_get_channel_type_id (approval->main_channel)
== TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION)
{
- tp_channel_dispatch_operation_claim_with_async (approval->operation,
- priv->auth_approver, reject_auth_channel_claim_cb,
- approval->main_channel);
+ tp_channel_dispatch_operation_close_channels_async (approval->operation,
+ NULL, NULL);
}
}
gtk_widget_destroy (approval->dialog);
approval->dialog = NULL;
- if (response != GTK_RESPONSE_ACCEPT)
+ if (response == GTK_RESPONSE_ACCEPT)
{
- reject_approval (approval);
+ event_manager_approval_approve (approval);
}
- else
+ else if (response == ACCEPT_WITHOUT_VIDEO)
{
+ tpy_call_channel_send_video (TPY_CALL_CHANNEL (approval->main_channel),
+ FALSE);
event_manager_approval_approve (approval);
}
+ else
+ {
+ reject_approval (approval);
+ }
}
static void
GtkWidget *image;
gboolean video;
gchar *title;
+ EmpathyEventType etype = event->public.type;
if (event->approval->dialog != NULL)
{
return;
}
- if (event->public.type == EMPATHY_EVENT_TYPE_VOIP)
+ 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 (event->public.type == EMPATHY_EVENT_TYPE_CALL)
+ else if (etype == EMPATHY_EVENT_TYPE_CALL)
{
TpyCallChannel *call;
call = TPY_CALL_CHANNEL (event->approval->handler_instance);
GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button), image);
+ if (video && etype == EMPATHY_EVENT_TYPE_CALL)
+ {
+ button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Answer"), ACCEPT_WITHOUT_VIDEO);
+
+ image = gtk_image_new_from_icon_name ("call-start",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+ }
+
button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Answer"), GTK_RESPONSE_ACCEPT);
+ video ? _("_Answer with video") : _("_Answer"), GTK_RESPONSE_ACCEPT);
- image = gtk_image_new_from_icon_name ("call-start", GTK_ICON_SIZE_BUTTON);
+ image = gtk_image_new_from_icon_name ("call-start",
+ GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button), image);
g_signal_connect (dialog, "response",
- G_CALLBACK (event_manager_call_window_confirmation_dialog_response_cb),
- event->approval);
+ G_CALLBACK (event_manager_call_window_confirmation_dialog_response_cb),
+ event->approval);
gtk_widget_show (dialog);
event_manager_approval_done (approval);
}
+static void
+event_manager_call_state_changed_cb (TpyCallChannel *call,
+ TpyCallState state,
+ TpyCallFlags flags,
+ const GValueArray *call_state_reason,
+ GHashTable *call_state_details,
+ EventManagerApproval *approval)
+{
+ if (state == TPY_CALL_STATE_ENDED)
+ {
+ DEBUG ("Call ended, seems we missed it :/");
+ reject_approval (approval);
+ }
+}
+
static void
event_manager_call_channel_got_contact_cb (TpConnection *connection,
EmpathyContact *contact,
gchar *header;
gboolean video;
+ call = TPY_CALL_CHANNEL (approval->handler_instance);
+
if (error != NULL)
{
DEBUG ("Can't get the contact for the call.. Rejecting?");
return;
}
+ if (tpy_call_channel_get_state (call, NULL, NULL) == TPY_CALL_STATE_ENDED)
+ {
+ DEBUG ("Call already ended, seems we missed it :/");
+ reject_approval (approval);
+ return;
+ }
+
+ approval->handler = g_signal_connect (call, "state-changed",
+ G_CALLBACK (event_manager_call_state_changed_cb), approval);
+
window = empathy_main_window_dup ();
approval->contact = g_object_ref (contact);
- call = TPY_CALL_CHANNEL (approval->handler_instance);
-
g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
header = g_strdup_printf (
TpyCallChannel *call = TPY_CALL_CHANNEL (channel);
const gchar *id;
- approval->handler_instance = G_OBJECT (call);
+ approval->handler_instance = g_object_ref (call);
id = tp_channel_get_identifier (channel);
handle = tp_channel_get_handle (channel, NULL);
- connection = tp_channel_borrow_connection (channel);
empathy_tp_contact_factory_get_from_handle (connection, handle,
event_manager_ft_got_contact_cb, approval, NULL, G_OBJECT (self));
}