aboutsummaryrefslogtreecommitdiff
path: root/src/QueueSave.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/QueueSave.cxx
parentfa3d1156a6bdbb8fab2a90e1716a1f152f7e8104 (diff)
database.h: eliminate db_*_song()
Use the C++ API.
Diffstat (limited to 'src/QueueSave.cxx')
-rw-r--r--src/QueueSave.cxx36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx
index 96713c70..d8b698a9 100644
--- a/src/QueueSave.cxx
+++ b/src/QueueSave.cxx
@@ -21,11 +21,12 @@
#include "QueueSave.hxx"
#include "song.h"
#include "SongSave.hxx"
+#include "DatabasePlugin.hxx"
+#include "DatabaseGlue.hxx"
extern "C" {
#include "queue.h"
#include "uri.h"
-#include "database.h"
#include "text_file.h"
}
@@ -69,20 +70,10 @@ queue_save(FILE *fp, const struct queue *queue)
}
}
-static struct song *
-get_song(const char *uri)
-{
- return uri_has_scheme(uri)
- ? song_remote_new(uri)
- : db_get_song(uri);
-}
-
void
queue_load_song(FILE *fp, GString *buffer, const char *line,
struct queue *queue)
{
- struct song *song;
-
if (queue_is_full(queue))
return;
@@ -95,6 +86,9 @@ queue_load_song(FILE *fp, GString *buffer, const char *line,
return;
}
+ const Database *db = nullptr;
+ struct song *song;
+
if (g_str_has_prefix(line, SONG_BEGIN)) {
const char *uri = line + sizeof(SONG_BEGIN) - 1;
if (!uri_has_scheme(uri) && !g_path_is_absolute(uri))
@@ -115,15 +109,23 @@ queue_load_song(FILE *fp, GString *buffer, const char *line,
return;
}
- line = endptr + 1;
+ const char *uri = endptr + 1;
- song = get_song(line);
- if (song == NULL)
- return;
+ if (uri_has_scheme(uri)) {
+ song = song_remote_new(uri);
+ } else {
+ db = GetDatabase(nullptr);
+ if (db == nullptr)
+ return;
+
+ song = db->GetSong(uri, nullptr);
+ if (song == nullptr)
+ return;
+ }
}
queue_append(queue, song, priority);
- if (song_in_database(song))
- db_return_song(song);
+ if (db != nullptr)
+ db->ReturnSong(song);
}