~ubuntu-branches/ubuntu/lucid/xmms2/lucid

« back to all changes in this revision

Viewing changes to src/clients/lib/ruby/rb_xmmsclient.c

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-03-07 04:11:24 UTC
  • mfrom: (1.1.7 upstream) (6.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100307041124-df7p8f9yejg1u1qn
Tags: 0.7DrNo-3ubuntu1
* Merge from Debian unstable (LP: #532278), remaining changes:
  - Use PulseAudio as default output plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
static VALUE eClientError, eDisconnectedError;
82
82
static ID id_lt, id_gt;
83
83
 
 
84
void Init_Client (VALUE);
 
85
 
84
86
static void
85
87
c_mark (RbXmmsClient *xmms)
86
88
{
160
162
        if (!NIL_P (path))
161
163
                p = StringValuePtr (path);
162
164
 
163
 
        if (!xmmsc_connect (xmms->real, p)) {
164
 
                char buf[255];
165
 
 
166
 
                snprintf (buf, sizeof (buf), "cannot connect to daemon (%s)\n",
 
165
        if (!xmmsc_connect (xmms->real, p))
 
166
                rb_raise (eClientError,
 
167
                          "cannot connect to daemon (%s)",
167
168
                          xmmsc_get_last_error (xmms->real));
168
169
 
169
 
                rb_raise (eClientError, buf);
170
 
        }
171
 
 
172
170
        return self;
173
171
}
174
172
 
530
528
 
531
529
/*
532
530
 * call-seq:
533
 
 *  xc.broadcast_configval_changed -> result
 
531
 *  xc.broadcast_config_value_changed -> result
534
532
 *
535
533
 * Retrieves configuration properties as a broadcast.
536
534
 */
537
535
static VALUE
538
 
c_broadcast_configval_changed (VALUE self)
 
536
c_broadcast_config_value_changed (VALUE self)
539
537
{
540
 
        METHOD_ADD_HANDLER (broadcast_configval_changed);
 
538
        METHOD_ADD_HANDLER (broadcast_config_value_changed);
541
539
}
542
540
 
543
541
/*
549
547
static VALUE
550
548
c_playback_seek_ms (VALUE self, VALUE ms)
551
549
{
552
 
        METHOD_ADD_HANDLER_UINT (playback_seek_ms, ms);
 
550
        METHOD_ADD_HANDLER_UINT (playback_seek_ms_abs, ms);
553
551
}
554
552
 
555
553
/*
573
571
static VALUE
574
572
c_playback_seek_samples (VALUE self, VALUE samples)
575
573
{
576
 
        METHOD_ADD_HANDLER_UINT (playback_seek_samples, samples);
 
574
        METHOD_ADD_HANDLER_UINT (playback_seek_samples_abs, samples);
577
575
}
578
576
 
579
577
 /*
1036
1034
 
1037
1035
/*
1038
1036
 * call-seq:
1039
 
 *  xc.configval_list -> result
 
1037
 *  xc.config_list_values -> result
1040
1038
 *
1041
1039
 * Retrieves a list of all config values.
1042
1040
 */
1043
1041
static VALUE
1044
 
c_configval_list (VALUE self)
 
1042
c_config_list_values (VALUE self)
1045
1043
{
1046
 
        METHOD_ADD_HANDLER (configval_list);
 
1044
        METHOD_ADD_HANDLER (config_list_values);
1047
1045
}
1048
1046
 
1049
1047
/*
1050
1048
 * call-seq:
1051
 
 *  xc.configval_get(key) -> result
 
1049
 *  xc.config_get_value(key) -> result
1052
1050
 *
1053
1051
 * Retrieves the value of the configuration property at _key_.
1054
1052
 */
1055
1053
static VALUE
1056
 
c_configval_get (VALUE self, VALUE key)
 
1054
c_config_get_value (VALUE self, VALUE key)
1057
1055
{
1058
 
        METHOD_ADD_HANDLER_STR (configval_get, key);
 
1056
        METHOD_ADD_HANDLER_STR (config_get_value, key);
1059
1057
}
1060
1058
 
1061
1059
/*
1062
1060
 * call-seq:
1063
 
 *  xc.configval_set(key, value) -> result
 
1061
 *  xc.config_set_value(key, value) -> result
1064
1062
 *
1065
1063
 * Sets the value of the configuration property at _key_ to _value_.
1066
1064
 */
1067
1065
static VALUE
1068
 
c_configval_set (VALUE self, VALUE key, VALUE val)
 
1066
c_config_set_value (VALUE self, VALUE key, VALUE val)
1069
1067
{
1070
 
        METHOD_ADD_HANDLER_STR_STR (configval_set, key, val);
 
1068
        METHOD_ADD_HANDLER_STR_STR (config_set_value, key, val);
1071
1069
}
1072
1070
 
1073
1071
/*
1074
1072
 * call-seq:
1075
 
 *  xc.configval_register(key, default_value) -> result
 
1073
 *  xc.config_register_value(key, default_value) -> result
1076
1074
 *
1077
1075
 * Registers a configuration property at _key_ with the given default value.
1078
1076
 */
1079
1077
static VALUE
1080
 
c_configval_register (VALUE self, VALUE key, VALUE defval)
 
1078
c_config_register_value (VALUE self, VALUE key, VALUE defval)
1081
1079
{
1082
 
        METHOD_ADD_HANDLER_STR_STR (configval_register, key, defval);
 
1080
        METHOD_ADD_HANDLER_STR_STR (config_register_value, key, defval);
1083
1081
}
1084
1082
 
1085
1083
/*
1419
1417
        int i;
1420
1418
 
1421
1419
        if (!NIL_P (rb_check_array_type (value))) {
1422
 
                struct RArray *ary = RARRAY (value);
1423
 
 
1424
 
                ret = malloc (sizeof (char *) * (ary->len + 1));
1425
 
 
1426
 
                for (i = 0; i < ary->len; i++)
1427
 
                        ret[i] = StringValuePtr (ary->ptr[i]);
 
1420
                VALUE *ary = RARRAY_PTR (value);
 
1421
                int ary_len = RARRAY_LEN (value);
 
1422
 
 
1423
                ret = malloc (sizeof (char *) * (ary_len + 1));
 
1424
 
 
1425
                for (i = 0; i < ary_len; i++)
 
1426
                        ret[i] = StringValuePtr (ary[i]);
1428
1427
 
1429
1428
                ret[i] = NULL;
1430
1429
        } else {
1448
1447
        list = xmmsv_new_list ();
1449
1448
 
1450
1449
        if (!NIL_P (rb_check_array_type (value))) {
1451
 
                struct RArray *ary = RARRAY (value);
1452
 
                int i;
 
1450
                VALUE *ary = RARRAY_PTR (value);
 
1451
                int i, ary_len = RARRAY_LEN (value);
1453
1452
 
1454
 
                for (i = 0; i < ary->len; i++) {
 
1453
                for (i = 0; i < ary_len; i++) {
1455
1454
                        xmmsv_t *elem;
1456
1455
 
1457
 
                        elem = xmmsv_new_string (StringValuePtr (ary->ptr[i]));
 
1456
                        elem = xmmsv_new_string (StringValuePtr (ary[i]));
1458
1457
                        xmmsv_list_append (list, elem);
1459
1458
                        xmmsv_unref (elem);
1460
1459
                }
1572
1571
        rb_define_method (c, "plugin_list", c_plugin_list, -1);
1573
1572
        rb_define_method (c, "main_stats", c_main_stats, 0);
1574
1573
 
1575
 
        rb_define_method (c, "configval_list", c_configval_list, 0);
1576
 
        rb_define_method (c, "configval_get", c_configval_get, 1);
1577
 
        rb_define_method (c, "configval_set", c_configval_set, 2);
1578
 
        rb_define_method (c, "configval_register", c_configval_register, 2);
1579
 
        rb_define_method (c, "broadcast_configval_changed",
1580
 
                          c_broadcast_configval_changed, 0);
 
1574
        rb_define_method (c, "config_list_values", c_config_list_values, 0);
 
1575
        rb_define_method (c, "config_get_value", c_config_get_value, 1);
 
1576
        rb_define_method (c, "config_set_value", c_config_set_value, 2);
 
1577
        rb_define_method (c, "config_register_value", c_config_register_value, 2);
 
1578
        rb_define_method (c, "broadcast_config_value_changed",
 
1579
                          c_broadcast_config_value_changed, 0);
1581
1580
 
1582
1581
        rb_define_method (c, "bindata_add", c_bindata_add, 1);
1583
1582
        rb_define_method (c, "bindata_retrieve", c_bindata_retrieve, 1);