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,
|
* @return true if the plugin was initialized successfully,
|
||||||
* false if the plugin is not available
|
* 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.
|
* Deinitialize a plugin which was initialized successfully.
|
||||||
@ -96,7 +96,7 @@ struct playlist_plugin {
|
|||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
playlist_plugin_init(const struct playlist_plugin *plugin,
|
playlist_plugin_init(const struct playlist_plugin *plugin,
|
||||||
const struct config_param *param)
|
const config_param ¶m)
|
||||||
{
|
{
|
||||||
return plugin->init != NULL
|
return plugin->init != NULL
|
||||||
? plugin->init(param)
|
? plugin->init(param)
|
||||||
|
@ -83,8 +83,7 @@ playlist_plugin_config(const char *plugin_name)
|
|||||||
assert(plugin_name != NULL);
|
assert(plugin_name != NULL);
|
||||||
|
|
||||||
while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) {
|
while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) {
|
||||||
const char *name =
|
const char *name = param->GetBlockValue("name");
|
||||||
config_get_block_string(param, "name", NULL);
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
MPD_ERROR("playlist configuration without 'plugin' name in line %d",
|
MPD_ERROR("playlist configuration without 'plugin' name in line %d",
|
||||||
param->line);
|
param->line);
|
||||||
@ -99,17 +98,20 @@ playlist_plugin_config(const char *plugin_name)
|
|||||||
void
|
void
|
||||||
playlist_list_global_init(void)
|
playlist_list_global_init(void)
|
||||||
{
|
{
|
||||||
|
const config_param empty;
|
||||||
|
|
||||||
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 playlist_plugin *plugin = playlist_plugins[i];
|
||||||
const struct config_param *param =
|
const struct config_param *param =
|
||||||
playlist_plugin_config(plugin->name);
|
playlist_plugin_config(plugin->name);
|
||||||
|
if (param == nullptr)
|
||||||
if (!config_get_block_bool(param, "enabled", true))
|
param = ∅
|
||||||
|
else if (!param->GetBlockValue("enabled", true))
|
||||||
/* the plugin is disabled in mpd.conf */
|
/* the plugin is disabled in mpd.conf */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
playlist_plugins_enabled[i] =
|
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;
|
} lastfm_config;
|
||||||
|
|
||||||
static bool
|
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 *user = param.GetBlockValue("user");
|
||||||
const char *passwd = config_get_block_string(param, "password", NULL);
|
const char *passwd = param.GetBlockValue("password");
|
||||||
|
|
||||||
if (user == NULL || passwd == NULL) {
|
if (user == NULL || passwd == NULL) {
|
||||||
g_debug("disabling the last.fm playlist plugin "
|
g_debug("disabling the last.fm playlist plugin "
|
||||||
|
@ -35,10 +35,9 @@ static struct {
|
|||||||
} soundcloud_config;
|
} soundcloud_config;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
soundcloud_init(const struct config_param *param)
|
soundcloud_init(const config_param ¶m)
|
||||||
{
|
{
|
||||||
soundcloud_config.apikey =
|
soundcloud_config.apikey = param.DupBlockString("apikey");
|
||||||
config_dup_block_string(param, "apikey", NULL);
|
|
||||||
if (soundcloud_config.apikey == NULL) {
|
if (soundcloud_config.apikey == NULL) {
|
||||||
g_debug("disabling the soundcloud playlist plugin "
|
g_debug("disabling the soundcloud playlist plugin "
|
||||||
"because API key is not set");
|
"because API key is not set");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user