aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-03 23:30:34 +0100
committerMax Kellermann <max@duempel.org>2014-02-03 23:50:19 +0100
commitb9c248e7e7a451aa8aa2718323abd02a73d3dab5 (patch)
treee4cf7e376b7e8147b81532fc9b1c396061a0c3a1
parentd533b59ee33f13df854b0adb2588ab03bcaedfff (diff)
downloadmpd-b9c248e7e7a451aa8aa2718323abd02a73d3dab5.tar.gz
mpd-b9c248e7e7a451aa8aa2718323abd02a73d3dab5.tar.xz
mpd-b9c248e7e7a451aa8aa2718323abd02a73d3dab5.zip
PlaylistFile: use class SongLoader
-rw-r--r--NEWS1
-rw-r--r--src/PlaylistFile.cxx27
-rw-r--r--src/PlaylistFile.hxx5
-rw-r--r--src/command/PlaylistCommands.cxx9
4 files changed, 17 insertions, 25 deletions
diff --git a/NEWS b/NEWS
index 7db9cd4da..c309c7630 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.19 (not yet released)
- new commands "addtagid", "cleartagid"
- "lsinfo" and "readcomments" allowed for remote files
- "listneighbors" lists file servers on the local network
+ - "playlistadd" supports file:///
* database
- proxy: forward "idle" events
- proxy: copy "Last-Modified" from remote directories
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index 11d5fc302..a729ac8a0 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -22,8 +22,8 @@
#include "PlaylistSave.hxx"
#include "db/PlaylistInfo.hxx"
#include "db/PlaylistVector.hxx"
-#include "db/DatabaseSong.hxx"
#include "DetachedSong.hxx"
+#include "SongLoader.hxx"
#include "Mapper.hxx"
#include "fs/TextFile.hxx"
#include "config/ConfigGlobal.hxx"
@@ -402,24 +402,17 @@ spl_append_song(const char *utf8path, const DetachedSong &song, Error &error)
}
bool
-spl_append_uri(const char *utf8file, const char *url, Error &error)
+spl_append_uri(const char *utf8file,
+ const SongLoader &loader, const char *url,
+ Error &error)
{
- if (uri_has_scheme(url)) {
- return spl_append_song(utf8file, DetachedSong(url),
- error);
- } else {
-#ifdef ENABLE_DATABASE
- DetachedSong *song = DatabaseDetachSong(url, error);
- if (song == nullptr)
- return false;
-
- bool success = spl_append_song(utf8file, *song, error);
- delete song;
- return success;
-#else
+ DetachedSong *song = loader.LoadSong(url, error);
+ if (song == nullptr)
return false;
-#endif
- }
+
+ bool success = spl_append_song(utf8file, *song, error);
+ delete song;
+ return success;
}
static bool
diff --git a/src/PlaylistFile.hxx b/src/PlaylistFile.hxx
index 75aba71d4..7154b1f84 100644
--- a/src/PlaylistFile.hxx
+++ b/src/PlaylistFile.hxx
@@ -24,6 +24,7 @@
#include <string>
class DetachedSong;
+class SongLoader;
class PlaylistVector;
class Error;
@@ -71,7 +72,9 @@ bool
spl_append_song(const char *utf8path, const DetachedSong &song, Error &error);
bool
-spl_append_uri(const char *path_utf8, const char *uri_utf8, Error &error);
+spl_append_uri(const char *path_utf8,
+ const SongLoader &loader, const char *uri_utf8,
+ Error &error);
bool
spl_rename(const char *utf8from, const char *utf8to, Error &error);
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index f624386a6..10dfff876 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.cxx
@@ -188,13 +188,8 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
bool success;
Error error;
if (uri_has_scheme(uri)) {
- if (!uri_supported_scheme(uri)) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "unsupported URI scheme");
- return CommandResult::ERROR;
- }
-
- success = spl_append_uri(playlist, uri, error);
+ const SongLoader loader(client);
+ success = spl_append_uri(playlist, loader, uri, error);
} else {
#ifdef ENABLE_DATABASE
success = search_add_to_playlist(uri, playlist, nullptr,