diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-02-15 23:00:45 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-02-15 23:00:45 +0800 |
commit | 3cac01703f75bf0ee31fb4720e204931dbca9e29 (patch) | |
tree | 45ae7b64de4614d88c20fba252212bfb6d66402d /libempathy/empathy-utils.c | |
parent | f7a1d31cec6f0e14e9944a87443e0a83b45a530e (diff) | |
download | gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar.gz gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar.bz2 gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar.lz gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar.xz gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.tar.zst gsoc2013-empathy-3cac01703f75bf0ee31fb4720e204931dbca9e29.zip |
Merge call branch from Elliot Fairweather with cleanups from Xavier Claessens.
svn path=/trunk/; revision=632
Diffstat (limited to 'libempathy/empathy-utils.c')
-rw-r--r-- | libempathy/empathy-utils.c | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 796d23ddf..8c6edafc5 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -37,6 +37,7 @@ #include "empathy-debug.h" #include "empathy-utils.h" +#include "empathy-contact-factory.h" #include "empathy-contact-manager.h" #include "empathy-tp-group.h" @@ -397,19 +398,61 @@ empathy_inspect_handle (McAccount *account, } void -empathy_call_with_contact (EmpathyContact *contact) +empathy_call_with_contact (EmpathyContact *contact) { #ifdef HAVE_VOIP MissionControl *mc; + McAccount *account; + TpConn *tp_conn; + gchar *object_path; + const gchar *bus_name; + TpChan *new_chan; + EmpathyTpGroup *group; + GError *error = NULL; + + g_return_if_fail (EMPATHY_IS_CONTACT (contact)); + + /* 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); + + group = empathy_tp_group_new (account, new_chan); + empathy_tp_group_add_member (group, contact, ""); + + g_object_unref (group); g_object_unref (mc); + g_object_unref (tp_conn); + g_object_unref (new_chan); + g_free (object_path); #endif } @@ -417,16 +460,14 @@ void empathy_call_with_contact_id (McAccount *account, const gchar *contact_id) { #ifdef HAVE_VOIP - MissionControl *mc; - - mc = empathy_mission_control_new (); - mission_control_request_channel_with_string_handle (mc, - account, - TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, - contact_id, - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + EmpathyContactFactory *factory; + EmpathyContact *contact; + + factory = empathy_contact_factory_new (); + contact = empathy_contact_factory_get_from_id (factory, account, contact_id); + empathy_call_with_contact (contact); + g_object_unref (contact); + g_object_unref (factory); #endif } |