aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-20 13:10:54 +0200
committerMax Kellermann <max@duempel.org>2013-10-20 13:10:54 +0200
commitcf4d80fc655a399615529bdd27e0be284754c5ab (patch)
tree531f5c7af53ce4abdfd9013cbbc9e8056c934e5a /src
parent8118bc93a85a903ddf95825c1ce7ecbbfff4780b (diff)
downloadmpd-cf4d80fc655a399615529bdd27e0be284754c5ab.tar.gz
mpd-cf4d80fc655a399615529bdd27e0be284754c5ab.tar.xz
mpd-cf4d80fc655a399615529bdd27e0be284754c5ab.zip
command: convert command_return to to a strictly-typed enum
Diffstat (limited to 'src')
-rw-r--r--src/AllCommands.cxx25
-rw-r--r--src/AllCommands.hxx4
-rw-r--r--src/ClientInternal.hxx4
-rw-r--r--src/ClientProcess.cxx34
-rw-r--r--src/ClientRead.cxx12
-rw-r--r--src/CommandError.cxx38
-rw-r--r--src/CommandError.hxx6
-rw-r--r--src/CommandResult.hxx (renamed from src/command.h)24
-rw-r--r--src/DatabaseCommands.cxx58
-rw-r--r--src/DatabaseCommands.hxx22
-rw-r--r--src/MessageCommands.cxx32
-rw-r--r--src/MessageCommands.hxx12
-rw-r--r--src/OtherCommands.cxx84
-rw-r--r--src/OtherCommands.hxx30
-rw-r--r--src/OutputCommands.cxx28
-rw-r--r--src/OutputCommands.hxx10
-rw-r--r--src/PlayerCommands.cxx106
-rw-r--r--src/PlayerCommands.hxx44
-rw-r--r--src/PlaylistCommands.cxx58
-rw-r--r--src/PlaylistCommands.hxx24
-rw-r--r--src/QueueCommands.cxx120
-rw-r--r--src/QueueCommands.hxx40
-rw-r--r--src/StickerCommands.cxx30
-rw-r--r--src/StickerCommands.hxx4
24 files changed, 428 insertions, 421 deletions
diff --git a/src/AllCommands.cxx b/src/AllCommands.cxx
index 95edb0f19..2271aeff2 100644
--- a/src/AllCommands.cxx
+++ b/src/AllCommands.cxx
@@ -19,7 +19,6 @@
#include "config.h"
#include "AllCommands.hxx"
-#include "command.h"
#include "QueueCommands.hxx"
#include "PlayerCommands.hxx"
#include "PlaylistCommands.hxx"
@@ -56,14 +55,14 @@ struct command {
unsigned permission;
int min;
int max;
- enum command_return (*handler)(Client &client, int argc, char **argv);
+ CommandResult (*handler)(Client &client, int argc, char **argv);
};
/* don't be fooled, this is the command handler for "commands" command */
-static enum command_return
+static CommandResult
handle_commands(Client &client, int argc, char *argv[]);
-static enum command_return
+static CommandResult
handle_not_commands(Client &client, int argc, char *argv[]);
/**
@@ -178,7 +177,7 @@ command_available(gcc_unused const struct command *cmd)
}
/* don't be fooled, this is the command handler for "commands" command */
-static enum command_return
+static CommandResult
handle_commands(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -193,10 +192,10 @@ handle_commands(Client &client,
client_printf(client, "command: %s\n", cmd->cmd);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-static enum command_return
+static CommandResult
handle_not_commands(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -210,7 +209,7 @@ handle_not_commands(Client &client,
client_printf(client, "command: %s\n", cmd->cmd);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
void command_init(void)
@@ -308,13 +307,13 @@ command_checked_lookup(Client &client, unsigned permission,
return cmd;
}
-enum command_return
+CommandResult
command_process(Client &client, unsigned num, char *line)
{
Error error;
char *argv[COMMAND_ARGV_MAX] = { nullptr };
const struct command *cmd;
- enum command_return ret = COMMAND_RETURN_ERROR;
+ CommandResult ret = CommandResult::ERROR;
command_list_num = num;
@@ -333,7 +332,7 @@ command_process(Client &client, unsigned num, char *line)
current_command = nullptr;
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
unsigned argc = 1;
@@ -353,13 +352,13 @@ command_process(Client &client, unsigned num, char *line)
if (argc >= COMMAND_ARGV_MAX) {
command_error(client, ACK_ERROR_ARG, "Too many arguments");
current_command = nullptr;
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
if (!tokenizer.IsEnd()) {
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
current_command = nullptr;
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
/* look up and invoke the command handler */
diff --git a/src/AllCommands.hxx b/src/AllCommands.hxx
index 4ab69755a..2be94c136 100644
--- a/src/AllCommands.hxx
+++ b/src/AllCommands.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_ALL_COMMANDS_HXX
#define MPD_ALL_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
@@ -28,7 +28,7 @@ void command_init(void);
void command_finish(void);
-enum command_return
+CommandResult
command_process(Client &client, unsigned num, char *line);
#endif
diff --git a/src/ClientInternal.hxx b/src/ClientInternal.hxx
index 4df58eee6..e0affb045 100644
--- a/src/ClientInternal.hxx
+++ b/src/ClientInternal.hxx
@@ -22,7 +22,7 @@
#include "check.h"
#include "Client.hxx"
-#include "command.h"
+#include "CommandResult.hxx"
enum {
CLIENT_MAX_SUBSCRIPTIONS = 16,
@@ -35,7 +35,7 @@ extern int client_timeout;
extern size_t client_max_command_list_size;
extern size_t client_max_output_buffer_size;
-enum command_return
+CommandResult
client_process_line(Client &client, char *line);
#endif
diff --git a/src/ClientProcess.cxx b/src/ClientProcess.cxx
index 808599ac6..39040f319 100644
--- a/src/ClientProcess.cxx
+++ b/src/ClientProcess.cxx
@@ -29,11 +29,11 @@
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_MODE_END "command_list_end"
-static enum command_return
+static CommandResult
client_process_command_list(Client &client, bool list_ok,
std::list<std::string> &&list)
{
- enum command_return ret = COMMAND_RETURN_OK;
+ CommandResult ret = CommandResult::OK;
unsigned num = 0;
for (auto &&i : list) {
@@ -42,7 +42,7 @@ client_process_command_list(Client &client, bool list_ok,
FormatDebug(client_domain, "process command \"%s\"", cmd);
ret = command_process(client, num++, cmd);
FormatDebug(client_domain, "command returned %i", ret);
- if (ret != COMMAND_RETURN_OK || client.IsExpired())
+ if (ret != CommandResult::OK || client.IsExpired())
break;
else if (list_ok)
client_puts(client, "list_OK\n");
@@ -51,10 +51,10 @@ client_process_command_list(Client &client, bool list_ok,
return ret;
}
-enum command_return
+CommandResult
client_process_line(Client &client, char *line)
{
- enum command_return ret;
+ CommandResult ret;
if (strcmp(line, "noidle") == 0) {
if (client.idle_waiting) {
@@ -67,14 +67,14 @@ client_process_line(Client &client, char *line)
has already received the full idle response from
client_idle_notify(), which he can now evaluate */
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
} else if (client.idle_waiting) {
/* during idle mode, clients must not send anything
except "noidle" */
FormatWarning(client_domain,
"[%u] command \"%s\" during idle",
client.num, line);
- return COMMAND_RETURN_CLOSE;
+ return CommandResult::CLOSE;
}
if (client.cmd_list.IsActive()) {
@@ -92,11 +92,11 @@ client_process_line(Client &client, char *line)
"[%u] process command "
"list returned %i", client.num, ret);
- if (ret == COMMAND_RETURN_CLOSE ||
+ if (ret == CommandResult::CLOSE ||
client.IsExpired())
- return COMMAND_RETURN_CLOSE;
+ return CommandResult::CLOSE;
- if (ret == COMMAND_RETURN_OK)
+ if (ret == CommandResult::OK)
command_success(client);
client.cmd_list.Reset();
@@ -107,18 +107,18 @@ client_process_line(Client &client, char *line)
"is larger than the max (%lu)",
client.num,
(unsigned long)client_max_command_list_size);
- return COMMAND_RETURN_CLOSE;
+ return CommandResult::CLOSE;
}
- ret = COMMAND_RETURN_OK;
+ ret = CommandResult::OK;
}
} else {
if (strcmp(line, CLIENT_LIST_MODE_BEGIN) == 0) {
client.cmd_list.Begin(false);
- ret = COMMAND_RETURN_OK;
+ ret = CommandResult::OK;
} else if (strcmp(line, CLIENT_LIST_OK_MODE_BEGIN) == 0) {
client.cmd_list.Begin(true);
- ret = COMMAND_RETURN_OK;
+ ret = CommandResult::OK;
} else {
FormatDebug(client_domain,
"[%u] process command \"%s\"",
@@ -128,11 +128,11 @@ client_process_line(Client &client, char *line)
"[%u] command returned %i",
client.num, ret);
- if (ret == COMMAND_RETURN_CLOSE ||
+ if (ret == CommandResult::CLOSE ||
client.IsExpired())
- return COMMAND_RETURN_CLOSE;
+ return CommandResult::CLOSE;
- if (ret == COMMAND_RETURN_OK)
+ if (ret == CommandResult::OK)
command_success(client);
}
}
diff --git a/src/ClientRead.cxx b/src/ClientRead.cxx
index 956f4f71b..2bb3c56c0 100644
--- a/src/ClientRead.cxx
+++ b/src/ClientRead.cxx
@@ -40,19 +40,19 @@ Client::OnSocketInput(void *data, size_t length)
BufferedSocket::ConsumeInput(newline + 1 - p);
- enum command_return result = client_process_line(*this, p);
+ CommandResult result = client_process_line(*this, p);
switch (result) {
- case COMMAND_RETURN_OK:
- case COMMAND_RETURN_IDLE:
- case COMMAND_RETURN_ERROR:
+ case CommandResult::OK:
+ case CommandResult::IDLE:
+ case CommandResult::ERROR:
break;
- case COMMAND_RETURN_KILL:
+ case CommandResult::KILL:
Close();
main_loop->Break();
return InputResult::CLOSED;
- case COMMAND_RETURN_CLOSE:
+ case CommandResult::CLOSE:
Close();
return InputResult::CLOSED;
}
diff --git a/src/CommandError.cxx b/src/CommandError.cxx
index f22ad10de..fe9d9481a 100644
--- a/src/CommandError.cxx
+++ b/src/CommandError.cxx
@@ -29,66 +29,66 @@
#include <assert.h>
#include <errno.h>
-enum command_return
+CommandResult
print_playlist_result(Client &client, PlaylistResult result)
{
switch (result) {
case PlaylistResult::SUCCESS:
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
case PlaylistResult::ERRNO:
command_error(client, ACK_ERROR_SYSTEM, "%s",
g_strerror(errno));
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::DENIED:
command_error(client, ACK_ERROR_PERMISSION, "Access denied");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::NO_SUCH_SONG:
command_error(client, ACK_ERROR_NO_EXIST, "No such song");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::NO_SUCH_LIST:
command_error(client, ACK_ERROR_NO_EXIST, "No such playlist");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::LIST_EXISTS:
command_error(client, ACK_ERROR_EXIST,
"Playlist already exists");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::BAD_NAME:
command_error(client, ACK_ERROR_ARG,
"playlist name is invalid: "
"playlist names may not contain slashes,"
" newlines or carriage returns");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::BAD_RANGE:
command_error(client, ACK_ERROR_ARG, "Bad song index");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::NOT_PLAYING:
command_error(client, ACK_ERROR_PLAYER_SYNC, "Not playing");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::TOO_LARGE:
command_error(client, ACK_ERROR_PLAYLIST_MAX,
"playlist is at the max size");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case PlaylistResult::DISABLED:
command_error(client, ACK_ERROR_UNKNOWN,
"stored playlist support is disabled");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
assert(0);
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
-enum command_return
+CommandResult
print_error(Client &client, const Error &error)
{
assert(error.IsDefined());
@@ -101,24 +101,24 @@ print_error(Client &client, const Error &error)
} else if (error.IsDomain(ack_domain)) {
command_error(client, (ack)error.GetCode(),
"%s", error.GetMessage());
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
} else if (error.IsDomain(db_domain)) {
switch ((enum db_error)error.GetCode()) {
case DB_DISABLED:
command_error(client, ACK_ERROR_NO_EXIST, "%s",
error.GetMessage());
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case DB_NOT_FOUND:
command_error(client, ACK_ERROR_NO_EXIST, "Not found");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
} else if (error.IsDomain(errno_domain)) {
command_error(client, ACK_ERROR_SYSTEM, "%s",
g_strerror(error.GetCode()));
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
command_error(client, ACK_ERROR_UNKNOWN, "error");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
diff --git a/src/CommandError.hxx b/src/CommandError.hxx
index 507250500..183797213 100644
--- a/src/CommandError.hxx
+++ b/src/CommandError.hxx
@@ -20,19 +20,19 @@
#ifndef MPD_COMMAND_ERROR_HXX
#define MPD_COMMAND_ERROR_HXX
-#include "command.h"
+#include "CommandResult.hxx"
#include "PlaylistError.hxx"
class Client;
class Error;
-enum command_return
+CommandResult
print_playlist_result(Client &client, PlaylistResult result);
/**
* Send the #Error to the client.
*/
-enum command_return
+CommandResult
print_error(Client &client, const Error &error);
#endif
diff --git a/src/command.h b/src/CommandResult.hxx
index 9ea5bb52f..4132dacb7 100644
--- a/src/command.h
+++ b/src/CommandResult.hxx
@@ -17,37 +17,45 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_COMMAND_H
-#define MPD_COMMAND_H
+#ifndef MPD_COMMAND_RESULT_HXX
+#define MPD_COMMAND_RESULT_HXX
-enum command_return {
+#ifdef WIN32
+#include <windows.h>
+/* damn you, windows.h! */
+#ifdef ERROR
+#undef ERROR
+#endif
+#endif
+
+enum class CommandResult {
/**
* The command has succeeded, but the "OK" response was not
* yet sent to the client.
*/
- COMMAND_RETURN_OK,
+ OK,
/**
* The connection is now in "idle" mode, and no response shall
* be generated.
*/
- COMMAND_RETURN_IDLE,
+ IDLE,
/**
* There was an error. The "ACK" response was sent to the
* client.
*/
- COMMAND_RETURN_ERROR,
+ ERROR,
/**
* The connection to this client shall be closed.
*/
- COMMAND_RETURN_CLOSE,
+ CLOSE,
/**
* The MPD process shall be shut down.
*/
- COMMAND_RETURN_KILL,
+ KILL,
};
#endif
diff --git a/src/DatabaseCommands.cxx b/src/DatabaseCommands.cxx
index 652b2b6d5..b86cbdae7 100644
--- a/src/DatabaseCommands.cxx
+++ b/src/DatabaseCommands.cxx
@@ -34,7 +34,7 @@
#include <assert.h>
#include <string.h>
-enum command_return
+CommandResult
handle_lsinfo2(Client &client, int argc, char *argv[])
{
const char *uri;
@@ -51,67 +51,67 @@ handle_lsinfo2(Client &client, int argc, char *argv[])
if (!db_selection_print(client, selection, true, error))
return print_error(client, error);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-static enum command_return
+static CommandResult
handle_match(Client &client, int argc, char *argv[], bool fold_case)
{
SongFilter filter;
if (!filter.Parse(argc - 1, argv + 1, fold_case)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
const DatabaseSelection selection("", true, &filter);
Error error;
return db_selection_print(client, selection, true, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_find(Client &client, int argc, char *argv[])
{
return handle_match(client, argc, argv, false);
}
-enum command_return
+CommandResult
handle_search(Client &client, int argc, char *argv[])
{
return handle_match(client, argc, argv, true);
}
-static enum command_return
+static CommandResult
handle_match_add(Client &client, int argc, char *argv[], bool fold_case)
{
SongFilter filter;
if (!filter.Parse(argc - 1, argv + 1, fold_case)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
const DatabaseSelection selection("", true, &filter);
Error error;
return AddFromDatabase(client.partition, selection, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_findadd(Client &client, int argc, char *argv[])
{
return handle_match_add(client, argc, argv, false);
}
-enum command_return
+CommandResult
handle_searchadd(Client &client, int argc, char *argv[])
{
return handle_match_add(client, argc, argv, true);
}
-enum command_return
+CommandResult
handle_searchaddpl(Client &client, int argc, char *argv[])
{
const char *playlist = argv[1];
@@ -119,31 +119,31 @@ handle_searchaddpl(Client &client, int argc, char *argv[])
SongFilter filter;
if (!filter.Parse(argc - 2, argv + 2, true)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
Error error;
return search_add_to_playlist("", playlist, &filter, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_count(Client &client, int argc, char *argv[])
{
SongFilter filter;
if (!filter.Parse(argc - 1, argv + 1, false)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
Error error;
return searchStatsForSongsIn(client, "", &filter, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_listall(Client &client, gcc_unused int argc, char *argv[])
{
const char *directory = "";
@@ -153,24 +153,24 @@ handle_listall(Client &client, gcc_unused int argc, char *argv[])
Error error;
return printAllIn(client, directory, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_list(Client &client, int argc, char *argv[])
{
unsigned tagType = locate_parse_type(argv[1]);
if (tagType == TAG_NUM_OF_ITEM_TYPES) {
command_error(client, ACK_ERROR_ARG, "\"%s\" is not known", argv[1]);
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
if (tagType == LOCATE_TAG_ANY_TYPE) {
command_error(client, ACK_ERROR_ARG,
"\"any\" is not a valid return tag type");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
/* for compatibility with < 0.12.0 */
@@ -180,7 +180,7 @@ handle_list(Client &client, int argc, char *argv[])
command_error(client, ACK_ERROR_ARG,
"should be \"%s\" for 3 arguments",
tag_item_names[TAG_ALBUM]);
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
filter = new SongFilter((unsigned)TAG_ARTIST, argv[2]);
@@ -190,15 +190,15 @@ handle_list(Client &client, int argc, char *argv[])
delete filter;
command_error(client, ACK_ERROR_ARG,
"not able to parse args");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
} else
filter = nullptr;
Error error;
- enum command_return ret =
+ CommandResult ret =
listAllUniqueTags(client, tagType, filter, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
delete filter;
@@ -206,7 +206,7 @@ handle_list(Client &client, int argc, char *argv[])
return ret;
}
-enum command_return
+CommandResult
handle_listallinfo(Client &client, gcc_unused int argc, char *argv[])
{
const char *directory = "";
@@ -216,6 +216,6 @@ handle_listallinfo(Client &client, gcc_unused int argc, char *argv[])
Error error;
return printInfoForAllIn(client, directory, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
diff --git a/src/DatabaseCommands.hxx b/src/DatabaseCommands.hxx
index 5e4130aba..c60caf246 100644
--- a/src/DatabaseCommands.hxx
+++ b/src/DatabaseCommands.hxx
@@ -20,38 +20,38 @@
#ifndef MPD_DATABASE_COMMANDS_HXX
#define MPD_DATABASE_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_lsinfo2(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_find(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_findadd(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_search(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_searchadd(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_searchaddpl(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_count(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_listall(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_list(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_listallinfo(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/MessageCommands.cxx b/src/MessageCommands.cxx
index 9dd22418b..7d9893e70 100644
--- a/src/MessageCommands.cxx
+++ b/src/MessageCommands.cxx
@@ -31,29 +31,29 @@
#include <assert.h>
-enum command_return
+CommandResult
handle_subscribe(Client &client, gcc_unused int argc, char *argv[])
{
assert(argc == 2);
switch (client.Subscribe(argv[1])) {
case Client::SubscribeResult::OK:
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
case Client::SubscribeResult::INVALID:
command_error(client, ACK_ERROR_ARG,
"invalid channel name");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case Client::SubscribeResult::ALREADY:
command_error(client, ACK_ERROR_EXIST,
"already subscribed to this channel");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
case Client::SubscribeResult::FULL:
command_error(client, ACK_ERROR_EXIST,
"subscription list is full");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
/* unreachable */
@@ -61,21 +61,21 @@ handle_subscribe(Client &client, gcc_unused int argc, char *argv[])
gcc_unreachable();
}
-enum command_return
+CommandResult
handle_unsubscribe(Client &client, gcc_unused int argc, char *argv[])
{
assert(argc == 2);
if (client.Unsubscribe(argv[1]))
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
else {
command_error(client, ACK_ERROR_NO_EXIST,
"not subscribed to this channel");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
-enum command_return
+CommandResult
handle_channels(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -89,10 +89,10 @@ handle_channels(Client &client,
for (const auto &channel : channels)
client_printf(client, "channel: %s\n", channel.c_str());
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_read_messages(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -106,10 +106,10 @@ handle_read_messages(Client &client,
client.messages.pop_front();
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_send_message(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -118,7 +118,7 @@ handle_send_message(Client &client,
if (!client_message_valid_channel_name(argv[1])) {
command_error(client, ACK_ERROR_ARG,
"invalid channel name");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
bool sent = false;
@@ -128,10 +128,10 @@ handle_send_message(Client &client,
sent = true;
if (sent)
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
else {
command_error(client, ACK_ERROR_NO_EXIST,
"nobody is subscribed to this channel");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
diff --git a/src/MessageCommands.hxx b/src/MessageCommands.hxx
index 150e0a2a2..921b20c94 100644
--- a/src/MessageCommands.hxx
+++ b/src/MessageCommands.hxx
@@ -20,23 +20,23 @@
#ifndef MPD_MESSAGE_COMMANDS_HXX
#define MPD_MESSAGE_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_subscribe(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_unsubscribe(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_channels(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_read_messages(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_send_message(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/OtherCommands.cxx b/src/OtherCommands.cxx
index 3e1e6fdd4..1291caf4e 100644
--- a/src/OtherCommands.cxx
+++ b/src/OtherCommands.cxx
@@ -63,47 +63,47 @@ print_spl_list(Client &client, const PlaylistVector &list)
}
}
-enum command_return
+CommandResult
handle_urlhandlers(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
if (client.IsLocal())
client_puts(client, "handler: file://\n");
print_supported_uri_schemes(client);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_decoders(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
decoder_list_print(client);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_tagtypes(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
tag_print_types(client);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_kill(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
- return COMMAND_RETURN_KILL;
+ return CommandResult::KILL;
}
-enum command_return
+CommandResult
handle_close(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
- return COMMAND_RETURN_CLOSE;
+ return CommandResult::CLOSE;
}
-enum command_return
+CommandResult
handle_lsinfo(Client &client, int argc, char *argv[])
{
const char *uri;
@@ -122,7 +122,7 @@ handle_lsinfo(Client &client, int argc, char *argv[])
if (path_fs.IsNull()) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported file name");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
Error error;
@@ -133,16 +133,16 @@ handle_lsinfo(Client &client, int argc, char *argv[])
if (song == NULL) {
command_error(client, ACK_ERROR_NO_EXIST,
"No such file");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
song_print_info(client, *song);
song->Free();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
- enum command_return result = handle_lsinfo2(client, argc, argv);
- if (result != COMMAND_RETURN_OK)
+ CommandResult result = handle_lsinfo2(client, argc, argv);
+ if (result != CommandResult::OK)
return result;
if (isRootDirectory(uri)) {
@@ -151,10 +151,10 @@ handle_lsinfo(Client &client, int argc, char *argv[])
print_spl_list(client, list);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_update(Client &client, gcc_unused int argc, char *argv[])
{
const char *path = "";
@@ -170,22 +170,22 @@ handle_update(Client &client, gcc_unused int argc, char *argv[])
else if (!uri_safe_local(path)) {
command_error(client, ACK_ERROR_ARG,
"Malformed path");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
ret = update_enqueue(path, false);
if (ret > 0) {
client_printf(client, "updating_db: %i\n", ret);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
} else {
command_error(client, ACK_ERROR_UPDATE_ALREADY,
"already updating");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
-enum command_return
+CommandResult
handle_rescan(Client &client, gcc_unused int argc, char *argv[])
{
const char *path = "";
@@ -198,93 +198,93 @@ handle_rescan(Client &client, gcc_unused int argc, char *argv[])
if (!uri_safe_local(path)) {
command_error(client, ACK_ERROR_ARG,
"Malformed path");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
ret = update_enqueue(path, true);
if (ret > 0) {
client_printf(client, "updating_db: %i\n", ret);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
} else {
command_error(client, ACK_ERROR_UPDATE_ALREADY,
"already updating");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
-enum command_return
+CommandResult
handle_setvol(Client &client, gcc_unused int argc, char *argv[])
{
unsigned level;
bool success;
if (!check_unsigned(client, &level, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (level > 100) {
command_error(client, ACK_ERROR_ARG, "Invalid volume value");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
success = volume_level_change(level);
if (!success) {
command_error(client, ACK_ERROR_SYSTEM,
"problems setting volume");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_stats(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
stats_print(client);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_ping(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_password(Client &client, gcc_unused int argc, char *argv[])
{
unsigned permission = 0;
if (getPermissionFromPassword(argv[1], &permission) < 0) {
command_error(client, ACK_ERROR_PASSWORD, "incorrect password");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
client.SetPermission(permission);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_config(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
if (!client.IsLocal()) {
command_error(client, ACK_ERROR_PERMISSION,
"Command only permitted to local clients");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
const char *path = mapper_get_music_directory_utf8();
if (path != NULL)
client_printf(client, "music_directory: %s\n", path);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_idle(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -311,5 +311,5 @@ handle_idle(Client &client,
/* enable "idle" mode on this client */
client.IdleWait(flags);
- return COMMAND_RETURN_IDLE;
+ return CommandResult::IDLE;
}
diff --git a/src/OtherCommands.hxx b/src/OtherCommands.hxx
index b0968d302..fe3e145c4 100644
--- a/src/OtherCommands.hxx
+++ b/src/OtherCommands.hxx
@@ -20,50 +20,50 @@
#ifndef MPD_OTHER_COMMANDS_HXX
#define MPD_OTHER_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_urlhandlers(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_decoders(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_tagtypes(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_kill(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_close(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_lsinfo(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_update(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_rescan(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_setvol(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_stats(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_ping(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_password(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_config(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_idle(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/OutputCommands.cxx b/src/OutputCommands.cxx
index ef35ba8ec..8d6ea8ed7 100644
--- a/src/OutputCommands.cxx
+++ b/src/OutputCommands.cxx
@@ -26,65 +26,65 @@
#include <string.h>
-enum command_return
+CommandResult
handle_enableoutput(Client &client, gcc_unused int argc, char *argv[])
{
unsigned device;
bool ret;
if (!check_unsigned(client, &device, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
ret = audio_output_enable_index(device);
if (!ret) {
command_error(client, ACK_ERROR_NO_EXIST,
"No such audio output");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_disableoutput(Client &client, gcc_unused int argc, char *argv[])
{
unsigned device;
bool ret;
if (!check_unsigned(client, &device, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
ret = audio_output_disable_index(device);
if (!ret) {
command_error(client, ACK_ERROR_NO_EXIST,
"No such audio output");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_toggleoutput(Client &client, gcc_unused int argc, char *argv[])
{
unsigned device;
if (!check_unsigned(client, &device, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!audio_output_toggle_index(device)) {
command_error(client, ACK_ERROR_NO_EXIST,
"No such audio output");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_devices(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
printAudioDevices(client);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
diff --git a/src/OutputCommands.hxx b/src/OutputCommands.hxx
index c0d3b9030..ac3c0211a 100644
--- a/src/OutputCommands.hxx
+++ b/src/OutputCommands.hxx
@@ -20,20 +20,20 @@
#ifndef MPD_OUTPUT_COMMANDS_HXX
#define MPD_OUTPUT_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_enableoutput(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_disableoutput(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_toggleoutput(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_devices(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/PlayerCommands.cxx b/src/PlayerCommands.cxx
index 9bc162ea7..d30bde273 100644
--- a/src/PlayerCommands.cxx
+++ b/src/PlayerCommands.cxx
@@ -52,62 +52,62 @@
#define COMMAND_STATUS_AUDIO "audio"
#define COMMAND_STATUS_UPDATING_DB "updating_db"
-enum command_return
+CommandResult
handle_play(Client &client, int argc, char *argv[])
{
int song = -1;
if (argc == 2 && !check_int(client, &song, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.PlayPosition(song);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_playid(Client &client, int argc, char *argv[])
{
int id = -1;
if (argc == 2 && !check_int(client, &id, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.PlayId(id);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_stop(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
client.partition.Stop();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_currentsong(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
playlist_print_current(client, client.playlist);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_pause(Client &client,
int argc, char *argv[])
{
if (argc == 2) {
bool pause_flag;
if (!check_bool(client, &pause_flag, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.player_control.SetPause(pause_flag);
} else
client.player_control.Pause();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_status(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -202,10 +202,10 @@ handle_status(Client &client,
song, playlist.PositionToId(song));
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_next(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -219,170 +219,170 @@ handle_next(Client &client,
client.partition.PlayNext();
playlist.queue.single = single;
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_previous(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
client.partition.PlayPrevious();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_repeat(Client &client, gcc_unused int argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.partition.SetRepeat(status);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_single(Client &client, gcc_unused int argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.partition.SetSingle(status);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_consume(Client &client, gcc_unused int argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.partition.SetConsume(status);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_random(Client &client, gcc_unused int argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.partition.SetRandom(status);
audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client.partition.GetRandom()));
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_clearerror(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
client.player_control.ClearError();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_seek(Client &client, gcc_unused int argc, char *argv[])
{
unsigned song, seek_time;
if (!check_unsigned(client, &song, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_unsigned(client, &seek_time, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SeekSongPosition(song, seek_time);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_seekid(Client &client, gcc_unused int argc, char *argv[])
{
unsigned id, seek_time;
if (!check_unsigned(client, &id, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_unsigned(client, &seek_time, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SeekSongId(id, seek_time);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_seekcur(Client &client, gcc_unused int argc, char *argv[])
{
const char *p = argv[1];
bool relative = *p == '+' || *p == '-';
int seek_time;
if (!check_int(client, &seek_time, p))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SeekCurrent(seek_time, relative);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_crossfade(Client &client, gcc_unused int argc, char *argv[])
{
unsigned xfade_time;
if (!check_unsigned(client, &xfade_time, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.player_control.SetCrossFade(xfade_time);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_mixrampdb(Client &client, gcc_unused int argc, char *argv[])
{
float db;
if (!check_float(client, &db, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.player_control.SetMixRampDb(db);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_mixrampdelay(Client &client, gcc_unused int argc, char *argv[])
{
float delay_secs;
if (!check_float(client, &delay_secs, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.player_control.SetMixRampDelay(delay_secs);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_replay_gain_mode(Client &client,
gcc_unused int argc, char *argv[])
{
if (!replay_gain_set_mode_string(argv[1])) {
command_error(client, ACK_ERROR_ARG,
"Unrecognized replay gain mode");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client.playlist.queue.random));
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_replay_gain_status(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
client_printf(client, "replay_gain_mode: %s\n",
replay_gain_get_mode_string());
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
diff --git a/src/PlayerCommands.hxx b/src/PlayerCommands.hxx
index 6bef71a01..c201c7a57 100644
--- a/src/PlayerCommands.hxx
+++ b/src/PlayerCommands.hxx
@@ -20,71 +20,71 @@
#ifndef MPD_PLAYER_COMMANDS_HXX
#define MPD_PLAYER_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_play(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_stop(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_currentsong(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_pause(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_status(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_next(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_previous(Client &client, int argc, char *avg[]);
-enum command_return
+CommandResult
handle_repeat(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_single(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_consume(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_random(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_clearerror(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_seek(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_seekid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_seekcur(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_crossfade(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_mixrampdb(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_mixrampdelay(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_replay_gain_mode(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_replay_gain_status(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/PlaylistCommands.cxx b/src/PlaylistCommands.cxx
index 02c21e01f..d178fa097 100644
--- a/src/PlaylistCommands.cxx
+++ b/src/PlaylistCommands.cxx
@@ -49,14 +49,14 @@ print_spl_list(Client &client, const PlaylistVector &list)
}
}
-enum command_return
+CommandResult
handle_save(Client &client, gcc_unused int argc, char *argv[])
{
PlaylistResult result = spl_save_playlist(argv[1], client.playlist);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_load(Client &client, int argc, char *argv[])
{
unsigned start_index, end_index;
@@ -65,7 +65,7 @@ handle_load(Client &client, int argc, char *argv[])
start_index = 0;
end_index = unsigned(-1);
} else if (!check_range(client, &start_index, &end_index, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
const PlaylistResult result =
playlist_open_into_queue(argv[1],
@@ -79,7 +79,7 @@ handle_load(Client &client, int argc, char *argv[])
if (playlist_load_spl(client.playlist, client.player_control,
argv[1], start_index, end_index,
error))
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
if (error.IsDomain(playlist_domain) &&
PlaylistResult(error.GetCode()) == PlaylistResult::BAD_NAME) {
@@ -95,91 +95,91 @@ handle_load(Client &client, int argc, char *argv[])
return print_error(client, error);
}
-enum command_return
+CommandResult
handle_listplaylist(Client &client, gcc_unused int argc, char *argv[])
{
if (playlist_file_print(client, argv[1], false))
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
Error error;
return spl_print(client, argv[1], false, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_listplaylistinfo(Client &client,
gcc_unused int argc, char *argv[])
{
if (playlist_file_print(client, argv[1], true))
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
Error error;
return spl_print(client, argv[1], true, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_rm(Client &client, gcc_unused int argc, char *argv[])
{
Error error;
return spl_delete(argv[1], error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_rename(Client &client, gcc_unused int argc, char *argv[])
{
Error error;
return spl_rename(argv[1], argv[2], error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_playlistdelete(Client &client,
gcc_unused int argc, char *argv[]) {
char *playlist = argv[1];
unsigned from;
if (!check_unsigned(client, &from, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
Error error;
return spl_remove_index(playlist, from, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_playlistmove(Client &client, gcc_unused int argc, char *argv[])
{
char *playlist = argv[1];
unsigned from, to;
if (!check_unsigned(client, &from, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_unsigned(client, &to, argv[3]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
Error error;
return spl_move_index(playlist, from, to, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_playlistclear(Client &client, gcc_unused int argc, char *argv[])
{
Error error;
return spl_clear(argv[1], error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
{
char *playlist = argv[1];
@@ -191,7 +191,7 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
if (!uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
success = spl_append_uri(uri, playlist, error);
@@ -202,13 +202,13 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
if (!success && !error.IsDefined()) {
command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return success ? COMMAND_RETURN_OK : print_error(client, error);
+ return success ? CommandResult::OK : print_error(client, error);
}
-enum command_return
+CommandResult
handle_listplaylists(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
@@ -218,5 +218,5 @@ handle_listplaylists(Client &client,
return print_error(client, error);
print_spl_list(client, list);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
diff --git a/src/PlaylistCommands.hxx b/src/PlaylistCommands.hxx
index a34ee6b32..786f8b89f 100644
--- a/src/PlaylistCommands.hxx
+++ b/src/PlaylistCommands.hxx
@@ -20,41 +20,41 @@
#ifndef MPD_PLAYLIST_COMMANDS_HXX
#define MPD_PLAYLIST_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_save(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_load(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_listplaylist(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_listplaylistinfo(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_rm(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_rename(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistdelete(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistmove(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistclear(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistadd(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_listplaylists(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx
index 92355bdff..a21eb75f0 100644
--- a/src/QueueCommands.cxx
+++ b/src/QueueCommands.cxx
@@ -39,7 +39,7 @@
#include <string.h>
-enum command_return
+CommandResult
handle_add(Client &client, gcc_unused int argc, char *argv[])
{
char *uri = argv[1];
@@ -52,7 +52,7 @@ handle_add(Client &client, gcc_unused int argc, char *argv[])
if (path_fs.IsNull()) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported file name");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
Error error;
@@ -67,7 +67,7 @@ handle_add(Client &client, gcc_unused int argc, char *argv[])
if (!uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
result = client.partition.AppendURI(uri);
@@ -77,11 +77,11 @@ handle_add(Client &client, gcc_unused int argc, char *argv[])
const DatabaseSelection selection(uri, true);
Error error;
return AddFromDatabase(client.partition, selection, error)
- ? COMMAND_RETURN_OK
+ ? CommandResult::OK
: print_error(client, error);
}
-enum command_return
+CommandResult
handle_addid(Client &client, int argc, char *argv[])
{
char *uri = argv[1];
@@ -95,7 +95,7 @@ handle_addid(Client &client, int argc, char *argv[])
if (path_fs.IsNull()) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported file name");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
Error error;
@@ -107,7 +107,7 @@ handle_addid(Client &client, int argc, char *argv[])
if (uri_has_scheme(uri) && !uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
result = client.partition.AppendURI(uri, &added_id);
@@ -119,10 +119,10 @@ handle_addid(Client &client, int argc, char *argv[])
if (argc == 3) {
unsigned to;
if (!check_unsigned(client, &to, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
result = client.partition.MoveId(added_id, to);
if (result != PlaylistResult::SUCCESS) {
- enum command_return ret =
+ CommandResult ret =
print_playlist_result(client, result);
client.partition.DeleteId(added_id);
return ret;
@@ -130,109 +130,109 @@ handle_addid(Client &client, int argc, char *argv[])
}
client_printf(client, "Id: %u\n", added_id);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_delete(Client &client, gcc_unused int argc, char *argv[])
{
unsigned start, end;
if (!check_range(client, &start, &end, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.DeleteRange(start, end);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_deleteid(Client &client, gcc_unused int argc, char *argv[])
{
unsigned id;
if (!check_unsigned(client, &id, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.DeleteId(id);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_playlist(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
playlist_print_uris(client, client.playlist);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_shuffle(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
unsigned start = 0, end = client.playlist.queue.GetLength();
if (argc == 2 && !check_range(client, &start, &end, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
client.partition.Shuffle(start, end);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_clear(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
client.partition.ClearQueue();
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_plchanges(Client &client, gcc_unused int argc, char *argv[])
{
uint32_t version;
if (!check_uint32(client, &version, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
playlist_print_changes_info(client, client.playlist, version);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_plchangesposid(Client &client, gcc_unused int argc, char *argv[])
{
uint32_t version;
if (!check_uint32(client, &version, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
playlist_print_changes_position(client, client.playlist, version);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_playlistinfo(Client &client, int argc, char *argv[])
{
unsigned start = 0, end = std::numeric_limits<unsigned>::max();
bool ret;
if (argc == 2 && !check_range(client, &start, &end, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
ret = playlist_print_info(client, client.playlist, start, end);
if (!ret)
return print_playlist_result(client,
PlaylistResult::BAD_RANGE);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_playlistid(Client &client, int argc, char *argv[])
{
if (argc >= 2) {
unsigned id;
if (!check_unsigned(client, &id, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
bool ret = playlist_print_id(client, client.playlist, id);
if (!ret)
@@ -243,54 +243,54 @@ handle_playlistid(Client &client, int argc, char *argv[])
0, std::numeric_limits<unsigned>::max());
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-static enum command_return
+static CommandResult
handle_playlist_match(Client &client, int argc, char *argv[],
bool fold_case)
{
SongFilter filter;
if (!filter.Parse(argc - 1, argv + 1, fold_case)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
playlist_print_find(client, client.playlist, filter);
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_playlistfind(Client &client, int argc, char *argv[])
{
return handle_playlist_match(client, argc, argv, false);
}
-enum command_return
+CommandResult
handle_playlistsearch(Client &client, int argc, char *argv[])
{
return handle_playlist_match(client, argc, argv, true);
}
-enum command_return
+CommandResult
handle_prio(Client &client, int argc, char *argv[])
{
unsigned priority;
if (!check_unsigned(client, &priority, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (priority > 0xff) {
command_error(client, ACK_ERROR_ARG,
"Priority out of range: %s", argv[1]);
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
for (int i = 2; i < argc; ++i) {
unsigned start_position, end_position;
if (!check_range(client, &start_position, &end_position,
argv[i]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SetPriorityRange(start_position,
@@ -300,27 +300,27 @@ handle_prio(Client &client, int argc, char *argv[])
return print_playlist_result(client, result);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_prioid(Client &client, int argc, char *argv[])
{
unsigned priority;
if (!check_unsigned(client, &priority, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (priority > 0xff) {
command_error(client, ACK_ERROR_ARG,
"Priority out of range: %s", argv[1]);
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
for (int i = 2; i < argc; ++i) {
unsigned song_id;
if (!check_unsigned(client, &song_id, argv[i]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SetPriorityId(song_id, priority);
@@ -328,63 +328,63 @@ handle_prioid(Client &client, int argc, char *argv[])
return print_playlist_result(client, result);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
}
-enum command_return
+CommandResult
handle_move(Client &client, gcc_unused int argc, char *argv[])
{
unsigned start, end;
int to;
if (!check_range(client, &start, &end, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_int(client, &to, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.MoveRange(start, end, to);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_moveid(Client &client, gcc_unused int argc, char *argv[])
{
unsigned id;
int to;
if (!check_unsigned(client, &id, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_int(client, &to, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.MoveId(id, to);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_swap(Client &client, gcc_unused int argc, char *argv[])
{
unsigned song1, song2;
if (!check_unsigned(client, &song1, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_unsigned(client, &song2, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result =
client.partition.SwapPositions(song1, song2);
return print_playlist_result(client, result);
}
-enum command_return
+CommandResult
handle_swapid(Client &client, gcc_unused int argc, char *argv[])
{
unsigned id1, id2;
if (!check_unsigned(client, &id1, argv[1]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
if (!check_unsigned(client, &id2, argv[2]))
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
PlaylistResult result = client.partition.SwapIds(id1, id2);
return print_playlist_result(client, result);
diff --git a/src/QueueCommands.hxx b/src/QueueCommands.hxx
index 09b489212..3beb28e52 100644
--- a/src/QueueCommands.hxx
+++ b/src/QueueCommands.hxx
@@ -20,65 +20,65 @@
#ifndef MPD_QUEUE_COMMANDS_HXX
#define MPD_QUEUE_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_add(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_addid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_delete(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_deleteid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlist(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_shuffle(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_clear(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_plchanges(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_plchangesposid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistinfo(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistfind(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_playlistsearch(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_prio(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_prioid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_move(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_moveid(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_swap(Client &client, int argc, char *argv[]);
-enum command_return
+CommandResult
handle_swapid(Client &client, int argc, char *argv[]);
#endif
diff --git a/src/StickerCommands.cxx b/src/StickerCommands.cxx
index 6688c0820..cbd371c8f 100644
--- a/src/StickerCommands.cxx
+++ b/src/StickerCommands.cxx
@@ -51,7 +51,7 @@ sticker_song_find_print_cb(Song &song, const char *value,
sticker_print_value(data->client, data->name, value);
}
-static enum command_return
+static CommandResult
handle_sticker_song(Client &client, int argc, char *argv[])
{
Error error;
@@ -70,12 +70,12 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if (value.empty()) {
command_error(client, ACK_ERROR_NO_EXIST,
"no such sticker");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
sticker_print_value(client, argv[4], value.c_str());
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
/* list song song_id */
} else if (argc == 4 && strcmp(argv[1], "list") == 0) {
Song *song = db->GetSong(argv[3], error);
@@ -89,7 +89,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
sticker_free(sticker);
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
/* set song song_id id key */
} else if (argc == 6 && strcmp(argv[1], "set") == 0) {
Song *song = db->GetSong(argv[3], error);
@@ -101,10 +101,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if (!ret) {
command_error(client, ACK_ERROR_SYSTEM,
"failed to set sticker value");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
/* delete song song_id [key] */
} else if ((argc == 4 || argc == 5) &&
strcmp(argv[1], "delete") == 0) {
@@ -119,10 +119,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if (!ret) {
command_error(client, ACK_ERROR_SYSTEM,
"no such sticker");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
/* find song dir key */
} else if (argc == 5 && strcmp(argv[1], "find") == 0) {
/* "sticker find song a/directory name" */
@@ -138,7 +138,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
db_unlock();
command_error(client, ACK_ERROR_NO_EXIST,
"no such directory");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
success = sticker_song_find(*directory, data.name,
@@ -147,17 +147,17 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if (!success) {
command_error(client, ACK_ERROR_SYSTEM,
"failed to set search sticker database");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
- return COMMAND_RETURN_OK;
+ return CommandResult::OK;
} else {
command_error(client, ACK_ERROR_ARG, "bad request");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
-enum command_return
+CommandResult
handle_sticker(Client &client, int argc, char *argv[])
{
assert(argc >= 4);
@@ -165,7 +165,7 @@ handle_sticker(Client &client, int argc, char *argv[])
if (!sticker_enabled()) {
command_error(client, ACK_ERROR_UNKNOWN,
"sticker database is disabled");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
if (strcmp(argv[2], "song") == 0)
@@ -173,6 +173,6 @@ handle_sticker(Client &client, int argc, char *argv[])
else {
command_error(client, ACK_ERROR_ARG,
"unknown sticker domain");
- return COMMAND_RETURN_ERROR;
+ return CommandResult::ERROR;
}
}
diff --git a/src/StickerCommands.hxx b/src/StickerCommands.hxx
index 0aaa74de0..fb91a8ad3 100644
--- a/src/StickerCommands.hxx
+++ b/src/StickerCommands.hxx
@@ -20,11 +20,11 @@
#ifndef MPD_STICKER_COMMANDS_HXX
#define MPD_STICKER_COMMANDS_HXX
-#include "command.h"
+#include "CommandResult.hxx"
class Client;
-enum command_return
+CommandResult
handle_sticker(Client &client, int argc, char *argv[]);
#endif