Exemple #1
0
MpdData * mpd_database_get_artists(MpdObj *mi)
{
	char *string = NULL;
	MpdData *data = NULL;
	if(!mpd_check_connected(mi))
	{
		debug_printf(DEBUG_WARNING,"not connected\n");
		return NULL;
	}
	if(mpd_lock_conn(mi))
	{
		debug_printf(DEBUG_ERROR,"lock failed\n");
		return NULL;
	}

	mpd_sendListCommand(mi->connection,MPD_TABLE_ARTIST,NULL);
	while (( string = mpd_getNextArtist(mi->connection)) != NULL)
	{
		data = mpd_new_data_struct_append(data);
		data->type = MPD_DATA_TYPE_TAG;
		data->tag_type = MPD_TAG_ITEM_ARTIST;
		data->tag = string;
	}
	mpd_finishCommand(mi->connection);

	/* unlock */
	mpd_unlock_conn(mi);
	if(data == NULL)
	{
		return NULL;
	}
	data = mpd_misc_sort_tag_list(data);
	return mpd_data_get_first(data);
}
static void queue_artist(ttk_menu_item *item)
{
    char *album;
    if (mpdc_tickle() < 0)
        return;
    mpd_sendListCommand(mpdz, MPD_TABLE_ALBUM, item->name);
    if (mpdz->error) {
        mpdc_tickle();
        return;
    }
    while ((album = mpd_getNextAlbum(mpdz))) {
        mpdc_queue_data(1, strdup(album), NULL, NULL);
    }
    mpd_finishCommand(mpdz);
    mpdc_queue_data(1, (void *)item->name, enqueue_album, NULL);
}