command: expect "file:///" url for local files

When adding a local file, clients have to use the "file" URI schema
described in RFC 1738 3.10.  By adding this schema to "urlhandlers", a
client can detect whether this feature is available.
This commit is contained in:
Max Kellermann 2008-10-17 17:53:43 +02:00
parent f548216ead
commit 7ca19736c9
1 changed files with 7 additions and 4 deletions

View File

@ -290,6 +290,8 @@ static void addCommand(const char *name,
static int handleUrlHandlers(struct client *client, static int handleUrlHandlers(struct client *client,
mpd_unused int argc, mpd_unused char *argv[]) mpd_unused int argc, mpd_unused char *argv[])
{ {
if (client_get_uid(client) > 0)
client_puts(client, "handler: file://\n");
return printRemoteUrlHandlers(client); return printRemoteUrlHandlers(client);
} }
@ -448,8 +450,8 @@ static int handleAdd(struct client *client,
char *path = argv[1]; char *path = argv[1];
enum playlist_result result; enum playlist_result result;
if (path[0] == '/' && path[1] != 0) { if (strncmp(path, "file:///", 8) == 0) {
result = playlist_append_file(path, client_get_uid(client), result = playlist_append_file(path + 7, client_get_uid(client),
NULL); NULL);
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
@ -473,8 +475,9 @@ static int handleAddId(struct client *client,
int added_id; int added_id;
enum playlist_result result; enum playlist_result result;
if (argv[1][0] == '/') if (strncmp(argv[1], "file:///", 8) == 0)
result = playlist_append_file(argv[1], client_get_uid(client), result = playlist_append_file(argv[1] + 7,
client_get_uid(client),
&added_id); &added_id);
else else
result = addToPlaylist(argv[1], &added_id); result = addToPlaylist(argv[1], &added_id);