summaryrefslogtreecommitdiff
path: root/src/playlist
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-15 23:17:53 +0200
committerMax Kellermann <max@duempel.org>2013-10-15 23:17:53 +0200
commit084fd8df63d98e8091a99a7d2d4950c6c25317d2 (patch)
tree356f1ebfa6f883e969eb2a7003e166a9926178eb /src/playlist
parent328131b7aa4344bc188b991f4c24a69d9739d4d2 (diff)
playlist/soundcloud: use std::string
Diffstat (limited to 'src/playlist')
-rw-r--r--src/playlist/SoundCloudPlaylistPlugin.cxx28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx
index ee256f31f..d70e4ed51 100644
--- a/src/playlist/SoundCloudPlaylistPlugin.cxx
+++ b/src/playlist/SoundCloudPlaylistPlugin.cxx
@@ -32,10 +32,12 @@
#include <glib.h>
#include <yajl/yajl_parse.h>
+#include <string>
+
#include <string.h>
static struct {
- char *apikey;
+ std::string apikey;
} soundcloud_config;
static constexpr Domain soundcloud_domain("soundcloud");
@@ -43,8 +45,8 @@ static constexpr Domain soundcloud_domain("soundcloud");
static bool
soundcloud_init(const config_param &param)
{
- soundcloud_config.apikey = param.DupBlockString("apikey");
- if (soundcloud_config.apikey == NULL) {
+ soundcloud_config.apikey = param.GetBlockValue("apikey", "");
+ if (soundcloud_config.apikey.empty()) {
LogDebug(soundcloud_domain,
"disabling the soundcloud playlist plugin "
"because API key is not set");
@@ -54,12 +56,6 @@ soundcloud_init(const config_param &param)
return true;
}
-static void
-soundcloud_finish(void)
-{
- g_free(soundcloud_config.apikey);
-}
-
/**
* Construct a full soundcloud resolver URL from the given fragment.
* @param uri uri of a soundcloud page (or just the path)
@@ -79,7 +75,8 @@ soundcloud_resolve(const char* uri) {
}
ru = g_strconcat("http://api.soundcloud.com/resolve.json?url=",
- u, "&client_id=", soundcloud_config.apikey, NULL);
+ u, "&client_id=",
+ soundcloud_config.apikey.c_str(), nullptr);
g_free(u);
return ru;
@@ -212,7 +209,8 @@ static int handle_end_map(void *ctx)
Song *s;
char *u;
- u = g_strconcat(data->stream_url, "?client_id=", soundcloud_config.apikey, NULL);
+ u = g_strconcat(data->stream_url, "?client_id=",
+ soundcloud_config.apikey.c_str(), nullptr);
s = Song::NewRemote(u);
g_free(u);
@@ -356,10 +354,12 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
char *u = NULL;
if (strcmp(arg, "track") == 0) {
u = g_strconcat("http://api.soundcloud.com/tracks/",
- rest, ".json?client_id=", soundcloud_config.apikey, NULL);
+ rest, ".json?client_id=",
+ soundcloud_config.apikey.c_str(), nullptr);
} else if (strcmp(arg, "playlist") == 0) {
u = g_strconcat("http://api.soundcloud.com/playlists/",
- rest, ".json?client_id=", soundcloud_config.apikey, NULL);
+ rest, ".json?client_id=",
+ soundcloud_config.apikey.c_str(), nullptr);
} else if (strcmp(arg, "url") == 0) {
/* Translate to soundcloud resolver call. libcurl will automatically
follow the redirect to the right resource. */
@@ -409,7 +409,7 @@ const struct playlist_plugin soundcloud_playlist_plugin = {
"soundcloud",
soundcloud_init,
- soundcloud_finish,
+ nullptr,
soundcloud_open_uri,
nullptr,