/* * call-seq: * xc.medialib_entry_property_remove(id, key, *source) -> result * * Remove a custom field in the medialib associated with the entry _id_. * _source_ is an optional argument that describes where to write the * mediainfo. If _source_ is omitted, "client/<yourclient>" is used, * where <yourclient> is the name you specified in * _Xmms::Client.new(name)_. */ static VALUE c_medialib_entry_property_remove (int argc, VALUE *argv, VALUE self) { VALUE tmp, key, src = Qnil; RbXmmsClient *xmms = NULL; xmmsc_result_t *res; const char *ckey; int32_t id; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); rb_scan_args (argc, argv, "21", &tmp, &key, &src); id = check_int32 (tmp); Check_Type (key, T_SYMBOL); ckey = rb_id2name (SYM2ID (key)); if (NIL_P (src)) res = xmmsc_medialib_entry_property_remove (xmms->real, id, ckey); else res = xmmsc_medialib_entry_property_remove_with_source ( xmms->real, id, StringValuePtr (src), ckey); return TO_XMMS_CLIENT_RESULT (self, res); }
/* * call-seq: * xc.io_want_out -> true or false * * Returns +true+ if an outgoing (to server) clientlib command is pending, * +false+ otherwise. */ static VALUE c_io_want_out (VALUE self) { RbXmmsClient *xmms = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); return xmmsc_io_want_out (xmms->real) ? Qtrue : Qfalse; }
/* * call-seq: * xc.io_fd -> integer * * Returns the file descriptor of the Xmms::Client IPC socket. */ static VALUE c_io_fd (VALUE self) { RbXmmsClient *xmms = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); return INT2NUM (xmmsc_io_fd_get (xmms->real)); }
/* * call-seq: * xc.io_disconnect -> nil * * Disconnects the IPC socket. This should only be used by event loop * implementations. */ static VALUE c_io_disconnect (VALUE self) { RbXmmsClient *xmms = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); xmmsc_io_disconnect (xmms->real); return Qnil; }
/* * call-seq: * xc.playback_volume_get -> result * * Gets the current playback volume. */ static VALUE c_playback_volume_get (VALUE self) { RbXmmsClient *xmms = NULL; xmmsc_result_t *res; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); res = xmmsc_playback_volume_get (xmms->real); return TO_XMMS_CLIENT_RESULT (self, res); }
/* * call-seq: * xc.last_error -> string or nil * * Returns the last error that occured in _xc_ or +nil+, if no error * occured yet. */ static VALUE c_last_error_get (VALUE self) { RbXmmsClient *xmms = NULL; const char *s; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); s = xmmsc_get_last_error (xmms->real); return s ? rb_str_new2 (s) : Qnil; }
static VALUE c_delete (VALUE self) { RbXmmsClient *xmms = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); xmmsc_unref (xmms->real); xmms->deleted = true; return Qnil; }
/* * call-seq: * xc.medialib_entry_property_set(id, key, value, *source) -> result * * Write info to the medialib at _id_. _source_ is an optional argument that * describes where to write the mediainfo. If _source_ is omitted, the * mediainfo is written to "client/<yourclient>" where <yourclient> is the * name you specified in _Xmms::Client.new(name)_. */ static VALUE c_medialib_entry_property_set (int argc, VALUE *argv, VALUE self) { VALUE tmp, key, value, src = Qnil; RbXmmsClient *xmms = NULL; xmmsc_result_t *res; const char *ckey; bool is_str = false; uint32_t id; int32_t ivalue; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); rb_scan_args (argc, argv, "31", &tmp, &key, &value, &src); id = check_int32 (tmp); Check_Type (key, T_SYMBOL); if (!NIL_P (rb_check_string_type (value))) is_str = true; else ivalue = check_int32 (value); ckey = rb_id2name (SYM2ID (key)); if (NIL_P (src) && is_str) res = xmmsc_medialib_entry_property_set_str (xmms->real, id, ckey, StringValuePtr (value)); else if (NIL_P (src)) res = xmmsc_medialib_entry_property_set_int (xmms->real, id, ckey, ivalue); else if (is_str) res = xmmsc_medialib_entry_property_set_str_with_source ( xmms->real, id, StringValuePtr (src), ckey, StringValuePtr (value)); else res = xmmsc_medialib_entry_property_set_int_with_source ( xmms->real, id, StringValuePtr (src), ckey, ivalue); return TO_XMMS_CLIENT_RESULT (self, res); }
/* * call-seq: * xc.playback_volume_set(channel, volume) -> result * * Sets playback volume for _channel_ to _volume_. */ static VALUE c_playback_volume_set (VALUE self, VALUE channel, VALUE volume) { RbXmmsClient *xmms = NULL; xmmsc_result_t *res; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); Check_Type (channel, T_SYMBOL); Check_Type (volume, T_FIXNUM); res = xmmsc_playback_volume_set (xmms->real, rb_id2name (SYM2ID (channel)), NUM2INT (volume)); return TO_XMMS_CLIENT_RESULT (self, res); }
/* * call-seq: * xc.io_on_need_out { |flag| } * * Sets the block that's called when the output socket state changes. */ static VALUE c_io_on_need_out (VALUE self) { RbXmmsClient *xmms = NULL; if (!rb_block_given_p ()) return Qnil; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); xmms->io_need_out_cb = rb_block_proc (); xmmsc_io_need_out_callback_set (xmms->real, on_io_need_out, (void *) self); return Qnil; }
/* * call-seq: * xc.connect([path]) -> self * * Connects _xc_ to the XMMS2 daemon listening at _path_. * If _path_ isn't given, the default path is used. */ static VALUE c_connect (int argc, VALUE *argv, VALUE self) { VALUE path; RbXmmsClient *xmms = NULL; char *p = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); rb_scan_args (argc, argv, "01", &path); if (!NIL_P (path)) p = StringValuePtr (path); if (!xmmsc_connect (xmms->real, p)) rb_raise (eClientError, "cannot connect to daemon (%s)", xmmsc_get_last_error (xmms->real)); return self; }