configure.ac: Move FAAD to Decoder Plugins, add header.
[mpd-mk.git] / src / queue_print.c
blobabd201d9f7079e4126722e160b96f80092c48891
1 /*
2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "config.h"
21 #include "queue_print.h"
22 #include "queue.h"
23 #include "song.h"
24 #include "song_print.h"
25 #include "locate.h"
26 #include "client.h"
28 /**
29 * Send detailed information about a range of songs in the queue to a
30 * client.
32 * @param client the client which has requested information
33 * @param start the index of the first song (including)
34 * @param end the index of the last song (excluding)
36 static void
37 queue_print_song_info(struct client *client, const struct queue *queue,
38 unsigned position)
40 song_print_info(client, queue_get(queue, position));
41 client_printf(client, "Pos: %u\nId: %u\n",
42 position, queue_position_to_id(queue, position));
45 void
46 queue_print_info(struct client *client, const struct queue *queue,
47 unsigned start, unsigned end)
49 assert(start <= end);
50 assert(end <= queue_length(queue));
52 for (unsigned i = start; i < end; ++i)
53 queue_print_song_info(client, queue, i);
56 void
57 queue_print_uris(struct client *client, const struct queue *queue,
58 unsigned start, unsigned end)
60 assert(start <= end);
61 assert(end <= queue_length(queue));
63 for (unsigned i = start; i < end; ++i) {
64 const struct song *song = queue_get(queue, i);
65 char *uri = song_get_uri(song);
67 client_printf(client, "%i:%s\n", i, uri);
68 g_free(uri);
72 void
73 queue_print_changes_info(struct client *client, const struct queue *queue,
74 uint32_t version)
76 for (unsigned i = 0; i < queue_length(queue); i++) {
77 if (queue_song_newer(queue, i, version))
78 queue_print_song_info(client, queue, i);
82 void
83 queue_print_changes_position(struct client *client, const struct queue *queue,
84 uint32_t version)
86 for (unsigned i = 0; i < queue_length(queue); i++)
87 if (queue_song_newer(queue, i, version))
88 client_printf(client, "cpos: %i\nId: %i\n",
89 i, queue_position_to_id(queue, i));
92 void
93 queue_search(struct client *client, const struct queue *queue,
94 const struct locate_item_list *criteria)
96 unsigned i;
97 struct locate_item_list *new_list =
98 locate_item_list_casefold(criteria);
100 for (i = 0; i < queue_length(queue); i++) {
101 const struct song *song = queue_get(queue, i);
103 if (locate_song_search(song, new_list))
104 queue_print_song_info(client, queue, i);
107 locate_item_list_free(new_list);
110 void
111 queue_find(struct client *client, const struct queue *queue,
112 const struct locate_item_list *criteria)
114 for (unsigned i = 0; i < queue_length(queue); i++) {
115 const struct song *song = queue_get(queue, i);
117 if (locate_song_match(song, criteria))
118 queue_print_song_info(client, queue, i);