[mpd/conf] Add config option to enable modifying stored playlists

This commit is contained in:
chme 2017-08-12 08:28:05 +02:00
parent dc3f9443e7
commit 8f49a6fb45
3 changed files with 27 additions and 1 deletions

View File

@ -265,9 +265,14 @@ mpd {
# the playqueue if playback is stopped.
# clear_queue_on_stop_disable = false
# Allows creating, deleting and modifying m3u playlists in the library directories.
# Defaults to being disabled.
# allow_modifying_stored_playlists = false
# A directory in one of the library directories that will be used as the default
# playlist directory. forked-dapd creates new playlists in this directory if only
# a playlist name is provided by the mpd client.
# a playlist name is provided by the mpd client (requires "allow_modify_stored_playlists"
# set to true).
# default_playlist_directory = ""
}

View File

@ -156,6 +156,7 @@ static cfg_opt_t sec_mpd[] =
CFG_INT("port", 6600, CFGF_NONE),
CFG_INT("http_port", 0, CFGF_NONE),
CFG_BOOL("clear_queue_on_stop_disable", cfg_false, CFGF_NONE),
CFG_BOOL("allow_modifying_stored_playlists", cfg_false, CFGF_NONE),
CFG_STR("default_playlist_directory", NULL, CFGF_NONE),
CFG_END()
};

View File

@ -72,6 +72,7 @@ struct evconnlistener *listener;
// Virtual path to the default playlist directory
static char *default_pl_dir;
static bool allow_modifying_stored_playlists;
#define COMMAND_ARGV_MAX 37
@ -2205,6 +2206,12 @@ mpd_command_playlistadd(struct evbuffer *evbuf, int argc, char **argv, char **er
char *vp_item;
int ret;
if (!allow_modifying_stored_playlists)
{
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
return ACK_ERROR_PERMISSION;
}
if (argc < 3)
{
*errmsg = safe_asprintf("Missing argument for command 'playlistadd'");
@ -2242,6 +2249,12 @@ mpd_command_rm(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
char *virtual_path;
int ret;
if (!allow_modifying_stored_playlists)
{
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
return ACK_ERROR_PERMISSION;
}
if (argc < 2)
{
*errmsg = safe_asprintf("Missing argument for command 'rm'");
@ -2276,6 +2289,12 @@ mpd_command_save(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
char *virtual_path;
int ret;
if (!allow_modifying_stored_playlists)
{
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
return ACK_ERROR_PERMISSION;
}
if (argc < 2)
{
*errmsg = safe_asprintf("Missing argument for command 'save'");
@ -4943,6 +4962,7 @@ int mpd_init(void)
}
}
allow_modifying_stored_playlists = cfg_getbool(cfg_getsec(cfg, "mpd"), "allow_modifying_stored_playlists");
pl_dir = cfg_getstr(cfg_getsec(cfg, "mpd"), "default_playlist_directory");
if (pl_dir)
default_pl_dir = safe_asprintf("/file:%s", pl_dir);