]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-view.c
Respect CALL feature when clicking on the contact list's microphone icon
[empathy.git] / libempathy-gtk / empathy-contact-list-view.c
index 4aeac322d513f1a4c309a08931a331a5cc4b517d..35557f10de25bafcbc07492b6506029ba7879d40 100644 (file)
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
+#include <libtelepathy/tp-helpers.h>
+
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-log-manager.h>
+#include <libempathy/empathy-tp-group.h>
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-marshal.h>
 #include "empathy-contact-groups.h"
 #include "empathy-cell-renderer-expander.h"
 #include "empathy-cell-renderer-text.h"
+#include "empathy-cell-renderer-activatable.h"
 #include "empathy-ui-utils.h"
 #include "empathy-contact-dialogs.h"
 //#include "empathy-chat-invite.h"
 //#include "empathy-ft-window.h"
 #include "empathy-log-window.h"
+#include "empathy-gtk-enum-types.h"
 
 #define DEBUG_DOMAIN "ContactListView"
 
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewPriv))
 
-struct _EmpathyContactListViewPriv {
-       EmpathyContactListStore *store;
-       GtkUIManager            *ui;
-       GtkTreeRowReference     *drag_row;
-};
+typedef struct {
+       EmpathyContactListStore    *store;
+       GtkUIManager               *ui;
+       GtkTreeRowReference        *drag_row;
+       EmpathyContactListFeatures  features;
+} EmpathyContactListViewPriv;
 
 typedef struct {
        EmpathyContactListView *view;
@@ -133,7 +139,14 @@ static void        contact_list_view_pixbuf_cell_data_func     (GtkTreeViewColum
                                                                GtkCellRenderer            *cell,
                                                                GtkTreeModel               *model,
                                                                GtkTreeIter                *iter,
-                                                               EmpathyContactListView      *view);
+                                                               EmpathyContactListView     *view);
+#ifdef HAVE_VOIP
+static void        contact_list_view_voip_cell_data_func       (GtkTreeViewColumn          *tree_column,
+                                                               GtkCellRenderer            *cell,
+                                                               GtkTreeModel               *model,
+                                                               GtkTreeIter                *iter,
+                                                               EmpathyContactListView     *view);
+#endif
 static void        contact_list_view_avatar_cell_data_func     (GtkTreeViewColumn          *tree_column,
                                                                GtkCellRenderer            *cell,
                                                                GtkTreeModel               *model,
@@ -151,7 +164,8 @@ static void        contact_list_view_expander_cell_data_func   (GtkTreeViewColum
                                                                EmpathyContactListView      *view);
 static GtkWidget * contact_list_view_get_contact_menu          (EmpathyContactListView      *view,
                                                                gboolean                    can_send_file,
-                                                               gboolean                    can_show_log);
+                                                               gboolean                    can_show_log,
+                                                               gboolean                    can_voip);
 static gboolean    contact_list_view_button_press_event_cb     (EmpathyContactListView      *view,
                                                                GdkEventButton             *event,
                                                                gpointer                    user_data);
@@ -159,17 +173,23 @@ static void        contact_list_view_row_activated_cb          (EmpathyContactLi
                                                                GtkTreePath                *path,
                                                                GtkTreeViewColumn          *col,
                                                                gpointer                    user_data);
+#ifdef HAVE_VOIP
+static void        contact_list_view_voip_activated_cb         (EmpathyCellRendererActivatable *cell,
+                                                               const gchar                *path_string,
+                                                               EmpathyContactListView     *view);
+#endif
 static void        contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView      *view,
                                                                GtkTreeIter                *iter,
                                                                GtkTreePath                *path,
                                                                gpointer                    user_data);
 static void        contact_list_view_action_cb                 (GtkAction                  *action,
                                                                EmpathyContactListView      *view);
