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.
21 #include "queue_print.h"
24 #include "song_print.h"
29 * Send detailed information about a range of songs in the queue to a
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)
37 queue_print_song_info(struct client
*client
, const struct queue
*queue
,
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
));
46 queue_print_info(struct client
*client
, const struct queue
*queue
,
47 unsigned start
, unsigned end
)
50 assert(end
<= queue_length(queue
));
52 for (unsigned i
= start
; i
< end
; ++i
)
53 queue_print_song_info(client
, queue
, i
);
57 queue_print_uris(struct client
*client
, const struct queue
*queue
,
58 unsigned start
, unsigned 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
);
73 queue_print_changes_info(struct client
*client
, const struct queue
*queue
,
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
);
83 queue_print_changes_position(struct client
*client
, const struct queue
*queue
,
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
));
93 queue_search(struct client
*client
, const struct queue
*queue
,
94 const struct locate_item_list
*criteria
)
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
);
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
);