]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-view.c
More flexible API for EmpathyContactWidget, we now have flags to set
[empathy.git] / libempathy-gtk / empathy-contact-list-view.c
index c959eec01eaae5de9b6a87c8950dad853112a4f7..e3816dda7ba8a5159db5e410e0de02531935940b 100644 (file)
@@ -139,11 +139,13 @@ static void        contact_list_view_pixbuf_cell_data_func     (GtkTreeViewColum
                                                                GtkTreeModel               *model,
                                                                GtkTreeIter                *iter,
                                                                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,
@@ -170,9 +172,11 @@ 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,
@@ -230,10 +234,12 @@ static const GtkActionEntry entries[] = {
          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);
@@ -242,7 +248,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/>"
@@ -629,6 +637,7 @@ contact_list_view_setup (EmpathyContactListView *view)
        gtk_tree_view_column_add_attribute (col, cell,
                                            "is_group", COL_IS_GROUP);
 
+#ifdef HAVE_VOIP
        /* Voip Capability Icon */
        cell = empathy_cell_renderer_activatable_new ();
        gtk_tree_view_column_pack_start (col, cell, FALSE);
@@ -644,6 +653,7 @@ contact_list_view_setup (EmpathyContactListView *view)
        g_signal_connect (cell, "path-activated",
                          G_CALLBACK (contact_list_view_voip_activated_cb),
                          view);
+#endif
 
        /* Avatar */
        cell = gtk_cell_renderer_pixbuf_new ();
@@ -1078,6 +1088,7 @@ 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,
@@ -1102,6 +1113,7 @@ contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
 
        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,
@@ -1208,8 +1220,10 @@ contact_list_view_get_contact_menu (EmpathyContactListView *view,
        action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log");
        gtk_action_set_sensitive (action, can_show_log);
 
+#ifdef HAVE_VOIP
        action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call");
        gtk_action_set_sensitive (action, can_voip);
+#endif
 
        action = gtk_ui_manager_get_action (priv->ui, "/Contact/SendFile");
        gtk_action_set_visible (action, can_send_file);
@@ -1306,6 +1320,7 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view,
        }
 }
 
+#ifdef HAVE_VOIP
 static void
 contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
                                     const gchar                    *path_string,
@@ -1332,6 +1347,7 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
                g_object_unref (contact);
        }
 }
+#endif
 
 
 static void
@@ -1386,10 +1402,10 @@ contact_list_view_action_cb (GtkAction             *action,
                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, TRUE);
        }
        else if (contact && strcmp (name, "Remove") == 0) {
                /* FIXME: Ask for confirmation */
@@ -1438,59 +1454,6 @@ static void
 contact_list_view_voip_activated (EmpathyContactListView *view,
                                  EmpathyContact         *contact)
 {
-       MissionControl *mc;
-       McAccount      *account;
-       TpConn         *tp_conn;
-       gchar          *object_path;
-       const gchar    *bus_name;
-       TpChan         *new_chan;
-       EmpathyTpGroup *group;
-       GError         *error;
-
-       /* StreamedMedia channels must have handle=0 and handle_type=none.
-        * To call a contact we have to add him in the group interface of the
-        * channel. MissionControl will detect the channel creation and 
-        * dispatch it to the VoIP chandler automatically. */
-
-       mc = empathy_mission_control_new ();
-       account = empathy_contact_get_account (contact);
-       tp_conn = mission_control_get_connection (mc, account, NULL);
-       /* FIXME: Should be async */
-       if (!tp_conn_request_channel (DBUS_G_PROXY (tp_conn),
-                                     TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-                                     TP_HANDLE_TYPE_NONE,
-                                     0,
-                                     FALSE,
-                                     &object_path,
-                                     &error)) {
-               empathy_debug (DEBUG_DOMAIN, 
-                             "Couldn't request channel: %s",
-                             error ? error->message : "No error given");
-               g_clear_error (&error);
-               g_object_unref (mc);
-               g_object_unref (tp_conn);
-               return;
-       }
-
-       bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn));
-       new_chan = tp_chan_new (tp_get_bus (),
-                               bus_name,
-                               object_path,
-                               TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-                               TP_HANDLE_TYPE_NONE,
-                               0);
-
-       /* FIXME: group is leaked, we can't unref it directly because
-        * _add_member is async so we have to wait for it to return before
-        * finalizing the group. I think EmpathyTpGroup should ref itself
-        * when it does async calls to avoid finalizing when there is calls
-        * in fligth like that we could unref it here. */
-       group = empathy_tp_group_new (account, new_chan);
-       empathy_tp_group_add_member (group, contact, "");
-
-       g_object_unref (mc);
-       g_object_unref (tp_conn);
-       g_object_unref (new_chan);
-       g_free (object_path);
+       empathy_call_contact (contact);
 }