Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
cf4d80fc
Commit
cf4d80fc
authored
Oct 20, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: convert command_return to to a strictly-typed enum
parent
8118bc93
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
429 additions
and
422 deletions
+429
-422
Makefile.am
Makefile.am
+1
-1
AllCommands.cxx
src/AllCommands.cxx
+12
-13
AllCommands.hxx
src/AllCommands.hxx
+2
-2
ClientInternal.hxx
src/ClientInternal.hxx
+2
-2
ClientProcess.cxx
src/ClientProcess.cxx
+17
-17
ClientRead.cxx
src/ClientRead.cxx
+6
-6
CommandError.cxx
src/CommandError.cxx
+19
-19
CommandError.hxx
src/CommandError.hxx
+3
-3
CommandResult.hxx
src/CommandResult.hxx
+16
-8
DatabaseCommands.cxx
src/DatabaseCommands.cxx
+29
-29
DatabaseCommands.hxx
src/DatabaseCommands.hxx
+11
-11
MessageCommands.cxx
src/MessageCommands.cxx
+16
-16
MessageCommands.hxx
src/MessageCommands.hxx
+6
-6
OtherCommands.cxx
src/OtherCommands.cxx
+42
-42
OtherCommands.hxx
src/OtherCommands.hxx
+15
-15
OutputCommands.cxx
src/OutputCommands.cxx
+14
-14
OutputCommands.hxx
src/OutputCommands.hxx
+5
-5
PlayerCommands.cxx
src/PlayerCommands.cxx
+53
-53
PlayerCommands.hxx
src/PlayerCommands.hxx
+22
-22
PlaylistCommands.cxx
src/PlaylistCommands.cxx
+29
-29
PlaylistCommands.hxx
src/PlaylistCommands.hxx
+12
-12
QueueCommands.cxx
src/QueueCommands.cxx
+60
-60
QueueCommands.hxx
src/QueueCommands.hxx
+20
-20
StickerCommands.cxx
src/StickerCommands.cxx
+15
-15
StickerCommands.hxx
src/StickerCommands.hxx
+2
-2
No files found.
Makefile.am
View file @
cf4d80fc
...
@@ -54,7 +54,6 @@ src_mpd_LDADD = \
...
@@ -54,7 +54,6 @@ src_mpd_LDADD = \
mpd_headers
=
\
mpd_headers
=
\
src/check.h
\
src/check.h
\
src/command.h
\
src/gerror.h
\
src/gerror.h
\
src/TextInputStream.hxx
\
src/TextInputStream.hxx
\
src/AudioCompress/config.h
\
src/AudioCompress/config.h
\
...
@@ -79,6 +78,7 @@ src_mpd_SOURCES = \
...
@@ -79,6 +78,7 @@ src_mpd_SOURCES = \
src/protocol/Ack.cxx src/protocol/Ack.hxx
\
src/protocol/Ack.cxx src/protocol/Ack.hxx
\
src/protocol/ArgParser.cxx src/protocol/ArgParser.hxx
\
src/protocol/ArgParser.cxx src/protocol/ArgParser.hxx
\
src/protocol/Result.cxx src/protocol/Result.hxx
\
src/protocol/Result.cxx src/protocol/Result.hxx
\
src/CommandResult.hxx
\
src/CommandError.cxx src/CommandError.hxx
\
src/CommandError.cxx src/CommandError.hxx
\
src/AllCommands.cxx src/AllCommands.hxx
\
src/AllCommands.cxx src/AllCommands.hxx
\
src/QueueCommands.cxx src/QueueCommands.hxx
\
src/QueueCommands.cxx src/QueueCommands.hxx
\
...
...
src/AllCommands.cxx
View file @
cf4d80fc
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "config.h"
#include "config.h"
#include "AllCommands.hxx"
#include "AllCommands.hxx"
#include "command.h"
#include "QueueCommands.hxx"
#include "QueueCommands.hxx"
#include "PlayerCommands.hxx"
#include "PlayerCommands.hxx"
#include "PlaylistCommands.hxx"
#include "PlaylistCommands.hxx"
...
@@ -56,14 +55,14 @@ struct command {
...
@@ -56,14 +55,14 @@ struct command {
unsigned
permission
;
unsigned
permission
;
int
min
;
int
min
;
int
max
;
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 */
/* 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
[]);
handle_commands
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
static
enum
command_return
static
CommandResult
handle_not_commands
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_not_commands
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
/**
/**
...
@@ -178,7 +177,7 @@ command_available(gcc_unused const struct command *cmd)
...
@@ -178,7 +177,7 @@ command_available(gcc_unused const struct command *cmd)
}
}
/* don't be fooled, this is the command handler for "commands" command */
/* don't be fooled, this is the command handler for "commands" command */
static
enum
command_return
static
CommandResult
handle_commands
(
Client
&
client
,
handle_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -193,10 +192,10 @@ handle_commands(Client &client,
...
@@ -193,10 +192,10 @@ handle_commands(Client &client,
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
static
enum
command_return
static
CommandResult
handle_not_commands
(
Client
&
client
,
handle_not_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -210,7 +209,7 @@ handle_not_commands(Client &client,
...
@@ -210,7 +209,7 @@ handle_not_commands(Client &client,
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
void
command_init
(
void
)
void
command_init
(
void
)
...
@@ -308,13 +307,13 @@ command_checked_lookup(Client &client, unsigned permission,
...
@@ -308,13 +307,13 @@ command_checked_lookup(Client &client, unsigned permission,
return
cmd
;
return
cmd
;
}
}
enum
command_return
CommandResult
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
)
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
)
{
{
Error
error
;
Error
error
;
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
const
struct
command
*
cmd
;
const
struct
command
*
cmd
;
enum
command_return
ret
=
COMMAND_RETURN_
ERROR
;
CommandResult
ret
=
CommandResult
::
ERROR
;
command_list_num
=
num
;
command_list_num
=
num
;
...
@@ -333,7 +332,7 @@ command_process(Client &client, unsigned num, char *line)
...
@@ -333,7 +332,7 @@ command_process(Client &client, unsigned num, char *line)
current_command
=
nullptr
;
current_command
=
nullptr
;
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
unsigned
argc
=
1
;
unsigned
argc
=
1
;
...
@@ -353,13 +352,13 @@ command_process(Client &client, unsigned num, char *line)
...
@@ -353,13 +352,13 @@ command_process(Client &client, unsigned num, char *line)
if
(
argc
>=
COMMAND_ARGV_MAX
)
{
if
(
argc
>=
COMMAND_ARGV_MAX
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Too many arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"Too many arguments"
);
current_command
=
nullptr
;
current_command
=
nullptr
;
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
if
(
!
tokenizer
.
IsEnd
())
{
if
(
!
tokenizer
.
IsEnd
())
{
command_error
(
client
,
ACK_ERROR_ARG
,
"%s"
,
error
.
GetMessage
());
command_error
(
client
,
ACK_ERROR_ARG
,
"%s"
,
error
.
GetMessage
());
current_command
=
nullptr
;
current_command
=
nullptr
;
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
/* look up and invoke the command handler */
/* look up and invoke the command handler */
...
...
src/AllCommands.hxx
View file @
cf4d80fc
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#ifndef MPD_ALL_COMMANDS_HXX
#ifndef MPD_ALL_COMMANDS_HXX
#define MPD_ALL_COMMANDS_HXX
#define MPD_ALL_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
...
@@ -28,7 +28,7 @@ void command_init(void);
...
@@ -28,7 +28,7 @@ void command_init(void);
void
command_finish
(
void
);
void
command_finish
(
void
);
enum
command_return
CommandResult
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
);
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
);
#endif
#endif
src/ClientInternal.hxx
View file @
cf4d80fc
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include "check.h"
#include "check.h"
#include "Client.hxx"
#include "Client.hxx"
#include "
command.h
"
#include "
CommandResult.hxx
"
enum
{
enum
{
CLIENT_MAX_SUBSCRIPTIONS
=
16
,
CLIENT_MAX_SUBSCRIPTIONS
=
16
,
...
@@ -35,7 +35,7 @@ extern int client_timeout;
...
@@ -35,7 +35,7 @@ extern int client_timeout;
extern
size_t
client_max_command_list_size
;
extern
size_t
client_max_command_list_size
;
extern
size_t
client_max_output_buffer_size
;
extern
size_t
client_max_output_buffer_size
;
enum
command_return
CommandResult
client_process_line
(
Client
&
client
,
char
*
line
);
client_process_line
(
Client
&
client
,
char
*
line
);
#endif
#endif
src/ClientProcess.cxx
View file @
cf4d80fc
...
@@ -29,11 +29,11 @@
...
@@ -29,11 +29,11 @@
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_MODE_END "command_list_end"
#define CLIENT_LIST_MODE_END "command_list_end"
static
enum
command_return
static
CommandResult
client_process_command_list
(
Client
&
client
,
bool
list_ok
,
client_process_command_list
(
Client
&
client
,
bool
list_ok
,
std
::
list
<
std
::
string
>
&&
list
)
std
::
list
<
std
::
string
>
&&
list
)
{
{
enum
command_return
ret
=
COMMAND_RETURN_
OK
;
CommandResult
ret
=
CommandResult
::
OK
;
unsigned
num
=
0
;
unsigned
num
=
0
;
for
(
auto
&&
i
:
list
)
{
for
(
auto
&&
i
:
list
)
{
...
@@ -42,7 +42,7 @@ client_process_command_list(Client &client, bool list_ok,
...
@@ -42,7 +42,7 @@ client_process_command_list(Client &client, bool list_ok,
FormatDebug
(
client_domain
,
"process command
\"
%s
\"
"
,
cmd
);
FormatDebug
(
client_domain
,
"process command
\"
%s
\"
"
,
cmd
);
ret
=
command_process
(
client
,
num
++
,
cmd
);
ret
=
command_process
(
client
,
num
++
,
cmd
);
FormatDebug
(
client_domain
,
"command returned %i"
,
ret
);
FormatDebug
(
client_domain
,
"command returned %i"
,
ret
);
if
(
ret
!=
C
OMMAND_RETURN_
OK
||
client
.
IsExpired
())
if
(
ret
!=
C
ommandResult
::
OK
||
client
.
IsExpired
())
break
;
break
;
else
if
(
list_ok
)
else
if
(
list_ok
)
client_puts
(
client
,
"list_OK
\n
"
);
client_puts
(
client
,
"list_OK
\n
"
);
...
@@ -51,10 +51,10 @@ client_process_command_list(Client &client, bool list_ok,
...
@@ -51,10 +51,10 @@ client_process_command_list(Client &client, bool list_ok,
return
ret
;
return
ret
;
}
}
enum
command_return
CommandResult
client_process_line
(
Client
&
client
,
char
*
line
)
client_process_line
(
Client
&
client
,
char
*
line
)
{
{
enum
command_return
ret
;
CommandResult
ret
;
if
(
strcmp
(
line
,
"noidle"
)
==
0
)
{
if
(
strcmp
(
line
,
"noidle"
)
==
0
)
{
if
(
client
.
idle_waiting
)
{
if
(
client
.
idle_waiting
)
{
...
@@ -67,14 +67,14 @@ client_process_line(Client &client, char *line)
...
@@ -67,14 +67,14 @@ client_process_line(Client &client, char *line)
has already received the full idle response from
has already received the full idle response from
client_idle_notify(), which he can now evaluate */
client_idle_notify(), which he can now evaluate */
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
else
if
(
client
.
idle_waiting
)
{
}
else
if
(
client
.
idle_waiting
)
{
/* during idle mode, clients must not send anything
/* during idle mode, clients must not send anything
except "noidle" */
except "noidle" */
FormatWarning
(
client_domain
,
FormatWarning
(
client_domain
,
"[%u] command
\"
%s
\"
during idle"
,
"[%u] command
\"
%s
\"
during idle"
,
client
.
num
,
line
);
client
.
num
,
line
);
return
C
OMMAND_RETURN_
CLOSE
;
return
C
ommandResult
::
CLOSE
;
}
}
if
(
client
.
cmd_list
.
IsActive
())
{
if
(
client
.
cmd_list
.
IsActive
())
{
...
@@ -92,11 +92,11 @@ client_process_line(Client &client, char *line)
...
@@ -92,11 +92,11 @@ client_process_line(Client &client, char *line)
"[%u] process command "
"[%u] process command "
"list returned %i"
,
client
.
num
,
ret
);
"list returned %i"
,
client
.
num
,
ret
);
if
(
ret
==
C
OMMAND_RETURN_
CLOSE
||
if
(
ret
==
C
ommandResult
::
CLOSE
||
client
.
IsExpired
())
client
.
IsExpired
())
return
C
OMMAND_RETURN_
CLOSE
;
return
C
ommandResult
::
CLOSE
;
if
(
ret
==
C
OMMAND_RETURN_
OK
)
if
(
ret
==
C
ommandResult
::
OK
)
command_success
(
client
);
command_success
(
client
);
client
.
cmd_list
.
Reset
();
client
.
cmd_list
.
Reset
();
...
@@ -107,18 +107,18 @@ client_process_line(Client &client, char *line)
...
@@ -107,18 +107,18 @@ client_process_line(Client &client, char *line)
"is larger than the max (%lu)"
,
"is larger than the max (%lu)"
,
client
.
num
,
client
.
num
,
(
unsigned
long
)
client_max_command_list_size
);
(
unsigned
long
)
client_max_command_list_size
);
return
C
OMMAND_RETURN_
CLOSE
;
return
C
ommandResult
::
CLOSE
;
}
}
ret
=
C
OMMAND_RETURN_
OK
;
ret
=
C
ommandResult
::
OK
;
}
}
}
else
{
}
else
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_BEGIN
)
==
0
)
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_BEGIN
)
==
0
)
{
client
.
cmd_list
.
Begin
(
false
);
client
.
cmd_list
.
Begin
(
false
);
ret
=
C
OMMAND_RETURN_
OK
;
ret
=
C
ommandResult
::
OK
;
}
else
if
(
strcmp
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
==
0
)
{
}
else
if
(
strcmp
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
==
0
)
{
client
.
cmd_list
.
Begin
(
true
);
client
.
cmd_list
.
Begin
(
true
);
ret
=
C
OMMAND_RETURN_
OK
;
ret
=
C
ommandResult
::
OK
;
}
else
{
}
else
{
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] process command
\"
%s
\"
"
,
"[%u] process command
\"
%s
\"
"
,
...
@@ -128,11 +128,11 @@ client_process_line(Client &client, char *line)
...
@@ -128,11 +128,11 @@ client_process_line(Client &client, char *line)
"[%u] command returned %i"
,
"[%u] command returned %i"
,
client
.
num
,
ret
);
client
.
num
,
ret
);
if
(
ret
==
C
OMMAND_RETURN_
CLOSE
||
if
(
ret
==
C
ommandResult
::
CLOSE
||
client
.
IsExpired
())
client
.
IsExpired
())
return
C
OMMAND_RETURN_
CLOSE
;
return
C
ommandResult
::
CLOSE
;
if
(
ret
==
C
OMMAND_RETURN_
OK
)
if
(
ret
==
C
ommandResult
::
OK
)
command_success
(
client
);
command_success
(
client
);
}
}
}
}
...
...
src/ClientRead.cxx
View file @
cf4d80fc
...
@@ -40,19 +40,19 @@ Client::OnSocketInput(void *data, size_t length)
...
@@ -40,19 +40,19 @@ Client::OnSocketInput(void *data, size_t length)
BufferedSocket
::
ConsumeInput
(
newline
+
1
-
p
);
BufferedSocket
::
ConsumeInput
(
newline
+
1
-
p
);
enum
command_return
result
=
client_process_line
(
*
this
,
p
);
CommandResult
result
=
client_process_line
(
*
this
,
p
);
switch
(
result
)
{
switch
(
result
)
{
case
C
OMMAND_RETURN_
OK
:
case
C
ommandResult
:
:
OK
:
case
C
OMMAND_RETURN_
IDLE
:
case
C
ommandResult
:
:
IDLE
:
case
C
OMMAND_RETURN_
ERROR
:
case
C
ommandResult
:
:
ERROR
:
break
;
break
;
case
C
OMMAND_RETURN_
KILL
:
case
C
ommandResult
:
:
KILL
:
Close
();
Close
();
main_loop
->
Break
();
main_loop
->
Break
();
return
InputResult
::
CLOSED
;
return
InputResult
::
CLOSED
;
case
C
OMMAND_RETURN_
CLOSE
:
case
C
ommandResult
:
:
CLOSE
:
Close
();
Close
();
return
InputResult
::
CLOSED
;
return
InputResult
::
CLOSED
;
}
}
...
...
src/CommandError.cxx
View file @
cf4d80fc
...
@@ -29,66 +29,66 @@
...
@@ -29,66 +29,66 @@
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
enum
command_return
CommandResult
print_playlist_result
(
Client
&
client
,
PlaylistResult
result
)
print_playlist_result
(
Client
&
client
,
PlaylistResult
result
)
{
{
switch
(
result
)
{
switch
(
result
)
{
case
PlaylistResult
:
:
SUCCESS
:
case
PlaylistResult
:
:
SUCCESS
:
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
case
PlaylistResult
:
:
ERRNO
:
case
PlaylistResult
:
:
ERRNO
:
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
g_strerror
(
errno
));
g_strerror
(
errno
));
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
DENIED
:
case
PlaylistResult
:
:
DENIED
:
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Access denied"
);
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Access denied"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
NO_SUCH_SONG
:
case
PlaylistResult
:
:
NO_SUCH_SONG
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such song"
);
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such song"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
NO_SUCH_LIST
:
case
PlaylistResult
:
:
NO_SUCH_LIST
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such playlist"
);
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such playlist"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
LIST_EXISTS
:
case
PlaylistResult
:
:
LIST_EXISTS
:
command_error
(
client
,
ACK_ERROR_EXIST
,
command_error
(
client
,
ACK_ERROR_EXIST
,
"Playlist already exists"
);
"Playlist already exists"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
BAD_NAME
:
case
PlaylistResult
:
:
BAD_NAME
:
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"playlist name is invalid: "
"playlist name is invalid: "
"playlist names may not contain slashes,"
"playlist names may not contain slashes,"
" newlines or carriage returns"
);
" newlines or carriage returns"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
BAD_RANGE
:
case
PlaylistResult
:
:
BAD_RANGE
:
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad song index"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad song index"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
NOT_PLAYING
:
case
PlaylistResult
:
:
NOT_PLAYING
:
command_error
(
client
,
ACK_ERROR_PLAYER_SYNC
,
"Not playing"
);
command_error
(
client
,
ACK_ERROR_PLAYER_SYNC
,
"Not playing"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
TOO_LARGE
:
case
PlaylistResult
:
:
TOO_LARGE
:
command_error
(
client
,
ACK_ERROR_PLAYLIST_MAX
,
command_error
(
client
,
ACK_ERROR_PLAYLIST_MAX
,
"playlist is at the max size"
);
"playlist is at the max size"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
PlaylistResult
:
:
DISABLED
:
case
PlaylistResult
:
:
DISABLED
:
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"stored playlist support is disabled"
);
"stored playlist support is disabled"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
assert
(
0
);
assert
(
0
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
enum
command_return
CommandResult
print_error
(
Client
&
client
,
const
Error
&
error
)
print_error
(
Client
&
client
,
const
Error
&
error
)
{
{
assert
(
error
.
IsDefined
());
assert
(
error
.
IsDefined
());
...
@@ -101,24 +101,24 @@ print_error(Client &client, const Error &error)
...
@@ -101,24 +101,24 @@ print_error(Client &client, const Error &error)
}
else
if
(
error
.
IsDomain
(
ack_domain
))
{
}
else
if
(
error
.
IsDomain
(
ack_domain
))
{
command_error
(
client
,
(
ack
)
error
.
GetCode
(),
command_error
(
client
,
(
ack
)
error
.
GetCode
(),
"%s"
,
error
.
GetMessage
());
"%s"
,
error
.
GetMessage
());
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
else
if
(
error
.
IsDomain
(
db_domain
))
{
}
else
if
(
error
.
IsDomain
(
db_domain
))
{
switch
((
enum
db_error
)
error
.
GetCode
())
{
switch
((
enum
db_error
)
error
.
GetCode
())
{
case
DB_DISABLED
:
case
DB_DISABLED
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"%s"
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"%s"
,
error
.
GetMessage
());
error
.
GetMessage
());
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
DB_NOT_FOUND
:
case
DB_NOT_FOUND
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"Not found"
);
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"Not found"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
else
if
(
error
.
IsDomain
(
errno_domain
))
{
}
else
if
(
error
.
IsDomain
(
errno_domain
))
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
g_strerror
(
error
.
GetCode
()));
g_strerror
(
error
.
GetCode
()));
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"error"
);
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"error"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
src/CommandError.hxx
View file @
cf4d80fc
...
@@ -20,19 +20,19 @@
...
@@ -20,19 +20,19 @@
#ifndef MPD_COMMAND_ERROR_HXX
#ifndef MPD_COMMAND_ERROR_HXX
#define MPD_COMMAND_ERROR_HXX
#define MPD_COMMAND_ERROR_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
#include "PlaylistError.hxx"
#include "PlaylistError.hxx"
class
Client
;
class
Client
;
class
Error
;
class
Error
;
enum
command_return
CommandResult
print_playlist_result
(
Client
&
client
,
PlaylistResult
result
);
print_playlist_result
(
Client
&
client
,
PlaylistResult
result
);
/**
/**
* Send the #Error to the client.
* Send the #Error to the client.
*/
*/
enum
command_return
CommandResult
print_error
(
Client
&
client
,
const
Error
&
error
);
print_error
(
Client
&
client
,
const
Error
&
error
);
#endif
#endif
src/
command.h
→
src/
CommandResult.hxx
View file @
cf4d80fc
...
@@ -17,37 +17,45 @@
...
@@ -17,37 +17,45 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
*/
#ifndef MPD_COMMAND_
H
#ifndef MPD_COMMAND_
RESULT_HXX
#define MPD_COMMAND_
H
#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
* The command has succeeded, but the "OK" response was not
* yet sent to the client.
* yet sent to the client.
*/
*/
COMMAND_RETURN_
OK
,
OK
,
/**
/**
* The connection is now in "idle" mode, and no response shall
* The connection is now in "idle" mode, and no response shall
* be generated.
* be generated.
*/
*/
COMMAND_RETURN_
IDLE
,
IDLE
,
/**
/**
* There was an error. The "ACK" response was sent to the
* There was an error. The "ACK" response was sent to the
* client.
* client.
*/
*/
COMMAND_RETURN_
ERROR
,
ERROR
,
/**
/**
* The connection to this client shall be closed.
* The connection to this client shall be closed.
*/
*/
C
OMMAND_RETURN_C
LOSE
,
CLOSE
,
/**
/**
* The MPD process shall be shut down.
* The MPD process shall be shut down.
*/
*/
COMMAND_RETURN_
KILL
,
KILL
,
};
};
#endif
#endif
src/DatabaseCommands.cxx
View file @
cf4d80fc
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
enum
command_return
CommandResult
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
uri
;
const
char
*
uri
;
...
@@ -51,67 +51,67 @@ handle_lsinfo2(Client &client, int argc, char *argv[])
...
@@ -51,67 +51,67 @@ handle_lsinfo2(Client &client, int argc, char *argv[])
if
(
!
db_selection_print
(
client
,
selection
,
true
,
error
))
if
(
!
db_selection_print
(
client
,
selection
,
true
,
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
static
enum
command_return
static
CommandResult
handle_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
handle_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
Error
error
;
Error
error
;
return
db_selection_print
(
client
,
selection
,
true
,
error
)
return
db_selection_print
(
client
,
selection
,
true
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match
(
client
,
argc
,
argv
,
false
);
return
handle_match
(
client
,
argc
,
argv
,
false
);
}
}
enum
command_return
CommandResult
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match
(
client
,
argc
,
argv
,
true
);
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
)
handle_match_add
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
Error
error
;
Error
error
;
return
AddFromDatabase
(
client
.
partition
,
selection
,
error
)
return
AddFromDatabase
(
client
.
partition
,
selection
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match_add
(
client
,
argc
,
argv
,
false
);
return
handle_match_add
(
client
,
argc
,
argv
,
false
);
}
}
enum
command_return
CommandResult
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match_add
(
client
,
argc
,
argv
,
true
);
return
handle_match_add
(
client
,
argc
,
argv
,
true
);
}
}
enum
command_return
CommandResult
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
playlist
=
argv
[
1
];
const
char
*
playlist
=
argv
[
1
];
...
@@ -119,31 +119,31 @@ handle_searchaddpl(Client &client, int argc, char *argv[])
...
@@ -119,31 +119,31 @@ handle_searchaddpl(Client &client, int argc, char *argv[])
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
2
,
argv
+
2
,
true
))
{
if
(
!
filter
.
Parse
(
argc
-
2
,
argv
+
2
,
true
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
Error
error
;
Error
error
;
return
search_add_to_playlist
(
""
,
playlist
,
&
filter
,
error
)
return
search_add_to_playlist
(
""
,
playlist
,
&
filter
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
false
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
false
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
Error
error
;
Error
error
;
return
searchStatsForSongsIn
(
client
,
""
,
&
filter
,
error
)
return
searchStatsForSongsIn
(
client
,
""
,
&
filter
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_listall
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listall
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
directory
=
""
;
const
char
*
directory
=
""
;
...
@@ -153,24 +153,24 @@ handle_listall(Client &client, gcc_unused int argc, char *argv[])
...
@@ -153,24 +153,24 @@ handle_listall(Client &client, gcc_unused int argc, char *argv[])
Error
error
;
Error
error
;
return
printAllIn
(
client
,
directory
,
error
)
return
printAllIn
(
client
,
directory
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
tagType
=
locate_parse_type
(
argv
[
1
]);
unsigned
tagType
=
locate_parse_type
(
argv
[
1
]);
if
(
tagType
==
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
tagType
==
TAG_NUM_OF_ITEM_TYPES
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not known"
,
argv
[
1
]);
command_error
(
client
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not known"
,
argv
[
1
]);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
if
(
tagType
==
LOCATE_TAG_ANY_TYPE
)
{
if
(
tagType
==
LOCATE_TAG_ANY_TYPE
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"
\"
any
\"
is not a valid return tag type"
);
"
\"
any
\"
is not a valid return tag type"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
/* for compatibility with < 0.12.0 */
/* for compatibility with < 0.12.0 */
...
@@ -180,7 +180,7 @@ handle_list(Client &client, int argc, char *argv[])
...
@@ -180,7 +180,7 @@ handle_list(Client &client, int argc, char *argv[])
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"should be
\"
%s
\"
for 3 arguments"
,
"should be
\"
%s
\"
for 3 arguments"
,
tag_item_names
[
TAG_ALBUM
]);
tag_item_names
[
TAG_ALBUM
]);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
filter
=
new
SongFilter
((
unsigned
)
TAG_ARTIST
,
argv
[
2
]);
filter
=
new
SongFilter
((
unsigned
)
TAG_ARTIST
,
argv
[
2
]);
...
@@ -190,15 +190,15 @@ handle_list(Client &client, int argc, char *argv[])
...
@@ -190,15 +190,15 @@ handle_list(Client &client, int argc, char *argv[])
delete
filter
;
delete
filter
;
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"not able to parse args"
);
"not able to parse args"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
else
}
else
filter
=
nullptr
;
filter
=
nullptr
;
Error
error
;
Error
error
;
enum
command_return
ret
=
CommandResult
ret
=
listAllUniqueTags
(
client
,
tagType
,
filter
,
error
)
listAllUniqueTags
(
client
,
tagType
,
filter
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
delete
filter
;
delete
filter
;
...
@@ -206,7 +206,7 @@ handle_list(Client &client, int argc, char *argv[])
...
@@ -206,7 +206,7 @@ handle_list(Client &client, int argc, char *argv[])
return
ret
;
return
ret
;
}
}
enum
command_return
CommandResult
handle_listallinfo
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listallinfo
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
directory
=
""
;
const
char
*
directory
=
""
;
...
@@ -216,6 +216,6 @@ handle_listallinfo(Client &client, gcc_unused int argc, char *argv[])
...
@@ -216,6 +216,6 @@ handle_listallinfo(Client &client, gcc_unused int argc, char *argv[])
Error
error
;
Error
error
;
return
printInfoForAllIn
(
client
,
directory
,
error
)
return
printInfoForAllIn
(
client
,
directory
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
src/DatabaseCommands.hxx
View file @
cf4d80fc
...
@@ -20,38 +20,38 @@
...
@@ -20,38 +20,38 @@
#ifndef MPD_DATABASE_COMMANDS_HXX
#ifndef MPD_DATABASE_COMMANDS_HXX
#define MPD_DATABASE_COMMANDS_HXX
#define MPD_DATABASE_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_listall
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_listall
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_listallinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_listallinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/MessageCommands.cxx
View file @
cf4d80fc
...
@@ -31,29 +31,29 @@
...
@@ -31,29 +31,29 @@
#include <assert.h>
#include <assert.h>
enum
command_return
CommandResult
handle_subscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_subscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
==
2
);
assert
(
argc
==
2
);
switch
(
client
.
Subscribe
(
argv
[
1
]))
{
switch
(
client
.
Subscribe
(
argv
[
1
]))
{
case
Client
:
:
SubscribeResult
::
OK
:
case
Client
:
:
SubscribeResult
::
OK
:
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
case
Client
:
:
SubscribeResult
::
INVALID
:
case
Client
:
:
SubscribeResult
::
INVALID
:
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"invalid channel name"
);
"invalid channel name"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
Client
:
:
SubscribeResult
::
ALREADY
:
case
Client
:
:
SubscribeResult
::
ALREADY
:
command_error
(
client
,
ACK_ERROR_EXIST
,
command_error
(
client
,
ACK_ERROR_EXIST
,
"already subscribed to this channel"
);
"already subscribed to this channel"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
case
Client
:
:
SubscribeResult
::
FULL
:
case
Client
:
:
SubscribeResult
::
FULL
:
command_error
(
client
,
ACK_ERROR_EXIST
,
command_error
(
client
,
ACK_ERROR_EXIST
,
"subscription list is full"
);
"subscription list is full"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
/* unreachable */
/* unreachable */
...
@@ -61,21 +61,21 @@ handle_subscribe(Client &client, gcc_unused int argc, char *argv[])
...
@@ -61,21 +61,21 @@ handle_subscribe(Client &client, gcc_unused int argc, char *argv[])
gcc_unreachable
();
gcc_unreachable
();
}
}
enum
command_return
CommandResult
handle_unsubscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_unsubscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
==
2
);
assert
(
argc
==
2
);
if
(
client
.
Unsubscribe
(
argv
[
1
]))
if
(
client
.
Unsubscribe
(
argv
[
1
]))
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
else
{
else
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"not subscribed to this channel"
);
"not subscribed to this channel"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
enum
command_return
CommandResult
handle_channels
(
Client
&
client
,
handle_channels
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -89,10 +89,10 @@ handle_channels(Client &client,
...
@@ -89,10 +89,10 @@ handle_channels(Client &client,
for
(
const
auto
&
channel
:
channels
)
for
(
const
auto
&
channel
:
channels
)
client_printf
(
client
,
"channel: %s
\n
"
,
channel
.
c_str
());
client_printf
(
client
,
"channel: %s
\n
"
,
channel
.
c_str
());
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_read_messages
(
Client
&
client
,
handle_read_messages
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -106,10 +106,10 @@ handle_read_messages(Client &client,
...
@@ -106,10 +106,10 @@ handle_read_messages(Client &client,
client
.
messages
.
pop_front
();
client
.
messages
.
pop_front
();
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_send_message
(
Client
&
client
,
handle_send_message
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -118,7 +118,7 @@ handle_send_message(Client &client,
...
@@ -118,7 +118,7 @@ handle_send_message(Client &client,
if
(
!
client_message_valid_channel_name
(
argv
[
1
]))
{
if
(
!
client_message_valid_channel_name
(
argv
[
1
]))
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"invalid channel name"
);
"invalid channel name"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
bool
sent
=
false
;
bool
sent
=
false
;
...
@@ -128,10 +128,10 @@ handle_send_message(Client &client,
...
@@ -128,10 +128,10 @@ handle_send_message(Client &client,
sent
=
true
;
sent
=
true
;
if
(
sent
)
if
(
sent
)
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
else
{
else
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"nobody is subscribed to this channel"
);
"nobody is subscribed to this channel"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
src/MessageCommands.hxx
View file @
cf4d80fc
...
@@ -20,23 +20,23 @@
...
@@ -20,23 +20,23 @@
#ifndef MPD_MESSAGE_COMMANDS_HXX
#ifndef MPD_MESSAGE_COMMANDS_HXX
#define MPD_MESSAGE_COMMANDS_HXX
#define MPD_MESSAGE_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_subscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_subscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_unsubscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_unsubscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_channels
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_channels
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_read_messages
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_read_messages
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_send_message
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_send_message
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/OtherCommands.cxx
View file @
cf4d80fc
...
@@ -63,47 +63,47 @@ print_spl_list(Client &client, const PlaylistVector &list)
...
@@ -63,47 +63,47 @@ print_spl_list(Client &client, const PlaylistVector &list)
}
}
}
}
enum
command_return
CommandResult
handle_urlhandlers
(
Client
&
client
,
handle_urlhandlers
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
if
(
client
.
IsLocal
())
if
(
client
.
IsLocal
())
client_puts
(
client
,
"handler: file://
\n
"
);
client_puts
(
client
,
"handler: file://
\n
"
);
print_supported_uri_schemes
(
client
);
print_supported_uri_schemes
(
client
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_decoders
(
Client
&
client
,
handle_decoders
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
decoder_list_print
(
client
);
decoder_list_print
(
client
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_tagtypes
(
Client
&
client
,
handle_tagtypes
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
tag_print_types
(
client
);
tag_print_types
(
client
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_kill
(
gcc_unused
Client
&
client
,
handle_kill
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
C
OMMAND_RETURN_
KILL
;
return
C
ommandResult
::
KILL
;
}
}
enum
command_return
CommandResult
handle_close
(
gcc_unused
Client
&
client
,
handle_close
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
C
OMMAND_RETURN_
CLOSE
;
return
C
ommandResult
::
CLOSE
;
}
}
enum
command_return
CommandResult
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
uri
;
const
char
*
uri
;
...
@@ -122,7 +122,7 @@ handle_lsinfo(Client &client, int argc, char *argv[])
...
@@ -122,7 +122,7 @@ handle_lsinfo(Client &client, int argc, char *argv[])
if
(
path_fs
.
IsNull
())
{
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
"unsupported file name"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
Error
error
;
Error
error
;
...
@@ -133,16 +133,16 @@ handle_lsinfo(Client &client, int argc, char *argv[])
...
@@ -133,16 +133,16 @@ handle_lsinfo(Client &client, int argc, char *argv[])
if
(
song
==
NULL
)
{
if
(
song
==
NULL
)
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such file"
);
"No such file"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
song_print_info
(
client
,
*
song
);
song_print_info
(
client
,
*
song
);
song
->
Free
();
song
->
Free
();
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
result
=
handle_lsinfo2
(
client
,
argc
,
argv
);
CommandResult
result
=
handle_lsinfo2
(
client
,
argc
,
argv
);
if
(
result
!=
C
OMMAND_RETURN_
OK
)
if
(
result
!=
C
ommandResult
::
OK
)
return
result
;
return
result
;
if
(
isRootDirectory
(
uri
))
{
if
(
isRootDirectory
(
uri
))
{
...
@@ -151,10 +151,10 @@ handle_lsinfo(Client &client, int argc, char *argv[])
...
@@ -151,10 +151,10 @@ handle_lsinfo(Client &client, int argc, char *argv[])
print_spl_list
(
client
,
list
);
print_spl_list
(
client
,
list
);
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_update
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_update
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
path
=
""
;
const
char
*
path
=
""
;
...
@@ -170,22 +170,22 @@ handle_update(Client &client, gcc_unused int argc, char *argv[])
...
@@ -170,22 +170,22 @@ handle_update(Client &client, gcc_unused int argc, char *argv[])
else
if
(
!
uri_safe_local
(
path
))
{
else
if
(
!
uri_safe_local
(
path
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"Malformed path"
);
"Malformed path"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
ret
=
update_enqueue
(
path
,
false
);
ret
=
update_enqueue
(
path
,
false
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
client_printf
(
client
,
"updating_db: %i
\n
"
,
ret
);
client_printf
(
client
,
"updating_db: %i
\n
"
,
ret
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
else
{
}
else
{
command_error
(
client
,
ACK_ERROR_UPDATE_ALREADY
,
command_error
(
client
,
ACK_ERROR_UPDATE_ALREADY
,
"already updating"
);
"already updating"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
enum
command_return
CommandResult
handle_rescan
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rescan
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
path
=
""
;
const
char
*
path
=
""
;
...
@@ -198,93 +198,93 @@ handle_rescan(Client &client, gcc_unused int argc, char *argv[])
...
@@ -198,93 +198,93 @@ handle_rescan(Client &client, gcc_unused int argc, char *argv[])
if
(
!
uri_safe_local
(
path
))
{
if
(
!
uri_safe_local
(
path
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"Malformed path"
);
"Malformed path"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
ret
=
update_enqueue
(
path
,
true
);
ret
=
update_enqueue
(
path
,
true
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
client_printf
(
client
,
"updating_db: %i
\n
"
,
ret
);
client_printf
(
client
,
"updating_db: %i
\n
"
,
ret
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
else
{
}
else
{
command_error
(
client
,
ACK_ERROR_UPDATE_ALREADY
,
command_error
(
client
,
ACK_ERROR_UPDATE_ALREADY
,
"already updating"
);
"already updating"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
enum
command_return
CommandResult
handle_setvol
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_setvol
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
level
;
unsigned
level
;
bool
success
;
bool
success
;
if
(
!
check_unsigned
(
client
,
&
level
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
level
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
if
(
level
>
100
)
{
if
(
level
>
100
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Invalid volume value"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"Invalid volume value"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
success
=
volume_level_change
(
level
);
success
=
volume_level_change
(
level
);
if
(
!
success
)
{
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
"problems setting volume"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_stats
(
Client
&
client
,
handle_stats
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
stats_print
(
client
);
stats_print
(
client
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_ping
(
gcc_unused
Client
&
client
,
handle_ping
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_password
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_password
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
permission
=
0
;
unsigned
permission
=
0
;
if
(
getPermissionFromPassword
(
argv
[
1
],
&
permission
)
<
0
)
{
if
(
getPermissionFromPassword
(
argv
[
1
],
&
permission
)
<
0
)
{
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
client
.
SetPermission
(
permission
);
client
.
SetPermission
(
permission
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_config
(
Client
&
client
,
handle_config
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
if
(
!
client
.
IsLocal
())
{
if
(
!
client
.
IsLocal
())
{
command_error
(
client
,
ACK_ERROR_PERMISSION
,
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Command only permitted to local clients"
);
"Command only permitted to local clients"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
const
char
*
path
=
mapper_get_music_directory_utf8
();
const
char
*
path
=
mapper_get_music_directory_utf8
();
if
(
path
!=
NULL
)
if
(
path
!=
NULL
)
client_printf
(
client
,
"music_directory: %s
\n
"
,
path
);
client_printf
(
client
,
"music_directory: %s
\n
"
,
path
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_idle
(
Client
&
client
,
handle_idle
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -311,5 +311,5 @@ handle_idle(Client &client,
...
@@ -311,5 +311,5 @@ handle_idle(Client &client,
/* enable "idle" mode on this client */
/* enable "idle" mode on this client */
client
.
IdleWait
(
flags
);
client
.
IdleWait
(
flags
);
return
C
OMMAND_RETURN_
IDLE
;
return
C
ommandResult
::
IDLE
;
}
}
src/OtherCommands.hxx
View file @
cf4d80fc
...
@@ -20,50 +20,50 @@
...
@@ -20,50 +20,50 @@
#ifndef MPD_OTHER_COMMANDS_HXX
#ifndef MPD_OTHER_COMMANDS_HXX
#define MPD_OTHER_COMMANDS_HXX
#define MPD_OTHER_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_urlhandlers
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_urlhandlers
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_decoders
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_decoders
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_tagtypes
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_tagtypes
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_kill
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_kill
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_close
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_close
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_update
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_update
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_rescan
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_rescan
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_setvol
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_setvol
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_stats
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_stats
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_ping
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_ping
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_password
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_password
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_config
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_config
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_idle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_idle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/OutputCommands.cxx
View file @
cf4d80fc
...
@@ -26,65 +26,65 @@
...
@@ -26,65 +26,65 @@
#include <string.h>
#include <string.h>
enum
command_return
CommandResult
handle_enableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_enableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
bool
ret
;
bool
ret
;
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
ret
=
audio_output_enable_index
(
device
);
ret
=
audio_output_enable_index
(
device
);
if
(
!
ret
)
{
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
"No such audio output"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_disableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_disableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
bool
ret
;
bool
ret
;
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
ret
=
audio_output_disable_index
(
device
);
ret
=
audio_output_disable_index
(
device
);
if
(
!
ret
)
{
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
"No such audio output"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_toggleoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_toggleoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
if
(
!
audio_output_toggle_index
(
device
))
{
if
(
!
audio_output_toggle_index
(
device
))
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
"No such audio output"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_devices
(
Client
&
client
,
handle_devices
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
printAudioDevices
(
client
);
printAudioDevices
(
client
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
src/OutputCommands.hxx
View file @
cf4d80fc
...
@@ -20,20 +20,20 @@
...
@@ -20,20 +20,20 @@
#ifndef MPD_OUTPUT_COMMANDS_HXX
#ifndef MPD_OUTPUT_COMMANDS_HXX
#define MPD_OUTPUT_COMMANDS_HXX
#define MPD_OUTPUT_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_enableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_enableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_disableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_disableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_toggleoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_toggleoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_devices
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_devices
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/PlayerCommands.cxx
View file @
cf4d80fc
...
@@ -52,62 +52,62 @@
...
@@ -52,62 +52,62 @@
#define COMMAND_STATUS_AUDIO "audio"
#define COMMAND_STATUS_AUDIO "audio"
#define COMMAND_STATUS_UPDATING_DB "updating_db"
#define COMMAND_STATUS_UPDATING_DB "updating_db"
enum
command_return
CommandResult
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
int
song
=
-
1
;
int
song
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
PlaylistResult
result
=
client
.
partition
.
PlayPosition
(
song
);
PlaylistResult
result
=
client
.
partition
.
PlayPosition
(
song
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
int
id
=
-
1
;
int
id
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
PlaylistResult
result
=
client
.
partition
.
PlayId
(
id
);
PlaylistResult
result
=
client
.
partition
.
PlayId
(
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_stop
(
Client
&
client
,
handle_stop
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
.
partition
.
Stop
();
client
.
partition
.
Stop
();
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_currentsong
(
Client
&
client
,
handle_currentsong
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
playlist_print_current
(
client
,
client
.
playlist
);
playlist_print_current
(
client
,
client
.
playlist
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_pause
(
Client
&
client
,
handle_pause
(
Client
&
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
bool
pause_flag
;
bool
pause_flag
;
if
(
!
check_bool
(
client
,
&
pause_flag
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
pause_flag
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
player_control
.
SetPause
(
pause_flag
);
client
.
player_control
.
SetPause
(
pause_flag
);
}
else
}
else
client
.
player_control
.
Pause
();
client
.
player_control
.
Pause
();
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_status
(
Client
&
client
,
handle_status
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -202,10 +202,10 @@ handle_status(Client &client,
...
@@ -202,10 +202,10 @@ handle_status(Client &client,
song
,
playlist
.
PositionToId
(
song
));
song
,
playlist
.
PositionToId
(
song
));
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_next
(
Client
&
client
,
handle_next
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -219,170 +219,170 @@ handle_next(Client &client,
...
@@ -219,170 +219,170 @@ handle_next(Client &client,
client
.
partition
.
PlayNext
();
client
.
partition
.
PlayNext
();
playlist
.
queue
.
single
=
single
;
playlist
.
queue
.
single
=
single
;
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_previous
(
Client
&
client
,
handle_previous
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
.
partition
.
PlayPrevious
();
client
.
partition
.
PlayPrevious
();
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_repeat
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_repeat
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
partition
.
SetRepeat
(
status
);
client
.
partition
.
SetRepeat
(
status
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_single
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_single
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
partition
.
SetSingle
(
status
);
client
.
partition
.
SetSingle
(
status
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_consume
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_consume
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
partition
.
SetConsume
(
status
);
client
.
partition
.
SetConsume
(
status
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_random
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_random
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
partition
.
SetRandom
(
status
);
client
.
partition
.
SetRandom
(
status
);
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
partition
.
GetRandom
()));
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
partition
.
GetRandom
()));
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_clearerror
(
gcc_unused
Client
&
client
,
handle_clearerror
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
.
player_control
.
ClearError
();
client
.
player_control
.
ClearError
();
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_seek
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seek
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
song
,
seek_time
;
unsigned
song
,
seek_time
;
if
(
!
check_unsigned
(
client
,
&
song
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
song
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
PlaylistResult
result
=
PlaylistResult
result
=
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_seekid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seekid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
id
,
seek_time
;
unsigned
id
,
seek_time
;
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
PlaylistResult
result
=
PlaylistResult
result
=
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_seekcur
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seekcur
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
p
=
argv
[
1
];
const
char
*
p
=
argv
[
1
];
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
int
seek_time
;
int
seek_time
;
if
(
!
check_int
(
client
,
&
seek_time
,
p
))
if
(
!
check_int
(
client
,
&
seek_time
,
p
))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
PlaylistResult
result
=
PlaylistResult
result
=
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_crossfade
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_crossfade
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
xfade_time
;
unsigned
xfade_time
;
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
player_control
.
SetCrossFade
(
xfade_time
);
client
.
player_control
.
SetCrossFade
(
xfade_time
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_mixrampdb
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_mixrampdb
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
float
db
;
float
db
;
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
player_control
.
SetMixRampDb
(
db
);
client
.
player_control
.
SetMixRampDb
(
db
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_mixrampdelay
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_mixrampdelay
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
float
delay_secs
;
float
delay_secs
;
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
client
.
player_control
.
SetMixRampDelay
(
delay_secs
);
client
.
player_control
.
SetMixRampDelay
(
delay_secs
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_replay_gain_mode
(
Client
&
client
,
handle_replay_gain_mode
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
!
replay_gain_set_mode_string
(
argv
[
1
]))
{
if
(
!
replay_gain_set_mode_string
(
argv
[
1
]))
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"Unrecognized replay gain mode"
);
"Unrecognized replay gain mode"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
playlist
.
queue
.
random
));
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
playlist
.
queue
.
random
));
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
enum
command_return
CommandResult
handle_replay_gain_status
(
Client
&
client
,
handle_replay_gain_status
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
replay_gain_get_mode_string
());
replay_gain_get_mode_string
());
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
src/PlayerCommands.hxx
View file @
cf4d80fc
...
@@ -20,71 +20,71 @@
...
@@ -20,71 +20,71 @@
#ifndef MPD_PLAYER_COMMANDS_HXX
#ifndef MPD_PLAYER_COMMANDS_HXX
#define MPD_PLAYER_COMMANDS_HXX
#define MPD_PLAYER_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_stop
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_stop
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_currentsong
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_currentsong
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_pause
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_pause
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_next
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_next
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_previous
(
Client
&
client
,
int
argc
,
char
*
avg
[]);
handle_previous
(
Client
&
client
,
int
argc
,
char
*
avg
[]);
enum
command_return
CommandResult
handle_repeat
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_repeat
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_single
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_single
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_consume
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_consume
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_random
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_random
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_clearerror
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_clearerror
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_seek
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_seek
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_seekid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_seekid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_seekcur
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_seekcur
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_crossfade
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_crossfade
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_mixrampdb
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_mixrampdb
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_mixrampdelay
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_mixrampdelay
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_replay_gain_mode
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_replay_gain_mode
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_replay_gain_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_replay_gain_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/PlaylistCommands.cxx
View file @
cf4d80fc
...
@@ -49,14 +49,14 @@ print_spl_list(Client &client, const PlaylistVector &list)
...
@@ -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
[])
handle_save
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
PlaylistResult
result
=
spl_save_playlist
(
argv
[
1
],
client
.
playlist
);
PlaylistResult
result
=
spl_save_playlist
(
argv
[
1
],
client
.
playlist
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
CommandResult
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
start_index
,
end_index
;
unsigned
start_index
,
end_index
;
...
@@ -65,7 +65,7 @@ handle_load(Client &client, int argc, char *argv[])
...
@@ -65,7 +65,7 @@ handle_load(Client &client, int argc, char *argv[])
start_index
=
0
;
start_index
=
0
;
end_index
=
unsigned
(
-
1
);
end_index
=
unsigned
(
-
1
);
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
argv
[
2
]))
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
argv
[
2
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
const
PlaylistResult
result
=
const
PlaylistResult
result
=
playlist_open_into_queue
(
argv
[
1
],
playlist_open_into_queue
(
argv
[
1
],
...
@@ -79,7 +79,7 @@ handle_load(Client &client, int argc, char *argv[])
...
@@ -79,7 +79,7 @@ handle_load(Client &client, int argc, char *argv[])
if
(
playlist_load_spl
(
client
.
playlist
,
client
.
player_control
,
if
(
playlist_load_spl
(
client
.
playlist
,
client
.
player_control
,
argv
[
1
],
start_index
,
end_index
,
argv
[
1
],
start_index
,
end_index
,
error
))
error
))
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
if
(
error
.
IsDomain
(
playlist_domain
)
&&
if
(
error
.
IsDomain
(
playlist_domain
)
&&
PlaylistResult
(
error
.
GetCode
())
==
PlaylistResult
::
BAD_NAME
)
{
PlaylistResult
(
error
.
GetCode
())
==
PlaylistResult
::
BAD_NAME
)
{
...
@@ -95,91 +95,91 @@ handle_load(Client &client, int argc, char *argv[])
...
@@ -95,91 +95,91 @@ handle_load(Client &client, int argc, char *argv[])
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_listplaylist
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listplaylist
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
false
))
if
(
playlist_file_print
(
client
,
argv
[
1
],
false
))
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
Error
error
;
Error
error
;
return
spl_print
(
client
,
argv
[
1
],
false
,
error
)
return
spl_print
(
client
,
argv
[
1
],
false
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_listplaylistinfo
(
Client
&
client
,
handle_listplaylistinfo
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
true
))
if
(
playlist_file_print
(
client
,
argv
[
1
],
true
))
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
Error
error
;
Error
error
;
return
spl_print
(
client
,
argv
[
1
],
true
,
error
)
return
spl_print
(
client
,
argv
[
1
],
true
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_rm
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rm
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_delete
(
argv
[
1
],
error
)
return
spl_delete
(
argv
[
1
],
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_rename
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rename
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_rename
(
argv
[
1
],
argv
[
2
],
error
)
return
spl_rename
(
argv
[
1
],
argv
[
2
],
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_playlistdelete
(
Client
&
client
,
handle_playlistdelete
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
gcc_unused
int
argc
,
char
*
argv
[])
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
unsigned
from
;
unsigned
from
;
if
(
!
check_unsigned
(
client
,
&
from
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
from
,
argv
[
2
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
Error
error
;
Error
error
;
return
spl_remove_index
(
playlist
,
from
,
error
)
return
spl_remove_index
(
playlist
,
from
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_playlistmove
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistmove
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
unsigned
from
,
to
;
unsigned
from
,
to
;
if
(
!
check_unsigned
(
client
,
&
from
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
from
,
argv
[
2
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
3
]))
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
3
]))
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
Error
error
;
Error
error
;
return
spl_move_index
(
playlist
,
from
,
to
,
error
)
return
spl_move_index
(
playlist
,
from
,
to
,
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_playlistclear
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistclear
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_clear
(
argv
[
1
],
error
)
return
spl_clear
(
argv
[
1
],
error
)
?
C
OMMAND_RETURN_
OK
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_playlistadd
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistadd
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
...
@@ -191,7 +191,7 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
...
@@ -191,7 +191,7 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
if
(
!
uri_supported_scheme
(
uri
))
{
if
(
!
uri_supported_scheme
(
uri
))
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported URI scheme"
);
"unsupported URI scheme"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
success
=
spl_append_uri
(
uri
,
playlist
,
error
);
success
=
spl_append_uri
(
uri
,
playlist
,
error
);
...
@@ -202,13 +202,13 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
...
@@ -202,13 +202,13 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
if
(
!
success
&&
!
error
.
IsDefined
())
{
if
(
!
success
&&
!
error
.
IsDefined
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
"directory or file not found"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
success
?
C
OMMAND_RETURN_
OK
:
print_error
(
client
,
error
);
return
success
?
C
ommandResult
::
OK
:
print_error
(
client
,
error
);
}
}
enum
command_return
CommandResult
handle_listplaylists
(
Client
&
client
,
handle_listplaylists
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
...
@@ -218,5 +218,5 @@ handle_listplaylists(Client &client,
...
@@ -218,5 +218,5 @@ handle_listplaylists(Client &client,
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
print_spl_list
(
client
,
list
);
print_spl_list
(
client
,
list
);
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
}
src/PlaylistCommands.hxx
View file @
cf4d80fc
...
@@ -20,41 +20,41 @@
...
@@ -20,41 +20,41 @@
#ifndef MPD_PLAYLIST_COMMANDS_HXX
#ifndef MPD_PLAYLIST_COMMANDS_HXX
#define MPD_PLAYLIST_COMMANDS_HXX
#define MPD_PLAYLIST_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_save
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_save
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_listplaylist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_listplaylistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_rm
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_rm
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_rename
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_rename
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistdelete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistdelete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistmove
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistmove
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistclear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistclear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_listplaylists
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylists
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/QueueCommands.cxx
View file @
cf4d80fc
This diff is collapsed.
Click to expand it.
src/QueueCommands.hxx
View file @
cf4d80fc
...
@@ -20,65 +20,65 @@
...
@@ -20,65 +20,65 @@
#ifndef MPD_QUEUE_COMMANDS_HXX
#ifndef MPD_QUEUE_COMMANDS_HXX
#define MPD_QUEUE_COMMANDS_HXX
#define MPD_QUEUE_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_add
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_add
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_addid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_addid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_delete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_delete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_deleteid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_deleteid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_shuffle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_shuffle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_clear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_clear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_plchanges
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_plchanges
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_plchangesposid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_plchangesposid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistfind
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistfind
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_playlistsearch
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_playlistsearch
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_prio
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_prio
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_prioid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_prioid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_move
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_move
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_moveid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_moveid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_swap
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_swap
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
CommandResult
handle_swapid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_swapid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/StickerCommands.cxx
View file @
cf4d80fc
...
@@ -51,7 +51,7 @@ sticker_song_find_print_cb(Song &song, const char *value,
...
@@ -51,7 +51,7 @@ sticker_song_find_print_cb(Song &song, const char *value,
sticker_print_value
(
data
->
client
,
data
->
name
,
value
);
sticker_print_value
(
data
->
client
,
data
->
name
,
value
);
}
}
static
enum
command_return
static
CommandResult
handle_sticker_song
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_sticker_song
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
...
@@ -70,12 +70,12 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -70,12 +70,12 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if
(
value
.
empty
())
{
if
(
value
.
empty
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"no such sticker"
);
"no such sticker"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
sticker_print_value
(
client
,
argv
[
4
],
value
.
c_str
());
sticker_print_value
(
client
,
argv
[
4
],
value
.
c_str
());
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
/* list song song_id */
/* list song song_id */
}
else
if
(
argc
==
4
&&
strcmp
(
argv
[
1
],
"list"
)
==
0
)
{
}
else
if
(
argc
==
4
&&
strcmp
(
argv
[
1
],
"list"
)
==
0
)
{
Song
*
song
=
db
->
GetSong
(
argv
[
3
],
error
);
Song
*
song
=
db
->
GetSong
(
argv
[
3
],
error
);
...
@@ -89,7 +89,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -89,7 +89,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
sticker_free
(
sticker
);
sticker_free
(
sticker
);
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
/* set song song_id id key */
/* set song song_id id key */
}
else
if
(
argc
==
6
&&
strcmp
(
argv
[
1
],
"set"
)
==
0
)
{
}
else
if
(
argc
==
6
&&
strcmp
(
argv
[
1
],
"set"
)
==
0
)
{
Song
*
song
=
db
->
GetSong
(
argv
[
3
],
error
);
Song
*
song
=
db
->
GetSong
(
argv
[
3
],
error
);
...
@@ -101,10 +101,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -101,10 +101,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if
(
!
ret
)
{
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"failed to set sticker value"
);
"failed to set sticker value"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
/* delete song song_id [key] */
/* delete song song_id [key] */
}
else
if
((
argc
==
4
||
argc
==
5
)
&&
}
else
if
((
argc
==
4
||
argc
==
5
)
&&
strcmp
(
argv
[
1
],
"delete"
)
==
0
)
{
strcmp
(
argv
[
1
],
"delete"
)
==
0
)
{
...
@@ -119,10 +119,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -119,10 +119,10 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if
(
!
ret
)
{
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"no such sticker"
);
"no such sticker"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
/* find song dir key */
/* find song dir key */
}
else
if
(
argc
==
5
&&
strcmp
(
argv
[
1
],
"find"
)
==
0
)
{
}
else
if
(
argc
==
5
&&
strcmp
(
argv
[
1
],
"find"
)
==
0
)
{
/* "sticker find song a/directory name" */
/* "sticker find song a/directory name" */
...
@@ -138,7 +138,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -138,7 +138,7 @@ handle_sticker_song(Client &client, int argc, char *argv[])
db_unlock
();
db_unlock
();
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"no such directory"
);
"no such directory"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
success
=
sticker_song_find
(
*
directory
,
data
.
name
,
success
=
sticker_song_find
(
*
directory
,
data
.
name
,
...
@@ -147,17 +147,17 @@ handle_sticker_song(Client &client, int argc, char *argv[])
...
@@ -147,17 +147,17 @@ handle_sticker_song(Client &client, int argc, char *argv[])
if
(
!
success
)
{
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"failed to set search sticker database"
);
"failed to set search sticker database"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
return
C
OMMAND_RETURN_
OK
;
return
C
ommandResult
::
OK
;
}
else
{
}
else
{
command_error
(
client
,
ACK_ERROR_ARG
,
"bad request"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"bad request"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
enum
command_return
CommandResult
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
>=
4
);
assert
(
argc
>=
4
);
...
@@ -165,7 +165,7 @@ handle_sticker(Client &client, int argc, char *argv[])
...
@@ -165,7 +165,7 @@ handle_sticker(Client &client, int argc, char *argv[])
if
(
!
sticker_enabled
())
{
if
(
!
sticker_enabled
())
{
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"sticker database is disabled"
);
"sticker database is disabled"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
if
(
strcmp
(
argv
[
2
],
"song"
)
==
0
)
if
(
strcmp
(
argv
[
2
],
"song"
)
==
0
)
...
@@ -173,6 +173,6 @@ handle_sticker(Client &client, int argc, char *argv[])
...
@@ -173,6 +173,6 @@ handle_sticker(Client &client, int argc, char *argv[])
else
{
else
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"unknown sticker domain"
);
"unknown sticker domain"
);
return
C
OMMAND_RETURN_
ERROR
;
return
C
ommandResult
::
ERROR
;
}
}
}
}
src/StickerCommands.hxx
View file @
cf4d80fc
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
#ifndef MPD_STICKER_COMMANDS_HXX
#ifndef MPD_STICKER_COMMANDS_HXX
#define MPD_STICKER_COMMANDS_HXX
#define MPD_STICKER_COMMANDS_HXX
#include "
command.h
"
#include "
CommandResult.hxx
"
class
Client
;
class
Client
;
enum
command_return
CommandResult
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment