aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-30 20:29:48 +0100
committerMax Kellermann <max@duempel.org>2014-01-30 20:39:40 +0100
commit4465e2c46bbed438377dc4a99df333bd5c058d5e (patch)
treecbc1d27aad939689f44b0ac3542a6ca1777b9dc1 /src
parent34b309b99aa2f274308f19974c428e1c7ac5d66f (diff)
downloadmpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.gz
mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.xz
mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.zip
db: add compile-time option to disable database
Diffstat (limited to 'src')
-rw-r--r--src/CommandLine.cxx14
-rw-r--r--src/Instance.cxx8
-rw-r--r--src/Instance.hxx25
-rw-r--r--src/Main.cxx23
-rw-r--r--src/Mapper.cxx35
-rw-r--r--src/Mapper.hxx12
-rw-r--r--src/Partition.hxx4
-rw-r--r--src/PlaylistEdit.cxx2
-rw-r--r--src/PlaylistFile.cxx8
-rw-r--r--src/PlaylistPrint.cxx10
-rw-r--r--src/PlaylistSave.cxx8
-rw-r--r--src/SongUpdate.cxx8
-rw-r--r--src/Stats.cxx10
-rw-r--r--src/command/AllCommands.cxx8
-rw-r--r--src/command/CommandError.cxx2
-rw-r--r--src/command/FileCommands.cxx5
-rw-r--r--src/command/OtherCommands.cxx26
-rw-r--r--src/command/PlayerCommands.cxx7
-rw-r--r--src/command/PlaylistCommands.cxx7
-rw-r--r--src/command/QueueCommands.cxx5
-rw-r--r--src/playlist/PlaylistMapper.cxx6
-rw-r--r--src/playlist/PlaylistSong.cxx4
-rw-r--r--src/queue/QueueSave.cxx2
23 files changed, 222 insertions, 17 deletions
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index 7884dea01..69af68495 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -23,8 +23,6 @@
#include "LogInit.hxx"
#include "Log.hxx"
#include "config/ConfigGlobal.hxx"
-#include "db/Registry.hxx"
-#include "db/DatabasePlugin.hxx"
#include "decoder/DecoderList.hxx"
#include "decoder/DecoderPlugin.hxx"
#include "output/Registry.hxx"
@@ -42,6 +40,11 @@
#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx"
+#ifdef ENABLE_DATABASE
+#include "db/Registry.hxx"
+#include "db/DatabasePlugin.hxx"
+#endif
+
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Registry.hxx"
#include "neighbor/NeighborPlugin.hxx"
@@ -102,12 +105,15 @@ static void version(void)
"Copyright (C) 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
"Copyright (C) 2008-2014 Max Kellermann <max@duempel.org>\n"
"This is free software; see the source for copying conditions. There is NO\n"
- "warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
- "\n"
+ "warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+
+#ifdef ENABLE_DATABASE
+ puts("\n"
"Database plugins:");
for (auto i = database_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
+#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
puts("\n\n"
diff --git a/src/Instance.cxx b/src/Instance.cxx
index 16000afb3..621b0d669 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -23,6 +23,8 @@
#include "Idle.hxx"
#include "Stats.hxx"
+#ifdef ENABLE_DATABASE
+
void
Instance::DeleteSong(const char *uri)
{
@@ -37,6 +39,8 @@ Instance::DatabaseModified()
idle_add(IDLE_DATABASE);
}
+#endif
+
void
Instance::TagModified()
{
@@ -49,12 +53,16 @@ Instance::SyncWithPlayer()
partition->SyncWithPlayer();
}
+#ifdef ENABLE_DATABASE
+
void
Instance::OnDatabaseModified()
{
DatabaseModified();
}
+#endif
+
#ifdef ENABLE_NEIGHBOR_PLUGINS
void
diff --git a/src/Instance.hxx b/src/Instance.hxx
index d67ff9a51..a2c141dc7 100644
--- a/src/Instance.hxx
+++ b/src/Instance.hxx
@@ -21,7 +21,6 @@
#define MPD_INSTANCE_HXX
#include "check.h"
-#include "db/DatabaseListener.hxx"
#include "Compiler.h"
#ifdef ENABLE_NEIGHBOR_PLUGINS
@@ -29,26 +28,42 @@
class NeighborGlue;
#endif
+#ifdef ENABLE_DATABASE
+#include "db/DatabaseListener.hxx"
class UpdateService;
+#endif
+
class ClientList;
struct Partition;
struct Instance final
- : public DatabaseListener
+#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
+ :
+#endif
+#ifdef ENABLE_DATABASE
+ public DatabaseListener
#ifdef ENABLE_NEIGHBOR_PLUGINS
- , public NeighborListener
+ ,
+#endif
+#endif
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+ public NeighborListener
#endif
{
#ifdef ENABLE_NEIGHBOR_PLUGINS
NeighborGlue *neighbors;
#endif
+#ifdef ENABLE_DATABASE
UpdateService *update;
+#endif
ClientList *client_list;
Partition *partition;
+#ifdef ENABLE_DATABASE
+
void DeleteSong(const char *uri);
/**
@@ -57,6 +72,8 @@ struct Instance final
*/
void DatabaseModified();
+#endif
+
/**
* A tag in the play queue has been modified by the player
* thread. Propagate the change to all subsystems.
@@ -69,7 +86,9 @@ struct Instance final
void SyncWithPlayer();
private:
+#ifdef ENABLE_DATABASE
virtual void OnDatabaseModified();
+#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
/* virtual methods from class NeighborListener */
diff --git a/src/Main.cxx b/src/Main.cxx
index 2c5d183ea..23b36ade3 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -23,13 +23,10 @@
#include "CommandLine.hxx"
#include "PlaylistFile.hxx"
#include "PlaylistGlobal.hxx"
-#include "db/update/Service.hxx"
#include "MusicChunk.hxx"
#include "StateFile.hxx"
#include "PlayerThread.hxx"
#include "Mapper.hxx"
-#include "db/DatabaseGlue.hxx"
-#include "db/DatabaseSimple.hxx"
#include "Permission.hxx"
#include "Listen.hxx"
#include "client/Client.hxx"
@@ -67,6 +64,12 @@
#include "config/ConfigOption.hxx"
#include "Stats.hxx"
+#ifdef ENABLE_DATABASE
+#include "db/update/Service.hxx"
+#include "db/DatabaseGlue.hxx"
+#include "db/DatabaseSimple.hxx"
+#endif
+
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Glue.hxx"
#endif
@@ -150,6 +153,8 @@ glue_mapper_init(Error &error)
return true;
}
+#ifdef ENABLE_DATABASE
+
/**
* Returns the database. If this function returns false, this has not
* succeeded, and the caller should create the database after the
@@ -202,6 +207,8 @@ glue_db_init_and_load(void)
return !db_is_simple() || db_exists();
}
+#endif
+
/**
* Configure and initialize the sticker subsystem.
*/
@@ -449,11 +456,13 @@ int mpd_main(int argc, char *argv[])
decoder_plugin_init_all();
+#ifdef ENABLE_DATABASE
const bool create_db = !glue_db_init_and_load();
instance->update = db_is_simple()
? new UpdateService(*main_loop)
: nullptr;
+#endif
glue_sticker_init();
@@ -490,6 +499,7 @@ int mpd_main(int argc, char *argv[])
player_create(instance->partition->pc);
+#ifdef ENABLE_DATABASE
if (create_db) {
/* the database failed to load: recreate the
database */
@@ -497,6 +507,7 @@ int mpd_main(int argc, char *argv[])
if (job == 0)
FatalError("directory update failed");
}
+#endif
if (!glue_state_file_init(error)) {
LogError(error);
@@ -562,6 +573,7 @@ int mpd_main(int argc, char *argv[])
}
#endif
+#ifdef ENABLE_DATABASE
delete instance->update;
const clock_t start = clock();
@@ -569,6 +581,7 @@ int mpd_main(int argc, char *argv[])
FormatDebug(main_domain,
"db_finish took %f seconds",
((float)(clock()-start))/CLOCKS_PER_SEC);
+#endif
#ifdef ENABLE_SQLITE
sticker_global_finish();
@@ -578,7 +591,11 @@ int mpd_main(int argc, char *argv[])
playlist_list_global_finish();
input_stream_global_finish();
+
+#ifdef ENABLE_DATABASE
mapper_finish();
+#endif
+
delete instance->partition;
command_finish();
decoder_plugin_deinit_all();
diff --git a/src/Mapper.cxx b/src/Mapper.cxx
index ebcab91bf..8d9544932 100644
--- a/src/Mapper.cxx
+++ b/src/Mapper.cxx
@@ -42,6 +42,8 @@
static constexpr Domain mapper_domain("mapper");
+#ifdef ENABLE_DATABASE
+
/**
* The absolute path of the music directory encoded in UTF-8.
*/
@@ -54,6 +56,8 @@ static size_t music_dir_utf8_length;
*/
static AllocatedPath music_dir_fs = AllocatedPath::Null();
+#endif
+
/**
* The absolute path of the playlist directory encoded in the
* filesystem character set.
@@ -91,6 +95,8 @@ check_directory(const char *path_utf8, const AllocatedPath &path_fs)
"No permission to read directory: %s", path_utf8);
}
+#ifdef ENABLE_DATABASE
+
static void
mapper_set_music_dir(AllocatedPath &&path)
{
@@ -105,6 +111,8 @@ mapper_set_music_dir(AllocatedPath &&path)
check_directory(music_dir_utf8.c_str(), music_dir_fs);
}
+#endif
+
static void
mapper_set_playlist_dir(AllocatedPath &&path)
{
@@ -119,8 +127,12 @@ mapper_set_playlist_dir(AllocatedPath &&path)
void
mapper_init(AllocatedPath &&_music_dir, AllocatedPath &&_playlist_dir)
{
+#ifdef ENABLE_DATABASE
if (!_music_dir.IsNull())
mapper_set_music_dir(std::move(_music_dir));
+#else
+ (void)_music_dir;
+#endif
if (!_playlist_dir.IsNull())
mapper_set_playlist_dir(std::move(_playlist_dir));
@@ -130,6 +142,8 @@ void mapper_finish(void)
{
}
+#ifdef ENABLE_DATABASE
+
const char *
mapper_get_music_directory_utf8(void)
{
@@ -144,17 +158,25 @@ mapper_get_music_directory_fs(void)
return music_dir_fs;
}
+#endif
+
const char *
map_to_relative_path(const char *path_utf8)
{
+#ifdef ENABLE_DATABASE
return !music_dir_utf8.empty() &&
memcmp(path_utf8, music_dir_utf8.c_str(),
music_dir_utf8_length) == 0 &&
PathTraitsUTF8::IsSeparator(path_utf8[music_dir_utf8_length])
? path_utf8 + music_dir_utf8_length + 1
: path_utf8;
+#else
+ return path_utf8;
+#endif
}
+#ifdef ENABLE_DATABASE
+
AllocatedPath
map_uri_fs(const char *uri)
{
@@ -240,15 +262,24 @@ map_song_fs(const Song &song)
: map_directory_child_fs(*song.parent, song.uri);
}
+#endif
+
AllocatedPath
map_song_fs(const DetachedSong &song)
{
if (song.IsAbsoluteFile())
return AllocatedPath::FromUTF8(song.GetRealURI());
- else
+ else {
+#ifdef ENABLE_DATABASE
return map_uri_fs(song.GetURI());
+#else
+ return AllocatedPath::Null();
+#endif
+ }
}
+#ifdef ENABLE_DATABASE
+
std::string
map_fs_to_utf8(const char *path_fs)
{
@@ -261,6 +292,8 @@ map_fs_to_utf8(const char *path_fs)
return PathToUTF8(path_fs);
}
+#endif
+
const AllocatedPath &
map_spl_path(void)
{
diff --git a/src/Mapper.hxx b/src/Mapper.hxx
index 5c01a9aff..33d3b94f5 100644
--- a/src/Mapper.hxx
+++ b/src/Mapper.hxx
@@ -41,6 +41,8 @@ mapper_init(AllocatedPath &&music_dir, AllocatedPath &&playlist_dir);
void mapper_finish(void);
+#ifdef ENABLE_DATABASE
+
/**
* Return the absolute path of the music directory encoded in UTF-8 or
* nullptr if no music directory was configured.
@@ -67,6 +69,8 @@ mapper_has_music_directory(void)
return mapper_get_music_directory_utf8() != nullptr;
}
+#endif
+
/**
* If the specified absolute path points inside the music directory,
* this function converts it to a relative path. If not, it returns
@@ -76,6 +80,8 @@ gcc_pure
const char *
map_to_relative_path(const char *path_utf8);
+#ifdef ENABLE_DATABASE
+
/**
* Determines the absolute file system path of a relative URI. This
* is basically done by converting the URI to the file system charset
@@ -126,10 +132,14 @@ gcc_pure
AllocatedPath
map_song_fs(const Song &song);
+#endif
+
gcc_pure
AllocatedPath
map_song_fs(const DetachedSong &song);
+#ifdef ENABLE_DATABASE
+
/**
* Maps a file system path (relative to the music directory or
* absolute) to a relative path in UTF-8 encoding.
@@ -142,6 +152,8 @@ gcc_pure
std::string
map_fs_to_utf8(const char *path_fs);
+#endif
+
/**
* Returns the playlist directory.
*/
diff --git a/src/Partition.hxx b/src/Partition.hxx
index 3ee110654..5e2469504 100644
--- a/src/Partition.hxx
+++ b/src/Partition.hxx
@@ -79,10 +79,14 @@ struct Partition {
return playlist.DeleteRange(pc, start, end);
}
+#ifdef ENABLE_DATABASE
+
void DeleteSong(const char *uri) {
playlist.DeleteSong(pc, uri);
}
+#endif
+
void Shuffle(unsigned start, unsigned end) {
playlist.Shuffle(pc, start, end);
}
diff --git a/src/PlaylistEdit.cxx b/src/PlaylistEdit.cxx
index 87a64c5c9..11b867546 100644
--- a/src/PlaylistEdit.cxx
+++ b/src/PlaylistEdit.cxx
@@ -112,8 +112,10 @@ playlist::AppendURI(PlayerControl &pc,
if (uri_has_scheme(uri)) {
song = new DetachedSong(uri);
} else {
+#ifdef ENABLE_DATABASE
song = DatabaseDetachSong(uri, IgnoreError());
if (song == nullptr)
+#endif
return PlaylistResult::NO_SUCH_SONG;
}
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index 71dbcba9c..86100fcde 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -243,6 +243,7 @@ LoadPlaylistFile(const char *utf8path, Error &error)
std::string uri_utf8;
if (!uri_has_scheme(s)) {
+#ifdef ENABLE_DATABASE
uri_utf8 = map_fs_to_utf8(s);
if (uri_utf8.empty()) {
if (PathTraitsFS::IsAbsolute(s)) {
@@ -254,6 +255,9 @@ LoadPlaylistFile(const char *utf8path, Error &error)
} else
continue;
}
+#else
+ continue;
+#endif
} else {
uri_utf8 = PathToUTF8(s);
if (uri_utf8.empty())
@@ -404,6 +408,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
return spl_append_song(utf8file, DetachedSong(url),
error);
} else {
+#ifdef ENABLE_DATABASE
DetachedSong *song = DatabaseDetachSong(url, error);
if (song == nullptr)
return false;
@@ -411,6 +416,9 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
bool success = spl_append_song(utf8file, *song, error);
delete song;
return success;
+#else
+ return false;
+#endif
}
}
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index faf373be7..377da25c9 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -110,6 +110,8 @@ 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)
{
@@ -126,16 +128,24 @@ 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());
}
diff --git a/src/PlaylistSave.cxx b/src/PlaylistSave.cxx
index 8eeab0f62..d9a0b4a47 100644
--- a/src/PlaylistSave.cxx
+++ b/src/PlaylistSave.cxx
@@ -55,10 +55,14 @@ playlist_print_song(FILE *file, const DetachedSong &song)
void
playlist_print_uri(FILE *file, const char *uri)
{
- auto path = playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
+ auto path =
+#ifdef ENABLE_DATABASE
+ playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
!PathTraitsUTF8::IsAbsolute(uri)
? map_uri_fs(uri)
- : AllocatedPath::FromUTF8(uri);
+ :
+#endif
+ AllocatedPath::FromUTF8(uri);
if (!path.IsNull())
fprintf(file, "%s\n", path.c_str());
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 0f3e9b172..665783279 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -39,6 +39,8 @@
#include <string.h>
#include <sys/stat.h>
+#ifdef ENABLE_DATABASE
+
Song *
Song::LoadFile(const char *path_utf8, Directory &parent)
{
@@ -64,6 +66,8 @@ Song::LoadFile(const char *path_utf8, Directory &parent)
return song;
}
+#endif
+
/**
* Attempts to load APE or ID3 tags from the specified file.
*/
@@ -75,6 +79,8 @@ tag_scan_fallback(Path path,
tag_id3_scan(path, handler, handler_ctx);
}
+#ifdef ENABLE_DATABASE
+
bool
Song::UpdateFile()
{
@@ -125,6 +131,8 @@ Song::UpdateFileInArchive()
return true;
}
+#endif
+
bool
DetachedSong::Update()
{
diff --git a/src/Stats.cxx b/src/Stats.cxx
index 940a984da..6d406a438 100644
--- a/src/Stats.cxx
+++ b/src/Stats.cxx
@@ -37,6 +37,8 @@
static unsigned start_time;
#endif
+#ifdef ENABLE_DATABASE
+
static DatabaseStats stats;
enum class StatsValidity : uint8_t {
@@ -45,6 +47,8 @@ enum class StatsValidity : uint8_t {
static StatsValidity stats_validity = StatsValidity::INVALID;
+#endif
+
void stats_global_init(void)
{
#ifndef WIN32
@@ -52,6 +56,8 @@ void stats_global_init(void)
#endif
}
+#ifdef ENABLE_DATABASE
+
void
stats_invalidate()
{
@@ -120,6 +126,8 @@ db_stats_print(Client &client)
(unsigned long)update_stamp);
}
+#endif
+
void
stats_print(Client &client)
{
@@ -133,6 +141,8 @@ stats_print(Client &client)
#endif
(unsigned long)(client.player_control.GetTotalPlayTime() + 0.5));
+#ifdef ENABLE_DATABASE
if (GetDatabase() != nullptr)
db_stats_print(client);
+#endif
}
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
diff --git a/src/playlist/PlaylistMapper.cxx b/src/playlist/PlaylistMapper.cxx
index 0df0bc61f..ec32abd32 100644
--- a/src/playlist/PlaylistMapper.cxx
+++ b/src/playlist/PlaylistMapper.cxx
@@ -64,6 +64,8 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond,
return playlist_open_path(path_fs.c_str(), mutex, cond, is_r);
}
+#ifdef ENABLE_DATABASE
+
/**
* Load a playlist from the configured music directory.
*/
@@ -80,6 +82,8 @@ playlist_open_in_music_dir(const char *uri, Mutex &mutex, Cond &cond,
return playlist_open_path(path.c_str(), mutex, cond, is_r);
}
+#endif
+
SongEnumerator *
playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond,
InputStream **is_r)
@@ -91,12 +95,14 @@ playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond,
return playlist;
}
+#ifdef ENABLE_DATABASE
if (uri_safe_local(uri)) {
auto playlist = playlist_open_in_music_dir(uri, mutex, cond,
is_r);
if (playlist != nullptr)
return playlist;
}
+#endif
return nullptr;
}
diff --git a/src/playlist/PlaylistSong.cxx b/src/playlist/PlaylistSong.cxx
index 69f8762ab..b382994a6 100644
--- a/src/playlist/PlaylistSong.cxx
+++ b/src/playlist/PlaylistSong.cxx
@@ -79,6 +79,7 @@ playlist_check_load_song(DetachedSong &song)
apply_song_metadata(song, tmp);
return true;
} else {
+#ifdef ENABLE_DATABASE
DetachedSong *tmp = DatabaseDetachSong(uri, IgnoreError());
if (tmp == nullptr)
return false;
@@ -86,6 +87,9 @@ playlist_check_load_song(DetachedSong &song)
apply_song_metadata(song, *tmp);
delete tmp;
return true;
+#else
+ return false;
+#endif
}
}
diff --git a/src/queue/QueueSave.cxx b/src/queue/QueueSave.cxx
index 11c61aa9a..051054da2 100644
--- a/src/queue/QueueSave.cxx
+++ b/src/queue/QueueSave.cxx
@@ -110,8 +110,10 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
if (uri_has_scheme(uri)) {
song = new DetachedSong(uri);
} else {
+#ifdef ENABLE_DATABASE
song = DatabaseDetachSong(uri, IgnoreError());
if (song == nullptr)
+#endif
return;
}
}