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