[mpd] add special handling to command "lsinfo" if the root directory was

passed as argument.

Clients like ympd and ncmpcpp are relying on this (deprecated) behavior
This commit is contained in:
chme 2015-06-04 11:40:58 +02:00
parent b9b3671d58
commit ceca9135c5

View File

@ -2568,8 +2568,20 @@ mpd_command_lsinfo(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
struct filelist_info *fi; struct filelist_info *fi;
struct media_file_info *mfi; struct media_file_info *mfi;
char modified[32]; char modified[32];
int print_playlists;
int ret; int ret;
print_playlists = 0;
if (argc > 1 && strncmp(argv[1], "/", 1) == 0 && strlen(argv[1]) == 1)
{
/*
* Special handling necessary if the root directory '/' is given.
* In this case additional to the directory contents the stored playlists will be returned.
* This behavior is deprecated in the mpd protocol but clients like ncmpccp or ympd uses it.
*/
print_playlists = 1;
}
if (argc < 2 || strlen(argv[1]) == 0 if (argc < 2 || strlen(argv[1]) == 0
|| (strncmp(argv[1], "/", 1) == 0 && strlen(argv[1]) == 1)) || (strncmp(argv[1], "/", 1) == 0 && strlen(argv[1]) == 1))
{ {
@ -2653,6 +2665,12 @@ mpd_command_lsinfo(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
if (fi) if (fi)
free_fi(fi, 0); free_fi(fi, 0);
if (print_playlists)
{
// If the root directory was passed as argument add the stored playlists to the response
return mpd_command_listplaylists(evbuf, argc, argv, errmsg);
}
return 0; return 0;
} }