-static void        contact_list_view_action_activated          (EmpathyContactListView      *view,
+static void        contact_list_view_voip_activated            (EmpathyContactListView      *view,
                                                                EmpathyContact              *contact);
 
 enum {
        PROP_0,
+       PROP_FEATURES
 };
 
 static const GtkActionEntry entries[] = {
@@ -209,10 +229,16 @@ static const GtkActionEntry entries[] = {
          N_("_Send File..."), NULL, N_("Send a file"),
          G_CALLBACK (contact_list_view_action_cb)
        },
-       { "Log", GTK_STOCK_JUSTIFY_LEFT,
+       { "Log", EMPATHY_IMAGE_LOG,
          N_("_View Previous Conversations"), NULL, N_("View previous conversations with this contact"),
          G_CALLBACK (contact_list_view_action_cb)
        },
+#ifdef HAVE_VOIP
+       { "Call", EMPATHY_IMAGE_VOIP,
+         N_("_Call"), NULL, N_("Start a voice or video conversation with this contact"),
+         G_CALLBACK (contact_list_view_action_cb)
+       },
+#endif
 };
 
 static guint n_entries = G_N_ELEMENTS (entries);
@@ -221,6 +247,9 @@ static const gchar *ui_info =
        "<ui>"
        "  <popup name='Contact'>"
        "    <menuitem action='Chat'/>"
+#ifdef HAVE_VOIP
+       "    <menuitem action='Call'/>"
+#endif
        "    <menuitem action='Log'/>"
        "    <menuitem action='SendFile'/>"
        "    <separator/>"
@@ -233,6 +262,7 @@ static const gchar *ui_info =
        "  </popup>"
        "  <popup name='Group'>"
        "    <menuitem action='Rename'/>"
+       "    <menuitem action='Remove'/>"
        "  </popup>"
        "</ui>";
 
@@ -296,6 +326,15 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass)
                              G_TYPE_NONE,
                              3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING);
 
+       g_object_class_install_property (object_class,
+                                        PROP_FEATURES,
+                                        g_param_spec_flags ("features",
+                                                            "Features of the view",
+                                                            "Falgs for all enabled features",
+                                                             EMPATHY_TYPE_CONTACT_LIST_FEATURES,
+                                                             0,
+                                                             G_PARAM_READWRITE));
+
        g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv));
 }
 
@@ -377,6 +416,9 @@ contact_list_view_get_property (GObject    *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_FEATURES:
+               g_value_set_flags (value, priv->features);
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@ -389,11 +431,15 @@ contact_list_view_set_property (GObject      *object,
                                const GValue *value,
                                GParamSpec   *pspec)
 {
+       EmpathyContactListView     *view = EMPATHY_CONTACT_LIST_VIEW (object);
        EmpathyContactListViewPriv *priv;
 
        priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_FEATURES:
+               empathy_contact_list_view_set_features (view, g_value_get_flags (value));
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@ -401,20 +447,71 @@ contact_list_view_set_property (GObject      *object,
 }
 
 EmpathyContactListView *
-empathy_contact_list_view_new (EmpathyContactListStore *store)
+empathy_contact_list_view_new (EmpathyContactListStore    *store,
+                              EmpathyContactListFeatures  features)
 {
-       EmpathyContactListViewPriv *priv;
        EmpathyContactListView     *view;
+       EmpathyContactListViewPriv *priv;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL);
        
-       view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, NULL);
-       priv = GET_PRIV (view);
+       view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
+                           "features", features,
+                           NULL);
 
+       priv = GET_PRIV (view);
        priv->store = g_object_ref (store);
-       contact_list_view_setup (view);
+       contact_list_view_setup (EMPATHY_CONTACT_LIST_VIEW (view));
 
        return view;
 }
 
