From 8c0060fae44a94bdfe978d8d4a66589f5a03a074 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Oct 2008 22:35:13 +0200 Subject: playlist: added support for adding songs not in the music database Clients which have authenticated via unix socket may add local files to the MPD playlist, provided that they own the file. --- src/command.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 3174faf70..b141bda45 100644 --- a/src/command.c +++ b/src/command.c @@ -229,6 +229,10 @@ static int print_playlist_result(struct client *client, command_error(client, ACK_ERROR_SYSTEM, strerror(errno)); return -1; + case PLAYLIST_RESULT_DENIED: + command_error(client, ACK_ERROR_NO_EXIST, "Access denied"); + return -1; + case PLAYLIST_RESULT_NO_SUCH_SONG: command_error(client, ACK_ERROR_NO_EXIST, "No such song"); return -1; @@ -444,6 +448,12 @@ static int handleAdd(struct client *client, char *path = argv[1]; enum playlist_result result; + if (path[0] == '/') { + result = playlist_append_file(path, client_get_uid(client), + NULL); + return print_playlist_result(client, result); + } + if (isRemoteUrl(path)) return addToPlaylist(path, NULL); @@ -461,7 +471,13 @@ static int handleAddId(struct client *client, int argc, char *argv[]) { int added_id; - enum playlist_result result = addToPlaylist(argv[1], &added_id); + enum playlist_result result; + + if (argv[1][0] == '/') + result = playlist_append_file(argv[1], client_get_uid(client), + &added_id); + else + result = addToPlaylist(argv[1], &added_id); if (result != PLAYLIST_RESULT_SUCCESS) return print_playlist_result(client, result); -- cgit v1.2.3