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
6edfc56c
Commit
6edfc56c
authored
Dec 06, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: use ConstBuffer<const char *> for argument list
parent
5837a639
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
417 additions
and
420 deletions
+417
-420
AllCommands.cxx
src/command/AllCommands.cxx
+30
-33
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+24
-38
DatabaseCommands.hxx
src/command/DatabaseCommands.hxx
+11
-10
FileCommands.cxx
src/command/FileCommands.cxx
+4
-4
FileCommands.hxx
src/command/FileCommands.hxx
+2
-1
MessageCommands.cxx
src/command/MessageCommands.cxx
+20
-16
MessageCommands.hxx
src/command/MessageCommands.hxx
+6
-5
NeighborCommands.cxx
src/command/NeighborCommands.cxx
+2
-2
NeighborCommands.hxx
src/command/NeighborCommands.hxx
+2
-1
OtherCommands.cxx
src/command/OtherCommands.cxx
+35
-48
OtherCommands.hxx
src/command/OtherCommands.hxx
+17
-16
OutputCommands.cxx
src/command/OutputCommands.cxx
+16
-8
OutputCommands.hxx
src/command/OutputCommands.hxx
+5
-4
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+39
-47
PlayerCommands.hxx
src/command/PlayerCommands.hxx
+22
-21
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+44
-34
PlaylistCommands.hxx
src/command/PlaylistCommands.hxx
+12
-11
QueueCommands.cxx
src/command/QueueCommands.cxx
+55
-59
QueueCommands.hxx
src/command/QueueCommands.hxx
+21
-20
StickerCommands.cxx
src/command/StickerCommands.cxx
+25
-22
StickerCommands.hxx
src/command/StickerCommands.hxx
+2
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+7
-6
StorageCommands.hxx
src/command/StorageCommands.hxx
+4
-3
TagCommands.cxx
src/command/TagCommands.cxx
+9
-8
TagCommands.hxx
src/command/TagCommands.hxx
+3
-2
No files found.
src/command/AllCommands.cxx
View file @
6edfc56c
...
...
@@ -37,6 +37,7 @@
#include "client/Client.hxx"
#include "util/Tokenizer.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#ifdef ENABLE_SQLITE
#include "StickerCommands.hxx"
...
...
@@ -60,15 +61,15 @@ struct command {
unsigned
permission
;
int
min
;
int
max
;
CommandResult
(
*
handler
)(
Client
&
client
,
unsigned
argc
,
char
**
argv
);
CommandResult
(
*
handler
)(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
};
/* don't be fooled, this is the command handler for "commands" command */
static
CommandResult
handle_commands
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_commands
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
static
CommandResult
handle_not_commands
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_not_commands
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
/**
* The command registry.
...
...
@@ -225,8 +226,7 @@ command_available(gcc_unused const Partition &partition,
/* don't be fooled, this is the command handler for "commands" command */
static
CommandResult
handle_commands
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_commands
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
const
unsigned
permission
=
client
.
GetPermission
();
...
...
@@ -242,8 +242,7 @@ handle_commands(Client &client,
}
static
CommandResult
handle_not_commands
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_not_commands
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
const
unsigned
permission
=
client
.
GetPermission
();
...
...
@@ -293,11 +292,8 @@ command_lookup(const char *name)
static
bool
command_check_request
(
const
struct
command
*
cmd
,
Client
&
client
,
unsigned
permission
,
unsigned
argc
,
char
*
argv
[]
)
unsigned
permission
,
ConstBuffer
<
const
char
*>
args
)
{
const
unsigned
min
=
cmd
->
min
+
1
;
const
unsigned
max
=
cmd
->
max
+
1
;
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
permission
))
{
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"you don't have permission for
\"
%s
\"
"
,
...
...
@@ -305,21 +301,24 @@ command_check_request(const struct command *cmd, Client &client,
return
false
;
}
if
(
min
==
0
)
const
int
min
=
cmd
->
min
;
const
int
max
=
cmd
->
max
;
if
(
min
<
0
)
return
true
;
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
min
==
max
&&
unsigned
(
max
)
!=
args
.
size
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"wrong number of arguments for
\"
%s
\"
"
,
argv
[
0
]
);
cmd
->
cmd
);
return
false
;
}
else
if
(
arg
c
<
min
)
{
}
else
if
(
arg
s
.
size
<
unsigned
(
min
)
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"too few arguments for
\"
%s
\"
"
,
argv
[
0
]
);
"too few arguments for
\"
%s
\"
"
,
cmd
->
cmd
);
return
false
;
}
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
}
else
if
(
max
>=
0
&&
args
.
size
>
unsigned
(
max
)
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"too many arguments for
\"
%s
\"
"
,
argv
[
0
]
);
"too many arguments for
\"
%s
\"
"
,
cmd
->
cmd
);
return
false
;
}
else
return
true
;
...
...
@@ -327,23 +326,20 @@ command_check_request(const struct command *cmd, Client &client,
static
const
struct
command
*
command_checked_lookup
(
Client
&
client
,
unsigned
permission
,
unsigned
argc
,
char
*
argv
[]
)
const
char
*
cmd_name
,
ConstBuffer
<
const
char
*>
args
)
{
current_command
=
""
;
if
(
argc
==
0
)
return
nullptr
;
const
struct
command
*
cmd
=
command_lookup
(
argv
[
0
]);
const
struct
command
*
cmd
=
command_lookup
(
cmd_name
);
if
(
cmd
==
nullptr
)
{
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"unknown command
\"
%s
\"
"
,
argv
[
0
]
);
"unknown command
\"
%s
\"
"
,
cmd_name
);
return
nullptr
;
}
current_command
=
cmd
->
cmd
;
if
(
!
command_check_request
(
cmd
,
client
,
permission
,
arg
c
,
argv
))
if
(
!
command_check_request
(
cmd
,
client
,
permission
,
arg
s
))
return
nullptr
;
return
cmd
;
...
...
@@ -362,9 +358,9 @@ command_process(Client &client, unsigned num, char *line)
Tokenizer
tokenizer
(
line
);
c
har
*
argv
[
COMMAND_ARGV_MAX
];
current_command
=
argv
[
0
]
=
tokenizer
.
NextWord
(
error
);
if
(
argv
[
0
]
==
nullptr
)
{
c
onst
char
*
const
cmd_name
=
current_command
=
tokenizer
.
NextWord
(
error
);
if
(
cmd_name
==
nullptr
)
{
current_command
=
""
;
if
(
tokenizer
.
IsEnd
())
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
...
...
@@ -380,12 +376,13 @@ command_process(Client &client, unsigned num, char *line)
return
CommandResult
::
FINISH
;
}
unsigned
argc
=
1
;
char
*
argv
[
COMMAND_ARGV_MAX
];
ConstBuffer
<
const
char
*>
args
(
argv
,
0
);
/* now parse the arguments (quoted or unquoted) */
while
(
true
)
{
if
(
arg
c
==
COMMAND_ARGV_MAX
)
{
if
(
arg
s
.
size
==
COMMAND_ARGV_MAX
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Too many arguments"
);
current_command
=
nullptr
;
...
...
@@ -402,17 +399,17 @@ command_process(Client &client, unsigned num, char *line)
return
CommandResult
::
ERROR
;
}
argv
[
arg
c
++
]
=
a
;
argv
[
arg
s
.
size
++
]
=
a
;
}
/* look up and invoke the command handler */
const
struct
command
*
cmd
=
command_checked_lookup
(
client
,
client
.
GetPermission
(),
argc
,
argv
);
cmd_name
,
args
);
CommandResult
ret
=
cmd
?
cmd
->
handler
(
client
,
arg
c
,
argv
)
?
cmd
->
handler
(
client
,
arg
s
)
:
CommandResult
::
ERROR
;
current_command
=
nullptr
;
...
...
src/command/DatabaseCommands.cxx
View file @
6edfc56c
...
...
@@ -50,12 +50,10 @@ handle_listfiles_db(Client &client, const char *uri)
}
CommandResult
handle_lsinfo2
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_lsinfo2
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
uri
=
argc
==
2
?
argv
[
1
]
/* default is root directory */
:
""
;
/* default is root directory */
const
char
*
const
uri
=
args
.
IsEmpty
()
?
""
:
args
.
front
();
const
DatabaseSelection
selection
(
uri
,
false
);
...
...
@@ -67,10 +65,8 @@ handle_lsinfo2(Client &client, unsigned argc, char *argv[])
}
static
CommandResult
handle_match
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
,
bool
fold_case
)
handle_match
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
,
bool
fold_case
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
unsigned
window_start
=
0
,
window_end
=
std
::
numeric_limits
<
int
>::
max
();
if
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"window"
)
==
0
)
{
if
(
!
check_range
(
client
,
&
window_start
,
&
window_end
,
...
...
@@ -97,22 +93,20 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case)
}
CommandResult
handle_find
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_find
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
return
handle_match
(
client
,
arg
c
,
argv
,
false
);
return
handle_match
(
client
,
arg
s
,
false
);
}
CommandResult
handle_search
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_search
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
return
handle_match
(
client
,
arg
c
,
argv
,
true
);
return
handle_match
(
client
,
arg
s
,
true
);
}
static
CommandResult
handle_match_add
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
,
bool
fold_case
)
handle_match_add
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
,
bool
fold_case
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
SongFilter
filter
;
if
(
!
filter
.
Parse
(
args
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
...
...
@@ -129,21 +123,20 @@ handle_match_add(Client &client, unsigned argc, char *argv[], bool fold_case)
}
CommandResult
handle_findadd
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_findadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
return
handle_match_add
(
client
,
arg
c
,
argv
,
false
);
return
handle_match_add
(
client
,
arg
s
,
false
);
}
CommandResult
handle_searchadd
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_searchadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
return
handle_match_add
(
client
,
arg
c
,
argv
,
true
);
return
handle_match_add
(
client
,
arg
s
,
true
);
}
CommandResult
handle_searchaddpl
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_searchaddpl
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
const
char
*
playlist
=
args
.
shift
();
SongFilter
filter
;
...
...
@@ -164,10 +157,8 @@ handle_searchaddpl(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_count
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_count
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
TagType
group
=
TAG_NUM_OF_ITEM_TYPES
;
if
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"group"
)
==
0
)
{
const
char
*
s
=
args
[
args
.
size
-
1
];
...
...
@@ -195,24 +186,21 @@ handle_count(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_listall
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_listall
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
directory
=
""
;
if
(
argc
==
2
)
directory
=
argv
[
1
];
/* default is root directory */
const
char
*
const
uri
=
args
.
IsEmpty
()
?
""
:
args
.
front
();
Error
error
;
return
db_selection_print
(
client
,
DatabaseSelection
(
directory
,
true
),
return
db_selection_print
(
client
,
DatabaseSelection
(
uri
,
true
),
false
,
false
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_list
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_list
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
const
char
*
tag_name
=
args
.
shift
();
unsigned
tagType
=
locate_parse_type
(
tag_name
);
...
...
@@ -283,15 +271,13 @@ handle_list(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_listallinfo
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_listallinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
directory
=
""
;
if
(
argc
==
2
)
directory
=
argv
[
1
];
/* default is root directory */
const
char
*
const
uri
=
args
.
IsEmpty
()
?
""
:
args
.
front
();
Error
error
;
return
db_selection_print
(
client
,
DatabaseSelection
(
directory
,
true
),
return
db_selection_print
(
client
,
DatabaseSelection
(
uri
,
true
),
true
,
false
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
...
...
src/command/DatabaseCommands.hxx
View file @
6edfc56c
...
...
@@ -23,38 +23,39 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_listfiles_db
(
Client
&
client
,
const
char
*
uri
);
CommandResult
handle_lsinfo2
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_lsinfo2
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_find
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_find
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_findadd
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_findadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_search
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_search
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_searchadd
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_searchadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_searchaddpl
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_searchaddpl
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_count
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_count
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listall
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listall
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_list
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_list
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listallinfo
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listallinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/FileCommands.cxx
View file @
6edfc56c
...
...
@@ -25,6 +25,7 @@
#include "protocol/Ack.hxx"
#include "protocol/Result.hxx"
#include "client/Client.hxx"
#include "util/ConstBuffer.hxx"
#include "util/CharUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
...
...
@@ -202,11 +203,10 @@ read_file_comments(Client &client, const Path path_fs)
}
CommandResult
handle_read_comments
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_read_comments
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
argc
==
2
);
const
char
*
const
uri
=
argv
[
1
];
assert
(
args
.
size
==
1
);
const
char
*
const
uri
=
args
.
front
();
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
/* read comments from arbitrary local file */
...
...
src/command/FileCommands.hxx
View file @
6edfc56c
...
...
@@ -23,11 +23,12 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_listfiles_local
(
Client
&
client
,
const
char
*
path_utf8
);
CommandResult
handle_read_comments
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_read_comments
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/MessageCommands.cxx
View file @
6edfc56c
...
...
@@ -24,6 +24,7 @@
#include "Instance.hxx"
#include "Partition.hxx"
#include "protocol/Result.hxx"
#include "util/ConstBuffer.hxx"
#include <set>
#include <string>
...
...
@@ -31,11 +32,12 @@
#include <assert.h>
CommandResult
handle_subscribe
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_subscribe
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
argc
==
2
);
assert
(
args
.
size
==
1
);
const
char
*
const
channel_name
=
args
[
0
];
switch
(
client
.
Subscribe
(
argv
[
1
]
))
{
switch
(
client
.
Subscribe
(
channel_name
))
{
case
Client
:
:
SubscribeResult
::
OK
:
return
CommandResult
::
OK
;
...
...
@@ -61,11 +63,12 @@ handle_subscribe(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_unsubscribe
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_unsubscribe
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
argc
==
2
);
assert
(
args
.
size
==
1
);
const
char
*
const
channel_name
=
args
[
0
];
if
(
client
.
Unsubscribe
(
argv
[
1
]
))
if
(
client
.
Unsubscribe
(
channel_name
))
return
CommandResult
::
OK
;
else
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
...
@@ -75,10 +78,9 @@ handle_unsubscribe(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_channels
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_channels
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
assert
(
arg
c
==
1
);
assert
(
arg
s
.
IsEmpty
()
);
std
::
set
<
std
::
string
>
channels
;
for
(
const
auto
&
c
:
*
client
.
partition
.
instance
.
client_list
)
...
...
@@ -93,9 +95,9 @@ handle_channels(Client &client,
CommandResult
handle_read_messages
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[]
)
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
assert
(
arg
c
==
1
);
assert
(
arg
s
.
IsEmpty
()
);
while
(
!
client
.
messages
.
empty
())
{
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
...
...
@@ -109,19 +111,21 @@ handle_read_messages(Client &client,
}
CommandResult
handle_send_message
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_send_message
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
arg
c
==
3
);
assert
(
arg
s
.
size
==
2
);
if
(
!
client_message_valid_channel_name
(
argv
[
1
]))
{
const
char
*
const
channel_name
=
args
[
0
];
const
char
*
const
message_text
=
args
[
1
];
if
(
!
client_message_valid_channel_name
(
channel_name
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"invalid channel name"
);
return
CommandResult
::
ERROR
;
}
bool
sent
=
false
;
const
ClientMessage
msg
(
argv
[
1
],
argv
[
2
]
);
const
ClientMessage
msg
(
channel_name
,
message_text
);
for
(
auto
&
c
:
*
client
.
partition
.
instance
.
client_list
)
if
(
c
.
PushMessage
(
msg
))
sent
=
true
;
...
...
src/command/MessageCommands.hxx
View file @
6edfc56c
...
...
@@ -23,20 +23,21 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_subscribe
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_subscribe
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_unsubscribe
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_unsubscribe
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_channels
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_channels
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_read_messages
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_read_messages
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_send_message
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_send_message
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/NeighborCommands.cxx
View file @
6edfc56c
...
...
@@ -25,6 +25,7 @@
#include "protocol/Result.hxx"
#include "neighbor/Glue.hxx"
#include "neighbor/Info.hxx"
#include "util/ConstBuffer.hxx"
#include <set>
#include <string>
...
...
@@ -38,8 +39,7 @@ neighbor_commands_available(const Instance &instance)
}
CommandResult
handle_listneighbors
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_listneighbors
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
const
NeighborGlue
*
const
neighbors
=
client
.
partition
.
instance
.
neighbors
;
...
...
src/command/NeighborCommands.hxx
View file @
6edfc56c
...
...
@@ -25,12 +25,13 @@
struct
Instance
;
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
gcc_pure
bool
neighbor_commands_available
(
const
Instance
&
instance
);
CommandResult
handle_listneighbors
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listneighbors
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/OtherCommands.cxx
View file @
6edfc56c
...
...
@@ -37,6 +37,7 @@
#include "mixer/Volume.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "fs/AllocatedPath.hxx"
#include "Stats.hxx"
#include "Permission.hxx"
...
...
@@ -68,8 +69,7 @@ print_spl_list(Client &client, const PlaylistVector &list)
}
CommandResult
handle_urlhandlers
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_urlhandlers
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
if
(
client
.
IsLocal
())
client_puts
(
client
,
"handler: file://
\n
"
);
...
...
@@ -78,31 +78,27 @@ handle_urlhandlers(Client &client,
}
CommandResult
handle_decoders
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_decoders
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
decoder_list_print
(
client
);
return
CommandResult
::
OK
;
}
CommandResult
handle_tagtypes
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_tagtypes
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
tag_print_types
(
client
);
return
CommandResult
::
OK
;
}
CommandResult
handle_kill
(
gcc_unused
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_kill
(
gcc_unused
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
return
CommandResult
::
KILL
;
}
CommandResult
handle_close
(
gcc_unused
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_close
(
gcc_unused
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
return
CommandResult
::
FINISH
;
}
...
...
@@ -116,12 +112,10 @@ print_tag(TagType type, const char *value, void *ctx)
}
CommandResult
handle_listfiles
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_listfiles
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
uri
=
argc
==
2
?
argv
[
1
]
/* default is root directory */
:
""
;
/* default is root directory */
const
char
*
const
uri
=
args
.
IsEmpty
()
?
""
:
args
.
front
();
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
/* list local directory */
...
...
@@ -157,12 +151,10 @@ static constexpr tag_handler print_tag_handler = {
};
CommandResult
handle_lsinfo
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_lsinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
uri
=
argc
==
2
?
argv
[
1
]
/* default is root directory */
:
""
;
/* default is root directory */
const
char
*
const
uri
=
args
.
IsEmpty
()
?
""
:
args
.
front
();
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
/* print information about an arbitrary local file */
...
...
@@ -207,7 +199,7 @@ handle_lsinfo(Client &client, unsigned argc, char *argv[])
}
#ifdef ENABLE_DATABASE
CommandResult
result
=
handle_lsinfo2
(
client
,
arg
c
,
argv
);
CommandResult
result
=
handle_lsinfo2
(
client
,
arg
s
);
if
(
result
!=
CommandResult
::
OK
)
return
result
;
#endif
...
...
@@ -265,14 +257,14 @@ handle_update(Client &client, Database &db,
#endif
static
CommandResult
handle_update
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
,
bool
discard
)
handle_update
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
,
bool
discard
)
{
#ifdef ENABLE_DATABASE
const
char
*
path
=
""
;
assert
(
arg
c
<=
2
);
if
(
argc
==
2
)
{
path
=
arg
v
[
1
]
;
assert
(
arg
s
.
size
<=
1
);
if
(
!
args
.
IsEmpty
()
)
{
path
=
arg
s
.
front
()
;
if
(
*
path
==
0
||
strcmp
(
path
,
"/"
)
==
0
)
/* backwards compatibility with MPD 0.15 */
...
...
@@ -292,8 +284,7 @@ handle_update(Client &client, unsigned argc, char *argv[], bool discard)
if
(
db
!=
nullptr
)
return
handle_update
(
client
,
*
db
,
path
,
discard
);
#else
(
void
)
argc
;
(
void
)
argv
;
(
void
)
args
;
(
void
)
discard
;
#endif
...
...
@@ -302,24 +293,24 @@ handle_update(Client &client, unsigned argc, char *argv[], bool discard)
}
CommandResult
handle_update
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_update
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
return
handle_update
(
client
,
arg
c
,
argv
,
false
);
return
handle_update
(
client
,
arg
s
,
false
);
}
CommandResult
handle_rescan
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_rescan
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
return
handle_update
(
client
,
arg
c
,
argv
,
true
);
return
handle_update
(
client
,
arg
s
,
true
);
}
CommandResult
handle_setvol
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_setvol
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
level
;
bool
success
;
if
(
!
check_unsigned
(
client
,
&
level
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
level
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
if
(
level
>
100
)
{
...
...
@@ -338,10 +329,10 @@ handle_setvol(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_volume
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_volume
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
int
relative
;
if
(
!
check_int
(
client
,
&
relative
,
arg
v
[
1
]
))
if
(
!
check_int
(
client
,
&
relative
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
if
(
relative
<
-
100
||
relative
>
100
)
{
...
...
@@ -372,26 +363,24 @@ handle_volume(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_stats
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_stats
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
stats_print
(
client
);
return
CommandResult
::
OK
;
}
CommandResult
handle_ping
(
gcc_unused
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_ping
(
gcc_unused
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
return
CommandResult
::
OK
;
}
CommandResult
handle_password
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_password
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
permission
=
0
;
if
(
getPermissionFromPassword
(
arg
v
[
1
]
,
&
permission
)
<
0
)
{
if
(
getPermissionFromPassword
(
arg
s
.
front
()
,
&
permission
)
<
0
)
{
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
return
CommandResult
::
ERROR
;
}
...
...
@@ -402,8 +391,7 @@ handle_password(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_config
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_config
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
if
(
!
client
.
IsLocal
())
{
command_error
(
client
,
ACK_ERROR_PERMISSION
,
...
...
@@ -423,17 +411,16 @@ handle_config(Client &client,
}
CommandResult
handle_idle
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_idle
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
flags
=
0
;
for
(
unsigned
i
=
1
;
i
<
argc
;
++
i
)
{
unsigned
event
=
idle_parse_name
(
argv
[
i
]
);
for
(
const
char
*
i
:
args
)
{
unsigned
event
=
idle_parse_name
(
i
);
if
(
event
==
0
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Unrecognized idle event: %s"
,
argv
[
i
]
);
i
);
return
CommandResult
::
ERROR
;
}
...
...
src/command/OtherCommands.hxx
View file @
6edfc56c
...
...
@@ -23,53 +23,54 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_urlhandlers
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_urlhandlers
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_decoders
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_decoders
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_tagtypes
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_tagtypes
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_kill
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_kill
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_close
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_close
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listfiles
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listfiles
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_lsinfo
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_lsinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_update
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_update
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_rescan
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_rescan
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_setvol
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_setvol
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_volume
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_volume
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_stats
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_stats
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_ping
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_ping
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_password
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_password
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_config
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_config
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_idle
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_idle
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/OutputCommands.cxx
View file @
6edfc56c
...
...
@@ -25,12 +25,15 @@
#include "protocol/ArgParser.hxx"
#include "client/Client.hxx"
#include "Partition.hxx"
#include "util/ConstBuffer.hxx"
CommandResult
handle_enableoutput
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_enableoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
args
.
size
==
1
);
unsigned
device
;
if
(
!
check_unsigned
(
client
,
&
device
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
device
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
if
(
!
audio_output_enable_index
(
client
.
partition
.
outputs
,
device
))
{
...
...
@@ -43,10 +46,12 @@ handle_enableoutput(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_disableoutput
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_disableoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
args
.
size
==
1
);
unsigned
device
;
if
(
!
check_unsigned
(
client
,
&
device
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
device
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
if
(
!
audio_output_disable_index
(
client
.
partition
.
outputs
,
device
))
{
...
...
@@ -59,10 +64,12 @@ handle_disableoutput(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_toggleoutput
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_toggleoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
args
.
size
==
1
);
unsigned
device
;
if
(
!
check_unsigned
(
client
,
&
device
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
device
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
if
(
!
audio_output_toggle_index
(
client
.
partition
.
outputs
,
device
))
{
...
...
@@ -75,9 +82,10 @@ handle_toggleoutput(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_devices
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_devices
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
assert
(
args
.
IsEmpty
());
printAudioDevices
(
client
,
client
.
partition
.
outputs
);
return
CommandResult
::
OK
;
...
...
src/command/OutputCommands.hxx
View file @
6edfc56c
...
...
@@ -23,17 +23,18 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_enableoutput
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_enableoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_disableoutput
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_disableoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_toggleoutput
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_toggleoutput
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_devices
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_devices
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/PlayerCommands.cxx
View file @
6edfc56c
...
...
@@ -30,6 +30,7 @@
#include "protocol/ArgParser.hxx"
#include "AudioFormat.hxx"
#include "ReplayGainConfig.hxx"
#include "util/ConstBuffer.hxx"
#ifdef ENABLE_DATABASE
#include "db/update/Service.hxx"
...
...
@@ -56,22 +57,22 @@
#define COMMAND_STATUS_UPDATING_DB "updating_db"
CommandResult
handle_play
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_play
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
int
song
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]
))
if
(
!
args
.
IsEmpty
()
&&
!
check_int
(
client
,
&
song
,
args
.
front
()
))
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
client
.
partition
.
PlayPosition
(
song
);
return
print_playlist_result
(
client
,
result
);
}
CommandResult
handle_playid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_playid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
int
id
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]
))
if
(
!
args
.
IsEmpty
()
&&
!
check_int
(
client
,
&
id
,
args
.
front
()
))
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
client
.
partition
.
PlayId
(
id
);
...
...
@@ -79,28 +80,25 @@ handle_playid(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_stop
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_stop
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
client
.
partition
.
Stop
();
return
CommandResult
::
OK
;
}
CommandResult
handle_currentsong
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_currentsong
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
playlist_print_current
(
client
,
client
.
playlist
);
return
CommandResult
::
OK
;
}
CommandResult
handle_pause
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[])
handle_pause
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
if
(
argc
==
2
)
{
if
(
!
args
.
IsEmpty
()
)
{
bool
pause_flag
;
if
(
!
check_bool
(
client
,
&
pause_flag
,
arg
v
[
1
]
))
if
(
!
check_bool
(
client
,
&
pause_flag
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
player_control
.
SetPause
(
pause_flag
);
...
...
@@ -111,8 +109,7 @@ handle_pause(Client &client,
}
CommandResult
handle_status
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_status
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
state
=
nullptr
;
int
song
;
...
...
@@ -226,8 +223,7 @@ handle_status(Client &client,
}
CommandResult
handle_next
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_next
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
playlist
&
playlist
=
client
.
playlist
;
...
...
@@ -243,18 +239,17 @@ handle_next(Client &client,
}
CommandResult
handle_previous
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_previous
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
client
.
partition
.
PlayPrevious
();
return
CommandResult
::
OK
;
}
CommandResult
handle_repeat
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_repeat
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
arg
v
[
1
]
))
if
(
!
check_bool
(
client
,
&
status
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
partition
.
SetRepeat
(
status
);
...
...
@@ -262,10 +257,10 @@ handle_repeat(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_single
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_single
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
arg
v
[
1
]
))
if
(
!
check_bool
(
client
,
&
status
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
partition
.
SetSingle
(
status
);
...
...
@@ -273,10 +268,10 @@ handle_single(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_consume
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_consume
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
arg
v
[
1
]
))
if
(
!
check_bool
(
client
,
&
status
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
partition
.
SetConsume
(
status
);
...
...
@@ -284,10 +279,10 @@ handle_consume(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_random
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_random
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
arg
v
[
1
]
))
if
(
!
check_bool
(
client
,
&
status
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
partition
.
SetRandom
(
status
);
...
...
@@ -296,22 +291,21 @@ handle_random(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_clearerror
(
gcc_unused
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_clearerror
(
gcc_unused
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
client
.
player_control
.
ClearError
();
return
CommandResult
::
OK
;
}
CommandResult
handle_seek
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_seek
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
song
;
SongTime
seek_time
;
if
(
!
check_unsigned
(
client
,
&
song
,
arg
v
[
1
]))
if
(
!
check_unsigned
(
client
,
&
song
,
arg
s
[
0
]))
return
CommandResult
::
ERROR
;
if
(
!
ParseCommandArg
(
client
,
seek_time
,
arg
v
[
2
]))
if
(
!
ParseCommandArg
(
client
,
seek_time
,
arg
s
[
1
]))
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
...
...
@@ -320,14 +314,14 @@ handle_seek(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_seekid
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_seekid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
id
;
SongTime
seek_time
;
if
(
!
check_unsigned
(
client
,
&
id
,
arg
v
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
arg
s
[
0
]))
return
CommandResult
::
ERROR
;
if
(
!
ParseCommandArg
(
client
,
seek_time
,
arg
v
[
2
]))
if
(
!
ParseCommandArg
(
client
,
seek_time
,
arg
s
[
1
]))
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
...
...
@@ -336,9 +330,9 @@ handle_seekid(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_seekcur
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_seekcur
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
p
=
arg
v
[
1
]
;
const
char
*
p
=
arg
s
.
front
()
;
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
SignedSongTime
seek_time
;
if
(
!
ParseCommandArg
(
client
,
seek_time
,
p
))
...
...
@@ -350,11 +344,11 @@ handle_seekcur(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_crossfade
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_crossfade
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
xfade_time
;
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
player_control
.
SetCrossFade
(
xfade_time
);
...
...
@@ -362,11 +356,11 @@ handle_crossfade(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_mixrampdb
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_mixrampdb
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
float
db
;
if
(
!
check_float
(
client
,
&
db
,
arg
v
[
1
]
))
if
(
!
check_float
(
client
,
&
db
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
player_control
.
SetMixRampDb
(
db
);
...
...
@@ -374,11 +368,11 @@ handle_mixrampdb(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_mixrampdelay
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_mixrampdelay
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
float
delay_secs
;
if
(
!
check_float
(
client
,
&
delay_secs
,
arg
v
[
1
]
))
if
(
!
check_float
(
client
,
&
delay_secs
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
client
.
player_control
.
SetMixRampDelay
(
delay_secs
);
...
...
@@ -386,10 +380,9 @@ handle_mixrampdelay(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_replay_gain_mode
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[])
handle_replay_gain_mode
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
if
(
!
replay_gain_set_mode_string
(
arg
v
[
1
]
))
{
if
(
!
replay_gain_set_mode_string
(
arg
s
.
front
()
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Unrecognized replay gain mode"
);
return
CommandResult
::
ERROR
;
...
...
@@ -400,8 +393,7 @@ handle_replay_gain_mode(Client &client,
}
CommandResult
handle_replay_gain_status
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_replay_gain_status
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
replay_gain_get_mode_string
());
...
...
src/command/PlayerCommands.hxx
View file @
6edfc56c
...
...
@@ -23,68 +23,69 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_play
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_play
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_stop
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_stop
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_currentsong
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_currentsong
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_pause
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_pause
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_status
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_status
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_next
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_next
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_previous
(
Client
&
client
,
unsigned
argc
,
char
*
avg
[]
);
handle_previous
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_repeat
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_repeat
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_single
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_single
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_consume
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_consume
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_random
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_random
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_clearerror
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_clearerror
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_seek
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_seek
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_seekid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_seekid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_seekcur
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_seekcur
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_crossfade
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_crossfade
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_mixrampdb
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_mixrampdb
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_mixrampdelay
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_mixrampdelay
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_replay_gain_mode
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_replay_gain_mode
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_replay_gain_status
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_replay_gain_status
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/PlaylistCommands.cxx
View file @
6edfc56c
...
...
@@ -39,6 +39,7 @@
#include "fs/AllocatedPath.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
bool
playlist_commands_available
()
...
...
@@ -58,28 +59,28 @@ print_spl_list(Client &client, const PlaylistVector &list)
}
CommandResult
handle_save
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_save
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
PlaylistResult
result
=
spl_save_playlist
(
arg
v
[
1
]
,
client
.
playlist
);
PlaylistResult
result
=
spl_save_playlist
(
arg
s
.
front
()
,
client
.
playlist
);
return
print_playlist_result
(
client
,
result
);
}
CommandResult
handle_load
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_load
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
start_index
,
end_index
;
if
(
arg
c
<
3
)
{
if
(
arg
s
.
size
<
2
)
{
start_index
=
0
;
end_index
=
unsigned
(
-
1
);
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
arg
v
[
2
]))
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
arg
s
[
1
]))
return
CommandResult
::
ERROR
;
const
ScopeBulkEdit
bulk_edit
(
client
.
partition
);
Error
error
;
const
SongLoader
loader
(
client
);
if
(
!
playlist_open_into_queue
(
arg
v
[
1
]
,
if
(
!
playlist_open_into_queue
(
arg
s
.
front
()
,
start_index
,
end_index
,
client
.
playlist
,
client
.
player_control
,
loader
,
error
))
...
...
@@ -89,94 +90,104 @@ handle_load(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_listplaylist
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_listplaylist
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
false
))
const
char
*
const
name
=
args
.
front
();
if
(
playlist_file_print
(
client
,
name
,
false
))
return
CommandResult
::
OK
;
Error
error
;
return
spl_print
(
client
,
argv
[
1
]
,
false
,
error
)
return
spl_print
(
client
,
name
,
false
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_listplaylistinfo
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[])
handle_listplaylistinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
true
))
const
char
*
const
name
=
args
.
front
();
if
(
playlist_file_print
(
client
,
name
,
true
))
return
CommandResult
::
OK
;
Error
error
;
return
spl_print
(
client
,
argv
[
1
]
,
true
,
error
)
return
spl_print
(
client
,
name
,
true
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_rm
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_rm
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
name
=
args
.
front
();
Error
error
;
return
spl_delete
(
argv
[
1
]
,
error
)
return
spl_delete
(
name
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_rename
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_rename
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
old_name
=
args
[
0
];
const
char
*
const
new_name
=
args
[
1
];
Error
error
;
return
spl_rename
(
argv
[
1
],
argv
[
2
]
,
error
)
return
spl_rename
(
old_name
,
new_name
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_playlistdelete
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[])
{
c
har
*
playlist
=
argv
[
1
];
handle_playlistdelete
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
c
onst
char
*
const
name
=
args
[
0
];
unsigned
from
;
if
(
!
check_unsigned
(
client
,
&
from
,
arg
v
[
2
]))
if
(
!
check_unsigned
(
client
,
&
from
,
arg
s
[
1
]))
return
CommandResult
::
ERROR
;
Error
error
;
return
spl_remove_index
(
playlist
,
from
,
error
)
return
spl_remove_index
(
name
,
from
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_playlistmove
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_playlistmove
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
c
har
*
playlist
=
argv
[
1
]
;
c
onst
char
*
const
name
=
args
.
front
()
;
unsigned
from
,
to
;
if
(
!
check_unsigned
(
client
,
&
from
,
arg
v
[
2
]))
if
(
!
check_unsigned
(
client
,
&
from
,
arg
s
[
1
]))
return
CommandResult
::
ERROR
;
if
(
!
check_unsigned
(
client
,
&
to
,
arg
v
[
3
]))
if
(
!
check_unsigned
(
client
,
&
to
,
arg
s
[
2
]))
return
CommandResult
::
ERROR
;
Error
error
;
return
spl_move_index
(
playlist
,
from
,
to
,
error
)
return
spl_move_index
(
name
,
from
,
to
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_playlistclear
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_playlistclear
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
const
char
*
const
name
=
args
.
front
();
Error
error
;
return
spl_clear
(
argv
[
1
]
,
error
)
return
spl_clear
(
name
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
handle_playlistadd
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_playlistadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
c
har
*
playlist
=
argv
[
1
];
c
har
*
uri
=
argv
[
2
];
c
onst
char
*
const
playlist
=
args
[
0
];
c
onst
char
*
const
uri
=
args
[
1
];
bool
success
;
Error
error
;
...
...
@@ -207,8 +218,7 @@ handle_playlistadd(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_listplaylists
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
handle_listplaylists
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
Error
error
;
const
auto
list
=
ListPlaylistFiles
(
error
);
...
...
src/command/PlaylistCommands.hxx
View file @
6edfc56c
...
...
@@ -24,42 +24,43 @@
#include "Compiler.h"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
gcc_const
bool
playlist_commands_available
();
CommandResult
handle_save
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_save
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_load
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_load
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listplaylist
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listplaylist
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listplaylistinfo
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listplaylistinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_rm
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_rm
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_rename
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_rename
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistdelete
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistdelete
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistmove
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistmove
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistclear
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistclear
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistadd
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistadd
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_listplaylists
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listplaylists
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/QueueCommands.cxx
View file @
6edfc56c
This diff is collapsed.
Click to expand it.
src/command/QueueCommands.hxx
View file @
6edfc56c
...
...
@@ -23,65 +23,66 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_add
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_add
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_addid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_addid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_rangeid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_rangeid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_delete
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_delete
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_deleteid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_deleteid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlist
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlist
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_shuffle
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_shuffle
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_clear
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_clear
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_plchanges
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_plchanges
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_plchangesposid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_plchangesposid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistinfo
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistinfo
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistfind
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistfind
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_playlistsearch
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_playlistsearch
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_prio
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_prio
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_prioid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_prioid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_move
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_move
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_moveid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_moveid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_swap
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_swap
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_swapid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_swapid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/StickerCommands.cxx
View file @
6edfc56c
...
...
@@ -31,6 +31,7 @@
#include "Partition.hxx"
#include "Instance.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include <string.h>
...
...
@@ -51,20 +52,22 @@ sticker_song_find_print_cb(const LightSong &song, const char *value,
}
static
CommandResult
handle_sticker_song
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_sticker_song
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
Error
error
;
const
Database
*
db
=
client
.
GetDatabase
(
error
);
if
(
db
==
nullptr
)
return
print_error
(
client
,
error
);
const
char
*
const
cmd
=
args
.
front
();
/* get song song_id key */
if
(
arg
c
==
5
&&
strcmp
(
argv
[
1
]
,
"get"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
v
[
3
],
error
);
if
(
arg
s
.
size
==
4
&&
strcmp
(
cmd
,
"get"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
s
[
2
],
error
);
if
(
song
==
nullptr
)
return
print_error
(
client
,
error
);
const
auto
value
=
sticker_song_get_value
(
*
song
,
arg
v
[
4
]);
const
auto
value
=
sticker_song_get_value
(
*
song
,
arg
s
[
3
]);
db
->
ReturnSong
(
song
);
if
(
value
.
empty
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
...
@@ -72,12 +75,12 @@ handle_sticker_song(Client &client, unsigned argc, char *argv[])
return
CommandResult
::
ERROR
;
}
sticker_print_value
(
client
,
arg
v
[
4
],
value
.
c_str
());
sticker_print_value
(
client
,
arg
s
[
3
],
value
.
c_str
());
return
CommandResult
::
OK
;
/* list song song_id */
}
else
if
(
arg
c
==
4
&&
strcmp
(
argv
[
1
]
,
"list"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
v
[
3
],
error
);
}
else
if
(
arg
s
.
size
==
3
&&
strcmp
(
cmd
,
"list"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
s
[
2
],
error
);
if
(
song
==
nullptr
)
return
print_error
(
client
,
error
);
...
...
@@ -90,12 +93,12 @@ handle_sticker_song(Client &client, unsigned argc, char *argv[])
return
CommandResult
::
OK
;
/* set song song_id id key */
}
else
if
(
arg
c
==
6
&&
strcmp
(
argv
[
1
]
,
"set"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
v
[
3
],
error
);
}
else
if
(
arg
s
.
size
==
5
&&
strcmp
(
cmd
,
"set"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
s
[
2
],
error
);
if
(
song
==
nullptr
)
return
print_error
(
client
,
error
);
bool
ret
=
sticker_song_set_value
(
*
song
,
arg
v
[
4
],
argv
[
5
]);
bool
ret
=
sticker_song_set_value
(
*
song
,
arg
s
[
3
],
args
[
4
]);
db
->
ReturnSong
(
song
);
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
...
...
@@ -105,15 +108,15 @@ handle_sticker_song(Client &client, unsigned argc, char *argv[])
return
CommandResult
::
OK
;
/* delete song song_id [key] */
}
else
if
((
arg
c
==
4
||
argc
==
5
)
&&
strcmp
(
argv
[
1
]
,
"delete"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
v
[
3
],
error
);
}
else
if
((
arg
s
.
size
==
3
||
args
.
size
==
4
)
&&
strcmp
(
cmd
,
"delete"
)
==
0
)
{
const
LightSong
*
song
=
db
->
GetSong
(
arg
s
[
2
],
error
);
if
(
song
==
nullptr
)
return
print_error
(
client
,
error
);
bool
ret
=
arg
c
==
4
bool
ret
=
arg
s
.
size
==
3
?
sticker_song_delete
(
*
song
)
:
sticker_song_delete_value
(
*
song
,
arg
v
[
4
]);
:
sticker_song_delete_value
(
*
song
,
arg
s
[
3
]);
db
->
ReturnSong
(
song
);
if
(
!
ret
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
...
...
@@ -123,15 +126,15 @@ handle_sticker_song(Client &client, unsigned argc, char *argv[])
return
CommandResult
::
OK
;
/* find song dir key */
}
else
if
(
arg
c
==
5
&&
strcmp
(
argv
[
1
]
,
"find"
)
==
0
)
{
}
else
if
(
arg
s
.
size
==
4
&&
strcmp
(
cmd
,
"find"
)
==
0
)
{
/* "sticker find song a/directory name" */
const
char
*
const
base_uri
=
arg
v
[
3
];
const
char
*
const
base_uri
=
arg
s
[
2
];
bool
success
;
struct
sticker_song_find_data
data
=
{
client
,
arg
v
[
4
],
arg
s
[
3
],
};
success
=
sticker_song_find
(
*
db
,
base_uri
,
data
.
name
,
...
...
@@ -150,9 +153,9 @@ handle_sticker_song(Client &client, unsigned argc, char *argv[])
}
CommandResult
handle_sticker
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_sticker
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
assert
(
arg
c
>=
4
);
assert
(
arg
s
.
size
>=
3
);
if
(
!
sticker_enabled
())
{
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
...
...
@@ -160,8 +163,8 @@ handle_sticker(Client &client, unsigned argc, char *argv[])
return
CommandResult
::
ERROR
;
}
if
(
strcmp
(
arg
v
[
2
],
"song"
)
==
0
)
return
handle_sticker_song
(
client
,
arg
c
,
argv
);
if
(
strcmp
(
arg
s
[
1
],
"song"
)
==
0
)
return
handle_sticker_song
(
client
,
arg
s
);
else
{
command_error
(
client
,
ACK_ERROR_ARG
,
"unknown sticker domain"
);
...
...
src/command/StickerCommands.hxx
View file @
6edfc56c
...
...
@@ -23,8 +23,9 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_sticker
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_sticker
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/StorageCommands.cxx
View file @
6edfc56c
...
...
@@ -25,6 +25,7 @@
#include "protocol/Result.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "fs/Traits.hxx"
#include "client/Client.hxx"
#include "Partition.hxx"
...
...
@@ -167,7 +168,7 @@ print_storage_uri(Client &client, const Storage &storage)
}
CommandResult
handle_listmounts
(
Client
&
client
,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[]
)
handle_listmounts
(
Client
&
client
,
gcc_unused
ConstBuffer
<
const
char
*>
args
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
if
(
_composite
==
nullptr
)
{
...
...
@@ -189,7 +190,7 @@ handle_listmounts(Client &client, gcc_unused unsigned argc, gcc_unused char *arg
}
CommandResult
handle_mount
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_mount
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
if
(
_composite
==
nullptr
)
{
...
...
@@ -199,8 +200,8 @@ handle_mount(Client &client, gcc_unused unsigned argc, char *argv[])
CompositeStorage
&
composite
=
*
(
CompositeStorage
*
)
_composite
;
const
char
*
const
local_uri
=
arg
v
[
1
];
const
char
*
const
remote_uri
=
arg
v
[
2
];
const
char
*
const
local_uri
=
arg
s
[
0
];
const
char
*
const
remote_uri
=
arg
s
[
1
];
if
(
*
local_uri
==
0
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad mount point"
);
...
...
@@ -252,7 +253,7 @@ handle_mount(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_unmount
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_unmount
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
if
(
_composite
==
nullptr
)
{
...
...
@@ -262,7 +263,7 @@ handle_unmount(Client &client, gcc_unused unsigned argc, char *argv[])
CompositeStorage
&
composite
=
*
(
CompositeStorage
*
)
_composite
;
const
char
*
const
local_uri
=
arg
v
[
1
]
;
const
char
*
const
local_uri
=
arg
s
.
front
()
;
if
(
*
local_uri
==
0
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad mount point"
);
...
...
src/command/StorageCommands.hxx
View file @
6edfc56c
...
...
@@ -24,6 +24,7 @@
class
Client
;
class
Storage
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_listfiles_storage
(
Client
&
client
,
Storage
&
storage
,
const
char
*
uri
);
...
...
@@ -32,12 +33,12 @@ CommandResult
handle_listfiles_storage
(
Client
&
client
,
const
char
*
uri
);
CommandResult
handle_listmounts
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_listmounts
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_mount
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_mount
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_unmount
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_unmount
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#endif
src/command/TagCommands.cxx
View file @
6edfc56c
...
...
@@ -25,15 +25,16 @@
#include "protocol/Result.hxx"
#include "tag/Tag.hxx"
#include "Partition.hxx"
#include "util/ConstBuffer.hxx"
CommandResult
handle_addtagid
(
Client
&
client
,
gcc_unused
unsigned
argc
,
char
*
argv
[]
)
handle_addtagid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
song_id
;
if
(
!
check_unsigned
(
client
,
&
song_id
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
song_id
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
const
char
*
const
tag_name
=
arg
v
[
2
];
const
char
*
const
tag_name
=
arg
s
[
1
];
const
TagType
tag_type
=
tag_name_parse_i
(
tag_name
);
if
(
tag_type
==
TAG_NUM_OF_ITEM_TYPES
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
...
...
@@ -41,7 +42,7 @@ handle_addtagid(Client &client, gcc_unused unsigned argc, char *argv[])
return
CommandResult
::
ERROR
;
}
const
char
*
const
value
=
arg
v
[
3
];
const
char
*
const
value
=
arg
s
[
2
];
Error
error
;
if
(
!
client
.
partition
.
playlist
.
AddSongIdTag
(
song_id
,
tag_type
,
value
,
...
...
@@ -52,15 +53,15 @@ handle_addtagid(Client &client, gcc_unused unsigned argc, char *argv[])
}
CommandResult
handle_cleartagid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
)
handle_cleartagid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
unsigned
song_id
;
if
(
!
check_unsigned
(
client
,
&
song_id
,
arg
v
[
1
]
))
if
(
!
check_unsigned
(
client
,
&
song_id
,
arg
s
.
front
()
))
return
CommandResult
::
ERROR
;
TagType
tag_type
=
TAG_NUM_OF_ITEM_TYPES
;
if
(
arg
c
>=
3
)
{
const
char
*
const
tag_name
=
arg
v
[
2
];
if
(
arg
s
.
size
>=
2
)
{
const
char
*
const
tag_name
=
arg
s
[
1
];
tag_type
=
tag_name_parse_i
(
tag_name
);
if
(
tag_type
==
TAG_NUM_OF_ITEM_TYPES
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
...
...
src/command/TagCommands.hxx
View file @
6edfc56c
...
...
@@ -23,11 +23,12 @@
#include "CommandResult.hxx"
class
Client
;
template
<
typename
T
>
struct
ConstBuffer
;
CommandResult
handle_addtagid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_addtagid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
CommandResult
handle_cleartagid
(
Client
&
client
,
unsigned
argc
,
char
*
argv
[]
);
handle_cleartagid
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
);
#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