PlaylistFile: use class SongLoader

This commit is contained in:
Max Kellermann 2014-02-03 23:30:34 +01:00
parent d533b59ee3
commit b9c248e7e7
4 changed files with 17 additions and 25 deletions

1
NEWS
View File

@ -3,6 +3,7 @@ ver 0.19 (not yet released)
- new commands "addtagid", "cleartagid" - new commands "addtagid", "cleartagid"
- "lsinfo" and "readcomments" allowed for remote files - "lsinfo" and "readcomments" allowed for remote files
- "listneighbors" lists file servers on the local network - "listneighbors" lists file servers on the local network
- "playlistadd" supports file:///
* database * database
- proxy: forward "idle" events - proxy: forward "idle" events
- proxy: copy "Last-Modified" from remote directories - proxy: copy "Last-Modified" from remote directories

View File

@ -22,8 +22,8 @@
#include "PlaylistSave.hxx" #include "PlaylistSave.hxx"
#include "db/PlaylistInfo.hxx" #include "db/PlaylistInfo.hxx"
#include "db/PlaylistVector.hxx" #include "db/PlaylistVector.hxx"
#include "db/DatabaseSong.hxx"
#include "DetachedSong.hxx" #include "DetachedSong.hxx"
#include "SongLoader.hxx"
#include "Mapper.hxx" #include "Mapper.hxx"
#include "fs/TextFile.hxx" #include "fs/TextFile.hxx"
#include "config/ConfigGlobal.hxx" #include "config/ConfigGlobal.hxx"
@ -402,24 +402,17 @@ spl_append_song(const char *utf8path, const DetachedSong &song, Error &error)
} }
bool 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)) { DetachedSong *song = loader.LoadSong(url, error);
return spl_append_song(utf8file, DetachedSong(url), if (song == nullptr)
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
return false; return false;
#endif
} bool success = spl_append_song(utf8file, *song, error);
delete song;
return success;
} }
static bool static bool

View File

@ -24,6 +24,7 @@
#include <string> #include <string>
class DetachedSong; class DetachedSong;
class SongLoader;
class PlaylistVector; class PlaylistVector;
class Error; class Error;
@ -71,7 +72,9 @@ bool
spl_append_song(const char *utf8path, const DetachedSong &song, Error &error); spl_append_song(const char *utf8path, const DetachedSong &song, Error &error);
bool 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 bool
spl_rename(const char *utf8from, const char *utf8to, Error &error); spl_rename(const char *utf8from, const char *utf8to, Error &error);

View File

@ -188,13 +188,8 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
bool success; bool success;
Error error; Error error;
if (uri_has_scheme(uri)) { if (uri_has_scheme(uri)) {
if (!uri_supported_scheme(uri)) { const SongLoader loader(client);
command_error(client, ACK_ERROR_NO_EXIST, success = spl_append_uri(playlist, loader, uri, error);
"unsupported URI scheme");
return CommandResult::ERROR;
}
success = spl_append_uri(playlist, uri, error);
} else { } else {
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
success = search_add_to_playlist(uri, playlist, nullptr, success = search_add_to_playlist(uri, playlist, nullptr,