PlaylistPlugin: pass config_param reference
This commit is contained in:
parent
65842cd99e
commit
fe53a376a3
@ -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 ¶m);
|
||||
|
||||
/**
|
||||
* 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 ¶m)
|
||||
{
|
||||
return plugin->init != NULL
|
||||
? plugin->init(param)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ static struct {
|
||||
} lastfm_config;
|
||||
|
||||
static bool
|
||||
lastfm_init(const struct config_param *param)
|
||||
lastfm_init(const config_param ¶m)
|
||||
{
|
||||
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 "
|
||||
|
@ -35,10 +35,9 @@ static struct {
|
||||
} soundcloud_config;
|
||||
|
||||
static bool
|
||||
soundcloud_init(const struct config_param *param)
|
||||
soundcloud_init(const config_param ¶m)
|
||||
{
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user