mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 22:46:02 -05:00
[mpd/conf] Add config option to enable modifying stored playlists
This commit is contained in:
parent
dc3f9443e7
commit
8f49a6fb45
@ -265,9 +265,14 @@ mpd {
|
|||||||
# the playqueue if playback is stopped.
|
# the playqueue if playback is stopped.
|
||||||
# clear_queue_on_stop_disable = false
|
# 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
|
# 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
|
# 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 = ""
|
# default_playlist_directory = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ static cfg_opt_t sec_mpd[] =
|
|||||||
CFG_INT("port", 6600, CFGF_NONE),
|
CFG_INT("port", 6600, CFGF_NONE),
|
||||||
CFG_INT("http_port", 0, CFGF_NONE),
|
CFG_INT("http_port", 0, CFGF_NONE),
|
||||||
CFG_BOOL("clear_queue_on_stop_disable", cfg_false, 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_STR("default_playlist_directory", NULL, CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
20
src/mpd.c
20
src/mpd.c
@ -72,6 +72,7 @@ struct evconnlistener *listener;
|
|||||||
|
|
||||||
// Virtual path to the default playlist directory
|
// Virtual path to the default playlist directory
|
||||||
static char *default_pl_dir;
|
static char *default_pl_dir;
|
||||||
|
static bool allow_modifying_stored_playlists;
|
||||||
|
|
||||||
#define COMMAND_ARGV_MAX 37
|
#define COMMAND_ARGV_MAX 37
|
||||||
|
|
||||||
@ -2205,6 +2206,12 @@ mpd_command_playlistadd(struct evbuffer *evbuf, int argc, char **argv, char **er
|
|||||||
char *vp_item;
|
char *vp_item;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!allow_modifying_stored_playlists)
|
||||||
|
{
|
||||||
|
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
|
||||||
|
return ACK_ERROR_PERMISSION;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
*errmsg = safe_asprintf("Missing argument for command 'playlistadd'");
|
*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;
|
char *virtual_path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!allow_modifying_stored_playlists)
|
||||||
|
{
|
||||||
|
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
|
||||||
|
return ACK_ERROR_PERMISSION;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
*errmsg = safe_asprintf("Missing argument for command 'rm'");
|
*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;
|
char *virtual_path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!allow_modifying_stored_playlists)
|
||||||
|
{
|
||||||
|
*errmsg = safe_asprintf("Modifying stored playlists is not enabled");
|
||||||
|
return ACK_ERROR_PERMISSION;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
*errmsg = safe_asprintf("Missing argument for command 'save'");
|
*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");
|
pl_dir = cfg_getstr(cfg_getsec(cfg, "mpd"), "default_playlist_directory");
|
||||||
if (pl_dir)
|
if (pl_dir)
|
||||||
default_pl_dir = safe_asprintf("/file:%s", pl_dir);
|
default_pl_dir = safe_asprintf("/file:%s", pl_dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user