aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlaylistPrint.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/PlaylistPrint.cxx')
-rw-r--r--src/PlaylistPrint.cxx83
1 files changed, 24 insertions, 59 deletions
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index e3d500be3..cfa56c7b3 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,23 +20,22 @@
#include "config.h"
#include "PlaylistPrint.hxx"
#include "PlaylistFile.hxx"
-#include "PlaylistAny.hxx"
-#include "PlaylistSong.hxx"
-#include "Playlist.hxx"
-#include "PlaylistRegistry.hxx"
-#include "PlaylistPlugin.hxx"
-#include "QueuePrint.hxx"
-#include "SongEnumerator.hxx"
+#include "queue/Playlist.hxx"
+#include "queue/QueuePrint.hxx"
#include "SongPrint.hxx"
-#include "DatabaseGlue.hxx"
-#include "DatabasePlugin.hxx"
-#include "Client.hxx"
-#include "InputStream.hxx"
-#include "Song.hxx"
+#include "Partition.hxx"
+#include "Instance.hxx"
+#include "db/Interface.hxx"
+#include "client/Client.hxx"
+#include "input/InputStream.hxx"
+#include "DetachedSong.hxx"
#include "fs/Traits.hxx"
#include "util/Error.hxx"
#include "thread/Cond.hxx"
+#define SONG_FILE "file: "
+#define SONG_TIME "Time: "
+
void
playlist_print_uris(Client &client, const playlist &playlist)
{
@@ -112,14 +111,16 @@ playlist_print_changes_position(Client &client,
queue_print_changes_position(client, playlist.queue, version);
}
+#ifdef ENABLE_DATABASE
+
static bool
PrintSongDetails(Client &client, const char *uri_utf8)
{
- const Database *db = GetDatabase();
+ const Database *db = client.partition.instance.database;
if (db == nullptr)
return false;
- Song *song = db->GetSong(uri_utf8, IgnoreError());
+ auto *song = db->GetSong(uri_utf8, IgnoreError());
if (song == nullptr)
return false;
@@ -128,63 +129,27 @@ PrintSongDetails(Client &client, const char *uri_utf8)
return true;
}
+#endif
+
bool
spl_print(Client &client, const char *name_utf8, bool detail,
Error &error)
{
+#ifndef ENABLE_DATABASE
+ (void)detail;
+#endif
+
PlaylistFileContents contents = LoadPlaylistFile(name_utf8, error);
if (contents.empty() && error.IsDefined())
return false;
for (const auto &uri_utf8 : contents) {
+#ifdef ENABLE_DATABASE
if (!detail || !PrintSongDetails(client, uri_utf8.c_str()))
+#endif
client_printf(client, SONG_FILE "%s\n",
uri_utf8.c_str());
}
return true;
}
-
-static void
-playlist_provider_print(Client &client, const char *uri,
- SongEnumerator &e, bool detail)
-{
- const std::string base_uri = uri != nullptr
- ? PathTraits::GetParentUTF8(uri)
- : std::string(".");
-
- Song *song;
- while ((song = e.NextSong()) != nullptr) {
- song = playlist_check_translate_song(song, base_uri.c_str(),
- false);
- if (song == nullptr)
- continue;
-
- if (detail)
- song_print_info(client, *song);
- else
- song_print_uri(client, *song);
-
- song->Free();
- }
-}
-
-bool
-playlist_file_print(Client &client, const char *uri, bool detail)
-{
- Mutex mutex;
- Cond cond;
-
- InputStream *is;
- SongEnumerator *playlist = playlist_open_any(uri, mutex, cond, &is);
- if (playlist == nullptr)
- return false;
-
- playlist_provider_print(client, uri, *playlist, detail);
- delete playlist;
-
- if (is != nullptr)
- is->Close();
-
- return true;
-}