#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-tp-call.h>
+#include <libempathy/empathy-tp-group.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
-typedef struct
+typedef struct
{
EmpathyTpCall *call;
GTimeVal start_time;
GtkWidget *video_button;
GtkWidget *hang_up_button;
GtkWidget *confirmation_dialog;
+ GtkWidget *keypad_expander;
} EmpathyCallWindow;
+static GSList *windows = NULL;
+
static gboolean
call_window_update_timer (gpointer data)
{
gtk_widget_set_sensitive (window->video_button, FALSE);
gtk_widget_set_sensitive (window->output_volume_button, FALSE);
gtk_widget_set_sensitive (window->input_volume_button, FALSE);
+ gtk_widget_set_sensitive (window->keypad_expander, FALSE);
if (window->call)
{
EmpathyCallWindow *window)
{
call_window_finalize (window);
+
g_object_unref (window->output_video_socket);
g_object_unref (window->preview_video_socket);
+
+ windows = g_slist_remove (windows, window);
g_slice_free (EmpathyCallWindow, window);
}
"is-incoming: %d video-stream direction: %d",
window->status, stream_state, is_incoming, video_stream->direction);
+ if (empathy_tp_call_has_dtmf (window->call))
+ {
+ gtk_widget_show (window->keypad_expander);
+ }
+ else
+ {
+ gtk_widget_hide (window->keypad_expander);
+ }
+
/* Depending on the status we have to set:
* - window's title
* - status's label
if (window->status == EMPATHY_TP_CALL_STATUS_READYING)
{
gtk_window_set_title (GTK_WINDOW (window->window), _("Empathy Call"));
+ /* To translators: Readying is the first state of the call, it is
+ * preparing the connection and it does not yet ring. */
gtk_label_set_text (GTK_LABEL (window->status_label), _("Readying"));
gtk_widget_set_sensitive (window->video_button, FALSE);
gtk_widget_set_sensitive (window->output_volume_button, FALSE);
gtk_widget_set_sensitive (window->input_volume_button, FALSE);
gtk_widget_set_sensitive (window->hang_up_button, FALSE);
+ gtk_widget_set_sensitive (window->keypad_expander, FALSE);
}
else if (window->status == EMPATHY_TP_CALL_STATUS_PENDING)
{
gtk_widget_set_sensitive (window->output_volume_button, TRUE);
gtk_widget_set_sensitive (window->input_volume_button, TRUE);
gtk_widget_set_sensitive (window->hang_up_button, TRUE);
+ gtk_widget_set_sensitive (window->keypad_expander, TRUE);
}
else if (window->status == EMPATHY_TP_CALL_STATUS_CLOSED)
call_window_finalize (window);
}
GtkWidget *
-empathy_call_window_new (EmpathyTpCall *call)
+empathy_call_window_new (TpChannel *channel)
{
EmpathyCallWindow *window;
GladeXML *glade;
gchar *filename;
const gchar *icons[] = {"audio-input-microphone", NULL};
- g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), NULL);
+ g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
+
+ if (windows)
+ {
+ window = (EmpathyCallWindow*) windows->data;
+ if (!window->call)
+ {
+ window->call = empathy_tp_call_new (channel);
+ g_signal_connect_swapped (G_OBJECT (window->call), "notify",
+ G_CALLBACK (call_window_update), window);
+ call_window_update (window);
+
+ if (GTK_WIDGET_REALIZED (GTK_WIDGET (window->preview_video_socket)))
+ {
+ call_window_socket_realized_cb (window->preview_video_socket,
+ window);
+ }
+ }
+ else
+ {
+ GtkWidget *dialog;
+ EmpathyContact *contact;
+ EmpathyTpGroup *tp_group;
+
+ tp_group = empathy_tp_group_new (channel);
+ empathy_run_until_ready (tp_group);
+ empathy_tp_group_get_invitation (tp_group, &contact);
+ empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_NAME,
+ NULL);
+
+ /* We don't want to have multiple calls running.
+ * FIXME: We should use the hold interface... */
+ tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);
+
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ _("Incoming call from %s rejected because there is already a"
+ " running call."), empathy_contact_get_name (contact));
+
+ g_object_unref (contact);
+ g_object_unref (tp_group);
+
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_widget_show (dialog);
+ }
+
+ gtk_window_present (GTK_WINDOW (window->window));
+ return window->window;
+ }
window = g_slice_new0 (EmpathyCallWindow);
- window->call = g_object_ref (call);
+ windows = g_slist_prepend (windows, window);
+ window->call = empathy_tp_call_new (channel);
filename = empathy_file_lookup ("empathy-call-window.glade", "src");
glade = empathy_glade_get_file (filename,
"status_label", &window->status_label,
"video_button", &window->video_button,
"hang_up_button", &window->hang_up_button,
+ "keypad_expander", &window->keypad_expander,
NULL);
g_free (filename);