aboutsummaryrefslogtreecommitdiff
path: root/src/PlaylistPrint.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-03 00:30:15 +0100
committerMax Kellermann <max@duempel.org>2013-01-03 00:37:18 +0100
commitb4b0b34e5a131f02f723f40cf9566cc43e37cf85 (patch)
treec2afa49fe0b8f879a4c0c393e36916fde3c8ea8a /src/PlaylistPrint.cxx
parentfa3d1156a6bdbb8fab2a90e1716a1f152f7e8104 (diff)
database.h: eliminate db_*_song()
Use the C++ API.
Diffstat (limited to 'src/PlaylistPrint.cxx')
-rw-r--r--src/PlaylistPrint.cxx33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index 88c0a0a0..6fc354f3 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -24,13 +24,14 @@
#include "PlaylistSong.hxx"
#include "QueuePrint.hxx"
#include "SongPrint.hxx"
+#include "DatabaseGlue.hxx"
+#include "DatabasePlugin.hxx"
extern "C" {
#include "playlist_list.h"
#include "playlist_plugin.h"
#include "playlist.h"
#include "song.h"
-#include "database.h"
#include "client.h"
#include "input_stream.h"
}
@@ -112,6 +113,22 @@ playlist_print_changes_position(struct client *client,
queue_print_changes_position(client, &playlist->queue, version);
}
+static bool
+PrintSongDetails(struct client *client, const char *uri_utf8)
+{
+ const Database *db = GetDatabase(nullptr);
+ if (db == nullptr)
+ return false;
+
+ song *song = db->GetSong(uri_utf8, nullptr);
+ if (song == nullptr)
+ return false;
+
+ song_print_info(client, song);
+ db->ReturnSong(song);
+ return true;
+}
+
bool
spl_print(struct client *client, const char *name_utf8, bool detail,
GError **error_r)
@@ -124,21 +141,9 @@ spl_print(struct client *client, const char *name_utf8, bool detail,
}
for (const auto &uri_utf8 : contents) {
- bool wrote = false;
-
- if (detail) {
- struct song *song = db_get_song(uri_utf8.c_str());
- if (song) {
- song_print_info(client, song);
- db_return_song(song);
- wrote = true;
- }
- }
-
- if (!wrote) {
+ if (!detail || !PrintSongDetails(client, uri_utf8.c_str()))
client_printf(client, SONG_FILE "%s\n",
uri_utf8.c_str());
- }
}
return true;