diff options
-rw-r--r-- | libempathy-gtk/empathy-location-manager.c | 2 | ||||
-rw-r--r-- | libempathy/empathy-dispatch-operation.c | 41 | ||||
-rw-r--r-- | libempathy/empathy-tp-call.c | 8 | ||||
-rw-r--r-- | libempathy/empathy-tp-call.h | 2 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 49 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 3 | ||||
-rw-r--r-- | src/empathy-call-window.c | 42 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 15 | ||||
-rw-r--r-- | src/empathy.c | 7 |
9 files changed, 135 insertions, 34 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c index 0a9d4dcf7..f4f1e0ae3 100644 --- a/libempathy-gtk/empathy-location-manager.c +++ b/libempathy-gtk/empathy-location-manager.c @@ -520,7 +520,7 @@ update_resources (EmpathyLocationManager *self) * being found as geoclue-manual report an empty address with * accuracy = NONE */ if (!geoclue_master_client_set_requirements (priv->gc_client, - GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, TRUE, priv->resources, + GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, FALSE, priv->resources, NULL)) { DEBUG ("set_requirements failed"); diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c index f6cc0d6ef..78438125b 100644 --- a/libempathy/empathy-dispatch-operation.c +++ b/libempathy/empathy-dispatch-operation.c @@ -433,6 +433,18 @@ empathy_dispatch_operation_set_status (EmpathyDispatchOperation *self, } static void +channel_wrapper_ready (EmpathyDispatchOperation *self) +{ + EmpathyDispatchOperationPriv *priv = GET_PRIV (self); + + g_signal_handler_disconnect (priv->channel_wrapper, priv->ready_handler); + priv->ready_handler = 0; + + empathy_dispatch_operation_set_status (self, + EMPATHY_DISPATCHER_OPERATION_STATE_PENDING); +} + +static void empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object, GParamSpec *spec, gpointer user_data) { @@ -442,11 +454,18 @@ empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object, if (!empathy_tp_chat_is_ready (EMPATHY_TP_CHAT (priv->channel_wrapper))) return; - g_signal_handler_disconnect (priv->channel_wrapper, priv->ready_handler); - priv->ready_handler = 0; + channel_wrapper_ready (self); +} - empathy_dispatch_operation_set_status (self, - EMPATHY_DISPATCHER_OPERATION_STATE_PENDING); +static void +call_status_changed_cb (EmpathyTpCall *call, + GParamSpec *spec, + EmpathyDispatchOperation *self) +{ + if (empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) + return; + + channel_wrapper_ready (self); } static void @@ -487,8 +506,22 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) { + gboolean requested; EmpathyTpCall *call = empathy_tp_call_new (channel); priv->channel_wrapper = G_OBJECT (call); + + requested = tp_asv_get_boolean (tp_channel_borrow_immutable_properties ( + channel), TP_PROP_CHANNEL_REQUESTED, NULL); + + if (!requested && + empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING) + { + /* For incoming calls, we have to wait that the TpCall is ready as + * the call-handler rely on it. */ + priv->ready_handler = g_signal_connect (call, + "notify::status", G_CALLBACK (call_status_changed_cb), self); + goto out; + } } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) { diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 78ee6d005..3aae89fce 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -854,3 +854,11 @@ empathy_tp_call_leave (EmpathyTpCall *self) tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, &array, "", leave_remove_members_cb, self, NULL, G_OBJECT (self)); } + +EmpathyTpCallStatus +empathy_tp_call_get_status (EmpathyTpCall *self) +{ + EmpathyTpCallPriv *priv = GET_PRIV (self); + + return priv->status; +} diff --git a/libempathy/empathy-tp-call.h b/libempathy/empathy-tp-call.h index ed3ae0d9f..ff51055e7 100644 --- a/libempathy/empathy-tp-call.h +++ b/libempathy/empathy-tp-call.h @@ -94,6 +94,8 @@ gboolean empathy_tp_call_has_initial_video (EmpathyTpCall *self); void empathy_tp_call_leave (EmpathyTpCall *self); +EmpathyTpCallStatus empathy_tp_call_get_status (EmpathyTpCall *self); + G_END_DECLS #endif /* __EMPATHY_TP_CALL_H__ */ diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index daf24a36a..858cfae27 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1834,3 +1834,52 @@ empathy_tp_chat_leave (EmpathyTpChat *self) g_array_free (array, TRUE); } + +static void +add_members_cb (TpChannel *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpChatPriv *priv = GET_PRIV (weak_object); + + if (error != NULL) { + DEBUG ("Failed to join chat (%s): %s", + tp_channel_get_identifier (priv->channel), error->message); + } +} + +void +empathy_tp_chat_join (EmpathyTpChat *self) +{ + EmpathyTpChatPriv *priv = GET_PRIV (self); + TpHandle self_handle; + GArray *members; + + self_handle = tp_channel_group_get_self_handle (priv->channel); + + members = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); + g_array_append_val (members, self_handle); + + tp_cli_channel_interface_group_call_add_members (priv->channel, -1, members, + "", add_members_cb, NULL, NULL, G_OBJECT (self)); + + g_array_free (members, TRUE); +} + +gboolean +empathy_tp_chat_is_invited (EmpathyTpChat *self) +{ + EmpathyTpChatPriv *priv = GET_PRIV (self); + TpHandle self_handle; + + if (!tp_proxy_has_interface (priv->channel, TP_IFACE_CHANNEL_INTERFACE_GROUP)) + return FALSE; + + self_handle = tp_channel_group_get_self_handle (priv->channel); + if (self_handle == 0) + return FALSE; + + return tp_channel_group_get_local_pending_info (priv->channel, self_handle, + NULL, NULL, NULL); +} diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index fd9724037..e5abe936f 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -99,6 +99,9 @@ gboolean empathy_tp_chat_provide_password_finish (EmpathyTpChat *chat, gboolean empathy_tp_chat_can_add_contact (EmpathyTpChat *self); void empathy_tp_chat_leave (EmpathyTpChat *chat); +void empathy_tp_chat_join (EmpathyTpChat *chat); + +gboolean empathy_tp_chat_is_invited (EmpathyTpChat *chat); G_END_DECLS diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 40c461488..5fd232bc6 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -224,7 +224,7 @@ static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle, EmpathyCallWindow *window); static void empathy_call_window_set_send_video (EmpathyCallWindow *window, - gboolean send); + CameraState state); static void empathy_call_window_mic_toggled_cb ( GtkToggleToolButton *toggle, EmpathyCallWindow *window); @@ -810,7 +810,7 @@ disable_camera (EmpathyCallWindow *self) display_video_preview (self, FALSE); if (priv->camera_state == CAMERA_STATE_ON) - empathy_call_window_set_send_video (self, FALSE); + empathy_call_window_set_send_video (self, CAMERA_STATE_OFF); block_camera_control_signals (self); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON ( @@ -860,10 +860,14 @@ enable_preview (EmpathyCallWindow *self) DEBUG ("Enable preview"); if (priv->camera_state == CAMERA_STATE_ON) - /* preview is already displayed so we just have to stop sending */ - empathy_call_window_set_send_video (self, FALSE); - - display_video_preview (self, TRUE); + { + /* preview is already displayed so we just have to stop sending */ + empathy_call_window_set_send_video (self, CAMERA_STATE_PREVIEW); + } + else + { + display_video_preview (self, TRUE); + } block_camera_control_signals (self); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON ( @@ -919,7 +923,7 @@ enable_camera (EmpathyCallWindow *self) DEBUG ("Enable camera"); - empathy_call_window_set_send_video (self, TRUE); + empathy_call_window_set_send_video (self, CAMERA_STATE_ON); block_camera_control_signals (self); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON ( @@ -2175,7 +2179,7 @@ empathy_call_window_connected (gpointer user_data) gtk_widget_set_sensitive (priv->dtmf_panel, TRUE); if (priv->video_input == NULL) - empathy_call_window_set_send_video (self, FALSE); + empathy_call_window_set_send_video (self, CAMERA_STATE_OFF); priv->sending_video = can_send_video ? empathy_tp_call_is_sending_video (call) : FALSE; @@ -2717,23 +2721,31 @@ empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle, static void empathy_call_window_set_send_video (EmpathyCallWindow *window, - gboolean send) + CameraState state) { EmpathyCallWindowPriv *priv = GET_PRIV (window); EmpathyTpCall *call; - priv->sending_video = send; + priv->sending_video = (state == CAMERA_STATE_ON); - /* When we start sending video, we want to show the video preview by - default. */ - display_video_preview (window, send); + if (state == CAMERA_STATE_PREVIEW || + state == CAMERA_STATE_ON) + { + /* When we start sending video, we want to show the video preview by + default. */ + display_video_preview (window, TRUE); + } + else + { + display_video_preview (window, FALSE); + } if (priv->call_state != CONNECTED) return; g_object_get (priv->handler, "tp-call", &call, NULL); - DEBUG ("%s sending video", send ? "start": "stop"); - empathy_tp_call_request_video_stream_direction (call, send); + DEBUG ("%s sending video", priv->sending_video ? "start": "stop"); + empathy_tp_call_request_video_stream_direction (call, priv->sending_video); g_object_unref (call); } diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 08f490966..2f269f573 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -536,9 +536,6 @@ invite_dialog_response_cb (GtkDialog *dialog, EventManagerApproval *approval) { EmpathyTpChat *tp_chat; - TpChannel *channel; - TpHandle self_handle; - GArray *members; gint64 timestamp; gtk_widget_destroy (GTK_WIDGET (approval->dialog)); @@ -559,15 +556,7 @@ invite_dialog_response_cb (GtkDialog *dialog, DEBUG ("Muc invitation accepted"); - /* join the room */ - channel = empathy_tp_chat_get_channel (tp_chat); - - self_handle = tp_channel_group_get_self_handle (channel); - members = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); - g_array_append_val (members, self_handle); - - tp_cli_channel_interface_group_call_add_members (channel, -1, members, - "", NULL, NULL, NULL, NULL); + /* We'll join the room when handling the channel */ timestamp = gtk_get_current_event_time (); if (timestamp == GDK_CURRENT_TIME) @@ -576,8 +565,6 @@ invite_dialog_response_cb (GtkDialog *dialog, empathy_dispatch_operation_set_user_action_time (approval->operation, timestamp); empathy_dispatch_operation_approve (approval->operation); - - g_array_free (members, TRUE); } static void diff --git a/src/empathy.c b/src/empathy.c index 5dcf035e3..9d59bba79 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -136,6 +136,13 @@ dispatch_cb (EmpathyDispatcher *dispatcher, empathy_chat_window_present_chat (chat, empathy_dispatch_operation_get_user_action_time (operation)); + if (empathy_tp_chat_is_invited (tp_chat)) + { + /* We have been invited to the room. Add ourself as member as this + * channel has been approved. */ + empathy_tp_chat_join (tp_chat); + } + empathy_dispatch_operation_claim (operation); } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) |