From cf9595df187d005489f8b94ed27dba2a6c94fd78 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 24 Jan 2009 14:55:28 +0100 Subject: playlist: removed locate functions to queue_print.c Now playlist.c does not contain any protocol specific code anymore. --- src/command.c | 4 ++-- src/playlist.c | 33 --------------------------------- src/playlist.h | 11 ----------- src/queue_print.c | 34 ++++++++++++++++++++++++++++++++++ src/queue_print.h | 9 +++++++++ 5 files changed, 45 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/command.c b/src/command.c index 911b6e8d8..cd47491ab 100644 --- a/src/command.c +++ b/src/command.c @@ -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); diff --git a/src/playlist.c b/src/playlist.c index d63180305..98fac5b7b 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -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. diff --git a/src/playlist.h b/src/playlist.h index e05fe0530..9d87c1e51 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -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 diff --git a/src/queue_print.c b/src/queue_print.c index 4ff43b181..fb56d4ad6 100644 --- a/src/queue_print.c +++ b/src/queue_print.c @@ -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); + } +} diff --git a/src/queue_print.h b/src/queue_print.h index 8ec7ff0fa..11740bb37 100644 --- a/src/queue_print.h +++ b/src/queue_print.h @@ -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 -- cgit v1.2.3