diff options
author | Max Kellermann <max@duempel.org> | 2013-01-03 00:30:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 00:37:18 +0100 |
commit | b4b0b34e5a131f02f723f40cf9566cc43e37cf85 (patch) | |
tree | c2afa49fe0b8f879a4c0c393e36916fde3c8ea8a /src/PlaylistEdit.cxx | |
parent | fa3d1156a6bdbb8fab2a90e1716a1f152f7e8104 (diff) |
database.h: eliminate db_*_song()
Use the C++ API.
Diffstat (limited to 'src/PlaylistEdit.cxx')
-rw-r--r-- | src/PlaylistEdit.cxx | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/PlaylistEdit.cxx b/src/PlaylistEdit.cxx index 76e10286..d44de058 100644 --- a/src/PlaylistEdit.cxx +++ b/src/PlaylistEdit.cxx @@ -27,12 +27,14 @@ extern "C" { #include "playlist_internal.h" #include "player_control.h" -#include "database.h" #include "uri.h" #include "song.h" #include "idle.h" } +#include "DatabaseGlue.hxx" +#include "DatabasePlugin.hxx" + #include <stdlib.h> static void playlist_increment_version(struct playlist *playlist) @@ -103,37 +105,30 @@ playlist_append_song(struct playlist *playlist, struct player_control *pc, return PLAYLIST_RESULT_SUCCESS; } -static struct song * -song_by_uri(const char *uri) -{ - struct song *song; - - song = db_get_song(uri); - if (song != NULL) - return song; - - if (uri_has_scheme(uri)) - return song_remote_new(uri); - - return NULL; -} - enum playlist_result playlist_append_uri(struct playlist *playlist, struct player_control *pc, const char *uri, unsigned *added_id) { - struct song *song; - g_debug("add to playlist: %s", uri); - song = song_by_uri(uri); - if (song == NULL) - return PLAYLIST_RESULT_NO_SUCH_SONG; + const Database *db = nullptr; + struct song *song; + if (uri_has_scheme(uri)) { + song = song_remote_new(uri); + } else { + db = GetDatabase(nullptr); + if (db == nullptr) + return PLAYLIST_RESULT_NO_SUCH_SONG; + + song = db->GetSong(uri, nullptr); + if (song == nullptr) + return PLAYLIST_RESULT_NO_SUCH_SONG; + } enum playlist_result result = playlist_append_song(playlist, pc, song, added_id); - if (song_in_database(song)) - db_return_song(song); + if (db != nullptr) + db->ReturnSong(song); return result; } |