From caedac5aea69b34dd415ba391a6b53d830639aae Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 28 Sep 2007 14:54:42 +0000 Subject: Ported from VOIP branch. 2007-09-28 Xavier Claessens * libempathy-gtk/empathy-contact-list-view.c: * libempathy-gtk/empathy-chat-window.c: * src/Makefile.am: * libempathy/empathy-tp-group.c: * libempathy/Makefile.am: Ported from VOIP branch. svn path=/trunk/; revision=335 --- libempathy-gtk/empathy-chat-window.c | 12 ++---- libempathy-gtk/empathy-contact-list-view.c | 59 +++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 15 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index 468c3236e..29fe5a521 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -877,21 +877,15 @@ chat_window_call_activate_cb (GtkWidget *menuitem, priv = GET_PRIV (window); if (!empathy_chat_is_group_chat (priv->current_chat)) { - MissionControl *mc; EmpathyPrivateChat *chat; EmpathyContact *contact; chat = EMPATHY_PRIVATE_CHAT (priv->current_chat); contact = empathy_private_chat_get_contact (chat); - mc = empathy_mission_control_new (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + /* FIXME: See contact_list_view_voip_activated() to know how to + * call a contact. We need a function to call a contact and use + * it here and in EmpathyContactListView. */ } } diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 27688602c..c959eec01 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -31,12 +31,15 @@ #include #include +#include + #include #include #include #include #include +#include #include #include #include @@ -1436,14 +1439,58 @@ 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 (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); + 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); } -- cgit v1.2.3