diff options
author | Max Kellermann <max@duempel.org> | 2009-10-13 16:19:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-13 16:19:21 +0200 |
commit | cb331ae436700efcfc81a15e6f98ae89c34392e0 (patch) | |
tree | 301d87ade3b499769517e17532765bb38ebf89e0 /src/playlist_list.c | |
parent | 767e27c8f0435325c18bdcebfac7ad5f1b813496 (diff) | |
download | mpd-cb331ae436700efcfc81a15e6f98ae89c34392e0.tar.gz mpd-cb331ae436700efcfc81a15e6f98ae89c34392e0.tar.xz mpd-cb331ae436700efcfc81a15e6f98ae89c34392e0.zip |
playlist_list: pass configuration to playlist plugins
This patch completes the configuration support.
Diffstat (limited to '')
-rw-r--r-- | src/playlist_list.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/playlist_list.c b/src/playlist_list.c index 5fb914a2f..6a0e85c64 100644 --- a/src/playlist_list.c +++ b/src/playlist_list.c @@ -23,10 +23,12 @@ #include "input_stream.h" #include "uri.h" #include "utils.h" +#include "conf.h" #include <glib.h> #include <assert.h> +#include <string.h> static const struct playlist_plugin *const playlist_plugins[] = { &m3u_playlist_plugin, @@ -36,12 +38,48 @@ static const struct playlist_plugin *const playlist_plugins[] = { /** which plugins have been initialized successfully? */ static bool playlist_plugins_enabled[G_N_ELEMENTS(playlist_plugins)]; +/** + * Find the "playlist" configuration block for the specified plugin. + * + * @param plugin_name the name of the playlist plugin + * @return the configuration block, or NULL if none was configured + */ +static const struct config_param * +playlist_plugin_config(const char *plugin_name) +{ + const struct config_param *param = NULL; + + assert(plugin_name != NULL); + + while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) { + const char *name = + config_get_block_string(param, "name", NULL); + if (name == NULL) + g_error("playlist configuration without 'plugin' name in line %d", + param->line); + + if (strcmp(name, plugin_name) == 0) + return param; + } + + return NULL; +} + void playlist_list_global_init(void) { - for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) + for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) { + const struct playlist_plugin *plugin = playlist_plugins[i]; + const struct config_param *param = + playlist_plugin_config(plugin->name); + + if (!config_get_block_bool(param, "enabled", true)) + /* the plugin is disabled in mpd.conf */ + continue; + playlist_plugins_enabled[i] = - playlist_plugin_init(playlist_plugins[i], NULL); + playlist_plugin_init(playlist_plugins[i], param); + } } void |