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/queue_print.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/queue_print.c') 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); + } +} -- cgit v1.2.3