PlaylistPlugin: pass config_param reference

This commit is contained in:
Max Kellermann 2013-08-04 13:54:14 +02:00
parent 65842cd99e
commit fe53a376a3
4 changed files with 14 additions and 13 deletions

View File

@ -55,7 +55,7 @@ struct playlist_plugin {
* @return true if the plugin was initialized successfully,
* false if the plugin is not available
*/
bool (*init)(const struct config_param *param);
bool (*init)(const config_param &param);
/**
* Deinitialize a plugin which was initialized successfully.
@ -96,7 +96,7 @@ struct playlist_plugin {
*/
static inline bool
playlist_plugin_init(const struct playlist_plugin *plugin,
const struct config_param *param)
const config_param &param)
{
return plugin->init != NULL
? plugin->init(param)

View File

@ -83,8 +83,7 @@ playlist_plugin_config(const char *plugin_name)
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);
const char *name = param->GetBlockValue("name");
if (name == NULL)
MPD_ERROR("playlist configuration without 'plugin' name in line %d",
param->line);
@ -99,17 +98,20 @@ playlist_plugin_config(const char *plugin_name)
void
playlist_list_global_init(void)
{
const config_param empty;
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))
if (param == nullptr)
param = ∅
else if (!param->GetBlockValue("enabled", true))
/* the plugin is disabled in mpd.conf */
continue;
playlist_plugins_enabled[i] =
playlist_plugin_init(playlist_plugins[i], param);
playlist_plugin_init(playlist_plugins[i], *param);
}
}

View File

@ -44,10 +44,10 @@ static struct {
} lastfm_config;
static bool
lastfm_init(const struct config_param *param)
lastfm_init(const config_param &param)
{
const char *user = config_get_block_string(param, "user", NULL);
const char *passwd = config_get_block_string(param, "password", NULL);
const char *user = param.GetBlockValue("user");
const char *passwd = param.GetBlockValue("password");
if (user == NULL || passwd == NULL) {
g_debug("disabling the last.fm playlist plugin "

View File

@ -35,10 +35,9 @@ static struct {
} soundcloud_config;
static bool
soundcloud_init(const struct config_param *param)
soundcloud_init(const config_param &param)
{
soundcloud_config.apikey =
config_dup_block_string(param, "apikey", NULL);
soundcloud_config.apikey = param.DupBlockString("apikey");
if (soundcloud_config.apikey == NULL) {
g_debug("disabling the soundcloud playlist plugin "
"because API key is not set");