Example #1
0
/**
  * Convenient function for inserting a directory at a given position
  * in the playlist, It will dive down the URL you feed it and
  * recursivly insert all files.
  *
  * @param playlist the playlist to add it URL to.
  * @param plname the name of the playlist to modify.
  * @param pos a position in the playlist.
  * @param nurl the URL of an directory you want to add
  * @param err an #xmms_error_t that should be defined upon error.
  */
static void
xmms_playlist_client_rinsert (xmms_playlist_t *playlist, const gchar *plname, gint32 pos,
                              const gchar *path, xmms_error_t *err)
{
	xmmsv_coll_t *idlist;
	xmmsv_list_iter_t *it;
	xmmsv_t *list;

	idlist = xmms_medialib_add_recursive (playlist->medialib, path, err);
	list = xmmsv_coll_idlist_get (idlist);

	xmmsv_get_list_iter (list, &it);
	xmmsv_list_iter_last (it);
	while (xmmsv_list_iter_valid (it)) {
		xmms_medialib_entry_t entry;
		xmmsv_t *value;

		xmmsv_list_iter_entry (it, &value);
		xmmsv_get_int (value, &entry);

		xmms_playlist_insert_entry (playlist, plname, pos, entry, err);

		xmmsv_list_iter_prev (it);
	}

	xmmsv_coll_unref (idlist);
}
Example #2
0
static void
xmms_playlist_client_insert_collection (xmms_playlist_t *playlist, const gchar *plname,
                                        gint32 pos, xmmsv_coll_t *coll,
                                        xmmsv_t *order, xmms_error_t *err)
{
	xmmsv_list_iter_t *it;
	xmmsv_t *list;

	list = xmms_collection_query_ids (playlist->colldag, coll, 0, 0, order, err);
	if (xmms_error_iserror (err)) {
		return;
	}

	xmmsv_get_list_iter (list, &it);

	xmmsv_list_iter_last (it);

	while (xmmsv_list_iter_valid (it)) {
		xmms_medialib_entry_t mid;
		xmmsv_t *entry;

		xmmsv_list_iter_entry (it, &entry);
		xmmsv_get_int (entry, &mid);

		xmms_playlist_insert_entry (playlist, plname, pos, mid, err);

		xmmsv_list_iter_prev (it);
	}

	xmmsv_unref (list);
}
Example #3
0
/**
 * Return a collection with several order-operators added.
 *
 * @param coll	the original collection
 * @param order list of ordering strings or dicts.
 *
 * @return	coll with order-operators added
 */
xmmsv_t *
xmmsv_coll_add_order_operators (xmmsv_t *coll, xmmsv_t *order)
{
	xmmsv_list_iter_t *it;
	xmmsv_t *current, *value;

	x_api_error_if (coll == NULL, "with a NULL coll", NULL);

	xmmsv_ref (coll);

	if (!order) {
		return coll;
	}

	x_api_error_if (!xmmsv_is_type (order, XMMSV_TYPE_LIST),
	                "with a non list order", coll);

	current = coll;

	xmmsv_get_list_iter (order, &it);
	xmmsv_list_iter_last (it);

	while (xmmsv_list_iter_entry (it, &value)) {
		xmmsv_t *ordered;

		ordered = xmmsv_coll_add_order_operator (current, value);
		xmmsv_unref (current);

		current = ordered;
		xmmsv_list_iter_prev (it);
	}

	return current;
}