Beispiel #1
0
void
set_volume (cli_infos_t *infos, gchar *channel, gint volume)
{
	xmmsc_result_t *res;
	xmmsv_t *val;
	GList *it, *channels = NULL;

	if (!channel) {
		/* get all channels */
		res = xmmsc_playback_volume_get (infos->sync);
		xmmsc_result_wait (res);
		val = xmmsc_result_get_value (res);
		xmmsv_dict_foreach (val, dict_keys, &channels);
		xmmsc_result_unref (res);
	} else {
		channels = g_list_prepend (channels, g_strdup (channel));
	}

	/* set volumes for channels in list */
	for (it = g_list_first (channels); it != NULL; it = g_list_next (it)) {
		res = xmmsc_playback_volume_set (infos->sync, it->data, volume);
		xmmsc_result_wait (res);
		xmmsc_result_unref (res);

		/* free channel string */
		g_free (it->data);
	}

	g_list_free (channels);

	cli_infos_loop_resume (infos);
}
Beispiel #2
0
static gboolean
ol_player_xmms2_go_rel (int rel)
{
  ol_log_func ();
  ol_debugf ("  rel:%d\n", rel);
  if (!ol_player_xmms2_ensure_connection ())
    return FALSE;
  xmmsc_result_t *result = xmmsc_playlist_set_next_rel (connection, rel);
  xmmsc_result_wait (result);
  xmmsv_t *return_value = xmmsc_result_get_value (result);
  if (xmmsv_is_error (return_value))
  {
    ol_debug ("Error on setting playlist next");
    return FALSE;
  }
  xmmsc_result_unref (result);

  result = xmmsc_playback_tickle (connection);
  xmmsc_result_wait (result);
  if (xmmsc_result_iserror (result))
  {
    ol_debug ("Error on tickle playback");
    return FALSE;
  }
  xmmsc_result_unref (result);
  return TRUE;
}
Beispiel #3
0
void
coll_save (cli_infos_t *infos, xmmsv_coll_t *coll,
           xmmsc_coll_namespace_t ns, gchar *name, gboolean force)
{
	xmmsc_result_t *res;
	xmmsv_t *val;
	gboolean save = TRUE;

	if (!force) {
		xmmsv_coll_t *exists;
		res = xmmsc_coll_get (infos->sync, name, ns);
		xmmsc_result_wait (res);
		val = xmmsc_result_get_value (res);
		if (xmmsv_get_coll (val, &exists)) {
			g_printf (_("Error: A collection already exists "
			            "with the target name!\n"));
			save = FALSE;
		}
		xmmsc_result_unref (res);
	}

	if (save) {
		res = xmmsc_coll_save (infos->sync, coll, name, ns);
		xmmsc_result_wait (res);
		done (res, infos);
	} else {
		cli_infos_loop_resume (infos);
	}
}
void
cli_cache_refresh (cli_infos_t *infos)
{
	xmmsc_result_t *res;

	res = xmmsc_playlist_current_pos (infos->conn, XMMS_ACTIVE_PLAYLIST);
	xmmsc_result_wait (res);
	refresh_currpos (xmmsc_result_get_value (res), infos->cache);
	xmmsc_result_unref (res);

	res = xmmsc_playback_current_id (infos->conn);
	xmmsc_result_wait (res);
	refresh_currid (xmmsc_result_get_value (res), infos->cache);
	xmmsc_result_unref (res);

	res = xmmsc_playback_status (infos->conn);
	xmmsc_result_wait (res);
	refresh_playback_status (xmmsc_result_get_value (res), infos->cache);
	xmmsc_result_unref (res);

	res = xmmsc_playlist_list_entries (infos->conn, XMMS_ACTIVE_PLAYLIST);
	xmmsc_result_wait (res);
	refresh_active_playlist (xmmsc_result_get_value (res), infos->cache);
	xmmsc_result_unref (res);

	res = xmmsc_playlist_current_active (infos->conn);
	xmmsc_result_wait (res);
	refresh_active_playlist_name (xmmsc_result_get_value (res), infos->cache);
	xmmsc_result_unref (res);
}
void plugin_config_setup (xmmsc_connection_t *con) 
{
    xmmsc_result_t* res;
    xmmsv_t *val;
    const gchar *err, *name;
    
    /* call only once */
    g_assert(plugins == NULL );

    /* get translation of plugins/configs */
    plugin_config_init_translation();

    /* get list of available plugins */
    res = xmmsc_main_list_plugins (con, XMMS_PLUGIN_TYPE_OUTPUT);
    /* we havn't entered async xmmsc_mainloop, so it's ok todo sync ops */
    xmmsc_result_wait (res);
    val = xmmsc_result_get_value (res);

    if (!xmmsv_get_error (val, &err)) {
	xmmsv_list_iter_t *it;

	xmmsv_get_list_iter (val, &it);
	for (xmmsv_list_iter_first (it);
	     xmmsv_list_iter_valid (it);
	     xmmsv_list_iter_next (it)) 
	{
	    xmmsv_t *elem;
	    Plugin *plugin;
	    xmmsv_list_iter_entry (it, &elem);
	    xmmsv_dict_entry_get_string (elem, "shortname", &name);

	    /* not blacklisted */
	    if ( g_strrstr( PLUGIN_BLACKLIST, name ) != NULL ) 
		continue;

	    plugin = g_slice_new( Plugin );
	    plugin->name = g_strdup(name);
	    plugin->config = NULL;
	    plugins = g_list_append(plugins, plugin);
	}
    } else {
	g_error ( "Server error: %s", err);
    }
    xmmsc_result_unref (res);

    /* get configuration options */
    res = xmmsc_config_list_values (con );
    xmmsc_result_wait (res);
    val = xmmsc_result_get_value (res);
    xmmsv_dict_foreach( val, plugin_config_setup_parameter, NULL);
        
}
Beispiel #6
0
void
cmd_playlists_list (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	const gchar *active_name;
	xmmsc_result_t *res, *active_res;
	xmmsv_t *val, *active_val;
	xmmsv_list_iter_t *it;

	active_res = xmmsc_playlist_current_active (conn);
	xmmsc_result_wait (active_res);
	active_val = xmmsc_result_get_value (active_res);

	if (xmmsv_is_error (active_val) ||
	    !xmmsv_get_string (active_val, &active_name)) {
		active_name = NULL;
	}

	res = xmmsc_playlist_list (conn);
	xmmsc_result_wait (res);
	val = xmmsc_result_get_value (res);

	if (xmmsv_is_error (val)) {
		print_error ("%s", xmmsv_get_error_old (val));
	}

	xmmsv_get_list_iter (val, &it);
	while (xmmsv_list_iter_valid (it)) {
		xmmsv_t *valstr;
		const gchar *name;

		xmmsv_list_iter_entry (it, &valstr);
		if (!xmmsv_get_string (valstr, &name)) {
			print_error ("Broken resultset");
		}

		/* Hide all lists that start with _ */
		if (name[0] != '_') {
			if (active_name != NULL && strcmp (active_name, name) == 0) {
				print_info ("->%s", name);
			} else {
				print_info ("  %s", name);
			}
		}
		xmmsv_list_iter_next (it);
	}
	xmmsc_result_unref (res);
	xmmsc_result_unref (active_res);
}
Beispiel #7
0
static void
pos_print_info_cb (gint pos, void *userdata)
{
	xmmsc_result_t *infores;
	pl_pos_udata_t *pack = (pl_pos_udata_t *) userdata;
	guint id;

	/* Skip if outside of playlist */
	if (pos >= pack->infos->cache->active_playlist->len) {
		return;
	}

	id = g_array_index (pack->infos->cache->active_playlist, guint, pos);

	infores = xmmsc_medialib_get_info (pack->infos->sync, id);
	xmmsc_result_wait (infores);

	/* Do not prepend newline before the first entry */
	if (pack->inc > 0) {
		g_printf ("\n");
	} else {
		pack->inc++;
	}
	id_print_info (infores, id, NULL);
}
Beispiel #8
0
void
cmd_addid (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	gint i;
	gchar *playlist = NULL;
	xmmsc_result_t *res;

	if (argc < 3) {
		print_error ("Need a medialib id to add");
	}

	for (i = 2; argv[i]; i++) {
		guint id = strtoul (argv[i], NULL, 10);
		if (id) {
			res = xmmsc_playlist_add_id (conn, playlist, id);
			xmmsc_result_wait (res);

			if (xmmsc_result_iserror (res)) {
				print_error ("Couldn't add %d to playlist: %s", id,
				             xmmsc_result_get_error (res));
			}
			xmmsc_result_unref (res);

			print_info ("Added medialib id %d to playlist", id);
		} else if (i == 2) {
			/* First argument is the playlist name */
			playlist = argv[i];
		}
	}
}
Beispiel #9
0
void
cmd_sort (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	gchar *playlist;
	xmmsv_t *sortby;
	xmmsc_result_t *res;

	if (argc < 3) {
		print_error ("Sort needs a property to sort on");
	} else if (argc == 3) {
		playlist = NULL;
		sortby = xmmsv_make_stringlist (&argv[2], argc - 2);
	} else {
		playlist = argv[2];
		sortby = xmmsv_make_stringlist (&argv[3], argc - 3);
	}

	res = xmmsc_playlist_sort (conn, playlist, sortby);
	xmmsc_result_wait (res);

	if (xmmsc_result_iserror (res)) {
		print_error ("%s", xmmsc_result_get_error (res));
	}
	xmmsc_result_unref (res);
	xmmsv_unref (sortby);
}
Beispiel #10
0
static gboolean
ol_player_xmms2_get_music_length (int *len)
{
  /* ol_log_func (); */
  ol_assert_ret (len != NULL, FALSE);
  if (!ol_player_xmms2_ensure_connection ())
    return FALSE;
  *len = 0;
  int32_t id = ol_player_xmms2_get_currend_id ();
  if (id > 0)
  {
    xmmsc_result_t *result = xmmsc_medialib_get_info (connection, id);
    xmmsc_result_wait (result);
    xmmsv_t *return_value = xmmsc_result_get_value (result);
    if (xmmsv_is_error (return_value))
    {
      ol_error ("Get music info from XMMS2 failed.");
    }
    else
    {
      xmmsv_t *dict = xmmsv_propdict_to_dict (return_value, NULL);
      *len = ol_player_xmms2_get_dict_int (return_value, "duration");
      xmmsv_unref (dict);
    }
    xmmsc_result_unref (result);
  }
  return TRUE;
}
Beispiel #11
0
static int32_t
ol_player_xmms2_get_currend_id ()
{
  /* ol_log_func (); */
  if (!ol_player_xmms2_ensure_connection ())
    return 0;
  int32_t ret = 0;
  xmmsc_result_t *result = xmmsc_playback_current_id (connection);
  xmmsc_result_wait (result);
  xmmsv_t *return_value = xmmsc_result_get_value (result);
  if (xmmsv_is_error (return_value))
  {
    ol_error ("Error on getting current id");
    ret = 0;
  }
  else
  {
    if (!xmmsv_get_int (return_value, &ret))
    {
      ol_error ("Get id from result failed");
      ret = 0;
    }
  }
  xmmsc_result_unref (result);
  return ret;
}
Beispiel #12
0
void
cmd_insertid (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	gchar *playlist = NULL;
	guint pos, mlib_id;
	char *endptr;
	xmmsc_result_t *res;

	if (argc < 4) {
		print_error ("Need a position and a medialib id");
	}

	pos = strtol (argv[2], &endptr, 10);
	if (*endptr == '\0') {
		mlib_id = strtol (argv[3], NULL, 10); /* No playlist name */
	} else {
		playlist = argv[2];  /* extract playlist name */
		pos = strtol (argv[3], NULL, 10);
		mlib_id = strtol (argv[4], NULL, 10);
	}

	res = xmmsc_playlist_insert_id (conn, playlist, pos, mlib_id);
	xmmsc_result_wait (res);

	if (xmmsc_result_iserror (res)) {
		print_error ("Unable to insert %u at position %u: %s", mlib_id,
		             pos, xmmsc_result_get_error (res));
	}

	print_info ("Inserted %u at position %u", mlib_id, pos);

	xmmsc_result_unref (res);
}
Beispiel #13
0
static void
playlist_setup_pshuffle (xmmsc_connection_t *conn, xmmsv_coll_t *coll, gchar *ref)
{
	xmmsc_result_t *psres;
	xmmsv_coll_t *refcoll;
	gchar *s_name, *s_namespace;

	if (!coll_read_collname (ref, &s_name, &s_namespace)) {
		print_error ("invalid source collection name");
	}

	/* Quick shortcut to use Universe for "All Media" */
	if (strcmp (s_name, "All Media") == 0) {
		refcoll = xmmsv_coll_universe ();
	} else {
		psres = xmmsc_coll_get (conn, s_name, s_namespace);
		xmmsc_result_wait (psres);

		if (xmmsc_result_iserror (psres)) {
			print_error ("%s", xmmsc_result_get_error (psres));
		}

		refcoll = xmmsv_coll_new (XMMS_COLLECTION_TYPE_REFERENCE);
		xmmsv_coll_attribute_set (refcoll, "reference", s_name);
		xmmsv_coll_attribute_set (refcoll, "namespace", s_namespace);
	}

	/* Set operand */
	xmmsv_coll_add_operand (coll, refcoll);
	xmmsv_coll_unref (refcoll);

	g_free (s_name);
	g_free (s_namespace);
}
Beispiel #14
0
static void
pos_move_cb (gint curr, void *userdata)
{
	xmmsc_result_t *movres;
	pl_pos_udata_t *pack = (pl_pos_udata_t *) userdata;

	/* Entries are moved in descending order, pack->inc is used as
	 * offset both for forward and backward moves, and reset
	 * inbetween. */

	if (curr < pack->pos) {
		/* moving forward */
		if (pack->inc >= 0) {
			pack->inc = -1; /* start inc at -1, decrement */
		}
		movres = xmmsc_playlist_move_entry (pack->infos->sync, pack->playlist,
		                                    curr, pack->pos + pack->inc);
		pack->inc--;
	} else {
		/* moving backward */
		movres = xmmsc_playlist_move_entry (pack->infos->sync, pack->playlist,
		                                    curr + pack->inc, pack->pos);
		pack->inc++;
	}

	xmmsc_result_wait (movres);
	xmmsc_result_unref (movres);
}
Beispiel #15
0
void
cmd_move (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	xmmsc_result_t *res;
	guint cur_pos, new_pos, arg_start;
	gchar *playlist;

	if (argc < 4) {
		print_error ("You'll need to specifiy current and new position");
	}

	if (argc == 4) {
		playlist = NULL;
		arg_start = 2;
	} else {
		playlist = argv[2];
		arg_start = 3;
	}

	cur_pos = strtol (argv[arg_start], NULL, 10);
	new_pos = strtol (argv[arg_start + 1], NULL, 10);

	res = xmmsc_playlist_move_entry (conn, playlist, cur_pos, new_pos);
	xmmsc_result_wait (res);

	if (xmmsc_result_iserror (res)) {
		print_error ("Unable to move playlist entry: %s",
		             xmmsc_result_get_error (res));
	}
	xmmsc_result_unref (res);

	print_info ("Moved %u to %u", cur_pos, new_pos);
}
Beispiel #16
0
void
coll_rename (cli_infos_t *infos, gchar *oldname, gchar *newname,
             xmmsc_coll_namespace_t ns, gboolean force)
{
	xmmsc_result_t *res;

	if (force) {
		res = xmmsc_coll_remove (infos->sync, newname, ns);
		xmmsc_result_wait (res);
		/* FIXME(g): check something? */
		xmmsc_result_unref (res);
	}

	res = xmmsc_coll_rename (infos->sync, oldname, newname, ns);
	xmmsc_result_wait (res);
	done (res, infos);
}
Beispiel #17
0
void
cmd_addpls (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	gchar *playlist;
	xmmsc_result_t *res, *res2;
	xmmsv_t *val;
	xmmsv_coll_t *coll;
	gchar *url;

	if (argc < 3) {
		print_error ("Supply path to playlist file");
	}

	if (argc == 3) {
		playlist = NULL;
		url = format_url (argv[2], G_FILE_TEST_IS_REGULAR);
	} else {
		playlist = argv[2];
		url = format_url (argv[3], G_FILE_TEST_IS_REGULAR);
	}

	res = xmmsc_coll_idlist_from_playlist_file (conn, url);
	g_free (url);

	xmmsc_result_wait (res);
	val = xmmsc_result_get_value (res);

	if (xmmsv_is_error (val)) {
		print_error ("%s", xmmsv_get_error_old (val));
	}

	if (!xmmsv_get_coll (val, &coll)) {
		print_error ("Couldn't get collection from result!");
	}

	res2 = xmmsc_playlist_add_idlist (conn, playlist, coll);
	xmmsc_result_wait (res2);
	if (xmmsc_result_iserror (res2)) {
		print_error ("%s", xmmsc_result_get_error (res2));
	}

	print_info ("Playlist with %d entries added", xmmsv_coll_idlist_get_size (coll));

	xmmsc_result_unref (res);
	xmmsc_result_unref (res2);
}
Beispiel #18
0
void
playback_pause (cli_infos_t *infos)
{
	xmmsc_result_t *res;

	res = xmmsc_playback_pause (infos->sync);
	xmmsc_result_wait (res);
	done (res, infos);
}
Beispiel #19
0
void
set_next_rel (cli_infos_t *infos, gint offset)
{
	xmmsc_result_t *res;

	res = xmmsc_playlist_set_next_rel (infos->sync, offset);
	xmmsc_result_wait (res);
	tickle (res, infos);
}
Beispiel #20
0
static void
pos_remove_cb (gint pos, void *userdata)
{
	xmmsc_result_t *res;
	pl_pos_udata_t *pack = (pl_pos_udata_t *) userdata;

	res = xmmsc_playlist_remove_entry (pack->infos->sync, pack->playlist, pos);
	xmmsc_result_wait (res);
	xmmsc_result_unref (res);
}
Beispiel #21
0
/*
 * call-seq:
 *  res.wait -> self
 *
 * Waits for _res_ to be handled.
 */
