diff options
author | Max Kellermann <max@duempel.org> | 2009-11-06 01:09:21 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-11-06 01:09:21 +0100 |
commit | 8cb9f9b0700e3d7a9cbb94aff674fcf632943eb6 (patch) | |
tree | 80b20221204a803786c61b751ce763ed82538f84 | |
parent | 61cb5df842cc3d5477e18b92ff7157110759ea3b (diff) | |
download | mpd-8cb9f9b0700e3d7a9cbb94aff674fcf632943eb6.tar.gz mpd-8cb9f9b0700e3d7a9cbb94aff674fcf632943eb6.tar.xz mpd-8cb9f9b0700e3d7a9cbb94aff674fcf632943eb6.zip |
playlist_queue: use playlist plugins to load from playlist_directory
This patch allows the client to load a playlist file from the playlist
directory with a plugin. This can be used with the "load" command,
but the client has to pass the file name including the suffix. We
will probably use the music directory in the future, to support
playlist files inside the music directory.
-rw-r--r-- | src/playlist_queue.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/playlist_queue.c b/src/playlist_queue.c index f392ce96a..55c394bd7 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -20,6 +20,8 @@ #include "playlist_queue.h" #include "playlist_list.h" #include "playlist_plugin.h" +#include "stored_playlist.h" +#include "mapper.h" #include "song.h" #include "uri.h" #include "ls.h" @@ -91,11 +93,42 @@ playlist_open_remote_into_queue(const char *uri, struct playlist *dest) return result; } +static enum playlist_result +playlist_open_local_into_queue(const char *uri, struct playlist *dest) +{ + struct playlist_provider *playlist; + const char *playlist_directory_fs; + char *path_fs; + struct input_stream is; + enum playlist_result result; + + assert(spl_valid_name(uri)); + + playlist_directory_fs = map_spl_path(); + if (playlist_directory_fs == NULL) + return PLAYLIST_RESULT_DISABLED; + + path_fs = g_build_filename(playlist_directory_fs, uri, NULL); + playlist = playlist_list_open_path(&is, path_fs); + g_free(path_fs); + if (playlist == NULL) + return PLAYLIST_RESULT_NO_SUCH_LIST; + + result = playlist_load_into_queue(playlist, dest); + playlist_plugin_close(playlist); + + input_stream_close(&is); + + return result; +} + enum playlist_result playlist_open_into_queue(const char *uri, struct playlist *dest) { if (uri_has_scheme(uri)) return playlist_open_remote_into_queue(uri, dest); + else if (spl_valid_name(uri)) + return playlist_open_local_into_queue(uri, dest); else return PLAYLIST_RESULT_NO_SUCH_LIST; } |