~ubuntu-branches/ubuntu/precise/empathy/precise

« back to all changes in this revision

Viewing changes to libempathy/empathy-utils.c

Tags: upstream-0.21.90
ImportĀ upstreamĀ versionĀ 0.21.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
208
208
        xmlDtd       *dtd;
209
209
        gboolean      ret;
210
210
 
211
 
        path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL);
 
211
        path = g_build_filename (UNINSTALLED_DTD_DIR, dtd_filename, NULL);
 
212
        if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
 
213
                g_free (path);
 
214
                path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL);
 
215
        }
 
216
        empathy_debug (DEBUG_DOMAIN, "Loading dtd file %s", path);
212
217
 
213
218
        /* The list of valid chars is taken from libxml. */
214
219
        escaped = xmlURIEscapeStr (path, ":@&=+$,/?;");
215
 
 
216
220
        g_free (path);
217
221
 
218
222
        memset (&cvp, 0, sizeof (cvp));
393
397
}
394
398
 
395
399
void
396
 
empathy_call_contact (EmpathyContact *contact)
397
 
{
398
 
#ifdef HAVE_VOIP
399
 
        MissionControl *mc;
400
 
        McAccount      *account;
401
 
        TpConn         *tp_conn;
402
 
        gchar          *object_path;
403
 
        const gchar    *bus_name;
404
 
        TpChan         *new_chan;
405
 
        EmpathyTpGroup *group;
406
 
        GError         *error = NULL;
407
 
 
408
 
        g_return_if_fail (EMPATHY_IS_CONTACT (contact));
409
 
 
410
 
        /* StreamedMedia channels must have handle=0 and handle_type=none.
411
 
         * To call a contact we have to add him in the group interface of the
412
 
         * channel. MissionControl will detect the channel creation and 
413
 
         * dispatch it to the VoIP chandler automatically. */
414
 
 
415
 
        mc = empathy_mission_control_new ();
416
 
        account = empathy_contact_get_account (contact);
417
 
        tp_conn = mission_control_get_connection (mc, account, NULL);
418
 
        /* FIXME: Should be async */
419
 
        if (!tp_conn_request_channel (DBUS_G_PROXY (tp_conn),
420
 
                                      TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
421
 
                                      TP_HANDLE_TYPE_NONE,
422
 
                                      0,
423
 
                                      FALSE,
424
 
                                      &object_path,
425
 
                                      &error)) {
426
 
                empathy_debug (DEBUG_DOMAIN, 
427
 
                              "Couldn't request channel: %s",
428
 
                              error ? error->message : "No error given");
429
 
                g_clear_error (&error);
430
 
                g_object_unref (mc);
431
 
                g_object_unref (tp_conn);
432
 
                return;
433
 
        }
434
 
 
435
 
        bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn));
436
 
        new_chan = tp_chan_new (tp_get_bus (),
437
 
                                bus_name,
438
 
                                object_path,
439
 
                                TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
440
 
                                TP_HANDLE_TYPE_NONE,
441
 
                                0);
442
 
 
443
 
        group = empathy_tp_group_new (account, new_chan);
444
 
        empathy_tp_group_add_member (group, contact, "");
445
 
 
446
 
        g_object_unref (group);
447
 
        g_object_unref (mc);
448
 
        g_object_unref (tp_conn);
449
 
        g_object_unref (new_chan);
450
 
        g_free (object_path);
 
400
empathy_call_with_contact (EmpathyContact  *contact)
 
401
{
 
402
#ifdef HAVE_VOIP
 
403
        MissionControl *mc;
 
404
 
 
405
        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,
 
411
                                         NULL, NULL);
 
412
        g_object_unref (mc);
 
413
#endif
 
414
}
 
415
 
 
416
void
 
417
empathy_call_with_contact_id (McAccount *account, const gchar *contact_id)
 
418
{
 
419
#ifdef HAVE_VOIP
 
420
        MissionControl *mc;
 
421
 
 
422
        mc = empathy_mission_control_new ();
 
423
        mission_control_request_channel_with_string_handle (mc,
 
424
                                                            account,
 
425
                                                            TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
 
426
                                                            contact_id,
 
427
                                                            TP_HANDLE_TYPE_CONTACT,
 
428
                                                            NULL, NULL);
 
429
        g_object_unref (mc);
451
430
#endif
452
431
}
453
432
 
481
460
        g_object_unref (mc);
482
461
}
483
462
 
 
463
const gchar *
 
464
empathy_presence_get_default_message (McPresence presence)
 
465
{
 
466
        switch (presence) {
 
467
        case MC_PRESENCE_AVAILABLE:
 
468
                return _("Available");
 
469
        case MC_PRESENCE_DO_NOT_DISTURB:
 
470
                return _("Busy");
 
471
        case MC_PRESENCE_AWAY:
 
472
        case MC_PRESENCE_EXTENDED_AWAY:
 
473
                return _("Away");
 
474
        case MC_PRESENCE_HIDDEN:
 
475
                return _("Hidden");
 
476
        case MC_PRESENCE_OFFLINE:
 
477
        case MC_PRESENCE_UNSET:
 
478
                return _("Offline");
 
479
        default:
 
480
                g_assert_not_reached ();
 
481
        }
 
482
 
 
483
        return NULL;
 
484
}
 
485
 
 
486
const gchar *
 
487
empathy_presence_to_str (McPresence presence)
 
488
{
 
489
        switch (presence) {
 
490
        case MC_PRESENCE_AVAILABLE:
 
491
                return "available";
 
492
        case MC_PRESENCE_DO_NOT_DISTURB:
 
493
                return "busy";
 
494
        case MC_PRESENCE_AWAY:
 
495
                return "away";
 
496
        case MC_PRESENCE_EXTENDED_AWAY:
 
497
                return "ext_away";
 
498
        case MC_PRESENCE_HIDDEN:
 
499
                return "hidden";
 
500
        case MC_PRESENCE_OFFLINE:
 
501
                return "offline";
 
502
        case MC_PRESENCE_UNSET:
 
503
                return "unset";
 
504
        default:
 
505
                g_assert_not_reached ();
 
506
        }
 
507
 
 
508
        return NULL;
 
509
}
 
510
 
 
511
McPresence
 
512
empathy_presence_from_str (const gchar *str)
 
513
{
 
514
        if (strcmp (str, "available") == 0) {
 
515
                return MC_PRESENCE_AVAILABLE;
 
516
        } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
 
517
                return MC_PRESENCE_DO_NOT_DISTURB;
 
518
        } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
 
519
                return MC_PRESENCE_AWAY;
 
520
        } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) {
 
521
                return MC_PRESENCE_EXTENDED_AWAY;
 
522
        } else if (strcmp (str, "hidden") == 0) {
 
523
                return MC_PRESENCE_HIDDEN;
 
524
        } else if (strcmp (str, "offline") == 0) {
 
525
                return MC_PRESENCE_OFFLINE;
 
526
        } else if (strcmp (str, "unset") == 0) {
 
527
                return MC_PRESENCE_UNSET;
 
528
        }
 
529
 
 
530
        return MC_PRESENCE_AVAILABLE;
 
531
}
 
532