static VALUE
c_wait (VALUE self)
{
	RbResult *res = NULL;

	Data_Get_Struct (self, RbResult, res);

	xmmsc_result_wait (res->real);

	return self;
}
Beispiel #22
0
void
remove_cached_list (xmmsc_result_t *matching, cli_infos_t *infos)
{
	/* FIXME: w00t at code copy-paste, please modularize */
	xmmsc_result_t *rmres;
	guint plid, id;
	gint plsize;
	GArray *playlist;
	gint i;

	const gchar *err;
	xmmsv_t *val;

	val = xmmsc_result_get_value (matching);

	plsize = infos->cache->active_playlist->len;
	playlist = infos->cache->active_playlist;

	if (xmmsv_get_error (val, &err) || !xmmsv_is_list (val)) {
		g_printf (_("Error retrieving the media matching the pattern!\n"));
	} else {
		xmmsv_list_iter_t *it;

		xmmsv_get_list_iter (val, &it);

		/* Loop on the playlist (backward, easier to remove) */
		for (i = plsize - 1; i >= 0; i--) {
			plid = g_array_index (playlist, guint, i);

			/* Loop on the matched media */
			for (xmmsv_list_iter_first (it);
			     xmmsv_list_iter_valid (it);
			     xmmsv_list_iter_next (it)) {
				xmmsv_t *entry;

				xmmsv_list_iter_entry (it, &entry);

				/* If both match, remove! */
				if (xmmsv_get_uint (entry, &id) && plid == id) {
					rmres = xmmsc_playlist_remove_entry (infos->sync, NULL, i);
					xmmsc_result_wait (rmres);
					xmmsc_result_unref (rmres);
					break;
				}
			}
		}
	}

	cli_infos_loop_resume (infos);
	xmmsc_result_unref (matching);
}
Beispiel #23
0
static void
id_coldisp_print_info (cli_infos_t *infos, column_display_t *coldisp, guint id)
{
	xmmsc_result_t *infores;
	xmmsv_t *info;

	infores = xmmsc_medialib_get_info (infos->sync, id);
	xmmsc_result_wait (infores);
	info = xmmsv_propdict_to_dict (xmmsc_result_get_value (infores), NULL);
	column_display_print (coldisp, info);

	xmmsc_result_unref (infores);
	xmmsv_unref (info);
}
Beispiel #24
0
void
print_config (cli_infos_t *infos, xmmsc_result_t *res, gchar *confname)
{
	const gchar *confval;
	xmmsv_t *val;

	if (confname == NULL) {
		res = xmmsc_configval_list (infos->sync);
		xmmsc_result_wait (res);
		val = xmmsc_result_get_value (res);
		xmmsv_dict_foreach (val, print_config_entry, NULL);
	} else {
		res = xmmsc_configval_get (infos->sync, confname);
		xmmsc_result_wait (res);
		val = xmmsc_result_get_value (res);
		xmmsv_get_string (val, &confval);
		print_config_entry (confname, val, NULL);
	}

	cli_infos_loop_resume (infos);

	xmmsc_result_unref (res);
}
Beispiel #25
0
void
configure_playlist (xmmsc_result_t *res, cli_infos_t *infos, gchar *playlist,
                    gint history, gint upcoming, xmmsv_coll_type_t type,
                    gchar *input)
{
	xmmsc_result_t *saveres;
	xmmsv_coll_t *coll;
	xmmsv_coll_t *newcoll;
	xmmsv_t *val;

	gboolean copied = FALSE;

	val = xmmsc_result_get_value (res);

	if (xmmsv_get_coll (val, &coll)) {
		if (type >= 0 && xmmsv_coll_get_type (coll) != type) {
			newcoll = coll_copy_retype (coll, type);
			coll = newcoll;
			copied = TRUE;
		}
		if (history >= 0) {
			coll_int_attribute_set (coll, "history", history);
		}
		if (upcoming >= 0) {
			coll_int_attribute_set (coll, "upcoming", upcoming);
		}
		if (input) {
			/* Replace previous operand. */
			newcoll = coll_make_reference (input, XMMS_COLLECTION_NS_COLLECTIONS);
			xmmsv_list_clear (xmmsv_coll_operands_get (coll));
			xmmsv_coll_add_operand (coll, newcoll);
			xmmsv_coll_unref (newcoll);
		}

		saveres = xmmsc_coll_save (infos->sync, coll, playlist,
		                           XMMS_COLLECTION_NS_PLAYLISTS);
		xmmsc_result_wait (saveres);
		done (saveres, infos);
	} else {
		g_printf (_("Cannot find the playlist to configure!\n"));
		cli_infos_loop_resume (infos);
	}

	if (copied) {
		xmmsv_coll_unref (coll);
	}

	xmmsc_result_unref (res);
}
Beispiel #26
0
void
position_jump (cli_infos_t *infos, playlist_positions_t *positions)
{
	xmmsc_result_t *jumpres;
	int pos;

	if (playlist_positions_get_single (positions, &pos)) {
		jumpres = xmmsc_playlist_set_next (infos->sync, pos);
		xmmsc_result_wait (jumpres);
		tickle (jumpres, infos);
	} else {
		g_printf (_("Cannot jump to several positions!\n"));
	}

	cli_infos_loop_resume (infos);
}
Beispiel #27
0
char *
emusic_album_cover_path(const char *picture_front)
{

	xmmsc_result_t *res;
	xmmsv_t *return_value;
	res = xmmsc_bindata_retrieve( em->conn, picture_front );
	xmmsc_result_wait (res);
	return_value = xmmsc_result_get_value (res);
	char *tmp_buf = _on_cover_retrieve(return_value, picture_front);

	//xmmsv_unref (return_value);
	xmmsc_result_unref (res);

	return tmp_buf;
}
Beispiel #28
0
void
cmd_playlist_load (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	xmmsc_result_t *res;

	if (argc < 4) {
		print_error ("Supply a playlist name");
	}

	res = xmmsc_playlist_load (conn, argv[3]);
	xmmsc_result_wait (res);

	if (xmmsc_result_iserror (res)) {
		print_error ("%s", xmmsc_result_get_error (res));
	}
	xmmsc_result_unref (res);
}
Beispiel #29
0
void
cmd_rinsert (xmmsc_connection_t *conn, gint argc, gchar **argv)
{
	gchar *playlist;
	gchar *endptr;
	xmmsc_result_t *res;
	guint pos;
	gint i, fileargn;

	if (argc < 4) {
		print_error ("Missing argument(s)");
	}


	pos = strtol (argv[2], &endptr, 10);
	if (*endptr == '\0') {
		playlist = NULL; /* No playlist name */
		fileargn = 3;
	} else {
		playlist = argv[2];  /* extract playlist name */
		pos = strtol (argv[3], NULL, 10);
		fileargn = 4;
	}

	for (i = fileargn; i < argc; i++) {
		gchar *rfile;

		rfile = format_url (argv[i], G_FILE_TEST_IS_DIR);
		if (!rfile) {
			print_info ("Ignoring invalid path '%s'", argv[i]);
			continue;
		}

		res = xmmsc_playlist_rinsert (conn, playlist, pos, rfile);
		g_free (rfile);

		xmmsc_result_wait (res);

		if (xmmsc_result_iserror (res)) {
			print_info ("Cannot insert path '%s' at position %u: %s",
			            argv[i], pos, xmmsc_result_get_error (res));
		}

		xmmsc_result_unref (res);
	}
}
Beispiel #30
0
/* Apply operation to an idlist */
void
apply_ids (cli_infos_t *infos, xmmsc_result_t *res, idlist_command_t cmd)
{
	const gchar *err;
	xmmsc_result_t *cmdres;
	xmmsv_t *val;

	val = xmmsc_result_get_value (res);

	if (!xmmsv_get_error (val, &err)) {
		xmmsv_list_iter_t *it;

		xmmsv_get_list_iter (val, &it);

		for (xmmsv_list_iter_first (it);
		     xmmsv_list_iter_valid (it);
		     xmmsv_list_iter_next (it)) {
			xmmsv_t *entry;
			guint id;

			xmmsv_list_iter_entry (it, &entry);

			if (xmmsv_get_uint (entry, &id)) {
				switch (cmd) {
				case IDLIST_CMD_REHASH:
					cmdres = xmmsc_medialib_rehash (infos->sync, id);
					break;
				case IDLIST_CMD_REMOVE:
					cmdres = xmmsc_medialib_remove_entry (infos->sync, id);
					break;
				default:
					break;
				}
				xmmsc_result_wait (cmdres);
				xmmsc_result_unref (cmdres);
			}
		}
	} else {
		g_printf (_("Server error: %s\n"), err);
	}

	cli_infos_loop_resume (infos);

	xmmsc_result_unref (res);
}