+void
+empathy_contact_list_view_set_features (EmpathyContactListView     *view,
+                                       EmpathyContactListFeatures  features)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
+
+       priv->features = features;
+
+       /* Update DnD source/dest */
+       if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) {
+               gtk_drag_source_set (GTK_WIDGET (view),
+                                    GDK_BUTTON1_MASK,
+                                    drag_types_source,
+                                    G_N_ELEMENTS (drag_types_source),
+                                    GDK_ACTION_MOVE | GDK_ACTION_COPY);
+       } else {
+               gtk_drag_source_unset (GTK_WIDGET (view));
+
+       }
+
+       if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) {
+               gtk_drag_dest_set (GTK_WIDGET (view),
+                                  GTK_DEST_DEFAULT_ALL,
+                                  drag_types_dest,
+                                  G_N_ELEMENTS (drag_types_dest),
+                                  GDK_ACTION_MOVE | GDK_ACTION_COPY);
+       } else {
+               /* FIXME: URI could still be  droped depending on FT feature */
+               gtk_drag_dest_unset (GTK_WIDGET (view));
+       }
+
+       g_object_notify (G_OBJECT (view), "features");
+}
+
+EmpathyContactListFeatures
+empathy_contact_list_view_get_features (EmpathyContactListView  *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE);
+
+       return priv->features;
+}
+
 EmpathyContact *
 empathy_contact_list_view_get_selected (EmpathyContactListView *view)
 {
@@ -433,7 +530,9 @@ empathy_contact_list_view_get_selected (EmpathyContactListView *view)
                return NULL;
        }
 
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        return contact;
 }
@@ -458,8 +557,8 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
        }
 
        gtk_tree_model_get (model, &iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        if (!is_group) {
@@ -470,45 +569,6 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
        return name;
 }
 
-GtkWidget *
-empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
-{
-       EmpathyContactListViewPriv *priv;
-       GtkWidget                 *widget;
-
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
-
-       priv = GET_PRIV (view);
-
-       widget = gtk_ui_manager_get_widget (priv->ui, "/Group");
-
-       return widget;
-}
-
-GtkWidget *
-empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
-                                          EmpathyContact         *contact)
-{
-       EmpathyLogManager *log_manager;
-       gboolean           can_show_log;
-       gboolean           can_send_file;
-
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
-       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
-       log_manager = empathy_log_manager_new ();
-       can_show_log = empathy_log_manager_exists (log_manager,
-                                                  empathy_contact_get_account (contact),
-                                                  empathy_contact_get_id (contact),
-                                                  FALSE);
-       can_send_file = FALSE;
-       g_object_unref (log_manager);
-
-       return contact_list_view_get_contact_menu (view,
-                                                  can_send_file,
-                                                  can_show_log);
-}
-
 static void
 contact_list_view_setup (EmpathyContactListView *view)
 {
@@ -561,11 +621,29 @@ contact_list_view_setup (EmpathyContactListView *view)
                view, NULL);
 
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "name", COL_NAME);
+                                           "name", EMPATHY_CONTACT_LIST_STORE_COL_NAME);
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "status", COL_STATUS);
+                                           "status", EMPATHY_CONTACT_LIST_STORE_COL_STATUS);
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "is_group", COL_IS_GROUP);
+                                           "is_group", EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP);
+
+#ifdef HAVE_VOIP
+       /* Voip Capability Icon */
+       cell = empathy_cell_renderer_activatable_new ();
+       gtk_tree_view_column_pack_start (col, cell, FALSE);
+       gtk_tree_view_column_set_cell_data_func (
+               col, cell,
+               (GtkTreeCellDataFunc) contact_list_view_voip_cell_data_func,
+               view, NULL);
+
+       g_object_set (cell,
+                     "visible", FALSE,
+                     NULL);
+
+       g_signal_connect (cell, "path-activated",
+                         G_CALLBACK (contact_list_view_voip_activated_cb),
+                         view);
+#endif
 
        /* Avatar */
        cell = gtk_cell_renderer_pixbuf_new ();
@@ -604,21 +682,6 @@ contact_list_view_setup (EmpathyContactListView *view)
                drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target,
                                                        FALSE);
        }
-
-       /* Note: We support the COPY action too, but need to make the
-        * MOVE action the default.
-        */
-       gtk_drag_source_set (GTK_WIDGET (view),
-                            GDK_BUTTON1_MASK,
-                            drag_types_source,
-                            G_N_ELEMENTS (drag_types_source),
-                            GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
-       gtk_drag_dest_set (GTK_WIDGET (view),
-                          GTK_DEST_DEFAULT_ALL,
-                          drag_types_dest,
-                          G_N_ELEMENTS (drag_types_dest),
-                          GDK_ACTION_MOVE | GDK_ACTION_COPY);
 }
 
 static void
