diff options
author | Max Kellermann <max@duempel.org> | 2014-01-30 20:29:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-30 20:39:40 +0100 |
commit | 4465e2c46bbed438377dc4a99df333bd5c058d5e (patch) | |
tree | cbc1d27aad939689f44b0ac3542a6ca1777b9dc1 /src/command | |
parent | 34b309b99aa2f274308f19974c428e1c7ac5d66f (diff) | |
download | mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.gz mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.xz mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.zip |
db: add compile-time option to disable database
Diffstat (limited to '')
-rw-r--r-- | src/command/AllCommands.cxx | 8 | ||||
-rw-r--r-- | src/command/CommandError.cxx | 2 | ||||
-rw-r--r-- | src/command/FileCommands.cxx | 5 | ||||
-rw-r--r-- | src/command/OtherCommands.cxx | 26 | ||||
-rw-r--r-- | src/command/PlayerCommands.cxx | 7 | ||||
-rw-r--r-- | src/command/PlaylistCommands.cxx | 7 | ||||
-rw-r--r-- | src/command/QueueCommands.cxx | 5 |
7 files changed, 56 insertions, 4 deletions
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index 750fd1219..3bc6ff6a9 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -85,7 +85,9 @@ static const struct command commands[] = { { "commands", PERMISSION_NONE, 0, 0, handle_commands }, { "config", PERMISSION_ADMIN, 0, 0, handle_config }, { "consume", PERMISSION_CONTROL, 1, 1, handle_consume }, +#ifdef ENABLE_DATABASE { "count", PERMISSION_READ, 2, -1, handle_count }, +#endif { "crossfade", PERMISSION_CONTROL, 1, 1, handle_crossfade }, { "currentsong", PERMISSION_READ, 0, 0, handle_currentsong }, { "decoders", PERMISSION_READ, 0, 0, handle_decoders }, @@ -93,13 +95,17 @@ static const struct command commands[] = { { "deleteid", PERMISSION_CONTROL, 1, 1, handle_deleteid }, { "disableoutput", PERMISSION_ADMIN, 1, 1, handle_disableoutput }, { "enableoutput", PERMISSION_ADMIN, 1, 1, handle_enableoutput }, +#ifdef ENABLE_DATABASE { "find", PERMISSION_READ, 2, -1, handle_find }, { "findadd", PERMISSION_READ, 2, -1, handle_findadd}, +#endif { "idle", PERMISSION_READ, 0, -1, handle_idle }, { "kill", PERMISSION_ADMIN, -1, -1, handle_kill }, +#ifdef ENABLE_DATABASE { "list", PERMISSION_READ, 1, -1, handle_list }, { "listall", PERMISSION_READ, 0, 1, handle_listall }, { "listallinfo", PERMISSION_READ, 0, 1, handle_listallinfo }, +#endif #ifdef ENABLE_NEIGHBOR_PLUGINS { "listneighbors", PERMISSION_READ, 0, 0, handle_listneighbors }, #endif @@ -146,9 +152,11 @@ static const struct command commands[] = { { "rescan", PERMISSION_CONTROL, 0, 1, handle_rescan }, { "rm", PERMISSION_CONTROL, 1, 1, handle_rm }, { "save", PERMISSION_CONTROL, 1, 1, handle_save }, +#ifdef ENABLE_DATABASE { "search", PERMISSION_READ, 2, -1, handle_search }, { "searchadd", PERMISSION_ADD, 2, -1, handle_searchadd }, { "searchaddpl", PERMISSION_CONTROL, 3, -1, handle_searchaddpl }, +#endif { "seek", PERMISSION_CONTROL, 2, 2, handle_seek }, { "seekcur", PERMISSION_CONTROL, 1, 1, handle_seekcur }, { "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid }, diff --git a/src/command/CommandError.cxx b/src/command/CommandError.cxx index 73e363f24..c94ffea63 100644 --- a/src/command/CommandError.cxx +++ b/src/command/CommandError.cxx @@ -101,6 +101,7 @@ print_error(Client &client, const Error &error) command_error(client, (ack)error.GetCode(), "%s", error.GetMessage()); return CommandResult::ERROR; +#ifdef ENABLE_DATABASE } else if (error.IsDomain(db_domain)) { switch ((enum db_error)error.GetCode()) { case DB_DISABLED: @@ -112,6 +113,7 @@ print_error(Client &client, const Error &error) command_error(client, ACK_ERROR_NO_EXIST, "Not found"); return CommandResult::ERROR; } +#endif } else if (error.IsDomain(errno_domain)) { command_error(client, ACK_ERROR_SYSTEM, "%s", strerror(error.GetCode())); diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index b3676fa48..345e9b85b 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -127,12 +127,17 @@ handle_read_comments(Client &client, gcc_unused int argc, char *argv[]) } else if (uri_has_scheme(uri)) { return read_stream_comments(client, uri); } else if (*uri != '/') { +#ifdef ENABLE_DATABASE path_fs = map_uri_fs(uri); if (path_fs.IsNull()) { command_error(client, ACK_ERROR_NO_EXIST, "No such file"); return CommandResult::ERROR; } +#else + command_error(client, ACK_ERROR_NO_EXIST, "No database"); + return CommandResult::ERROR; +#endif } else { command_error(client, ACK_ERROR_NO_EXIST, "No such file"); return CommandResult::ERROR; diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index 3c546b9b4..76f97f389 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -19,8 +19,6 @@ #include "config.h" #include "OtherCommands.hxx" -#include "DatabaseCommands.hxx" -#include "db/update/Service.hxx" #include "CommandError.hxx" #include "db/Uri.hxx" #include "DetachedSong.hxx" @@ -49,6 +47,11 @@ #include "Instance.hxx" #include "Idle.hxx" +#ifdef ENABLE_DATABASE +#include "DatabaseCommands.hxx" +#include "db/update/Service.hxx" +#endif + #include <assert.h> #include <string.h> @@ -170,14 +173,21 @@ handle_lsinfo(Client &client, int argc, char *argv[]) return CommandResult::OK; } +#ifdef ENABLE_DATABASE CommandResult result = handle_lsinfo2(client, argc, argv); if (result != CommandResult::OK) return result; +#endif if (isRootDirectory(uri)) { Error error; const auto &list = ListPlaylistFiles(error); print_spl_list(client, list); + } else { +#ifndef ENABLE_DATABASE + command_error(client, ACK_ERROR_NO_EXIST, "No database"); + return CommandResult::ERROR; +#endif } return CommandResult::OK; @@ -186,6 +196,7 @@ handle_lsinfo(Client &client, int argc, char *argv[]) static CommandResult handle_update(Client &client, int argc, char *argv[], bool discard) { +#ifdef ENABLE_DATABASE const char *path = ""; assert(argc <= 2); @@ -217,6 +228,15 @@ handle_update(Client &client, int argc, char *argv[], bool discard) "already updating"); return CommandResult::ERROR; } +#else + (void)client; + (void)argc; + (void)argv; + (void)discard; + + command_error(client, ACK_ERROR_NO_EXIST, "No database"); + return CommandResult::ERROR; +#endif } CommandResult @@ -329,9 +349,11 @@ handle_config(Client &client, return CommandResult::ERROR; } +#ifdef ENABLE_DATABASE const char *path = mapper_get_music_directory_utf8(); if (path != nullptr) client_printf(client, "music_directory: %s\n", path); +#endif return CommandResult::OK; } diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx index d51dbdc3d..a4e0ec0a7 100644 --- a/src/command/PlayerCommands.cxx +++ b/src/command/PlayerCommands.cxx @@ -22,7 +22,6 @@ #include "CommandError.hxx" #include "Playlist.hxx" #include "PlaylistPrint.hxx" -#include "db/update/Service.hxx" #include "client/Client.hxx" #include "mixer/Volume.hxx" #include "Partition.hxx" @@ -32,6 +31,10 @@ #include "AudioFormat.hxx" #include "ReplayGainConfig.hxx" +#ifdef ENABLE_DATABASE +#include "db/update/Service.hxx" +#endif + #define COMMAND_STATUS_STATE "state" #define COMMAND_STATUS_REPEAT "repeat" #define COMMAND_STATUS_SINGLE "single" @@ -187,6 +190,7 @@ handle_status(Client &client, } } +#ifdef ENABLE_DATABASE const UpdateService *update_service = client.partition.instance.update; unsigned updateJobId = update_service != nullptr ? update_service->GetId() @@ -196,6 +200,7 @@ handle_status(Client &client, COMMAND_STATUS_UPDATING_DB ": %i\n", updateJobId); } +#endif Error error = client.player_control.LockGetError(); if (error.IsDefined()) diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index bd2e24a17..272fb0ee4 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -193,9 +193,14 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[]) } success = spl_append_uri(uri, playlist, error); - } else + } else { +#ifdef ENABLE_DATABASE success = search_add_to_playlist(uri, playlist, nullptr, error); +#else + success = false; +#endif + } if (!success && !error.IsDefined()) { command_error(client, ACK_ERROR_NO_EXIST, diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx index ed2b551c4..0f326698b 100644 --- a/src/command/QueueCommands.cxx +++ b/src/command/QueueCommands.cxx @@ -74,11 +74,16 @@ handle_add(Client &client, gcc_unused int argc, char *argv[]) return print_playlist_result(client, result); } +#ifdef ENABLE_DATABASE const DatabaseSelection selection(uri, true); Error error; return AddFromDatabase(client.partition, selection, error) ? CommandResult::OK : print_error(client, error); +#else + command_error(client, ACK_ERROR_NO_EXIST, "No database"); + return CommandResult::ERROR; +#endif } CommandResult |