aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-08-13 12:48:31 +0200
committerMax Kellermann <max@duempel.org>2015-08-13 12:48:31 +0200
commit86e036c3933def22b6ff0eae5bcf9cd7103240e7 (patch)
treee8d812461e22b189cea3b3df908515cebbfe0cd1 /src
parent7652a2986b0d0ad55b2776685130f1c68d7108c7 (diff)
downloadmpd-86e036c3933def22b6ff0eae5bcf9cd7103240e7.tar.gz
mpd-86e036c3933def22b6ff0eae5bcf9cd7103240e7.tar.xz
mpd-86e036c3933def22b6ff0eae5bcf9cd7103240e7.zip
command: pass Response object to command callbacks
Diffstat (limited to 'src')
-rw-r--r--src/command/AllCommands.cxx31
-rw-r--r--src/command/DatabaseCommands.cxx51
-rw-r--r--src/command/DatabaseCommands.hxx23
-rw-r--r--src/command/FileCommands.cxx9
-rw-r--r--src/command/FileCommands.hxx6
-rw-r--r--src/command/MessageCommands.cxx17
-rw-r--r--src/command/MessageCommands.hxx11
-rw-r--r--src/command/NeighborCommands.cxx4
-rw-r--r--src/command/NeighborCommands.hxx3
-rw-r--r--src/command/OtherCommands.cxx81
-rw-r--r--src/command/OtherCommands.hxx33
-rw-r--r--src/command/OutputCommands.cxx16
-rw-r--r--src/command/OutputCommands.hxx9
-rw-r--r--src/command/PlayerCommands.cxx77
-rw-r--r--src/command/PlayerCommands.hxx43
-rw-r--r--src/command/PlaylistCommands.cxx44
-rw-r--r--src/command/PlaylistCommands.hxx23
-rw-r--r--src/command/QueueCommands.cxx81
-rw-r--r--src/command/QueueCommands.hxx41
-rw-r--r--src/command/StickerCommands.cxx4
-rw-r--r--src/command/StickerCommands.hxx3
-rw-r--r--src/command/StorageCommands.cxx12
-rw-r--r--src/command/StorageCommands.hxx6
-rw-r--r--src/command/TagCommands.cxx8
-rw-r--r--src/command/TagCommands.hxx5
25 files changed, 246 insertions, 395 deletions
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx
index 57d4db983..aa60736f3 100644
--- a/src/command/AllCommands.cxx
+++ b/src/command/AllCommands.cxx
@@ -64,15 +64,15 @@ struct command {
unsigned permission;
int min;
int max;
- CommandResult (*handler)(Client &client, Request args);
+ CommandResult (*handler)(Client &client, Request request, Response &response);
};
/* don't be fooled, this is the command handler for "commands" command */
static CommandResult
-handle_commands(Client &client, Request args);
+handle_commands(Client &client, Request request, Response &response);
static CommandResult
-handle_not_commands(Client &client, Request args);
+handle_not_commands(Client &client, Request request, Response &response);
/**
* The command registry.
@@ -257,17 +257,15 @@ PrintUnavailableCommands(Response &r, unsigned permission)
/* don't be fooled, this is the command handler for "commands" command */
static CommandResult
-handle_commands(Client &client, gcc_unused Request args)
+handle_commands(Client &client, gcc_unused Request request, Response &r)
{
- Response r(client);
return PrintAvailableCommands(r, client.partition,
client.GetPermission());
}
static CommandResult
-handle_not_commands(Client &client, gcc_unused Request args)
+handle_not_commands(Client &client, gcc_unused Request request, Response &r)
{
- Response r(client);
return PrintUnavailableCommands(r, client.GetPermission());
}
@@ -308,11 +306,10 @@ command_lookup(const char *name)
}
static bool
-command_check_request(const struct command *cmd, Client &client,
+command_check_request(const struct command *cmd, Response &r,
unsigned permission, Request args)
{
if (cmd->permission != (permission & cmd->permission)) {
- Response r(client);
r.FormatError(ACK_ERROR_PERMISSION,
"you don't have permission for \"%s\"",
cmd->cmd);
@@ -326,18 +323,15 @@ command_check_request(const struct command *cmd, Client &client,
return true;
if (min == max && unsigned(max) != args.size) {
- Response r(client);
r.FormatError(ACK_ERROR_ARG,
"wrong number of arguments for \"%s\"",
cmd->cmd);
return false;
} else if (args.size < unsigned(min)) {
- Response r(client);
r.FormatError(ACK_ERROR_ARG,
"too few arguments for \"%s\"", cmd->cmd);
return false;
} else if (max >= 0 && args.size > unsigned(max)) {
- Response r(client);
r.FormatError(ACK_ERROR_ARG,
"too many arguments for \"%s\"", cmd->cmd);
return false;
@@ -346,14 +340,13 @@ command_check_request(const struct command *cmd, Client &client,
}
static const struct command *
-command_checked_lookup(Client &client, unsigned permission,
+command_checked_lookup(Response &r, unsigned permission,
const char *cmd_name, Request args)
{
current_command = "";
const struct command *cmd = command_lookup(cmd_name);
if (cmd == nullptr) {
- Response r(client);
r.FormatError(ACK_ERROR_UNKNOWN,
"unknown command \"%s\"", cmd_name);
return nullptr;
@@ -361,7 +354,7 @@ command_checked_lookup(Client &client, unsigned permission,
current_command = cmd->cmd;
- if (!command_check_request(cmd, client, permission, args))
+ if (!command_check_request(cmd, r, permission, args))
return nullptr;
return cmd;
@@ -370,6 +363,7 @@ command_checked_lookup(Client &client, unsigned permission,
CommandResult
command_process(Client &client, unsigned num, char *line)
{
+ Response r(client);
Error error;
command_list_num = num;
@@ -385,7 +379,6 @@ command_process(Client &client, unsigned num, char *line)
if (cmd_name == nullptr) {
current_command = "";
- Response r(client);
if (tokenizer.IsEnd())
r.FormatError(ACK_ERROR_UNKNOWN, "No command given");
else
@@ -405,7 +398,6 @@ command_process(Client &client, unsigned num, char *line)
while (true) {
if (args.size == COMMAND_ARGV_MAX) {
- Response r(client);
r.Error(ACK_ERROR_ARG, "Too many arguments");
current_command = nullptr;
return CommandResult::ERROR;
@@ -416,7 +408,6 @@ command_process(Client &client, unsigned num, char *line)
if (tokenizer.IsEnd())
break;
- Response r(client);
r.Error(ACK_ERROR_UNKNOWN, error.GetMessage());
current_command = nullptr;
return CommandResult::ERROR;
@@ -428,11 +419,11 @@ command_process(Client &client, unsigned num, char *line)
/* look up and invoke the command handler */
const struct command *cmd =
- command_checked_lookup(client, client.GetPermission(),
+ command_checked_lookup(r, client.GetPermission(),
cmd_name, args);
CommandResult ret = cmd
- ? cmd->handler(client, args)
+ ? cmd->handler(client, args, r)
: CommandResult::ERROR;
current_command = nullptr;
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index 62764139e..ff139d925 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -38,9 +38,8 @@
#include <string.h>
CommandResult
-handle_listfiles_db(Client &client, const char *uri)
+handle_listfiles_db(Client &client, Response &r, const char *uri)
{
- Response r(client);
const DatabaseSelection selection(uri, false);
Error error;
@@ -52,10 +51,8 @@ handle_listfiles_db(Client &client, const char *uri)
}
CommandResult
-handle_lsinfo2(Client &client, Request args)
+handle_lsinfo2(Client &client, Request args, Response &r)
{
- Response r(client);
-
/* default is root directory */
const auto uri = args.GetOptional(0, "");
@@ -70,10 +67,8 @@ handle_lsinfo2(Client &client, Request args)
}
static CommandResult
-handle_match(Client &client, Request args, bool fold_case)
+handle_match(Client &client, Request args, Response &r, bool fold_case)
{
- Response r(client);
-
RangeArg window;
if (args.size >= 2 && strcmp(args[args.size - 2], "window") == 0) {
if (!args.Parse(args.size - 1, window, r))
@@ -101,22 +96,20 @@ handle_match(Client &client, Request args, bool fold_case)
}
CommandResult
-handle_find(Client &client, Request args)
+handle_find(Client &client, Request args, Response &r)
{
- return handle_match(client, args, false);
+ return handle_match(client, args, r, false);
}
CommandResult
-handle_search(Client &client, Request args)
+handle_search(Client &client, Request args, Response &r)
{
- return handle_match(client, args, true);
+ return handle_match(client, args, r, true);
}
static CommandResult
-handle_match_add(Client &client, Request args, bool fold_case)
+handle_match_add(Client &client, Request args, Response &r, bool fold_case)
{
- Response r(client);
-
SongFilter filter;
if (!filter.Parse(args, fold_case)) {
r.Error(ACK_ERROR_ARG, "incorrect arguments");
@@ -133,22 +126,20 @@ handle_match_add(Client &client, Request args, bool fold_case)
}
CommandResult
-handle_findadd(Client &client, Request args)
+handle_findadd(Client &client, Request args, Response &r)
{
- return handle_match_add(client, args, false);
+ return handle_match_add(client, args, r, false);
}
CommandResult
-handle_searchadd(Client &client, Request args)
+handle_searchadd(Client &client, Request args, Response &r)
{
- return handle_match_add(client, args, true);
+ return handle_match_add(client, args, r, true);
}
CommandResult
-handle_searchaddpl(Client &client, Request args)
+handle_searchaddpl(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *playlist = args.shift();
SongFilter filter;
@@ -169,10 +160,8 @@ handle_searchaddpl(Client &client, Request args)
}
CommandResult
-handle_count(Client &client, Request args)
+handle_count(Client &client, Request args, Response &r)
{
- Response r(client);
-
TagType group = TAG_NUM_OF_ITEM_TYPES;
if (args.size >= 2 && strcmp(args[args.size - 2], "group") == 0) {
const char *s = args[args.size - 1];
@@ -200,10 +189,8 @@ handle_count(Client &client, Request args)
}
CommandResult
-handle_listall(Client &client, Request args)
+handle_listall(Client &client, Request args, Response &r)
{
- Response r(client);
-
/* default is root directory */
const auto uri = args.GetOptional(0, "");
@@ -216,10 +203,8 @@ handle_listall(Client &client, Request args)
}
CommandResult
-handle_list(Client &client, Request args)
+handle_list(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *tag_name = args.shift();
unsigned tagType = locate_parse_type(tag_name);
@@ -290,10 +275,8 @@ handle_list(Client &client, Request args)
}
CommandResult
-handle_listallinfo(Client &client, Request args)
+handle_listallinfo(Client &client, Request args, Response &r)
{
- Response r(client);
-
/* default is root directory */
const auto uri = args.GetOptional(0, "");
diff --git a/src/command/DatabaseCommands.hxx b/src/command/DatabaseCommands.hxx
index 1f2cb8c6d..42dc75c71 100644
--- a/src/command/DatabaseCommands.hxx
+++ b/src/command/DatabaseCommands.hxx
@@ -24,38 +24,39 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_listfiles_db(Client &client, const char *uri);
+handle_listfiles_db(Client &client, Response &r, const char *uri);
CommandResult
-handle_lsinfo2(Client &client, Request args);
+handle_lsinfo2(Client &client, Request request, Response &response);
CommandResult
-handle_find(Client &client, Request args);
+handle_find(Client &client, Request request, Response &response);
CommandResult
-handle_findadd(Client &client, Request args);
+handle_findadd(Client &client, Request request, Response &response);
CommandResult
-handle_search(Client &client, Request args);
+handle_search(Client &client, Request request, Response &response);
CommandResult
-handle_searchadd(Client &client, Request args);
+handle_searchadd(Client &client, Request request, Response &response);
CommandResult
-handle_searchaddpl(Client &client, Request args);
+handle_searchaddpl(Client &client, Request request, Response &response);
CommandResult
-handle_count(Client &client, Request args);
+handle_count(Client &client, Request request, Response &response);
CommandResult
-handle_listall(Client &client, Request args);
+handle_listall(Client &client, Request request, Response &response);
CommandResult
-handle_list(Client &client, Request args);
+handle_list(Client &client, Request request, Response &response);
CommandResult
-handle_listallinfo(Client &client, Request args);
+handle_listallinfo(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx
index c30dad8c8..73b9b3dbe 100644
--- a/src/command/FileCommands.cxx
+++ b/src/command/FileCommands.cxx
@@ -70,10 +70,9 @@ skip_path(Path name_fs)
#endif
CommandResult
-handle_listfiles_local(Client &client, const char *path_utf8)
+handle_listfiles_local(Client &client, Response &r,
+ const char *path_utf8)
{
- Response r(client);
-
const auto path_fs = AllocatedPath::FromUTF8(path_utf8);
if (path_fs.IsNull()) {
r.Error(ACK_ERROR_NO_EXIST, "unsupported file name");
@@ -214,10 +213,8 @@ translate_uri(const char *uri)
}
CommandResult
-handle_read_comments(Client &client, Request args)
+handle_read_comments(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
const char *const uri = translate_uri(args.front());
diff --git a/src/command/FileCommands.hxx b/src/command/FileCommands.hxx
index 9812fd362..c072d2028 100644
--- a/src/command/FileCommands.hxx
+++ b/src/command/FileCommands.hxx
@@ -24,11 +24,13 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_listfiles_local(Client &client, const char *path_utf8);
+handle_listfiles_local(Client &client, Response &response,
+ const char *path_utf8);
CommandResult
-handle_read_comments(Client &client, Request args);
+handle_read_comments(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/MessageCommands.cxx b/src/command/MessageCommands.cxx
index 62d47ff0e..28f97a52f 100644
--- a/src/command/MessageCommands.cxx
+++ b/src/command/MessageCommands.cxx
@@ -33,10 +33,8 @@
#include <assert.h>
CommandResult
-handle_subscribe(Client &client, Request args)
+handle_subscribe(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
const char *const channel_name = args[0];
@@ -63,10 +61,8 @@ handle_subscribe(Client &client, Request args)
}
CommandResult
-handle_unsubscribe(Client &client, Request args)
+handle_unsubscribe(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
const char *const channel_name = args[0];
@@ -79,7 +75,7 @@ handle_unsubscribe(Client &client, Request args)
}
CommandResult
-handle_channels(Client &client, gcc_unused Request args)
+handle_channels(Client &client, gcc_unused Request args, Response &r)
{
assert(args.IsEmpty());
@@ -88,7 +84,6 @@ handle_channels(Client &client, gcc_unused Request args)
channels.insert(c.subscriptions.begin(),
c.subscriptions.end());
- Response r(client);
for (const auto &channel : channels)
r.Format("channel: %s\n", channel.c_str());
@@ -97,11 +92,10 @@ handle_channels(Client &client, gcc_unused Request args)
CommandResult
handle_read_messages(Client &client,
- gcc_unused Request args)
+ gcc_unused Request args, Response &r)
{
assert(args.IsEmpty());
- Response r(client);
while (!client.messages.empty()) {
const ClientMessage &msg = client.messages.front();
@@ -114,14 +108,13 @@ handle_read_messages(Client &client,
}
CommandResult
-handle_send_message(Client &client, Request args)
+handle_send_message(Client &client, Request args, Response &r)
{
assert(args.size == 2);
const char *const channel_name = args[0];
const char *const message_text = args[1];
- Response r(client);
if (!client_message_valid_channel_name(channel_name)) {
r.Error(ACK_ERROR_ARG, "invalid channel name");
return CommandResult::ERROR;
diff --git a/src/command/MessageCommands.hxx b/src/command/MessageCommands.hxx
index 99106457b..986c7cf6a 100644
--- a/src/command/MessageCommands.hxx
+++ b/src/command/MessageCommands.hxx
@@ -24,20 +24,21 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_subscribe(Client &client, Request args);
+handle_subscribe(Client &client, Request request, Response &response);
CommandResult
-handle_unsubscribe(Client &client, Request args);
+handle_unsubscribe(Client &client, Request request, Response &response);
CommandResult
-handle_channels(Client &client, Request args);
+handle_channels(Client &client, Request request, Response &response);
CommandResult
-handle_read_messages(Client &client, Request args);
+handle_read_messages(Client &client, Request request, Response &response);
CommandResult
-handle_send_message(Client &client, Request args);
+handle_send_message(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/NeighborCommands.cxx b/src/command/NeighborCommands.cxx
index d1b2ec7c7..254f7a346 100644
--- a/src/command/NeighborCommands.cxx
+++ b/src/command/NeighborCommands.cxx
@@ -40,10 +40,8 @@ neighbor_commands_available(const Instance &instance)
}
CommandResult
-handle_listneighbors(Client &client, gcc_unused Request args)
+handle_listneighbors(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
-
const NeighborGlue *const neighbors =
client.partition.instance.neighbors;
if (neighbors == nullptr) {
diff --git a/src/command/NeighborCommands.hxx b/src/command/NeighborCommands.hxx
index c077f5b61..efe05c5ae 100644
--- a/src/command/NeighborCommands.hxx
+++ b/src/command/NeighborCommands.hxx
@@ -26,12 +26,13 @@
struct Instance;
class Client;
class Request;
+class Response;
gcc_pure
bool
neighbor_commands_available(const Instance &instance);
CommandResult
-handle_listneighbors(Client &client, Request args);
+handle_listneighbors(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx
index c1346ca44..96415962f 100644
--- a/src/command/OtherCommands.cxx
+++ b/src/command/OtherCommands.cxx
@@ -69,9 +69,8 @@ print_spl_list(Response &r, const PlaylistVector &list)
}
CommandResult
-handle_urlhandlers(Client &client, gcc_unused Request args)
+handle_urlhandlers(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
if (client.IsLocal())
r.Format("handler: file://\n");
print_supported_uri_schemes(r);
@@ -79,29 +78,31 @@ handle_urlhandlers(Client &client, gcc_unused Request args)
}
CommandResult
-handle_decoders(Client &client, gcc_unused Request args)
+handle_decoders(gcc_unused Client &client, gcc_unused Request args,
+ Response &r)
{
- Response r(client);
decoder_list_print(r);
return CommandResult::OK;
}
CommandResult
-handle_tagtypes(Client &client, gcc_unused Request args)
+handle_tagtypes(gcc_unused Client &client, gcc_unused Request request,
+ Response &r)
{
- Response r(client);
tag_print_types(r);
return CommandResult::OK;
}
CommandResult
-handle_kill(gcc_unused Client &client, gcc_unused Request args)
+handle_kill(gcc_unused Client &client, gcc_unused Request request,
+ gcc_unused Response &r)
{
return CommandResult::KILL;
}
CommandResult
-handle_close(gcc_unused Client &client, gcc_unused Request args)
+handle_close(gcc_unused Client &client, gcc_unused Request args,
+ gcc_unused Response &r)
{
return CommandResult::FINISH;
}
@@ -115,16 +116,14 @@ print_tag(TagType type, const char *value, void *ctx)
}
CommandResult
-handle_listfiles(Client &client, Request args)
+handle_listfiles(Client &client, Request args, Response &r)
{
- Response r(client);
-
/* default is root directory */
const auto uri = args.GetOptional(0, "");
if (memcmp(uri, "file:///", 8) == 0)
/* list local directory */
- return handle_listfiles_local(client, uri + 7);
+ return handle_listfiles_local(client, r, uri + 7);
#ifdef ENABLE_DATABASE
if (uri_has_scheme(uri))
@@ -142,7 +141,7 @@ handle_listfiles(Client &client, Request args)
uri);
/* fall back to entries from database if we have no storage */
- return handle_listfiles_db(client, uri);
+ return handle_listfiles_db(client, r, uri);
#else
r.Error(ACK_ERROR_NO_EXIST, "No database");
return CommandResult::ERROR;
@@ -156,13 +155,11 @@ static constexpr tag_handler print_tag_handler = {
};
CommandResult
-handle_lsinfo(Client &client, Request args)
+handle_lsinfo(Client &client, Request args, Response &r)
{
/* default is root directory */
const auto uri = args.GetOptional(0, "");
- Response r(client);
-
if (memcmp(uri, "file:///", 8) == 0) {
/* print information about an arbitrary local file */
const char *path_utf8 = uri + 7;
@@ -202,7 +199,7 @@ handle_lsinfo(Client &client, Request args)
}
#ifdef ENABLE_DATABASE
- CommandResult result = handle_lsinfo2(client, args);
+ CommandResult result = handle_lsinfo2(client, args, r);
if (result != CommandResult::OK)
return result;
#endif
@@ -224,11 +221,9 @@ handle_lsinfo(Client &client, Request args)
#ifdef ENABLE_DATABASE
static CommandResult
-handle_update(Client &client, UpdateService &update,
+handle_update(Response &r, UpdateService &update,
const char *uri_utf8, bool discard)
{
- Response r(client);
-
unsigned ret = update.Enqueue(uri_utf8, discard);
if (ret > 0) {
r.Format("updating_db: %i\n", ret);
@@ -240,11 +235,9 @@ handle_update(Client &client, UpdateService &update,
}
static CommandResult
-handle_update(Client &client, Database &db,
+handle_update(Response &r, Database &db,
const char *uri_utf8, bool discard)
{
- Response r(client);
-
Error error;
unsigned id = db.Update(uri_utf8, discard, error);
if (id > 0) {
@@ -263,10 +256,8 @@ handle_update(Client &client, Database &db,
#endif
static CommandResult
-handle_update(Client &client, Request args, bool discard)
+handle_update(Client &client, Request args, Response &r, bool discard)
{
- Response r(client);
-
#ifdef ENABLE_DATABASE
const char *path = "";
@@ -285,11 +276,11 @@ handle_update(Client &client, Request args, bool discard)
UpdateService *update = client.partition.instance.update;
if (update != nullptr)
- return handle_update(client, *update, path, discard);
+ return handle_update(r, *update, path, discard);
Database *db = client.partition.instance.database;
if (db != nullptr)
- return handle_update(client, *db, path, discard);
+ return handle_update(r, *db, path, discard);
#else
(void)args;
(void)discard;
@@ -300,22 +291,20 @@ handle_update(Client &client, Request args, bool discard)
}
CommandResult
-handle_update(Client &client, gcc_unused Request args)
+handle_update(Client &client, Request args, gcc_unused Response &r)
{
- return handle_update(client, args, false);
+ return handle_update(client, args, r, false);
}
CommandResult
-handle_rescan(Client &client, gcc_unused Request args)
+handle_rescan(Client &client, Request args, Response &r)
{
- return handle_update(client, args, true);
+ return handle_update(client, args, r, true);
}
CommandResult
-handle_setvol(Client &client, Request args)
+handle_setvol(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned level;
if (!args.Parse(0, level, r, 100))
return CommandResult::ERROR;
@@ -329,10 +318,8 @@ handle_setvol(Client &client, Request args)
}
CommandResult
-handle_volume(Client &client, Request args)
+handle_volume(Client &client, Request args, Response &r)
{
- Response r(client);
-
int relative;
if (!args.Parse(0, relative, r, -100, 100))
return CommandResult::ERROR;
@@ -359,24 +346,22 @@ handle_volume(Client &client, Request args)
}
CommandResult
-handle_stats(Client &client, gcc_unused Request args)
+handle_stats(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
stats_print(r, client.partition);
return CommandResult::OK;
}
CommandResult
-handle_ping(gcc_unused Client &client, gcc_unused Request args)
+handle_ping(gcc_unused Client &client, gcc_unused Request args,
+ gcc_unused Response &r)
{
return CommandResult::OK;
}
CommandResult
-handle_password(Client &client, Request args)
+handle_password(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned permission = 0;
if (getPermissionFromPassword(args.front(), &permission) < 0) {
r.Error(ACK_ERROR_PASSWORD, "incorrect password");
@@ -389,10 +374,8 @@ handle_password(Client &client, Request args)
}
CommandResult
-handle_config(Client &client, gcc_unused Request args)
+handle_config(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
-
if (!client.IsLocal()) {
r.Error(ACK_ERROR_PERMISSION,
"Command only permitted to local clients");
@@ -411,10 +394,8 @@ handle_config(Client &client, gcc_unused Request args)
}
CommandResult
-handle_idle(Client &client, Request args)
+handle_idle(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned flags = 0;
for (const char *i : args) {
unsigned event = idle_parse_name(i);
diff --git a/src/command/OtherCommands.hxx b/src/command/OtherCommands.hxx
index bcc1224e4..2a918df97 100644
--- a/src/command/OtherCommands.hxx
+++ b/src/command/OtherCommands.hxx
@@ -24,53 +24,54 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_urlhandlers(Client &client, Request args);
+handle_urlhandlers(Client &client, Request request, Response &response);
CommandResult
-handle_decoders(Client &client, Request args);
+handle_decoders(Client &client, Request request, Response &response);
CommandResult
-handle_tagtypes(Client &client, Request args);
+handle_tagtypes(Client &client, Request request, Response &response);
CommandResult
-handle_kill(Client &client, Request args);
+handle_kill(Client &client, Request request, Response &response);
CommandResult
-handle_close(Client &client, Request args);
+handle_close(Client &client, Request request, Response &response);
CommandResult
-handle_listfiles(Client &client, Request args);
+handle_listfiles(Client &client, Request request, Response &response);
CommandResult
-handle_lsinfo(Client &client, Request args);
+handle_lsinfo(Client &client, Request request, Response &response);
CommandResult
-handle_update(Client &client, Request args);
+handle_update(Client &client, Request request, Response &response);
CommandResult
-handle_rescan(Client &client, Request args);
+handle_rescan(Client &client, Request request, Response &response);
CommandResult
-handle_setvol(Client &client, Request args);
+handle_setvol(Client &client, Request request, Response &response);
CommandResult
-handle_volume(Client &client, Request args);
+handle_volume(Client &client, Request request, Response &response);
CommandResult
-handle_stats(Client &client, Request args);
+handle_stats(Client &client, Request request, Response &response);
CommandResult
-handle_ping(Client &client, Request args);
+handle_ping(Client &client, Request request, Response &response);
CommandResult
-handle_password(Client &client, Request args);
+handle_password(Client &client, Request request, Response &response);
CommandResult
-handle_config(Client &client, Request args);
+handle_config(Client &client, Request request, Response &response);
CommandResult
-handle_idle(Client &client, Request args);
+handle_idle(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/OutputCommands.cxx b/src/command/OutputCommands.cxx
index 472516860..7bbe5f905 100644
--- a/src/command/OutputCommands.cxx
+++ b/src/command/OutputCommands.cxx
@@ -28,10 +28,8 @@
#include "util/ConstBuffer.hxx"
CommandResult
-handle_enableoutput(Client &client, Request args)
+handle_enableoutput(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
unsigned device;
if (!args.Parse(0, device, r))
@@ -46,10 +44,8 @@ handle_enableoutput(Client &client, Request args)
}
CommandResult
-handle_disableoutput(Client &client, Request args)
+handle_disableoutput(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
unsigned device;
if (!args.Parse(0, device, r))
@@ -64,10 +60,8 @@ handle_disableoutput(Client &client, Request args)
}
CommandResult
-handle_toggleoutput(Client &client, Request args)
+handle_toggleoutput(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size == 1);
unsigned device;
if (!args.Parse(0, device, r))
@@ -82,12 +76,10 @@ handle_toggleoutput(Client &client, Request args)
}
CommandResult
-handle_devices(Client &client, gcc_unused Request args)
+handle_devices(Client &client, gcc_unused Request args, Response &r)
{
assert(args.IsEmpty());
- Response r(client);
printAudioDevices(r, client.partition.outputs);
-
return CommandResult::OK;
}
diff --git a/src/command/OutputCommands.hxx b/src/command/OutputCommands.hxx
index f985032a5..3dd81bc23 100644
--- a/src/command/OutputCommands.hxx
+++ b/src/command/OutputCommands.hxx
@@ -24,17 +24,18 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_enableoutput(Client &client, Request args);
+handle_enableoutput(Client &client, Request request, Response &response);
CommandResult
-handle_disableoutput(Client &client, Request args);
+handle_disableoutput(Client &client, Request request, Response &response);
CommandResult
-handle_toggleoutput(Client &client, Request args);
+handle_toggleoutput(Client &client, Request request, Response &response);
CommandResult
-handle_devices(Client &client, Request args);
+handle_devices(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx
index 3e58cecb1..11cde2e98 100644
--- a/src/command/PlayerCommands.cxx
+++ b/src/command/PlayerCommands.cxx
@@ -57,10 +57,8 @@
#define COMMAND_STATUS_UPDATING_DB "updating_db"
CommandResult
-handle_play(Client &client, Request args)
+handle_play(Client &client, Request args, Response &r)
{
- Response r(client);
-
int song = -1;
if (!args.ParseOptional(0, song, r))
return CommandResult::ERROR;
@@ -70,10 +68,8 @@ handle_play(Client &client, Request args)
}
CommandResult
-handle_playid(Client &client, Request args)
+handle_playid(Client &client, Request args, Response &r)
{
- Response r(client);
-
int id = -1;
if (!args.ParseOptional(0, id, r))
return CommandResult::ERROR;
@@ -83,25 +79,22 @@ handle_playid(Client &client, Request args)
}
CommandResult
-handle_stop(Client &client, gcc_unused Request args)
+handle_stop(Client &client, gcc_unused Request args, gcc_unused Response &r)
{
client.partition.Stop();
return CommandResult::OK;
}
CommandResult
-handle_currentsong(Client &client, gcc_unused Request args)
+handle_currentsong(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
playlist_print_current(r, client.partition, client.playlist);
return CommandResult::OK;
}
CommandResult
-handle_pause(Client &client, Request args)
+handle_pause(Client &client, Request args, Response &r)
{
- Response r(client);
-
if (!args.IsEmpty()) {
bool pause_flag;
if (!args.Parse(0, pause_flag, r))
@@ -115,7 +108,7 @@ handle_pause(Client &client, Request args)
}
CommandResult
-handle_status(Client &client, gcc_unused Request args)
+handle_status(Client &client, gcc_unused Request args, Response &r)
{
const char *state = nullptr;
int song;
@@ -134,8 +127,6 @@ handle_status(Client &client, gcc_unused Request args)
break;
}
- Response r(client);
-
const playlist &playlist = client.playlist;
r.Format("volume: %i\n"
COMMAND_STATUS_REPEAT ": %i\n"
@@ -221,7 +212,7 @@ handle_status(Client &client, gcc_unused Request args)
}
CommandResult
-handle_next(Client &client, gcc_unused Request args)
+handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
{
playlist &playlist = client.playlist;
@@ -237,17 +228,16 @@ handle_next(Client &client, gcc_unused Request args)
}
CommandResult
-handle_previous(Client &client, gcc_unused Request args)
+handle_previous(Client &client, gcc_unused Request args,
+ gcc_unused Response &r)
{
client.partition.PlayPrevious();
return CommandResult::OK;
}
CommandResult
-handle_repeat(Client &client, Request args)
+handle_repeat(Client &client, Request args, Response &r)
{
- Response r(client);
-
bool status;
if (!args.Parse(0, status, r))
return CommandResult::ERROR;
@@ -257,10 +247,8 @@ handle_repeat(Client &client, Request args)
}
CommandResult
-handle_single(Client &client, Request args)
+handle_single(Client &client, Request args, Response &r)
{
- Response r(client);
-
bool status;
if (!args.Parse(0, status, r))
return CommandResult::ERROR;
@@ -270,10 +258,8 @@ handle_single(Client &client, Request args)
}
CommandResult
-handle_consume(Client &client, Request args)
+handle_consume(Client &client, Request args, Response &r)
{
- Response r(client);
-
bool status;
if (!args.Parse(0, status, r))
return CommandResult::ERROR;
@@ -283,10 +269,8 @@ handle_consume(Client &client, Request args)
}
CommandResult
-handle_random(Client &client, Request args)
+handle_random(Client &client, Request args, Response &r)
{
- Response r(client);
-
bool status;
if (!args.Parse(0, status, r))
return CommandResult::ERROR;
@@ -297,17 +281,16 @@ handle_random(Client &client, Request args)
}
CommandResult
-handle_clearerror(gcc_unused Client &client, gcc_unused Request args)
+handle_clearerror(Client &client, gcc_unused Request args,
+ gcc_unused Response &r)
{
client.player_control.ClearError();
return CommandResult::OK;
}
CommandResult
-handle_seek(Client &client, Request args)
+handle_seek(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned song;
SongTime seek_time;
if (!args.Parse(0, song, r) || !args.Parse(1, seek_time, r))
@@ -319,10 +302,8 @@ handle_seek(Client &client, Request args)
}
CommandResult
-handle_seekid(Client &client, Request args)
+handle_seekid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned id;
SongTime seek_time;
if (!args.Parse(0, id, r))
@@ -336,10 +317,8 @@ handle_seekid(Client &client, Request args)
}
CommandResult
-handle_seekcur(Client &client, Request args)
+handle_seekcur(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *p = args.front();
bool relative = *p == '+' || *p == '-';
SignedSongTime seek_time;
@@ -352,10 +331,8 @@ handle_seekcur(Client &client, Request args)
}
CommandResult
-handle_crossfade(Client &client, Request args)
+handle_crossfade(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned xfade_time;
if (!args.Parse(0, xfade_time, r))
return CommandResult::ERROR;
@@ -365,10 +342,8 @@ handle_crossfade(Client &client, Request args)
}
CommandResult
-handle_mixrampdb(Client &client, Request args)
+handle_mixrampdb(Client &client, Request args, Response &r)
{
- Response r(client);
-
float db;
if (!args.Parse(0, db, r))
return CommandResult::ERROR;
@@ -378,10 +353,8 @@ handle_mixrampdb(Client &client, Request args)
}
CommandResult
-handle_mixrampdelay(Client &client, Request args)
+handle_mixrampdelay(Client &client, Request args, Response &r)
{
- Response r(client);
-
float delay_secs;
if (!args.Parse(0, delay_secs, r))
return CommandResult::ERROR;
@@ -392,10 +365,8 @@ handle_mixrampdelay(Client &client, Request args)
}
CommandResult
-handle_replay_gain_mode(Client &client, Request args)
+handle_replay_gain_mode(Client &client, Request args, Response &r)
{
- Response r(client);
-
if (!replay_gain_set_mode_string(args.front())) {
r.Error(ACK_ERROR_ARG, "Unrecognized replay gain mode");
return CommandResult::ERROR;
@@ -406,9 +377,9 @@ handle_replay_gain_mode(Client &client, Request args)
}
CommandResult
-handle_replay_gain_status(Client &client, gcc_unused Request args)
+handle_replay_gain_status(gcc_unused Client &client, gcc_unused Request args,
+ Response &r)
{
- Response r(client);
r.Format("replay_gain_mode: %s\n", replay_gain_get_mode_string());
return CommandResult::OK;
}
diff --git a/src/command/PlayerCommands.hxx b/src/command/PlayerCommands.hxx
index ecf2c05ab..76ce51ef5 100644
--- a/src/command/PlayerCommands.hxx
+++ b/src/command/PlayerCommands.hxx
@@ -24,68 +24,69 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_play(Client &client, Request args);
+handle_play(Client &client, Request request, Response &response);
CommandResult
-handle_playid(Client &client, Request args);
+handle_playid(Client &client, Request request, Response &response);
CommandResult
-handle_stop(Client &client, Request args);
+handle_stop(Client &client, Request request, Response &response);
CommandResult
-handle_currentsong(Client &client, Request args);
+handle_currentsong(Client &client, Request request, Response &response);
CommandResult
-handle_pause(Client &client, Request args);
+handle_pause(Client &client, Request request, Response &response);
CommandResult
-handle_status(Client &client, Request args);
+handle_status(Client &client, Request request, Response &response);
CommandResult
-handle_next(Client &client, Request args);
+handle_next(Client &client, Request request, Response &response);
CommandResult
-handle_previous(Client &client, Request args);
+handle_previous(Client &client, Request request, Response &response);
CommandResult
-handle_repeat(Client &client, Request args);
+handle_repeat(Client &client, Request request, Response &response);
CommandResult
-handle_single(Client &client, Request args);
+handle_single(Client &client, Request request, Response &response);
CommandResult
-handle_consume(Client &client, Request args);
+handle_consume(Client &client, Request request, Response &response);
CommandResult
-handle_random(Client &client, Request args);
+handle_random(Client &client, Request request, Response &response);
CommandResult
-handle_clearerror(Client &client, Request args);
+handle_clearerror(Client &client, Request request, Response &response);
CommandResult
-handle_seek(Client &client, Request args);
+handle_seek(Client &client, Request request, Response &response);
CommandResult
-handle_seekid(Client &client, Request args);
+handle_seekid(Client &client, Request request, Response &response);
CommandResult
-handle_seekcur(Client &client, Request args);
+handle_seekcur(Client &client, Request request, Response &response);
CommandResult
-handle_crossfade(Client &client, Request args);
+handle_crossfade(Client &client, Request request, Response &response);
CommandResult
-handle_mixrampdb(Client &client, Request args);
+handle_mixrampdb(Client &client, Request request, Response &response);
CommandResult
-handle_mixrampdelay(Client &client, Request args);
+handle_mixrampdelay(Client &client, Request request, Response &response);
CommandResult
-handle_replay_gain_mode(Client &client, Request args);
+handle_replay_gain_mode(Client &client, Request request, Response &response);
CommandResult
-handle_replay_gain_status(Client &client, Request args);
+handle_replay_gain_status(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index 1e075e088..625e82055 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.cxx
@@ -59,9 +59,8 @@ print_spl_list(Response &r, const PlaylistVector &list)
}
CommandResult
-handle_save(Client &client, Request args)
+handle_save(Client &client, Request args, Response &r)
{
- Response r(client);
Error error;
return spl_save_playlist(args.front(), client.playlist, error)
? CommandResult::OK
@@ -69,10 +68,8 @@ handle_save(Client &client, Request args)
}
CommandResult
-handle_load(Client &client, Request args)
+handle_load(Client &client, Request args, Response &r)
{
- Response r(client);
-
RangeArg range = RangeArg::All();
if (!args.ParseOptional(1, range, r))
return CommandResult::ERROR;
@@ -91,10 +88,8 @@ handle_load(Client &client, Request args)
}
CommandResult
-handle_listplaylist(Client &client, Request args)
+handle_listplaylist(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args.front();
if (playlist_file_print(r, client.partition, SongLoader(client),
@@ -108,10 +103,8 @@ handle_listplaylist(Client &client, Request args)
}
CommandResult
-handle_listplaylistinfo(Client &client, Request args)
+handle_listplaylistinfo(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args.front();
if (playlist_file_print(r, client.partition, SongLoader(client),
@@ -125,10 +118,8 @@ handle_listplaylistinfo(Client &client, Request args)
}
CommandResult
-handle_rm(Client &client, Request args)
+handle_rm(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args.front();
Error error;
@@ -138,10 +129,8 @@ handle_rm(Client &client, Request args)
}
CommandResult
-handle_rename(Client &client, Request args)
+handle_rename(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const old_name = args[0];
const char *const new_name = args[1];
@@ -152,10 +141,8 @@ handle_rename(Client &client, Request args)
}
CommandResult
-handle_playlistdelete(Client &client, Request args)
+handle_playlistdelete(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args[0];
unsigned from;
if (!args.Parse(1, from, r))
@@ -168,10 +155,8 @@ handle_playlistdelete(Client &client, Request args)
}
CommandResult
-handle_playlistmove(Client &client, Request args)
+handle_playlistmove(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args.front();
unsigned from, to;
if (!args.Parse(1, from, r) || !args.Parse(2, to, r))
@@ -184,10 +169,8 @@ handle_playlistmove(Client &client, Request args)
}
CommandResult
-handle_playlistclear(Client &client, Request args)
+handle_playlistclear(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const name = args.front();
Error error;
@@ -197,10 +180,8 @@ handle_playlistclear(Client &client, Request args)
}
CommandResult
-handle_playlistadd(Client &client, Request args)
+handle_playlistadd(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const playlist = args[0];
const char *const uri = args[1];
@@ -232,10 +213,9 @@ handle_playlistadd(Client &client, Request args)
}
CommandResult
-handle_listplaylists(Client &client, gcc_unused Request args)
+handle_listplaylists(gcc_unused Client &client, gcc_unused Request args,
+ Response &r)
{
- Response r(client);
-
Error error;
const auto list = ListPlaylistFiles(error);
if (list.empty() && error.IsDefined())
diff --git a/src/command/PlaylistCommands.hxx b/src/command/PlaylistCommands.hxx
index 276d27ad8..9f263df62 100644
--- a/src/command/PlaylistCommands.hxx
+++ b/src/command/PlaylistCommands.hxx
@@ -25,42 +25,43 @@
class Client;
class Request;
+class Response;
gcc_const
bool
playlist_commands_available();
CommandResult
-handle_save(Client &client, Request args);
+handle_save(Client &client, Request request, Response &response);
CommandResult
-handle_load(Client &client, Request args);
+handle_load(Client &client, Request request, Response &response);
CommandResult
-handle_listplaylist(Client &client, Request args);
+handle_listplaylist(Client &client, Request request, Response &response);
CommandResult
-handle_listplaylistinfo(Client &client, Request args);
+handle_listplaylistinfo(Client &client, Request request, Response &response);
CommandResult
-handle_rm(Client &client, Request args);
+handle_rm(Client &client, Request request, Response &response);
CommandResult
-handle_rename(Client &client, Request args);
+handle_rename(Client &client, Request request, Response &response);
CommandResult
-handle_playlistdelete(Client &client, Request args);
+handle_playlistdelete(Client &client, Request request, Response &response);
CommandResult
-handle_playlistmove(Client &client, Request args);
+handle_playlistmove(Client &client, Request request, Response &response);
CommandResult
-handle_playlistclear(Client &client, Request args);
+handle_playlistclear(Client &client, Request request, Response &response);
CommandResult
-handle_playlistadd(Client &client, Request args);
+handle_playlistadd(Client &client, Request request, Response &response);
CommandResult
-handle_listplaylists(Client &client, Request args);
+handle_listplaylists(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index 850631ded..1698e88df 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -54,10 +54,8 @@ translate_uri(const char *uri)
}
CommandResult
-handle_add(Client &client, Request args)
+handle_add(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *uri = args.front();
if (memcmp(uri, "/", 2) == 0)
/* this URI is malformed, but some clients are buggy
@@ -94,10 +92,8 @@ handle_add(Client &client, Request args)
}
CommandResult
-handle_addid(Client &client, Request args)
+handle_addid(Client &client, Request args, Response &r)
{
- Response r(client);
-
const char *const uri = translate_uri(args.front());
const SongLoader loader(client);
@@ -156,10 +152,8 @@ parse_time_range(const char *p, SongTime &start_r, SongTime &end_r)
}
CommandResult
-handle_rangeid(Client &client, Request args)
+handle_rangeid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned id;
if (!args.Parse(0, id, r))
return CommandResult::ERROR;
@@ -180,10 +174,8 @@ handle_rangeid(Client &client, Request args)
}
CommandResult
-handle_delete(Client &client, Request args)
+handle_delete(Client &client, Request args, Response &r)
{
- Response r(client);
-
RangeArg range;
if (!args.Parse(0, range, r))
return CommandResult::ERROR;
@@ -193,10 +185,8 @@ handle_delete(Client &client, Request args)
}
CommandResult
-handle_deleteid(Client &client, Request args)
+handle_deleteid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned id;
if (!args.Parse(0, id, r))
return CommandResult::ERROR;
@@ -206,18 +196,15 @@ handle_deleteid(Client &client, Request args)
}
CommandResult
-handle_playlist(Client &client, gcc_unused Request args)
+handle_playlist(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
playlist_print_uris(r, client.partition, client.playlist);
return CommandResult::OK;
}
CommandResult
-handle_shuffle(gcc_unused Client &client, Request args)
+handle_shuffle(gcc_unused Client &client, Request args, Response &r)
{
- Response r(client);
-
RangeArg range = RangeArg::All();
if (!args.ParseOptional(0, range, r))
return CommandResult::ERROR;
@@ -227,17 +214,15 @@ handle_shuffle(gcc_unused Client &client, Request args)
}
CommandResult
-handle_clear(gcc_unused Client &client, gcc_unused Request args)
+handle_clear(Client &client, gcc_unused Request args, gcc_unused Response &r)
{
client.partition.ClearQueue();
return CommandResult::OK;
}
CommandResult
-handle_plchanges(Client &client, Request args)
+handle_plchanges(Client &client, Request args, Response &r)
{
- Response r(client);
-
uint32_t version;
if (!ParseCommandArg32(r, version, args.front()))
return CommandResult::ERROR;
@@ -248,10 +233,8 @@ handle_plchanges(Client &client, Request args)
}
CommandResult
-handle_plchangesposid(Client &client, Request args)
+handle_plchangesposid(Client &client, Request args, Response &r)
{
- Response r(client);
-
uint32_t version;
if (!ParseCommandArg32(r, version, args.front()))
return CommandResult::ERROR;
@@ -261,10 +244,8 @@ handle_plchangesposid(Client &client, Request args)
}
CommandResult
-handle_playlistinfo(Client &client, Request args)
+handle_playlistinfo(Client &client, Request args, Response &r)
{
- Response r(client);
-
RangeArg range = RangeArg::All();
if (!args.ParseOptional(0, range, r))
return CommandResult::ERROR;
@@ -278,10 +259,8 @@ handle_playlistinfo(Client &client, Request args)
}
CommandResult
-handle_playlistid(Client &client, Request args)
+handle_playlistid(Client &client, Request args, Response &r)
{
- Response r(client);
-
if (!args.IsEmpty()) {
unsigned id;
if (!args.Parse(0, id, r))
@@ -300,11 +279,9 @@ handle_playlistid(Client &client, Request args)
}
static CommandResult
-handle_playlist_match(Client &client, Request args,
+handle_playlist_match(Client &client, Request args, Response &r,
bool fold_case)
{
- Response r(client);
-
SongFilter filter;
if (!filter.Parse(args, fold_case)) {
r.Error(ACK_ERROR_ARG, "incorrect arguments");
@@ -316,22 +293,20 @@ handle_playlist_match(Client &client, Request args,
}
CommandResult
-handle_playlistfind(Client &client, Request args)
+handle_playlistfind(Client &client, Request args, Response &r)
{
- return handle_playlist_match(client, args, false);
+ return handle_playlist_match(client, args, r, false);
}
CommandResult
-handle_playlistsearch(Client &client, Request args)
+handle_playlistsearch(Client &client, Request args, Response &r)
{
- return handle_playlist_match(client, args, true);
+ return handle_playlist_match(client, args, r, true);
}
CommandResult
-handle_prio(Client &client, Request args)
+handle_prio(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned priority;
if (!args.ParseShift(0, priority, r, 0xff))
return CommandResult::ERROR;
@@ -353,10 +328,8 @@ handle_prio(Client &client, Request args)
}
CommandResult
-handle_prioid(Client &client, Request args)
+handle_prioid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned priority;
if (!args.ParseShift(0, priority, r, 0xff))
return CommandResult::ERROR;
@@ -376,10 +349,8 @@ handle_prioid(Client &client, Request args)
}
CommandResult
-handle_move(Client &client, Request args)
+handle_move(Client &client, Request args, Response &r)
{
- Response r(client);
-
RangeArg range;
int to;
@@ -392,10 +363,8 @@ handle_move(Client &client, Request args)
}
CommandResult
-handle_moveid(Client &client, Request args)
+handle_moveid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned id;
int to;
if (!args.Parse(0, id, r) || !args.Parse(1, to, r))
@@ -406,10 +375,8 @@ handle_moveid(Client &client, Request args)
}
CommandResult
-handle_swap(Client &client, Request args)
+handle_swap(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned song1, song2;
if (!args.Parse(0, song1, r) || !args.Parse(1, song2, r))
return CommandResult::ERROR;
@@ -420,10 +387,8 @@ handle_swap(Client &client, Request args)
}
CommandResult
-handle_swapid(Client &client, Request args)
+handle_swapid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned id1, id2;
if (!args.Parse(0, id1, r) || !args.Parse(1, id2, r))
return CommandResult::ERROR;
diff --git a/src/command/QueueCommands.hxx b/src/command/QueueCommands.hxx
index bccb9a370..49499d8ea 100644
--- a/src/command/QueueCommands.hxx
+++ b/src/command/QueueCommands.hxx
@@ -24,65 +24,66 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_add(Client &client, Request args);
+handle_add(Client &client, Request request, Response &response);
CommandResult
-handle_addid(Client &client, Request args);
+handle_addid(Client &client, Request request, Response &response);
CommandResult
-handle_rangeid(Client &client, Request args);
+handle_rangeid(Client &client, Request request, Response &response);
CommandResult
-handle_delete(Client &client, Request args);
+handle_delete(Client &client, Request request, Response &response);
CommandResult
-handle_deleteid(Client &client, Request args);
+handle_deleteid(Client &client, Request request, Response &response);
CommandResult
-handle_playlist(Client &client, Request args);
+handle_playlist(Client &client, Request request, Response &response);
CommandResult
-handle_shuffle(Client &client, Request args);
+handle_shuffle(Client &client, Request request, Response &response);
CommandResult
-handle_clear(Client &client, Request args);
+handle_clear(Client &client, Request request, Response &response);
CommandResult
-handle_plchanges(Client &client, Request args);
+handle_plchanges(Client &client, Request request, Response &response);
CommandResult
-handle_plchangesposid(Client &client, Request args);
+handle_plchangesposid(Client &client, Request request, Response &response);
CommandResult
-handle_playlistinfo(Client &client, Request args);
+handle_playlistinfo(Client &client, Request request, Response &response);
CommandResult
-handle_playlistid(Client &client, Request args);
+handle_playlistid(Client &client, Request request, Response &response);
CommandResult
-handle_playlistfind(Client &client, Request args);
+handle_playlistfind(Client &client, Request request, Response &response);
CommandResult
-handle_playlistsearch(Client &client, Request args);
+handle_playlistsearch(Client &client, Request request, Response &response);
CommandResult
-handle_prio(Client &client, Request args);
+handle_prio(Client &client, Request request, Response &response);
CommandResult
-handle_prioid(Client &client, Request args);
+handle_prioid(Client &client, Request request, Response &response);
CommandResult
-handle_move(Client &client, Request args);
+handle_move(Client &client, Request request, Response &response);
CommandResult
-handle_moveid(Client &client, Request args);
+handle_moveid(Client &client, Request request, Response &response);
CommandResult
-handle_swap(Client &client, Request args);
+handle_swap(Client &client, Request request, Response &response);
CommandResult
-handle_swapid(Client &client, Request args);
+handle_swapid(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/StickerCommands.cxx b/src/command/StickerCommands.cxx
index 25d354b2e..d04dc0fcd 100644
--- a/src/command/StickerCommands.cxx
+++ b/src/command/StickerCommands.cxx
@@ -191,10 +191,8 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
}
CommandResult
-handle_sticker(Client &client, Request args)
+handle_sticker(Client &client, Request args, Response &r)
{
- Response r(client);
-
assert(args.size >= 3);
if (!sticker_enabled()) {
diff --git a/src/command/StickerCommands.hxx b/src/command/StickerCommands.hxx
index 51682d29f..5bb9cc426 100644
--- a/src/command/StickerCommands.hxx
+++ b/src/command/StickerCommands.hxx
@@ -24,8 +24,9 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_sticker(Client &client, Request args);
+handle_sticker(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/StorageCommands.cxx b/src/command/StorageCommands.cxx
index edf2f60b8..3c11eb0d7 100644
--- a/src/command/StorageCommands.cxx
+++ b/src/command/StorageCommands.cxx
@@ -168,10 +168,8 @@ print_storage_uri(Client &client, Response &r, const Storage &storage)
}
CommandResult
-handle_listmounts(Client &client, gcc_unused Request args)
+handle_listmounts(Client &client, gcc_unused Request args, Response &r)
{
- Response r(client);
-
Storage *_composite = client.partition.instance.storage;
if (_composite == nullptr) {
r.Error(ACK_ERROR_NO_EXIST, "No database");
@@ -192,10 +190,8 @@ handle_listmounts(Client &client, gcc_unused Request args)
}
CommandResult
-handle_mount(Client &client, Request args)
+handle_mount(Client &client, Request args, Response &r)
{
- Response r(client);
-
Storage *_composite = client.partition.instance.storage;
if (_composite == nullptr) {
r.Error(ACK_ERROR_NO_EXIST, "No database");
@@ -256,10 +252,8 @@ handle_mount(Client &client, Request args)
}
CommandResult
-handle_unmount(Client &client, Request args)
+handle_unmount(Client &client, Request args, Response &r)
{
- Response r(client);
-
Storage *_composite = client.partition.instance.storage;
if (_composite == nullptr) {
r.Error(ACK_ERROR_NO_EXIST, "No database");
diff --git a/src/command/StorageCommands.hxx b/src/command/StorageCommands.hxx
index bbc0149bd..7d3c552f6 100644
--- a/src/command/StorageCommands.hxx
+++ b/src/command/StorageCommands.hxx
@@ -34,12 +34,12 @@ CommandResult
handle_listfiles_storage(Response &r, const char *uri);
CommandResult
-handle_listmounts(Client &client, Request args);
+handle_listmounts(Client &client, Request request, Response &response);
CommandResult
-handle_mount(Client &client, Request args);
+handle_mount(Client &client, Request request, Response &response);
CommandResult
-handle_unmount(Client &client, Request args);
+handle_unmount(Client &client, Request request, Response &response);
#endif
diff --git a/src/command/TagCommands.cxx b/src/command/TagCommands.cxx
index 35efa5859..2a7076bdc 100644
--- a/src/command/TagCommands.cxx
+++ b/src/command/TagCommands.cxx
@@ -28,10 +28,8 @@
#include "util/ConstBuffer.hxx"
CommandResult
-handle_addtagid(Client &client, Request args)
+handle_addtagid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned song_id;
if (!args.Parse(0, song_id, r))
return CommandResult::ERROR;
@@ -54,10 +52,8 @@ handle_addtagid(Client &client, Request args)
}
CommandResult
-handle_cleartagid(Client &client, Request args)
+handle_cleartagid(Client &client, Request args, Response &r)
{
- Response r(client);
-
unsigned song_id;
if (!args.Parse(0, song_id, r))
return CommandResult::ERROR;
diff --git a/src/command/TagCommands.hxx b/src/command/TagCommands.hxx
index 12d40b5a3..868d6d783 100644
--- a/src/command/TagCommands.hxx
+++ b/src/command/TagCommands.hxx
@@ -24,11 +24,12 @@
class Client;
class Request;
+class Response;
CommandResult
-handle_addtagid(Client &client, Request args);
+handle_addtagid(Client &client, Request request, Response &response);
CommandResult
-handle_cleartagid(Client &client, Request args);
+handle_cleartagid(Client &client, Request request, Response &response);
#endif