@@ -627,12 +690,13 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel          *model,
                                            GtkTreeIter           *iter,
                                            EmpathyContactListView *view)
 {
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
        gboolean  is_group = FALSE;
        gchar    *name = NULL;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        if (!is_group || G_STR_EMPTY (name)) {
@@ -640,7 +704,8 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel          *model,
                return;
        }
 
-       if (empathy_contact_group_get_expanded (name)) {
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) ||
+           empathy_contact_group_get_expanded (name)) {
                g_signal_handlers_block_by_func (view,
                                                 contact_list_view_row_expand_or_collapse_cb,
                                                 GINT_TO_POINTER (TRUE));
@@ -702,7 +767,6 @@ contact_list_view_drag_data_received (GtkWidget         *widget,
                g_object_unref (account);
        }
        g_object_unref (factory);
-       g_object_unref (account);
        g_strfreev (strv);
 
        if (!contact) {
@@ -804,8 +868,7 @@ contact_list_view_drag_motion (GtkWidget      *widget,
                dm->view = EMPATHY_CONTACT_LIST_VIEW (widget);
                dm->path = gtk_tree_path_copy (path);
 
-               dm->timeout_id = g_timeout_add (
-                       1500,
+               dm->timeout_id = g_timeout_add_seconds (1,
                        (GSourceFunc) contact_list_view_drag_motion_cb,
                        dm);
        }
@@ -866,7 +929,6 @@ contact_list_view_drag_data_get (GtkWidget        *widget,
        const gchar                *contact_id;
        const gchar                *account_id;
        gchar                      *str;
-       
 
        priv = GET_PRIV (widget);
 
@@ -946,27 +1008,21 @@ contact_list_view_cell_set_background (EmpathyContactListView *view,
 
        style = gtk_widget_get_style (GTK_WIDGET (view));
 
-       if (!is_group) {
-               if (is_active) {
-                       color = style->bg[GTK_STATE_SELECTED];
-
-                       /* Here we take the current theme colour and add it to
-                        * the colour for white and average the two. This
-                        * gives a colour which is inline with the theme but
-                        * slightly whiter.
-                        */
-                       color.red = (color.red + (style->white).red) / 2;
-                       color.green = (color.green + (style->white).green) / 2;
-                       color.blue = (color.blue + (style->white).blue) / 2;
-
-                       g_object_set (cell,
-                                     "cell-background-gdk", &color,
-                                     NULL);
-               } else {
-                       g_object_set (cell,
-                                     "cell-background-gdk", NULL,
-                                     NULL);
-               }
+       if (!is_group && is_active) {
+               color = style->bg[GTK_STATE_SELECTED];
+
+               /* Here we take the current theme colour and add it to
+                * the colour for white and average the two. This
+                * gives a colour which is inline with the theme but
+                * slightly whiter.
+                */
+               color.red = (color.red + (style->white).red) / 2;
+               color.green = (color.green + (style->white).green) / 2;
+               color.blue = (color.blue + (style->white).blue) / 2;
+
+               g_object_set (cell,
+                             "cell-background-gdk", &color,
+                             NULL);
        } else {
                g_object_set (cell,
                              "cell-background-gdk", NULL,
@@ -986,9 +1042,9 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean  is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
-                           COL_ICON_STATUS, &icon_name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, &icon_name,
                            -1);
 
        g_object_set (cell,
@@ -1001,6 +1057,33 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn     *tree_column,
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
 
+#ifdef HAVE_VOIP
+static void
+contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
+                                      GtkCellRenderer        *cell,
+                                      GtkTreeModel           *model,
+                                      GtkTreeIter            *iter,
+                                      EmpathyContactListView *view)
+{
+       gboolean is_group;
+       gboolean is_active;
+       gboolean can_voip;
+
+       gtk_tree_model_get (model, iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, &can_voip,
+                           -1);
+
+       g_object_set (cell,
+                     "visible", !is_group && can_voip,
+                     "icon-name", EMPATHY_IMAGE_VOIP,
+                     NULL);
+
+       contact_list_view_cell_set_background (view, cell, is_group, is_active);
+}
+#endif
+
 static void
 contact_list_view_avatar_cell_data_func (GtkTreeViewColumn     *tree_column,
                                         GtkCellRenderer       *cell,
@@ -1014,10 +1097,10 @@ contact_list_view_avatar_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean   is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_PIXBUF_AVATAR, &pixbuf,
-                           COL_PIXBUF_AVATAR_VISIBLE, &show_avatar,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, &pixbuf,
+                           EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, &show_avatar,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
                            -1);
 
        g_object_set (cell,
@@ -1044,9 +1127,9 @@ contact_list_view_text_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean show_status;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
-                           COL_STATUS_VISIBLE, &show_status,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, &show_status,
                            -1);
 
        g_object_set (cell,
@@ -1067,8 +1150,8 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn     *column,
        gboolean is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
                            -1);
 
        if (gtk_tree_model_iter_has_child (model, iter)) {
@@ -1093,24 +1176,103 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn     *column,
 static GtkWidget *
 contact_list_view_get_contact_menu (EmpathyContactListView *view,
                                    gboolean               can_send_file,
-                                   gboolean               can_show_log)
+                                   gboolean               can_show_log,
+                                   gboolean               can_voip)
 {
-       EmpathyContactListViewPriv *priv;
-       GtkAction                 *action;
-       GtkWidget                 *widget;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkAction                  *action;
+
+       if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE))) {
+               return NULL;
+       }
 
-       priv = GET_PRIV (view);
+       /* Sort out sensitive/visible items */
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Chat");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT);
+
+#ifdef HAVE_VOIP
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call");
+       gtk_action_set_sensitive (action, can_voip);
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL);
+#endif
 
-       /* Sort out sensitive items */
        action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log");
        gtk_action_set_sensitive (action, can_show_log);
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG);
+
 
        action = gtk_ui_manager_get_action (priv->ui, "/Contact/SendFile");
-       gtk_action_set_visible (action, can_send_file);
+       gtk_action_set_visible (action, can_send_file && (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT));
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Invite");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE);
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Edit");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT);
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Information");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO);
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Remove");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE);
+
+       return gtk_ui_manager_get_widget (priv->ui, "/Contact");
+}
+
+GtkWidget *
+empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkAction                  *action;
 
-       widget = gtk_ui_manager_get_widget (priv->ui, "/Contact");
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
+
+       if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME |
+                               EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) {
+               return NULL;
+       }
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Group/Rename");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME);
+
+       action = gtk_ui_manager_get_action (priv->ui, "/Group/Remove");
+       gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE);
+
+       return gtk_ui_manager_get_widget (priv->ui, "/Group");
+}
+
+GtkWidget *
+empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
+                                           EmpathyContact         *contact)
+{
+       EmpathyLogManager *log_manager;
+       gboolean           can_show_log;
+       gboolean           can_send_file;
+       gboolean           can_voip;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
+       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+       log_manager = empathy_log_manager_new ();
+       can_show_log = empathy_log_manager_exists (log_manager,
+                                                  empathy_contact_get_account (contact),
+                                                  empathy_contact_get_id (contact),
+                                                  FALSE);
+       g_object_unref (log_manager);
+       can_send_file = FALSE;
+       can_voip = empathy_contact_can_voip (contact);
 
-       return widget;
+       return contact_list_view_get_contact_menu (view,
+                                                  can_send_file,
+                                                  can_show_log,
+                                                  can_voip);
 }
 
 static gboolean
