aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/PlaylistCommands.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/PlaylistCommands.cxx')
-rw-r--r--src/command/PlaylistCommands.cxx71
1 files changed, 29 insertions, 42 deletions
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index d178fa097..e18673544 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.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
@@ -19,25 +19,24 @@
#include "config.h"
#include "PlaylistCommands.hxx"
-#include "DatabasePlaylist.hxx"
+#include "db/DatabasePlaylist.hxx"
#include "CommandError.hxx"
#include "PlaylistPrint.hxx"
#include "PlaylistSave.hxx"
#include "PlaylistFile.hxx"
-#include "PlaylistVector.hxx"
-#include "PlaylistQueue.hxx"
+#include "db/PlaylistVector.hxx"
+#include "SongLoader.hxx"
+#include "playlist/PlaylistQueue.hxx"
+#include "playlist/Print.hxx"
+#include "queue/Playlist.hxx"
#include "TimePrint.hxx"
-#include "Client.hxx"
+#include "client/Client.hxx"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
-#include "Playlist.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
-#include <assert.h>
-#include <stdlib.h>
-
static void
print_spl_list(Client &client, const PlaylistVector &list)
{
@@ -67,32 +66,15 @@ handle_load(Client &client, int argc, char *argv[])
} else if (!check_range(client, &start_index, &end_index, argv[2]))
return CommandResult::ERROR;
- const PlaylistResult result =
- playlist_open_into_queue(argv[1],
- start_index, end_index,
- client.playlist,
- client.player_control, true);
- if (result != PlaylistResult::NO_SUCH_LIST)
- return print_playlist_result(client, result);
-
Error error;
- if (playlist_load_spl(client.playlist, client.player_control,
- argv[1], start_index, end_index,
- error))
- return CommandResult::OK;
-
- if (error.IsDomain(playlist_domain) &&
- PlaylistResult(error.GetCode()) == PlaylistResult::BAD_NAME) {
- /* the message for BAD_NAME is confusing when the
- client wants to load a playlist file from the music
- directory; patch the Error object to show "no such
- playlist" instead */
- Error error2(playlist_domain, int(PlaylistResult::NO_SUCH_LIST),
- error.GetMessage());
- error = std::move(error2);
- }
+ const SongLoader loader(client);
+ if (!playlist_open_into_queue(argv[1],
+ start_index, end_index,
+ client.playlist,
+ client.player_control, loader, error))
+ return print_error(client, error);
- return print_error(client, error);
+ return CommandResult::OK;
}
CommandResult
@@ -188,16 +170,21 @@ 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(uri, playlist, error);
- } else
- success = search_add_to_playlist(uri, playlist, nullptr,
+ const SongLoader loader(client);
+ success = spl_append_uri(playlist, loader, uri, error);
+ } else {
+#ifdef ENABLE_DATABASE
+ const Database *db = client.GetDatabase(error);
+ if (db == nullptr)
+ return print_error(client, error);
+
+ success = search_add_to_playlist(*db, *client.GetStorage(),
+ uri, playlist, nullptr,
error);
+#else
+ success = false;
+#endif
+ }
if (!success && !error.IsDefined()) {
command_error(client, ACK_ERROR_NO_EXIST,