diff options
author | Max Kellermann <max@duempel.org> | 2013-01-21 18:24:26 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-21 19:01:10 +0100 |
commit | 9ec069104f82184fbdc33bb82ead393441a41728 (patch) | |
tree | d887d486682b9f3916f84032d08812954d6b9aeb /src | |
parent | 7d21d60dbaefa90a2d52636766f7d060cb1cf481 (diff) | |
download | mpd-9ec069104f82184fbdc33bb82ead393441a41728.tar.gz mpd-9ec069104f82184fbdc33bb82ead393441a41728.tar.xz mpd-9ec069104f82184fbdc33bb82ead393441a41728.zip |
input,playlist/despotify: convert to C++
Diffstat (limited to 'src')
-rw-r--r-- | src/DespotifyUtils.cxx (renamed from src/despotify_utils.c) | 16 | ||||
-rw-r--r-- | src/DespotifyUtils.hxx (renamed from src/despotify_utils.h) | 2 | ||||
-rw-r--r-- | src/InputRegistry.cxx | 2 | ||||
-rw-r--r-- | src/input/DespotifyInputPlugin.cxx (renamed from src/input/despotify_input_plugin.c) | 28 | ||||
-rw-r--r-- | src/input/DespotifyInputPlugin.hxx (renamed from src/input/despotify_input_plugin.h) | 6 | ||||
-rw-r--r-- | src/playlist/DespotifyPlaylistPlugin.cxx (renamed from src/playlist/despotify_playlist_plugin.c) | 44 | ||||
-rw-r--r-- | src/playlist/DespotifyPlaylistPlugin.hxx (renamed from src/playlist/despotify_playlist_plugin.h) | 6 | ||||
-rw-r--r-- | src/playlist_list.c | 2 |
8 files changed, 61 insertions, 45 deletions
diff --git a/src/despotify_utils.c b/src/DespotifyUtils.cxx index 9f23c6336..c9a1edf0c 100644 --- a/src/despotify_utils.c +++ b/src/DespotifyUtils.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,12 +17,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "despotify_utils.h" +#include "DespotifyUtils.hxx" #include "tag.h" #include "conf.h" #include <glib.h> + +extern "C" { #include <despotify.h> +} static struct despotify_session *g_session; static void (*registered_callbacks[8])(struct despotify_session *, @@ -116,24 +119,25 @@ struct despotify_session *mpd_despotify_get_session(void) if (user == NULL || passwd == NULL) { g_debug("disabling despotify because account is not configured"); - return NULL; + return nullptr; } + if (!despotify_init()) { g_debug("Can't initialize despotify\n"); - return false; + return nullptr; } g_session = despotify_init_client(callback, NULL, high_bitrate, true); if (!g_session) { g_debug("Can't initialize despotify client\n"); - return false; + return nullptr; } if (!despotify_authenticate(g_session, user, passwd)) { g_debug("Can't authenticate despotify session\n"); despotify_exit(g_session); - return false; + return nullptr; } return g_session; diff --git a/src/despotify_utils.h b/src/DespotifyUtils.hxx index ab2968ab0..7e35edc3c 100644 --- a/src/despotify_utils.h +++ b/src/DespotifyUtils.hxx @@ -20,8 +20,6 @@ #ifndef MPD_DESPOTIFY_H #define MPD_DESPOTIFY_H -#include <stdbool.h> - struct despotify_session; struct ds_track; diff --git a/src/InputRegistry.cxx b/src/InputRegistry.cxx index 6c0898477..fa468724b 100644 --- a/src/InputRegistry.cxx +++ b/src/InputRegistry.cxx @@ -46,7 +46,7 @@ #endif #ifdef ENABLE_DESPOTIFY -#include "input/despotify_input_plugin.h" +#include "input/DespotifyInputPlugin.hxx" #endif #include <glib.h> diff --git a/src/input/despotify_input_plugin.c b/src/input/DespotifyInputPlugin.cxx index 200a0afd6..b42979e3b 100644 --- a/src/input/despotify_input_plugin.c +++ b/src/input/DespotifyInputPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Music Player Daemon Project + * Copyright (C) 2011-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,18 +18,21 @@ */ #include "config.h" -#include "input/despotify_input_plugin.h" +#include "DespotifyInputPlugin.hxx" +#include "DespotifyUtils.hxx" #include "input_internal.h" #include "input_plugin.h" #include "tag.h" -#include "despotify_utils.h" + +extern "C" { +#include <despotify.h> +} #include <glib.h> #include <unistd.h> #include <string.h> #include <errno.h> -#include <despotify.h> #include <stdio.h> @@ -220,11 +223,16 @@ input_despotify_tag(struct input_stream *is) } const struct input_plugin input_plugin_despotify = { - .name = "spt", - .open = input_despotify_open, - .close = input_despotify_close, - .read = input_despotify_read, - .eof = input_despotify_eof, - .seek = input_despotify_seek, + "spt", + nullptr, + nullptr, + input_despotify_open, + input_despotify_close, + nullptr, + nullptr, .tag = input_despotify_tag, + nullptr, + input_despotify_read, + input_despotify_eof, + input_despotify_seek, }; diff --git a/src/input/despotify_input_plugin.h b/src/input/DespotifyInputPlugin.hxx index 4c070d882..00d699408 100644 --- a/src/input/despotify_input_plugin.h +++ b/src/input/DespotifyInputPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Music Player Daemon Project + * Copyright (C) 2011-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef INPUT_DESPOTIFY_H -#define INPUT_DESPOTIFY_H +#ifndef INPUT_DESPOTIFY_HXX +#define INPUT_DESPOTIFY_HXX extern const struct input_plugin input_plugin_despotify; diff --git a/src/playlist/despotify_playlist_plugin.c b/src/playlist/DespotifyPlaylistPlugin.cxx index 30b852c73..049c9499c 100644 --- a/src/playlist/despotify_playlist_plugin.c +++ b/src/playlist/DespotifyPlaylistPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Music Player Daemon Project + * Copyright (C) 2011-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,8 @@ */ #include "config.h" -#include "playlist/despotify_playlist_plugin.h" +#include "DespotifyPlaylistPlugin.hxx" +#include "DespotifyUtils.hxx" #include "playlist_plugin.h" #include "playlist_list.h" #include "conf.h" @@ -26,14 +27,16 @@ #include "tag.h" #include "song.h" #include "input_stream.h" -#include "despotify_utils.h" + +extern "C" { +#include <despotify.h> +} #include <glib.h> #include <assert.h> #include <string.h> #include <stdlib.h> -#include <despotify.h> struct despotify_playlist { struct playlist_provider base; @@ -131,7 +134,7 @@ despotify_playlist_open_uri(const char *url, G_GNUC_UNUSED GMutex *mutex, ctx = g_new(struct despotify_playlist, 1); - ctx->list = NULL; + ctx->list = nullptr; ctx->session = session; playlist_provider_init(&ctx->base, &despotify_playlist_plugin); @@ -159,7 +162,7 @@ clean_playlist: g_slist_free(ctx->list); clean_none: - return NULL; + return nullptr; } static void @@ -175,7 +178,7 @@ despotify_playlist_close(struct playlist_provider *_playlist) { struct despotify_playlist *ctx = (struct despotify_playlist *)_playlist; - g_slist_foreach(ctx->list, track_free_callback, NULL); + g_slist_foreach(ctx->list, track_free_callback, nullptr); g_slist_free(ctx->list); g_free(ctx); @@ -186,13 +189,12 @@ static struct song * despotify_playlist_read(struct playlist_provider *_playlist) { struct despotify_playlist *ctx = (struct despotify_playlist *)_playlist; - struct song *out; if (!ctx->list) - return NULL; + return nullptr; /* Remove the current track */ - out = ctx->list->data; + song *out = (song *)ctx->list->data; ctx->list = g_slist_remove(ctx->list, out); return out; @@ -200,18 +202,22 @@ despotify_playlist_read(struct playlist_provider *_playlist) static const char *const despotify_schemes[] = { - "spt", - NULL + "spt", + nullptr }; const struct playlist_plugin despotify_playlist_plugin = { - .name = "despotify", + "despotify", + + despotify_playlist_init, + despotify_playlist_finish, - .init = despotify_playlist_init, - .finish = despotify_playlist_finish, - .open_uri = despotify_playlist_open_uri, - .read = despotify_playlist_read, - .close = despotify_playlist_close, + despotify_playlist_open_uri, + nullptr, + despotify_playlist_close, + despotify_playlist_read, - .schemes = despotify_schemes, + despotify_schemes, + nullptr, + nullptr, }; diff --git a/src/playlist/despotify_playlist_plugin.h b/src/playlist/DespotifyPlaylistPlugin.hxx index f8ee20de0..c1e5b7f39 100644 --- a/src/playlist/despotify_playlist_plugin.h +++ b/src/playlist/DespotifyPlaylistPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Music Player Daemon Project + * Copyright (C) 2011-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_H -#define MPD_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_H +#ifndef MPD_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_HXX +#define MPD_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_HXX extern const struct playlist_plugin despotify_playlist_plugin; diff --git a/src/playlist_list.c b/src/playlist_list.c index 68d24fe49..9ba78f38c 100644 --- a/src/playlist_list.c +++ b/src/playlist_list.c @@ -24,7 +24,7 @@ #include "playlist/m3u_playlist_plugin.h" #include "playlist/xspf_playlist_plugin.h" #include "playlist/lastfm_playlist_plugin.h" -#include "playlist/despotify_playlist_plugin.h" +#include "playlist/DespotifyPlaylistPlugin.hxx" #include "playlist/soundcloud_playlist_plugin.h" #include "playlist/pls_playlist_plugin.h" #include "playlist/asx_playlist_plugin.h" |