@@ -1127,12 +1289,12 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
        gboolean                   row_exists;
        GtkWidget                 *menu;
 
+       priv = GET_PRIV (view);
+
        if (event->button != 3) {
                return FALSE;
        }
 
-       priv = GET_PRIV (view);
-
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
@@ -1152,7 +1314,9 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
        gtk_tree_model_get_iter (model, &iter, path);
        gtk_tree_path_free (path);
 
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        if (contact) {
                menu = empathy_contact_list_view_get_contact_menu (view, contact);
@@ -1176,39 +1340,83 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
 
 static void
 contact_list_view_row_activated_cb (EmpathyContactListView *view,
-                                   GtkTreePath           *path,
-                                   GtkTreeViewColumn     *col,
-                                   gpointer               user_data)
+                                   GtkTreePath            *path,
+                                   GtkTreeViewColumn      *col,
+                                   gpointer                user_data)
 {
-       EmpathyContact *contact;
-       GtkTreeModel  *model;
-       GtkTreeIter    iter;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       EmpathyContact             *contact;
+       GtkTreeModel               *model;
+       GtkTreeIter                 iter;
+
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT)) {
+               return;
+       }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
        gtk_tree_model_get_iter (model, &iter, path);
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        if (contact) {
-               contact_list_view_action_activated (view, contact);
+               empathy_chat_with_contact (contact);
                g_object_unref (contact);
        }
 }
 
