]> git.0d.be Git - empathy.git/commitdiff
Added functions to determine if a contact has video capabilities
authorJonathan Tellier <jonathan.tellier@gmail.com>
Thu, 2 Jul 2009 16:08:43 +0000 (12:08 -0400)
committerjtellier <jonathan.tellier@collabora.co.uk>
Thu, 2 Jul 2009 16:08:43 +0000 (12:08 -0400)
Activating the "Video Call" button only if the remote contact support
video.
The call window's "Send Video" is only sensitive if the contact has
video capabilities.

libempathy-gtk/empathy-contact-menu.c
libempathy/empathy-contact.c
libempathy/empathy-contact.h
src/empathy-call-window.c

index 2bad5c9fe4baaee812c5d0e73744defc68a54741..0f98bbdce62398e5c3dd3a927718202dd0350af5 100644 (file)
@@ -167,7 +167,7 @@ empathy_contact_audio_call_menu_item_new (EmpathyContact *contact)
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-       gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_voip_audio (contact));
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
@@ -199,7 +199,7 @@ empathy_contact_video_call_menu_item_new (EmpathyContact *contact)
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VIDEO_CALL,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VIDEO_CALL,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-       gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_voip_video (contact));
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
index d351aecbc53e9d2b5a619b79a0c06fb6a38592ce..c82ecd46714a2580715430107dfeea1348b331b2 100644 (file)
@@ -801,6 +801,30 @@ empathy_contact_can_voip (EmpathyContact *contact)
       EMPATHY_CAPABILITIES_VIDEO);
 }
 
       EMPATHY_CAPABILITIES_VIDEO);
 }
 
+gboolean
+empathy_contact_can_voip_audio (EmpathyContact *contact)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+  priv = GET_PRIV (contact);
+
+  return priv->capabilities & EMPATHY_CAPABILITIES_AUDIO;
+}
+
+gboolean
+empathy_contact_can_voip_video (EmpathyContact *contact)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+  priv = GET_PRIV (contact);
+
+  return priv->capabilities & EMPATHY_CAPABILITIES_VIDEO;
+}
+
 gboolean
 empathy_contact_can_send_files (EmpathyContact *contact)
 {
 gboolean
 empathy_contact_can_send_files (EmpathyContact *contact)
 {
index d4e3859248f08affb745262356b7bb71274ee17f..4e9c98756cc18e52d4c09afb55d94e4d2b5c67e5 100644 (file)
@@ -99,6 +99,8 @@ void empathy_contact_set_is_user (EmpathyContact *contact,
 gboolean empathy_contact_is_online (EmpathyContact *contact);
 const gchar * empathy_contact_get_status (EmpathyContact *contact);
 gboolean empathy_contact_can_voip (EmpathyContact *contact);
 gboolean empathy_contact_is_online (EmpathyContact *contact);
 const gchar * empathy_contact_get_status (EmpathyContact *contact);
 gboolean empathy_contact_can_voip (EmpathyContact *contact);
+gboolean empathy_contact_can_voip_audio (EmpathyContact *contact);
+gboolean empathy_contact_can_voip_video (EmpathyContact *contact);
 gboolean empathy_contact_can_send_files (EmpathyContact *contact);
 gboolean empathy_contact_can_use_stream_tube (EmpathyContact *contact);
 guint empathy_contact_hash (gconstpointer key);
 gboolean empathy_contact_can_send_files (EmpathyContact *contact);
 gboolean empathy_contact_can_use_stream_tube (EmpathyContact *contact);
 guint empathy_contact_hash (gconstpointer key);
index a71e9c8bebdaf2d27c6ce4119043bb8be77d775a..520a928215a6707bde1648d1e3771a5fca852195 100644 (file)
@@ -809,7 +809,6 @@ static void
 init_contact_avatar_with_size (EmpathyContact *contact, GtkWidget *image_widget,
     gint size)
 {
 init_contact_avatar_with_size (EmpathyContact *contact, GtkWidget *image_widget,
     gint size)
 {
-
   GdkPixbuf *pixbuf_avatar = NULL;
 
   if (contact != NULL)
   GdkPixbuf *pixbuf_avatar = NULL;
 
   if (contact != NULL)
@@ -1347,6 +1346,8 @@ empathy_call_window_connected (gpointer user_data)
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   EmpathyTpCall *call;
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   EmpathyTpCall *call;
+  gboolean can_send_video = priv->video_input != NULL && priv->contact != NULL
+    && empathy_contact_can_voip_video (priv->contact);
 
   g_object_get (priv->handler, "tp-call", &call, NULL);
 
 
   g_object_get (priv->handler, "tp-call", &call, NULL);
 
@@ -1357,9 +1358,10 @@ empathy_call_window_connected (gpointer user_data)
     gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
 
   if (priv->video_input == NULL)
     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, FALSE);
 
 
-  priv->sending_video = empathy_tp_call_is_sending_video (call);
+  priv->sending_video = can_send_video ?
+    empathy_tp_call_is_sending_video (call) : FALSE;
 
   gtk_action_set_sensitive (priv->show_preview, TRUE);
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (priv->show_preview),
 
   gtk_action_set_sensitive (priv->show_preview, TRUE);
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (priv->show_preview),
@@ -1370,8 +1372,8 @@ empathy_call_window_connected (gpointer user_data)
   gtk_toggle_tool_button_set_active (
       GTK_TOGGLE_TOOL_BUTTON (priv->camera_button),
       priv->sending_video && priv->video_input != NULL);
   gtk_toggle_tool_button_set_active (
       GTK_TOGGLE_TOOL_BUTTON (priv->camera_button),
       priv->sending_video && priv->video_input != NULL);
-  gtk_widget_set_sensitive (priv->camera_button, priv->video_input != NULL);
-  gtk_action_set_sensitive (priv->send_video, priv->video_input != NULL);
+  gtk_widget_set_sensitive (priv->camera_button, can_send_video);
+  gtk_action_set_sensitive (priv->send_video, can_send_video);
 
   gtk_action_set_sensitive (priv->redial, FALSE);
   gtk_widget_set_sensitive (priv->redial_button, FALSE);
 
   gtk_action_set_sensitive (priv->redial, FALSE);
   gtk_widget_set_sensitive (priv->redial_button, FALSE);