diff options
author | Max Kellermann <max@duempel.org> | 2012-08-16 00:20:02 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-08-16 00:29:25 +0200 |
commit | 7968fa377923c305d381185e984cac7018a4e025 (patch) | |
tree | fc75c57a3b16d9242b5214266b021a36b30a4404 /src/db | |
parent | 31009bb1f6052fb3c6a41e3a97fdf09405cd577d (diff) | |
download | mpd-7968fa377923c305d381185e984cac7018a4e025.tar.gz mpd-7968fa377923c305d381185e984cac7018a4e025.tar.xz mpd-7968fa377923c305d381185e984cac7018a4e025.zip |
ProxyDatabase: implement GetSong()
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/ProxyDatabasePlugin.cxx | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 5604daf10..d36cebcfd 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -183,15 +183,38 @@ ProxyDatabase::Close() mpd_connection_free(connection); } +static song * +Convert(const struct mpd_song *song); + struct song * ProxyDatabase::GetSong(const char *uri, GError **error_r) const { // TODO: implement // TODO: auto-reconnect - g_set_error(error_r, db_quark(), DB_NOT_FOUND, - "No such song: %s", uri); - return nullptr; + if (!mpd_send_list_meta(connection, uri)) { + CheckError(connection, error_r); + return nullptr; + } + + struct mpd_song *song = mpd_recv_song(connection); + struct song *song2 = song != nullptr + ? Convert(song) + : nullptr; + mpd_song_free(song); + if (!mpd_response_finish(connection)) { + if (song2 != nullptr) + song_free(song2); + + CheckError(connection, error_r); + return nullptr; + } + + if (song2 == nullptr) + g_set_error(error_r, db_quark(), DB_NOT_FOUND, + "No such song: %s", uri); + + return song2; } void |