diff options
author | Max Kellermann <max@duempel.org> | 2013-08-04 13:54:14 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-04 14:07:50 +0200 |
commit | fe53a376a3c2d6e7aa14c73df56df816e2d89d6f (patch) | |
tree | fd558f8cc84de5d1abe1059c152349e5eb8bb73c /src | |
parent | 65842cd99e82e30801bf287cd027c14e4ce3bd15 (diff) | |
download | mpd-fe53a376a3c2d6e7aa14c73df56df816e2d89d6f.tar.gz mpd-fe53a376a3c2d6e7aa14c73df56df816e2d89d6f.tar.xz mpd-fe53a376a3c2d6e7aa14c73df56df816e2d89d6f.zip |
PlaylistPlugin: pass config_param reference
Diffstat (limited to 'src')
-rw-r--r-- | src/PlaylistPlugin.hxx | 4 | ||||
-rw-r--r-- | src/PlaylistRegistry.cxx | 12 | ||||
-rw-r--r-- | src/playlist/LastFMPlaylistPlugin.cxx | 6 | ||||
-rw-r--r-- | src/playlist/SoundCloudPlaylistPlugin.cxx | 5 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/PlaylistPlugin.hxx b/src/PlaylistPlugin.hxx index ea39f6258..069b818ba 100644 --- a/src/PlaylistPlugin.hxx +++ b/src/PlaylistPlugin.hxx @@ -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) diff --git a/src/PlaylistRegistry.cxx b/src/PlaylistRegistry.cxx index 5e8b453df..97681d99e 100644 --- a/src/PlaylistRegistry.cxx +++ b/src/PlaylistRegistry.cxx @@ -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); } } diff --git a/src/playlist/LastFMPlaylistPlugin.cxx b/src/playlist/LastFMPlaylistPlugin.cxx index b4933e6a3..34abaeb5f 100644 --- a/src/playlist/LastFMPlaylistPlugin.cxx +++ b/src/playlist/LastFMPlaylistPlugin.cxx @@ -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 " diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index 01055d1c9..ce9bd1385 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -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"); |