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
c7396b06
Commit
c7396b06
authored
Feb 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: add method GetPartition(), make partition private
parent
e3ee60e7
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
57 deletions
+71
-57
Client.hxx
src/client/Client.hxx
+5
-1
AllCommands.cxx
src/command/AllCommands.cxx
+1
-1
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+10
-9
OtherCommands.cxx
src/command/OtherCommands.cxx
+6
-4
OutputCommands.cxx
src/command/OutputCommands.cxx
+4
-4
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+19
-17
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+3
-3
QueueCommands.cxx
src/command/QueueCommands.cxx
+22
-17
StickerCommands.cxx
src/command/StickerCommands.cxx
+1
-1
No files found.
src/client/Client.hxx
View file @
c7396b06
...
@@ -50,9 +50,9 @@ class Storage;
...
@@ -50,9 +50,9 @@ class Storage;
class
Client
final
class
Client
final
:
FullyBufferedSocket
,
TimeoutMonitor
,
:
FullyBufferedSocket
,
TimeoutMonitor
,
public
boost
::
intrusive
::
list_base_hook
<
boost
::
intrusive
::
link_mode
<
boost
::
intrusive
::
normal_link
>>
{
public
boost
::
intrusive
::
list_base_hook
<
boost
::
intrusive
::
link_mode
<
boost
::
intrusive
::
normal_link
>>
{
public
:
Partition
&
partition
;
Partition
&
partition
;
public
:
unsigned
permission
;
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
/** the uid of the client process, or -1 if unknown */
...
@@ -188,6 +188,10 @@ public:
...
@@ -188,6 +188,10 @@ public:
*/
*/
void
AllowFile
(
Path
path_fs
)
const
;
void
AllowFile
(
Path
path_fs
)
const
;
Partition
&
GetPartition
()
{
return
partition
;
}
gcc_pure
gcc_pure
Instance
&
GetInstance
();
Instance
&
GetInstance
();
...
...
src/command/AllCommands.cxx
View file @
c7396b06
...
@@ -262,7 +262,7 @@ PrintUnavailableCommands(Response &r, unsigned permission)
...
@@ -262,7 +262,7 @@ PrintUnavailableCommands(Response &r, unsigned permission)
static
CommandResult
static
CommandResult
handle_commands
(
Client
&
client
,
gcc_unused
Request
request
,
Response
&
r
)
handle_commands
(
Client
&
client
,
gcc_unused
Request
request
,
Response
&
r
)
{
{
return
PrintAvailableCommands
(
r
,
client
.
partition
,
return
PrintAvailableCommands
(
r
,
client
.
GetPartition
()
,
client
.
GetPermission
());
client
.
GetPermission
());
}
}
...
...
src/command/DatabaseCommands.cxx
View file @
c7396b06
...
@@ -41,7 +41,7 @@ CommandResult
...
@@ -41,7 +41,7 @@ CommandResult
handle_listfiles_db
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
)
handle_listfiles_db
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
)
{
{
const
DatabaseSelection
selection
(
uri
,
false
);
const
DatabaseSelection
selection
(
uri
,
false
);
db_selection_print
(
r
,
client
.
partition
,
db_selection_print
(
r
,
client
.
GetPartition
()
,
selection
,
false
,
true
);
selection
,
false
,
true
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -50,7 +50,7 @@ CommandResult
...
@@ -50,7 +50,7 @@ CommandResult
handle_lsinfo2
(
Client
&
client
,
const
char
*
uri
,
Response
&
r
)
handle_lsinfo2
(
Client
&
client
,
const
char
*
uri
,
Response
&
r
)
{
{
const
DatabaseSelection
selection
(
uri
,
false
);
const
DatabaseSelection
selection
(
uri
,
false
);
db_selection_print
(
r
,
client
.
partition
,
db_selection_print
(
r
,
client
.
GetPartition
()
,
selection
,
true
,
false
);
selection
,
true
,
false
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -85,7 +85,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
...
@@ -85,7 +85,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
db_selection_print
(
r
,
client
.
partition
,
db_selection_print
(
r
,
client
.
GetPartition
()
,
selection
,
true
,
false
,
selection
,
true
,
false
,
sort
,
sort
,
window
.
start
,
window
.
end
);
window
.
start
,
window
.
end
);
...
@@ -113,10 +113,11 @@ handle_match_add(Client &client, Request args, Response &r, bool fold_case)
...
@@ -113,10 +113,11 @@ handle_match_add(Client &client, Request args, Response &r, bool fold_case)
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
const
ScopeBulkEdit
bulk_edit
(
client
.
partition
);
auto
&
partition
=
client
.
GetPartition
();
const
ScopeBulkEdit
bulk_edit
(
partition
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
AddFromDatabase
(
client
.
partition
,
selection
);
AddFromDatabase
(
partition
,
selection
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -173,7 +174,7 @@ handle_count(Client &client, Request args, Response &r)
...
@@ -173,7 +174,7 @@ handle_count(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
PrintSongCount
(
r
,
client
.
partition
,
""
,
&
filter
,
group
);
PrintSongCount
(
r
,
client
.
GetPartition
()
,
""
,
&
filter
,
group
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -183,7 +184,7 @@ handle_listall(Client &client, Request args, Response &r)
...
@@ -183,7 +184,7 @@ handle_listall(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
,
""
);
db_selection_print
(
r
,
client
.
partition
,
db_selection_print
(
r
,
client
.
GetPartition
()
,
DatabaseSelection
(
uri
,
true
),
DatabaseSelection
(
uri
,
true
),
false
,
false
);
false
,
false
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
@@ -248,7 +249,7 @@ handle_list(Client &client, Request args, Response &r)
...
@@ -248,7 +249,7 @@ handle_list(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
PrintUniqueTags
(
r
,
client
.
partition
,
PrintUniqueTags
(
r
,
client
.
GetPartition
()
,
tagType
,
group_mask
,
filter
.
get
());
tagType
,
group_mask
,
filter
.
get
());
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -259,7 +260,7 @@ handle_listallinfo(Client &client, Request args, Response &r)
...
@@ -259,7 +260,7 @@ handle_listallinfo(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
,
""
);
db_selection_print
(
r
,
client
.
partition
,
db_selection_print
(
r
,
client
.
GetPartition
()
,
DatabaseSelection
(
uri
,
true
),
DatabaseSelection
(
uri
,
true
),
true
,
false
);
true
,
false
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
...
src/command/OtherCommands.cxx
View file @
c7396b06
...
@@ -329,7 +329,7 @@ handle_setvol(Client &client, Request args, Response &r)
...
@@ -329,7 +329,7 @@ handle_setvol(Client &client, Request args, Response &r)
{
{
unsigned
level
=
args
.
ParseUnsigned
(
0
,
100
);
unsigned
level
=
args
.
ParseUnsigned
(
0
,
100
);
if
(
!
volume_level_change
(
client
.
partition
.
outputs
,
level
))
{
if
(
!
volume_level_change
(
client
.
GetPartition
()
.
outputs
,
level
))
{
r
.
Error
(
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
r
.
Error
(
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -342,7 +342,9 @@ handle_volume(Client &client, Request args, Response &r)
...
@@ -342,7 +342,9 @@ handle_volume(Client &client, Request args, Response &r)
{
{
int
relative
=
args
.
ParseInt
(
0
,
-
100
,
100
);
int
relative
=
args
.
ParseInt
(
0
,
-
100
,
100
);
const
int
old_volume
=
volume_level_get
(
client
.
partition
.
outputs
);
auto
&
outputs
=
client
.
GetPartition
().
outputs
;
const
int
old_volume
=
volume_level_get
(
outputs
);
if
(
old_volume
<
0
)
{
if
(
old_volume
<
0
)
{
r
.
Error
(
ACK_ERROR_SYSTEM
,
"No mixer"
);
r
.
Error
(
ACK_ERROR_SYSTEM
,
"No mixer"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
@@ -355,7 +357,7 @@ handle_volume(Client &client, Request args, Response &r)
...
@@ -355,7 +357,7 @@ handle_volume(Client &client, Request args, Response &r)
new_volume
=
100
;
new_volume
=
100
;
if
(
new_volume
!=
old_volume
&&
if
(
new_volume
!=
old_volume
&&
!
volume_level_change
(
client
.
partition
.
outputs
,
new_volume
))
{
!
volume_level_change
(
outputs
,
new_volume
))
{
r
.
Error
(
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
r
.
Error
(
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -366,7 +368,7 @@ handle_volume(Client &client, Request args, Response &r)
...
@@ -366,7 +368,7 @@ handle_volume(Client &client, Request args, Response &r)
CommandResult
CommandResult
handle_stats
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
handle_stats
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
{
stats_print
(
r
,
client
.
partition
);
stats_print
(
r
,
client
.
GetPartition
()
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
...
src/command/OutputCommands.cxx
View file @
c7396b06
...
@@ -32,7 +32,7 @@ handle_enableoutput(Client &client, Request args, Response &r)
...
@@ -32,7 +32,7 @@ handle_enableoutput(Client &client, Request args, Response &r)
assert
(
args
.
size
==
1
);
assert
(
args
.
size
==
1
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
if
(
!
audio_output_enable_index
(
client
.
partition
.
outputs
,
device
))
{
if
(
!
audio_output_enable_index
(
client
.
GetPartition
()
.
outputs
,
device
))
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -46,7 +46,7 @@ handle_disableoutput(Client &client, Request args, Response &r)
...
@@ -46,7 +46,7 @@ handle_disableoutput(Client &client, Request args, Response &r)
assert
(
args
.
size
==
1
);
assert
(
args
.
size
==
1
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
if
(
!
audio_output_disable_index
(
client
.
partition
.
outputs
,
device
))
{
if
(
!
audio_output_disable_index
(
client
.
GetPartition
()
.
outputs
,
device
))
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -60,7 +60,7 @@ handle_toggleoutput(Client &client, Request args, Response &r)
...
@@ -60,7 +60,7 @@ handle_toggleoutput(Client &client, Request args, Response &r)
assert
(
args
.
size
==
1
);
assert
(
args
.
size
==
1
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
unsigned
device
=
args
.
ParseUnsigned
(
0
);
if
(
!
audio_output_toggle_index
(
client
.
partition
.
outputs
,
device
))
{
if
(
!
audio_output_toggle_index
(
client
.
GetPartition
()
.
outputs
,
device
))
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No such audio output"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -73,6 +73,6 @@ handle_devices(Client &client, gcc_unused Request args, Response &r)
...
@@ -73,6 +73,6 @@ handle_devices(Client &client, gcc_unused Request args, Response &r)
{
{
assert
(
args
.
IsEmpty
());
assert
(
args
.
IsEmpty
());
printAudioDevices
(
r
,
client
.
partition
.
outputs
);
printAudioDevices
(
r
,
client
.
GetPartition
()
.
outputs
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
src/command/PlayerCommands.cxx
View file @
c7396b06
...
@@ -63,7 +63,7 @@ handle_play(Client &client, Request args, gcc_unused Response &r)
...
@@ -63,7 +63,7 @@ handle_play(Client &client, Request args, gcc_unused Response &r)
{
{
int
song
=
args
.
ParseOptional
(
0
,
-
1
);
int
song
=
args
.
ParseOptional
(
0
,
-
1
);
client
.
partition
.
PlayPosition
(
song
);
client
.
GetPartition
()
.
PlayPosition
(
song
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -72,14 +72,14 @@ handle_playid(Client &client, Request args, gcc_unused Response &r)
...
@@ -72,14 +72,14 @@ handle_playid(Client &client, Request args, gcc_unused Response &r)
{
{
int
id
=
args
.
ParseOptional
(
0
,
-
1
);
int
id
=
args
.
ParseOptional
(
0
,
-
1
);
client
.
partition
.
PlayId
(
id
);
client
.
GetPartition
()
.
PlayId
(
id
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
CommandResult
CommandResult
handle_stop
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
handle_stop
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
{
{
client
.
partition
.
Stop
();
client
.
GetPartition
()
.
Stop
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -136,7 +136,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
...
@@ -136,7 +136,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
COMMAND_STATUS_PLAYLIST_LENGTH
": %i
\n
"
COMMAND_STATUS_PLAYLIST_LENGTH
": %i
\n
"
COMMAND_STATUS_MIXRAMPDB
": %f
\n
"
COMMAND_STATUS_MIXRAMPDB
": %f
\n
"
COMMAND_STATUS_STATE
": %s
\n
"
,
COMMAND_STATUS_STATE
": %s
\n
"
,
volume_level_get
(
client
.
partition
.
outputs
),
volume_level_get
(
client
.
GetPartition
()
.
outputs
),
playlist
.
GetRepeat
(),
playlist
.
GetRepeat
(),
playlist
.
GetRandom
(),
playlist
.
GetRandom
(),
playlist
.
GetSingle
(),
playlist
.
GetSingle
(),
...
@@ -222,7 +222,7 @@ handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
...
@@ -222,7 +222,7 @@ handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
playlist
.
queue
.
single
=
single
;
playlist
.
queue
.
single
=
single
;
};
};
client
.
partition
.
PlayNext
();
client
.
GetPartition
()
.
PlayNext
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -230,7 +230,7 @@ CommandResult
...
@@ -230,7 +230,7 @@ CommandResult
handle_previous
(
Client
&
client
,
gcc_unused
Request
args
,
handle_previous
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
gcc_unused
Response
&
r
)
{
{
client
.
partition
.
PlayPrevious
();
client
.
GetPartition
()
.
PlayPrevious
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -238,7 +238,7 @@ CommandResult
...
@@ -238,7 +238,7 @@ CommandResult
handle_repeat
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_repeat
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
bool
status
=
args
.
ParseBool
(
0
);
bool
status
=
args
.
ParseBool
(
0
);
client
.
partition
.
SetRepeat
(
status
);
client
.
GetPartition
()
.
SetRepeat
(
status
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -246,7 +246,7 @@ CommandResult
...
@@ -246,7 +246,7 @@ CommandResult
handle_single
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_single
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
bool
status
=
args
.
ParseBool
(
0
);
bool
status
=
args
.
ParseBool
(
0
);
client
.
partition
.
SetSingle
(
status
);
client
.
GetPartition
()
.
SetSingle
(
status
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -254,7 +254,7 @@ CommandResult
...
@@ -254,7 +254,7 @@ CommandResult
handle_consume
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_consume
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
bool
status
=
args
.
ParseBool
(
0
);
bool
status
=
args
.
ParseBool
(
0
);
client
.
partition
.
SetConsume
(
status
);
client
.
GetPartition
()
.
SetConsume
(
status
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -262,8 +262,9 @@ CommandResult
...
@@ -262,8 +262,9 @@ CommandResult
handle_random
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_random
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
bool
status
=
args
.
ParseBool
(
0
);
bool
status
=
args
.
ParseBool
(
0
);
client
.
partition
.
SetRandom
(
status
);
auto
&
partition
=
client
.
GetPartition
();
client
.
partition
.
UpdateEffectiveReplayGainMode
();
partition
.
SetRandom
(
status
);
partition
.
UpdateEffectiveReplayGainMode
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -281,7 +282,7 @@ handle_seek(Client &client, Request args, gcc_unused Response &r)
...
@@ -281,7 +282,7 @@ handle_seek(Client &client, Request args, gcc_unused Response &r)
unsigned
song
=
args
.
ParseUnsigned
(
0
);
unsigned
song
=
args
.
ParseUnsigned
(
0
);
SongTime
seek_time
=
args
.
ParseSongTime
(
1
);
SongTime
seek_time
=
args
.
ParseSongTime
(
1
);
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
client
.
GetPartition
()
.
SeekSongPosition
(
song
,
seek_time
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -291,7 +292,7 @@ handle_seekid(Client &client, Request args, gcc_unused Response &r)
...
@@ -291,7 +292,7 @@ handle_seekid(Client &client, Request args, gcc_unused Response &r)
unsigned
id
=
args
.
ParseUnsigned
(
0
);
unsigned
id
=
args
.
ParseUnsigned
(
0
);
SongTime
seek_time
=
args
.
ParseSongTime
(
1
);
SongTime
seek_time
=
args
.
ParseSongTime
(
1
);
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
client
.
GetPartition
()
.
SeekSongId
(
id
,
seek_time
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -302,7 +303,7 @@ handle_seekcur(Client &client, Request args, gcc_unused Response &r)
...
@@ -302,7 +303,7 @@ handle_seekcur(Client &client, Request args, gcc_unused Response &r)
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
SignedSongTime
seek_time
=
ParseCommandArgSignedSongTime
(
p
);
SignedSongTime
seek_time
=
ParseCommandArgSignedSongTime
(
p
);
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
client
.
GetPartition
()
.
SeekCurrent
(
seek_time
,
relative
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -334,8 +335,9 @@ CommandResult
...
@@ -334,8 +335,9 @@ CommandResult
handle_replay_gain_mode
(
Client
&
client
,
Request
args
,
Response
&
)
handle_replay_gain_mode
(
Client
&
client
,
Request
args
,
Response
&
)
{
{
auto
new_mode
=
FromString
(
args
.
front
());
auto
new_mode
=
FromString
(
args
.
front
());
client
.
partition
.
SetReplayGainMode
(
new_mode
);
auto
&
partition
=
client
.
GetPartition
();
client
.
partition
.
EmitIdle
(
IDLE_OPTIONS
);
partition
.
SetReplayGainMode
(
new_mode
);
partition
.
EmitIdle
(
IDLE_OPTIONS
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -344,6 +346,6 @@ handle_replay_gain_status(Client &client, gcc_unused Request args,
...
@@ -344,6 +346,6 @@ handle_replay_gain_status(Client &client, gcc_unused Request args,
Response
&
r
)
Response
&
r
)
{
{
r
.
Format
(
"replay_gain_mode: %s
\n
"
,
r
.
Format
(
"replay_gain_mode: %s
\n
"
,
ToString
(
client
.
partition
.
replay_gain_mode
));
ToString
(
client
.
GetPartition
()
.
replay_gain_mode
));
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
src/command/PlaylistCommands.cxx
View file @
c7396b06
...
@@ -67,7 +67,7 @@ handle_load(Client &client, Request args, gcc_unused Response &r)
...
@@ -67,7 +67,7 @@ handle_load(Client &client, Request args, gcc_unused Response &r)
{
{
RangeArg
range
=
args
.
ParseOptional
(
1
,
RangeArg
::
All
());
RangeArg
range
=
args
.
ParseOptional
(
1
,
RangeArg
::
All
());
const
ScopeBulkEdit
bulk_edit
(
client
.
partition
);
const
ScopeBulkEdit
bulk_edit
(
client
.
GetPartition
()
);
const
SongLoader
loader
(
client
);
const
SongLoader
loader
(
client
);
playlist_open_into_queue
(
args
.
front
(),
playlist_open_into_queue
(
args
.
front
(),
...
@@ -82,7 +82,7 @@ handle_listplaylist(Client &client, Request args, Response &r)
...
@@ -82,7 +82,7 @@ handle_listplaylist(Client &client, Request args, Response &r)
{
{
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
.
GetPartition
()
,
SongLoader
(
client
),
name
,
false
))
name
,
false
))
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
@@ -94,7 +94,7 @@ handle_listplaylistinfo(Client &client, Request args, Response &r)
...
@@ -94,7 +94,7 @@ handle_listplaylistinfo(Client &client, Request args, Response &r)
{
{
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
.
GetPartition
()
,
SongLoader
(
client
),
name
,
true
))
name
,
true
))
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
...
src/command/QueueCommands.cxx
View file @
c7396b06
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
static
void
static
void
AddUri
(
Client
&
client
,
const
LocatedUri
&
uri
)
AddUri
(
Client
&
client
,
const
LocatedUri
&
uri
)
{
{
auto
&
partition
=
client
.
partition
;
auto
&
partition
=
client
.
GetPartition
()
;
partition
.
playlist
.
AppendSong
(
partition
.
pc
,
partition
.
playlist
.
AppendSong
(
partition
.
pc
,
SongLoader
(
client
).
LoadSong
(
uri
));
SongLoader
(
client
).
LoadSong
(
uri
));
}
}
...
@@ -53,10 +53,11 @@ AddDatabaseSelection(Client &client, const char *uri,
...
@@ -53,10 +53,11 @@ AddDatabaseSelection(Client &client, const char *uri,
gcc_unused
Response
&
r
)
gcc_unused
Response
&
r
)
{
{
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
const
ScopeBulkEdit
bulk_edit
(
client
.
partition
);
auto
&
partition
=
client
.
GetPartition
();
const
ScopeBulkEdit
bulk_edit
(
partition
);
const
DatabaseSelection
selection
(
uri
,
true
);
const
DatabaseSelection
selection
(
uri
,
true
);
AddFromDatabase
(
client
.
partition
,
selection
);
AddFromDatabase
(
partition
,
selection
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
#else
#else
(
void
)
client
;
(
void
)
client
;
...
@@ -103,17 +104,18 @@ handle_addid(Client &client, Request args, Response &r)
...
@@ -103,17 +104,18 @@ handle_addid(Client &client, Request args, Response &r)
{
{
const
char
*
const
uri
=
args
.
front
();
const
char
*
const
uri
=
args
.
front
();
auto
&
partition
=
client
.
GetPartition
();
const
SongLoader
loader
(
client
);
const
SongLoader
loader
(
client
);
unsigned
added_id
=
client
.
partition
.
AppendURI
(
loader
,
uri
);
unsigned
added_id
=
partition
.
AppendURI
(
loader
,
uri
);
if
(
args
.
size
==
2
)
{
if
(
args
.
size
==
2
)
{
unsigned
to
=
args
.
ParseUnsigned
(
1
);
unsigned
to
=
args
.
ParseUnsigned
(
1
);
try
{
try
{
client
.
partition
.
MoveId
(
added_id
,
to
);
partition
.
MoveId
(
added_id
,
to
);
}
catch
(...)
{
}
catch
(...)
{
/* rollback */
/* rollback */
client
.
partition
.
DeleteId
(
added_id
);
partition
.
DeleteId
(
added_id
);
throw
;
throw
;
}
}
}
}
...
@@ -173,7 +175,7 @@ CommandResult
...
@@ -173,7 +175,7 @@ CommandResult
handle_delete
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_delete
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
RangeArg
range
=
args
.
ParseRange
(
0
);
RangeArg
range
=
args
.
ParseRange
(
0
);
client
.
partition
.
DeleteRange
(
range
.
start
,
range
.
end
);
client
.
GetPartition
()
.
DeleteRange
(
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -181,7 +183,7 @@ CommandResult
...
@@ -181,7 +183,7 @@ CommandResult
handle_deleteid
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_deleteid
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
unsigned
id
=
args
.
ParseUnsigned
(
0
);
client
.
partition
.
DeleteId
(
id
);
client
.
GetPartition
()
.
DeleteId
(
id
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -196,14 +198,14 @@ CommandResult
...
@@ -196,14 +198,14 @@ CommandResult
handle_shuffle
(
gcc_unused
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_shuffle
(
gcc_unused
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
RangeArg
range
=
args
.
ParseOptional
(
0
,
RangeArg
::
All
());
RangeArg
range
=
args
.
ParseOptional
(
0
,
RangeArg
::
All
());
client
.
partition
.
Shuffle
(
range
.
start
,
range
.
end
);
client
.
GetPartition
()
.
Shuffle
(
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
CommandResult
CommandResult
handle_clear
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
handle_clear
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
{
{
client
.
partition
.
ClearQueue
();
client
.
GetPartition
()
.
ClearQueue
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -283,10 +285,11 @@ handle_prio(Client &client, Request args, gcc_unused Response &r)
...
@@ -283,10 +285,11 @@ handle_prio(Client &client, Request args, gcc_unused Response &r)
unsigned
priority
=
args
.
ParseUnsigned
(
0
,
0xff
);
unsigned
priority
=
args
.
ParseUnsigned
(
0
,
0xff
);
args
.
shift
();
args
.
shift
();
auto
&
partition
=
client
.
GetPartition
();
for
(
const
char
*
i
:
args
)
{
for
(
const
char
*
i
:
args
)
{
RangeArg
range
=
ParseCommandArgRange
(
i
);
RangeArg
range
=
ParseCommandArgRange
(
i
);
client
.
partition
.
SetPriorityRange
(
range
.
start
,
range
.
end
,
partition
.
SetPriorityRange
(
range
.
start
,
range
.
end
,
priority
);
priority
);
}
}
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
@@ -298,9 +301,11 @@ handle_prioid(Client &client, Request args, gcc_unused Response &r)
...
@@ -298,9 +301,11 @@ handle_prioid(Client &client, Request args, gcc_unused Response &r)
unsigned
priority
=
args
.
ParseUnsigned
(
0
,
0xff
);
unsigned
priority
=
args
.
ParseUnsigned
(
0
,
0xff
);
args
.
shift
();
args
.
shift
();
auto
&
partition
=
client
.
GetPartition
();
for
(
const
char
*
i
:
args
)
{
for
(
const
char
*
i
:
args
)
{
unsigned
song_id
=
ParseCommandArgUnsigned
(
i
);
unsigned
song_id
=
ParseCommandArgUnsigned
(
i
);
client
.
partition
.
SetPriorityId
(
song_id
,
priority
);
partition
.
SetPriorityId
(
song_id
,
priority
);
}
}
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
@@ -311,7 +316,7 @@ handle_move(Client &client, Request args, gcc_unused Response &r)
...
@@ -311,7 +316,7 @@ handle_move(Client &client, Request args, gcc_unused Response &r)
{
{
RangeArg
range
=
args
.
ParseRange
(
0
);
RangeArg
range
=
args
.
ParseRange
(
0
);
int
to
=
args
.
ParseInt
(
1
);
int
to
=
args
.
ParseInt
(
1
);
client
.
partition
.
MoveRange
(
range
.
start
,
range
.
end
,
to
);
client
.
GetPartition
()
.
MoveRange
(
range
.
start
,
range
.
end
,
to
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -320,7 +325,7 @@ handle_moveid(Client &client, Request args, gcc_unused Response &r)
...
@@ -320,7 +325,7 @@ handle_moveid(Client &client, Request args, gcc_unused Response &r)
{
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
unsigned
id
=
args
.
ParseUnsigned
(
0
);
int
to
=
args
.
ParseInt
(
1
);
int
to
=
args
.
ParseInt
(
1
);
client
.
partition
.
MoveId
(
id
,
to
);
client
.
GetPartition
()
.
MoveId
(
id
,
to
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -329,7 +334,7 @@ handle_swap(Client &client, Request args, gcc_unused Response &r)
...
@@ -329,7 +334,7 @@ handle_swap(Client &client, Request args, gcc_unused Response &r)
{
{
unsigned
song1
=
args
.
ParseUnsigned
(
0
);
unsigned
song1
=
args
.
ParseUnsigned
(
0
);
unsigned
song2
=
args
.
ParseUnsigned
(
1
);
unsigned
song2
=
args
.
ParseUnsigned
(
1
);
client
.
partition
.
SwapPositions
(
song1
,
song2
);
client
.
GetPartition
()
.
SwapPositions
(
song1
,
song2
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -338,6 +343,6 @@ handle_swapid(Client &client, Request args, gcc_unused Response &r)
...
@@ -338,6 +343,6 @@ handle_swapid(Client &client, Request args, gcc_unused Response &r)
{
{
unsigned
id1
=
args
.
ParseUnsigned
(
0
);
unsigned
id1
=
args
.
ParseUnsigned
(
0
);
unsigned
id2
=
args
.
ParseUnsigned
(
1
);
unsigned
id2
=
args
.
ParseUnsigned
(
1
);
client
.
partition
.
SwapIds
(
id1
,
id2
);
client
.
GetPartition
()
.
SwapIds
(
id1
,
id2
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
src/command/StickerCommands.cxx
View file @
c7396b06
...
@@ -161,7 +161,7 @@ handle_sticker(Client &client, Request args, Response &r)
...
@@ -161,7 +161,7 @@ handle_sticker(Client &client, Request args, Response &r)
}
}
if
(
StringIsEqual
(
args
[
1
],
"song"
))
if
(
StringIsEqual
(
args
[
1
],
"song"
))
return
handle_sticker_song
(
r
,
client
.
partition
,
args
);
return
handle_sticker_song
(
r
,
client
.
GetPartition
()
,
args
);
else
{
else
{
r
.
Error
(
ACK_ERROR_ARG
,
"unknown sticker domain"
);
r
.
Error
(
ACK_ERROR_ARG
,
"unknown sticker domain"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
...
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