playlist: removed locate functions to queue_print.c
Now playlist.c does not contain any protocol specific code anymore.
This commit is contained in:
parent
53e712aca4
commit
cf9595df18
@ -914,7 +914,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
findSongsInPlaylist(client, numItems, items);
|
||||
queue_find(client, playlist_get_queue(), numItems, items);
|
||||
|
||||
freeLocateTagItemArray(numItems, items);
|
||||
|
||||
@ -934,7 +934,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
searchForSongsInPlaylist(client, numItems, items);
|
||||
queue_search(client, playlist_get_queue(), numItems, items);
|
||||
|
||||
freeLocateTagItemArray(numItems, items);
|
||||
|
||||
|
@ -1177,39 +1177,6 @@ enum playlist_result loadPlaylist(const char *utf8file)
|
||||
return PLAYLIST_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
searchForSongsInPlaylist(struct client *client,
|
||||
unsigned numItems, const struct locate_item *items)
|
||||
{
|
||||
unsigned i;
|
||||
struct locate_item *new_items =
|
||||
g_memdup(items, sizeof(items[0]) * numItems);
|
||||
|
||||
for (i = 0; i < numItems; i++)
|
||||
new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1);
|
||||
|
||||
for (i = 0; i < queue_length(&playlist.queue); i++) {
|
||||
const struct song *song = queue_get(&playlist.queue, i);
|
||||
|
||||
if (strstrSearchTags(song, numItems, items))
|
||||
queue_print_song_info(client, &playlist.queue, i);
|
||||
}
|
||||
|
||||
freeLocateTagItemArray(numItems, new_items);
|
||||
}
|
||||
|
||||
void
|
||||
findSongsInPlaylist(struct client *client,
|
||||
unsigned numItems, const struct locate_item *items)
|
||||
{
|
||||
for (unsigned i = 0; i < queue_length(&playlist.queue); i++) {
|
||||
const struct song *song = queue_get(&playlist.queue, i);
|
||||
|
||||
if (tagItemsFoundAndMatches(song, numItems, items))
|
||||
queue_print_song_info(client, &playlist.queue, i);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Not supporting '/' was done out of laziness, and we should really
|
||||
* strive to support it in the future.
|
||||
|
@ -26,9 +26,6 @@
|
||||
|
||||
#define PLAYLIST_COMMENT '#'
|
||||
|
||||
struct client;
|
||||
struct locate_item;
|
||||
|
||||
enum playlist_result {
|
||||
PLAYLIST_RESULT_SUCCESS,
|
||||
PLAYLIST_RESULT_ERRNO,
|
||||
@ -175,14 +172,6 @@ enum playlist_result seekSongInPlaylistById(unsigned id, float seek_time);
|
||||
|
||||
void playlistVersionChange(void);
|
||||
|
||||
void
|
||||
searchForSongsInPlaylist(struct client *client,
|
||||
unsigned numItems, const struct locate_item *items);
|
||||
|
||||
void
|
||||
findSongsInPlaylist(struct client *client,
|
||||
unsigned numItems, const struct locate_item *items);
|
||||
|
||||
int is_valid_playlist_name(const char *utf8path);
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "queue.h"
|
||||
#include "song.h"
|
||||
#include "song_print.h"
|
||||
#include "locate.h"
|
||||
#include "client.h"
|
||||
|
||||
void
|
||||
@ -77,3 +78,36 @@ queue_print_changes_position(struct client *client, const struct queue *queue,
|
||||
client_printf(client, "cpos: %i\nId: %i\n",
|
||||
i, queue_position_to_id(queue, i));
|
||||
}
|
||||
|
||||
void
|
||||
queue_search(struct client *client, const struct queue *queue,
|
||||
unsigned num_items, const struct locate_item *items)
|
||||
{
|
||||
unsigned i;
|
||||
struct locate_item *new_items =
|
||||
g_memdup(items, sizeof(items[0]) * num_items);
|
||||
|
||||
for (i = 0; i < num_items; i++)
|
||||
new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1);
|
||||
|
||||
for (i = 0; i < queue_length(queue); i++) {
|
||||
const struct song *song = queue_get(queue, i);
|
||||
|
||||
if (strstrSearchTags(song, num_items, items))
|
||||
queue_print_song_info(client, queue, i);
|
||||
}
|
||||
|
||||
freeLocateTagItemArray(num_items, new_items);
|
||||
}
|
||||
|
||||
void
|
||||
queue_find(struct client *client, const struct queue *queue,
|
||||
unsigned num_items, const struct locate_item *items)
|
||||
{
|
||||
for (unsigned i = 0; i < queue_length(queue); i++) {
|
||||
const struct song *song = queue_get(queue, i);
|
||||
|
||||
if (tagItemsFoundAndMatches(song, num_items, items))
|
||||
queue_print_song_info(client, queue, i);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
struct client;
|
||||
struct queue;
|
||||
struct locate_item;
|
||||
|
||||
void
|
||||
queue_print_song_info(struct client *client, const struct queue *queue,
|
||||
@ -57,4 +58,12 @@ void
|
||||
queue_print_changes_position(struct client *client, const struct queue *queue,
|
||||
uint32_t version);
|
||||
|
||||
void
|
||||
queue_search(struct client *client, const struct queue *queue,
|
||||
unsigned num_items, const struct locate_item *items);
|
||||
|
||||
void
|
||||
queue_find(struct client *client, const struct queue *queue,
|
||||
unsigned num_items, const struct locate_item *items);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user