+#ifdef HAVE_VOIP
+static void
+contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
+                                    const gchar                    *path_string,
+                                    EmpathyContactListView         *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkTreeModel               *model;
+       GtkTreeIter                 iter;
+       EmpathyContact             *contact;
+
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL)) {
+               return;
+       }
+
+       model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+       if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string)) {
+               return;
+       }
+
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
+
+       if (contact) {
+               contact_list_view_voip_activated (view, contact);
+               g_object_unref (contact);
+       }
+}
+#endif
+
+
 static void
 contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view,
                                             GtkTreeIter           *iter,
                                             GtkTreePath           *path,
                                             gpointer               user_data)
 {
-       GtkTreeModel *model;
-       gchar        *name;
-       gboolean      expanded;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkTreeModel               *model;
+       gchar                      *name;
+       gboolean                    expanded;
+
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) {
+               return;
+       }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
        gtk_tree_model_get (model, iter,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        expanded = GPOINTER_TO_INT (user_data);
@@ -1241,13 +1449,16 @@ contact_list_view_action_cb (GtkAction             *action,
        parent = empathy_get_toplevel_window (GTK_WIDGET (view));
 
        if (contact && strcmp (name, "Chat") == 0) {
-               contact_list_view_action_activated (view, contact);
+               empathy_chat_with_contact (contact);
+       }
+       else if (contact && strcmp (name, "Call") == 0) {
+               contact_list_view_voip_activated (view, contact);
        }
        else if (contact && strcmp (name, "Information") == 0) {
-               empathy_contact_information_dialog_show (contact, parent, FALSE);
+               empathy_contact_information_dialog_show (contact, parent, FALSE, FALSE);
        }
        else if (contact && strcmp (name, "Edit") == 0) {
-               empathy_contact_information_dialog_show (contact, parent, TRUE);
+               empathy_contact_information_dialog_show (contact, parent, TRUE, FALSE);
        }
        else if (contact && strcmp (name, "Remove") == 0) {
                /* FIXME: Ask for confirmation */
@@ -1269,6 +1480,12 @@ contact_list_view_action_cb (GtkAction             *action,
        }
        else if (group && strcmp (name, "Rename") == 0) {
        }
+       else if (group && strcmp (name, "Remove") == 0) {
+               EmpathyContactList *list;
+
+               list = empathy_contact_list_store_get_list_iface (priv->store);
+               empathy_contact_list_remove_group (list, group);
+       }
 
        g_free (group);
        if (contact) {
@@ -1277,18 +1494,9 @@ contact_list_view_action_cb (GtkAction             *action,
 }
 
 static void
-contact_list_view_action_activated (EmpathyContactListView *view,
-                                   EmpathyContact         *contact)
+contact_list_view_voip_activated (EmpathyContactListView *view,
+                                 EmpathyContact         *contact)
 {
-       MissionControl *mc;
-
-       mc = empathy_mission_control_new ();
-       mission_control_request_channel (mc,
-                                        empathy_contact_get_account (contact),
-                                        TP_IFACE_CHANNEL_TYPE_TEXT,
-                                        empathy_contact_get_handle (contact),
-                                        TP_HANDLE_TYPE_CONTACT,
-                                        NULL, NULL);
-       g_object_unref (mc);
+       empathy_call_contact (contact);
 }