400
empathy_call_with_contact (EmpathyContact *contact)
403
empathy_call_with_contact (EmpathyContact *contact)
410
const gchar *bus_name;
412
EmpathyContactFactory *factory;
413
EmpathyTpGroup *group;
414
EmpathyContact *self_contact;
415
GError *error = NULL;
417
g_return_if_fail (EMPATHY_IS_CONTACT (contact));
419
/* StreamedMedia channels must have handle=0 and handle_type=none.
420
* To call a contact we have to add him in the group interface of the
421
* channel. MissionControl will detect the channel creation and
422
* dispatch it to the VoIP chandler automatically. */
405
424
mc = empathy_mission_control_new ();
406
mission_control_request_channel (mc,
407
empathy_contact_get_account (contact),
408
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
409
empathy_contact_get_handle (contact),
410
TP_HANDLE_TYPE_CONTACT,
425
account = empathy_contact_get_account (contact);
426
tp_conn = mission_control_get_connection (mc, account, NULL);
427
/* FIXME: Should be async */
428
if (!tp_conn_request_channel (DBUS_G_PROXY (tp_conn),
429
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
435
empathy_debug (DEBUG_DOMAIN,
436
"Couldn't request channel: %s",
437
error ? error->message : "No error given");
438
g_clear_error (&error);
440
g_object_unref (tp_conn);
444
bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn));
445
new_chan = tp_chan_new (tp_get_bus (),
448
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
452
group = empathy_tp_group_new (account, new_chan);
453
factory = empathy_contact_factory_new ();
454
self_contact = empathy_contact_factory_get_user (factory, account);
455
empathy_tp_group_add_member (group, contact, "");
456
empathy_tp_group_add_member (group, self_contact, "");
458
g_object_unref (factory);
459
g_object_unref (self_contact);
460
g_object_unref (group);
412
461
g_object_unref (mc);
462
g_object_unref (tp_conn);
463
g_object_unref (new_chan);
464
g_free (object_path);
470
got_handle_cb (EmpathyContact *contact,
471
GParamSpec *property,
472
EmpathyContactFactory *factory)
474
g_signal_handlers_disconnect_by_func (contact,
478
empathy_call_with_contact (contact);
479
g_object_unref (factory);
480
g_object_unref (contact);
417
485
empathy_call_with_contact_id (McAccount *account, const gchar *contact_id)
422
mc = empathy_mission_control_new ();
423
mission_control_request_channel_with_string_handle (mc,
425
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
427
TP_HANDLE_TYPE_CONTACT,
488
EmpathyContactFactory *factory;
489
EmpathyContact *contact;
491
factory = empathy_contact_factory_new ();
492
contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
494
if (empathy_contact_get_handle (contact) != 0) {
495
empathy_call_with_contact (contact);
496
g_object_unref (contact);
497
g_object_unref (factory);
499
g_signal_connect (contact, "notify::handle",
500
G_CALLBACK (got_handle_cb),