aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-29 20:16:43 +0100
committerMax Kellermann <max@duempel.org>2014-01-30 18:47:05 +0100
commitc6725884bc155da431889468c86c546f0f64f9a1 (patch)
tree61d89751ecc98db9600620ac1788f32dea9214e1 /src/command
parenta31738f6f1473f4f621bc16513ed0c6024749389 (diff)
downloadmpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.gz
mpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.xz
mpd-c6725884bc155da431889468c86c546f0f64f9a1.zip
db/update: convert to OO API
Move global variables into the new classes. That may allow multiple update threads for multiple databases one day.
Diffstat (limited to '')
-rw-r--r--src/command/OtherCommands.cxx21
-rw-r--r--src/command/PlayerCommands.cxx10
2 files changed, 23 insertions, 8 deletions
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx
index f8976e561..2aa67f22c 100644
--- a/src/command/OtherCommands.cxx
+++ b/src/command/OtherCommands.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "OtherCommands.hxx"
#include "DatabaseCommands.hxx"
-#include "db/update/UpdateGlue.hxx"
+#include "db/update/Service.hxx"
#include "CommandError.hxx"
#include "db/Uri.hxx"
#include "DetachedSong.hxx"
@@ -46,6 +46,7 @@
#include "client/ClientFile.hxx"
#include "client/Client.hxx"
#include "Partition.hxx"
+#include "Instance.hxx"
#include "Idle.hxx"
#include <assert.h>
@@ -186,7 +187,6 @@ CommandResult
handle_update(Client &client, gcc_unused int argc, char *argv[])
{
const char *path = "";
- unsigned ret;
assert(argc <= 2);
if (argc == 2) {
@@ -202,7 +202,13 @@ handle_update(Client &client, gcc_unused int argc, char *argv[])
}
}
- ret = update_enqueue(path, false);
+ UpdateService *update = client.partition.instance.update;
+ if (update == nullptr) {
+ command_error(client, ACK_ERROR_NO_EXIST, "No database");
+ return CommandResult::ERROR;
+ }
+
+ unsigned ret = update->Enqueue(path, false);
if (ret > 0) {
client_printf(client, "updating_db: %i\n", ret);
return CommandResult::OK;
@@ -217,7 +223,6 @@ CommandResult
handle_rescan(Client &client, gcc_unused int argc, char *argv[])
{
const char *path = "";
- unsigned ret;
assert(argc <= 2);
if (argc == 2) {
@@ -230,7 +235,13 @@ handle_rescan(Client &client, gcc_unused int argc, char *argv[])
}
}
- ret = update_enqueue(path, true);
+ UpdateService *update = client.partition.instance.update;
+ if (update == nullptr) {
+ command_error(client, ACK_ERROR_NO_EXIST, "No database");
+ return CommandResult::ERROR;
+ }
+
+ unsigned ret = update->Enqueue(path, true);
if (ret > 0) {
client_printf(client, "updating_db: %i\n", ret);
return CommandResult::OK;
diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx
index 5dc55b485..d51dbdc3d 100644
--- a/src/command/PlayerCommands.cxx
+++ b/src/command/PlayerCommands.cxx
@@ -22,10 +22,11 @@
#include "CommandError.hxx"
#include "Playlist.hxx"
#include "PlaylistPrint.hxx"
-#include "db/update/UpdateGlue.hxx"
+#include "db/update/Service.hxx"
#include "client/Client.hxx"
#include "mixer/Volume.hxx"
#include "Partition.hxx"
+#include "Instance.hxx"
#include "protocol/Result.hxx"
#include "protocol/ArgParser.hxx"
#include "AudioFormat.hxx"
@@ -111,7 +112,6 @@ handle_status(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
const char *state = nullptr;
- int updateJobId;
int song;
const auto player_status = client.player_control.GetStatus();
@@ -187,7 +187,11 @@ handle_status(Client &client,
}
}
- if ((updateJobId = isUpdatingDB())) {
+ const UpdateService *update_service = client.partition.instance.update;
+ unsigned updateJobId = update_service != nullptr
+ ? update_service->GetId()
+ : 0;
+ if (updateJobId != 0) {
client_printf(client,
COMMAND_STATUS_UPDATING_DB ": %i\n",
updateJobId);