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
c772bc45
Commit
c772bc45
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlaylistError: convert playlist_result to a strictly-typed enum
parent
c1e7be3b
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
175 additions
and
178 deletions
+175
-178
CommandError.cxx
src/CommandError.cxx
+13
-13
CommandError.hxx
src/CommandError.hxx
+1
-1
DatabaseQueue.cxx
src/DatabaseQueue.cxx
+3
-3
Partition.hxx
src/Partition.hxx
+16
-16
PlayerCommands.cxx
src/PlayerCommands.cxx
+5
-5
Playlist.hxx
src/Playlist.hxx
+18
-18
PlaylistCommands.cxx
src/PlaylistCommands.cxx
+6
-9
PlaylistControl.cxx
src/PlaylistControl.cxx
+16
-16
PlaylistEdit.cxx
src/PlaylistEdit.cxx
+38
-38
PlaylistError.hxx
src/PlaylistError.hxx
+12
-12
PlaylistFile.cxx
src/PlaylistFile.cxx
+9
-9
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+7
-7
PlaylistQueue.hxx
src/PlaylistQueue.hxx
+2
-2
PlaylistSave.cxx
src/PlaylistSave.cxx
+11
-11
PlaylistSave.hxx
src/PlaylistSave.hxx
+2
-2
QueueCommands.cxx
src/QueueCommands.cxx
+16
-16
No files found.
src/CommandError.cxx
View file @
c772bc45
...
@@ -30,55 +30,55 @@
...
@@ -30,55 +30,55 @@
#include <errno.h>
#include <errno.h>
enum
command_return
enum
command_return
print_playlist_result
(
Client
&
client
,
enum
playlist_r
esult
result
)
print_playlist_result
(
Client
&
client
,
PlaylistR
esult
result
)
{
{
switch
(
result
)
{
switch
(
result
)
{
case
P
LAYLIST_RESULT_
SUCCESS
:
case
P
laylistResult
:
:
SUCCESS
:
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
case
P
LAYLIST_RESULT_
ERRNO
:
case
P
laylistResult
:
:
ERRNO
:
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"%s"
,
g_strerror
(
errno
));
g_strerror
(
errno
));
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
DENIED
:
case
P
laylistResult
:
:
DENIED
:
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Access denied"
);
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Access denied"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
NO_SUCH_SONG
:
case
P
laylistResult
:
:
NO_SUCH_SONG
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such song"
);
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such song"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
NO_SUCH_LIST
:
case
P
laylistResult
:
:
NO_SUCH_LIST
:
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such playlist"
);
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"No such playlist"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
LIST_EXISTS
:
case
P
laylistResult
:
:
LIST_EXISTS
:
command_error
(
client
,
ACK_ERROR_EXIST
,
command_error
(
client
,
ACK_ERROR_EXIST
,
"Playlist already exists"
);
"Playlist already exists"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
BAD_NAME
:
case
P
laylistResult
:
:
BAD_NAME
:
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"playlist name is invalid: "
"playlist name is invalid: "
"playlist names may not contain slashes,"
"playlist names may not contain slashes,"
" newlines or carriage returns"
);
" newlines or carriage returns"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
BAD_RANGE
:
case
P
laylistResult
:
:
BAD_RANGE
:
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad song index"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad song index"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
NOT_PLAYING
:
case
P
laylistResult
:
:
NOT_PLAYING
:
command_error
(
client
,
ACK_ERROR_PLAYER_SYNC
,
"Not playing"
);
command_error
(
client
,
ACK_ERROR_PLAYER_SYNC
,
"Not playing"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
TOO_LARGE
:
case
P
laylistResult
:
:
TOO_LARGE
:
command_error
(
client
,
ACK_ERROR_PLAYLIST_MAX
,
command_error
(
client
,
ACK_ERROR_PLAYLIST_MAX
,
"playlist is at the max size"
);
"playlist is at the max size"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
case
P
LAYLIST_RESULT_
DISABLED
:
case
P
laylistResult
:
:
DISABLED
:
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"stored playlist support is disabled"
);
"stored playlist support is disabled"
);
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
...
@@ -97,7 +97,7 @@ print_error(Client &client, const Error &error)
...
@@ -97,7 +97,7 @@ print_error(Client &client, const Error &error)
if
(
error
.
IsDomain
(
playlist_domain
))
{
if
(
error
.
IsDomain
(
playlist_domain
))
{
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
playlist_r
esult
(
error
.
GetCode
()));
PlaylistR
esult
(
error
.
GetCode
()));
}
else
if
(
error
.
IsDomain
(
ack_domain
))
{
}
else
if
(
error
.
IsDomain
(
ack_domain
))
{
command_error
(
client
,
(
ack
)
error
.
GetCode
(),
command_error
(
client
,
(
ack
)
error
.
GetCode
(),
"%s"
,
error
.
GetMessage
());
"%s"
,
error
.
GetMessage
());
...
...
src/CommandError.hxx
View file @
c772bc45
...
@@ -27,7 +27,7 @@ class Client;
...
@@ -27,7 +27,7 @@ class Client;
class
Error
;
class
Error
;
enum
command_return
enum
command_return
print_playlist_result
(
Client
&
client
,
enum
playlist_r
esult
result
);
print_playlist_result
(
Client
&
client
,
PlaylistR
esult
result
);
/**
/**
* Send the #Error to the client.
* Send the #Error to the client.
...
...
src/DatabaseQueue.cxx
View file @
c772bc45
...
@@ -30,10 +30,10 @@
...
@@ -30,10 +30,10 @@
static
bool
static
bool
AddToQueue
(
Partition
&
partition
,
Song
&
song
,
Error
&
error
)
AddToQueue
(
Partition
&
partition
,
Song
&
song
,
Error
&
error
)
{
{
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
partition
.
playlist
.
AppendSong
(
partition
.
pc
,
&
song
,
NULL
);
partition
.
playlist
.
AppendSong
(
partition
.
pc
,
&
song
,
NULL
);
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
{
if
(
result
!=
P
laylistResult
::
SUCCESS
)
{
error
.
Set
(
playlist_domain
,
result
,
"Playlist error"
);
error
.
Set
(
playlist_domain
,
int
(
result
)
,
"Playlist error"
);
return
false
;
return
false
;
}
}
...
...
src/Partition.hxx
View file @
c772bc45
...
@@ -48,21 +48,21 @@ struct Partition {
...
@@ -48,21 +48,21 @@ struct Partition {
playlist
.
Clear
(
pc
);
playlist
.
Clear
(
pc
);
}
}
enum
playlist_r
esult
AppendFile
(
const
char
*
path_utf8
,
PlaylistR
esult
AppendFile
(
const
char
*
path_utf8
,
unsigned
*
added_id
=
nullptr
)
{
unsigned
*
added_id
=
nullptr
)
{
return
playlist
.
AppendFile
(
pc
,
path_utf8
,
added_id
);
return
playlist
.
AppendFile
(
pc
,
path_utf8
,
added_id
);
}
}
enum
playlist_r
esult
AppendURI
(
const
char
*
uri_utf8
,
PlaylistR
esult
AppendURI
(
const
char
*
uri_utf8
,
unsigned
*
added_id
=
nullptr
)
{
unsigned
*
added_id
=
nullptr
)
{
return
playlist
.
AppendURI
(
pc
,
uri_utf8
,
added_id
);
return
playlist
.
AppendURI
(
pc
,
uri_utf8
,
added_id
);
}
}
enum
playlist_r
esult
DeletePosition
(
unsigned
position
)
{
PlaylistR
esult
DeletePosition
(
unsigned
position
)
{
return
playlist
.
DeletePosition
(
pc
,
position
);
return
playlist
.
DeletePosition
(
pc
,
position
);
}
}
enum
playlist_r
esult
DeleteId
(
unsigned
id
)
{
PlaylistR
esult
DeleteId
(
unsigned
id
)
{
return
playlist
.
DeleteId
(
pc
,
id
);
return
playlist
.
DeleteId
(
pc
,
id
);
}
}
...
@@ -72,7 +72,7 @@ struct Partition {
...
@@ -72,7 +72,7 @@ struct Partition {
* @param start the position of the first song to delete
* @param start the position of the first song to delete
* @param end the position after the last song to delete
* @param end the position after the last song to delete
*/
*/
enum
playlist_r
esult
DeleteRange
(
unsigned
start
,
unsigned
end
)
{
PlaylistR
esult
DeleteRange
(
unsigned
start
,
unsigned
end
)
{
return
playlist
.
DeleteRange
(
pc
,
start
,
end
);
return
playlist
.
DeleteRange
(
pc
,
start
,
end
);
}
}
...
@@ -84,23 +84,23 @@ struct Partition {
...
@@ -84,23 +84,23 @@ struct Partition {
playlist
.
Shuffle
(
pc
,
start
,
end
);
playlist
.
Shuffle
(
pc
,
start
,
end
);
}
}
enum
playlist_r
esult
MoveRange
(
unsigned
start
,
unsigned
end
,
int
to
)
{
PlaylistR
esult
MoveRange
(
unsigned
start
,
unsigned
end
,
int
to
)
{
return
playlist
.
MoveRange
(
pc
,
start
,
end
,
to
);
return
playlist
.
MoveRange
(
pc
,
start
,
end
,
to
);
}
}
enum
playlist_r
esult
MoveId
(
unsigned
id
,
int
to
)
{
PlaylistR
esult
MoveId
(
unsigned
id
,
int
to
)
{
return
playlist
.
MoveId
(
pc
,
id
,
to
);
return
playlist
.
MoveId
(
pc
,
id
,
to
);
}
}
enum
playlist_r
esult
SwapPositions
(
unsigned
song1
,
unsigned
song2
)
{
PlaylistR
esult
SwapPositions
(
unsigned
song1
,
unsigned
song2
)
{
return
playlist
.
SwapPositions
(
pc
,
song1
,
song2
);
return
playlist
.
SwapPositions
(
pc
,
song1
,
song2
);
}
}
enum
playlist_r
esult
SwapIds
(
unsigned
id1
,
unsigned
id2
)
{
PlaylistR
esult
SwapIds
(
unsigned
id1
,
unsigned
id2
)
{
return
playlist
.
SwapIds
(
pc
,
id1
,
id2
);
return
playlist
.
SwapIds
(
pc
,
id1
,
id2
);
}
}
enum
playlist_r
esult
SetPriorityRange
(
unsigned
start_position
,
PlaylistR
esult
SetPriorityRange
(
unsigned
start_position
,
unsigned
end_position
,
unsigned
end_position
,
uint8_t
priority
)
{
uint8_t
priority
)
{
return
playlist
.
SetPriorityRange
(
pc
,
return
playlist
.
SetPriorityRange
(
pc
,
...
@@ -108,7 +108,7 @@ struct Partition {
...
@@ -108,7 +108,7 @@ struct Partition {
priority
);
priority
);
}
}
enum
playlist_r
esult
SetPriorityId
(
unsigned
song_id
,
PlaylistR
esult
SetPriorityId
(
unsigned
song_id
,
uint8_t
priority
)
{
uint8_t
priority
)
{
return
playlist
.
SetPriorityId
(
pc
,
song_id
,
priority
);
return
playlist
.
SetPriorityId
(
pc
,
song_id
,
priority
);
}
}
...
@@ -117,11 +117,11 @@ struct Partition {
...
@@ -117,11 +117,11 @@ struct Partition {
playlist
.
Stop
(
pc
);
playlist
.
Stop
(
pc
);
}
}
enum
playlist_r
esult
PlayPosition
(
int
position
)
{
PlaylistR
esult
PlayPosition
(
int
position
)
{
return
playlist
.
PlayPosition
(
pc
,
position
);
return
playlist
.
PlayPosition
(
pc
,
position
);
}
}
enum
playlist_r
esult
PlayId
(
int
id
)
{
PlaylistR
esult
PlayId
(
int
id
)
{
return
playlist
.
PlayId
(
pc
,
id
);
return
playlist
.
PlayId
(
pc
,
id
);
}
}
...
@@ -133,16 +133,16 @@ struct Partition {
...
@@ -133,16 +133,16 @@ struct Partition {
return
playlist
.
PlayPrevious
(
pc
);
return
playlist
.
PlayPrevious
(
pc
);
}
}
enum
playlist_r
esult
SeekSongPosition
(
unsigned
song_position
,
PlaylistR
esult
SeekSongPosition
(
unsigned
song_position
,
float
seek_time
)
{
float
seek_time
)
{
return
playlist
.
SeekSongPosition
(
pc
,
song_position
,
seek_time
);
return
playlist
.
SeekSongPosition
(
pc
,
song_position
,
seek_time
);
}
}
enum
playlist_r
esult
SeekSongId
(
unsigned
song_id
,
float
seek_time
)
{
PlaylistR
esult
SeekSongId
(
unsigned
song_id
,
float
seek_time
)
{
return
playlist
.
SeekSongId
(
pc
,
song_id
,
seek_time
);
return
playlist
.
SeekSongId
(
pc
,
song_id
,
seek_time
);
}
}
enum
playlist_r
esult
SeekCurrent
(
float
seek_time
,
bool
relative
)
{
PlaylistR
esult
SeekCurrent
(
float
seek_time
,
bool
relative
)
{
return
playlist
.
SeekCurrent
(
pc
,
seek_time
,
relative
);
return
playlist
.
SeekCurrent
(
pc
,
seek_time
,
relative
);
}
}
...
...
src/PlayerCommands.cxx
View file @
c772bc45
...
@@ -59,7 +59,7 @@ handle_play(Client &client, int argc, char *argv[])
...
@@ -59,7 +59,7 @@ handle_play(Client &client, int argc, char *argv[])
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
PlayPosition
(
song
);
PlaylistR
esult
result
=
client
.
partition
.
PlayPosition
(
song
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -71,7 +71,7 @@ handle_playid(Client &client, int argc, char *argv[])
...
@@ -71,7 +71,7 @@ handle_playid(Client &client, int argc, char *argv[])
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
PlayId
(
id
);
PlaylistR
esult
result
=
client
.
partition
.
PlayId
(
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -293,7 +293,7 @@ handle_seek(Client &client, gcc_unused int argc, char *argv[])
...
@@ -293,7 +293,7 @@ handle_seek(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -308,7 +308,7 @@ handle_seekid(Client &client, gcc_unused int argc, char *argv[])
...
@@ -308,7 +308,7 @@ handle_seekid(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
seek_time
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -322,7 +322,7 @@ handle_seekcur(Client &client, gcc_unused int argc, char *argv[])
...
@@ -322,7 +322,7 @@ handle_seekcur(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_int
(
client
,
&
seek_time
,
p
))
if
(
!
check_int
(
client
,
&
seek_time
,
p
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
...
src/Playlist.hxx
View file @
c772bc45
...
@@ -132,7 +132,7 @@ public:
...
@@ -132,7 +132,7 @@ public:
void
FullIncrementVersions
();
void
FullIncrementVersions
();
enum
playlist_r
esult
AppendSong
(
player_control
&
pc
,
PlaylistR
esult
AppendSong
(
player_control
&
pc
,
Song
*
song
,
Song
*
song
,
unsigned
*
added_id
=
nullptr
);
unsigned
*
added_id
=
nullptr
);
...
@@ -142,11 +142,11 @@ public:
...
@@ -142,11 +142,11 @@ public:
*
*
* Note: the caller is responsible for checking permissions.
* Note: the caller is responsible for checking permissions.
*/
*/
enum
playlist_r
esult
AppendFile
(
player_control
&
pc
,
PlaylistR
esult
AppendFile
(
player_control
&
pc
,
const
char
*
path_utf8
,
const
char
*
path_utf8
,
unsigned
*
added_id
=
nullptr
);
unsigned
*
added_id
=
nullptr
);
enum
playlist_r
esult
AppendURI
(
player_control
&
pc
,
PlaylistR
esult
AppendURI
(
player_control
&
pc
,
const
char
*
uri_utf8
,
const
char
*
uri_utf8
,
unsigned
*
added_id
=
nullptr
);
unsigned
*
added_id
=
nullptr
);
...
@@ -155,15 +155,15 @@ protected:
...
@@ -155,15 +155,15 @@ protected:
unsigned
song
,
const
Song
**
queued_p
);
unsigned
song
,
const
Song
**
queued_p
);
public
:
public
:
enum
playlist_r
esult
DeletePosition
(
player_control
&
pc
,
PlaylistR
esult
DeletePosition
(
player_control
&
pc
,
unsigned
position
);
unsigned
position
);
enum
playlist_r
esult
DeleteOrder
(
player_control
&
pc
,
PlaylistR
esult
DeleteOrder
(
player_control
&
pc
,
unsigned
order
)
{
unsigned
order
)
{
return
DeletePosition
(
pc
,
queue
.
OrderToPosition
(
order
));
return
DeletePosition
(
pc
,
queue
.
OrderToPosition
(
order
));
}
}
enum
playlist_r
esult
DeleteId
(
player_control
&
pc
,
unsigned
id
);
PlaylistR
esult
DeleteId
(
player_control
&
pc
,
unsigned
id
);
/**
/**
* Deletes a range of songs from the playlist.
* Deletes a range of songs from the playlist.
...
@@ -171,49 +171,49 @@ public:
...
@@ -171,49 +171,49 @@ public:
* @param start the position of the first song to delete
* @param start the position of the first song to delete
* @param end the position after the last song to delete
* @param end the position after the last song to delete
*/
*/
enum
playlist_r
esult
DeleteRange
(
player_control
&
pc
,
PlaylistR
esult
DeleteRange
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
);
unsigned
start
,
unsigned
end
);
void
DeleteSong
(
player_control
&
pc
,
const
Song
&
song
);
void
DeleteSong
(
player_control
&
pc
,
const
Song
&
song
);
void
Shuffle
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
);
void
Shuffle
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
);
enum
playlist_r
esult
MoveRange
(
player_control
&
pc
,
PlaylistR
esult
MoveRange
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
,
int
to
);
unsigned
start
,
unsigned
end
,
int
to
);
enum
playlist_r
esult
MoveId
(
player_control
&
pc
,
unsigned
id
,
int
to
);
PlaylistR
esult
MoveId
(
player_control
&
pc
,
unsigned
id
,
int
to
);
enum
playlist_r
esult
SwapPositions
(
player_control
&
pc
,
PlaylistR
esult
SwapPositions
(
player_control
&
pc
,
unsigned
song1
,
unsigned
song2
);
unsigned
song1
,
unsigned
song2
);
enum
playlist_r
esult
SwapIds
(
player_control
&
pc
,
PlaylistR
esult
SwapIds
(
player_control
&
pc
,
unsigned
id1
,
unsigned
id2
);
unsigned
id1
,
unsigned
id2
);
enum
playlist_r
esult
SetPriorityRange
(
player_control
&
pc
,
PlaylistR
esult
SetPriorityRange
(
player_control
&
pc
,
unsigned
start_position
,
unsigned
start_position
,
unsigned
end_position
,
unsigned
end_position
,
uint8_t
priority
);
uint8_t
priority
);
enum
playlist_r
esult
SetPriorityId
(
player_control
&
pc
,
PlaylistR
esult
SetPriorityId
(
player_control
&
pc
,
unsigned
song_id
,
uint8_t
priority
);
unsigned
song_id
,
uint8_t
priority
);
void
Stop
(
player_control
&
pc
);
void
Stop
(
player_control
&
pc
);
enum
playlist_r
esult
PlayPosition
(
player_control
&
pc
,
int
position
);
PlaylistR
esult
PlayPosition
(
player_control
&
pc
,
int
position
);
void
PlayOrder
(
player_control
&
pc
,
int
order
);
void
PlayOrder
(
player_control
&
pc
,
int
order
);
enum
playlist_r
esult
PlayId
(
player_control
&
pc
,
int
id
);
PlaylistR
esult
PlayId
(
player_control
&
pc
,
int
id
);
void
PlayNext
(
player_control
&
pc
);
void
PlayNext
(
player_control
&
pc
);
void
PlayPrevious
(
player_control
&
pc
);
void
PlayPrevious
(
player_control
&
pc
);
enum
playlist_r
esult
SeekSongPosition
(
player_control
&
pc
,
PlaylistR
esult
SeekSongPosition
(
player_control
&
pc
,
unsigned
song_position
,
unsigned
song_position
,
float
seek_time
);
float
seek_time
);
enum
playlist_r
esult
SeekSongId
(
player_control
&
pc
,
PlaylistR
esult
SeekSongId
(
player_control
&
pc
,
unsigned
song_id
,
float
seek_time
);
unsigned
song_id
,
float
seek_time
);
/**
/**
...
@@ -224,7 +224,7 @@ public:
...
@@ -224,7 +224,7 @@ public:
* @param relative if true, then the specified time is relative to the
* @param relative if true, then the specified time is relative to the
* current position
* current position
*/
*/
enum
playlist_r
esult
SeekCurrent
(
player_control
&
pc
,
PlaylistR
esult
SeekCurrent
(
player_control
&
pc
,
float
seek_time
,
bool
relative
);
float
seek_time
,
bool
relative
);
bool
GetRepeat
()
const
{
bool
GetRepeat
()
const
{
...
...
src/PlaylistCommands.cxx
View file @
c772bc45
...
@@ -52,9 +52,7 @@ print_spl_list(Client &client, const PlaylistVector &list)
...
@@ -52,9 +52,7 @@ print_spl_list(Client &client, const PlaylistVector &list)
enum
command_return
enum
command_return
handle_save
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_save
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
PlaylistResult
result
=
spl_save_playlist
(
argv
[
1
],
client
.
playlist
);
result
=
spl_save_playlist
(
argv
[
1
],
client
.
playlist
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -69,13 +67,12 @@ handle_load(Client &client, int argc, char *argv[])
...
@@ -69,13 +67,12 @@ handle_load(Client &client, int argc, char *argv[])
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
argv
[
2
]))
}
else
if
(
!
check_range
(
client
,
&
start_index
,
&
end_index
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
;
const
PlaylistResult
result
=
playlist_open_into_queue
(
argv
[
1
],
result
=
playlist_open_into_queue
(
argv
[
1
],
start_index
,
end_index
,
start_index
,
end_index
,
client
.
playlist
,
client
.
playlist
,
client
.
player_control
,
true
);
client
.
player_control
,
true
);
if
(
result
!=
P
LAYLIST_RESULT_
NO_SUCH_LIST
)
if
(
result
!=
P
laylistResult
::
NO_SUCH_LIST
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
Error
error
;
Error
error
;
...
@@ -85,12 +82,12 @@ handle_load(Client &client, int argc, char *argv[])
...
@@ -85,12 +82,12 @@ handle_load(Client &client, int argc, char *argv[])
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
if
(
error
.
IsDomain
(
playlist_domain
)
&&
if
(
error
.
IsDomain
(
playlist_domain
)
&&
error
.
GetCode
()
==
PLAYLIST_RESULT_
BAD_NAME
)
{
PlaylistResult
(
error
.
GetCode
())
==
PlaylistResult
::
BAD_NAME
)
{
/* the message for BAD_NAME is confusing when the
/* the message for BAD_NAME is confusing when the
client wants to load a playlist file from the music
client wants to load a playlist file from the music
directory; patch the Error object to show "no such
directory; patch the Error object to show "no such
playlist" instead */
playlist" instead */
Error
error2
(
playlist_domain
,
PLAYLIST_RESULT_NO_SUCH_LIST
,
Error
error2
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_LIST
)
,
error
.
GetMessage
());
error
.
GetMessage
());
error
=
std
::
move
(
error2
);
error
=
std
::
move
(
error2
);
}
}
...
...
src/PlaylistControl.cxx
View file @
c772bc45
...
@@ -56,7 +56,7 @@ playlist::Stop(player_control &pc)
...
@@ -56,7 +56,7 @@ playlist::Stop(player_control &pc)
}
}
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
PlayPosition
(
player_control
&
pc
,
int
song
)
playlist
::
PlayPosition
(
player_control
&
pc
,
int
song
)
{
{
pc
.
ClearError
();
pc
.
ClearError
();
...
@@ -66,13 +66,13 @@ playlist::PlayPosition(player_control &pc, int song)
...
@@ -66,13 +66,13 @@ playlist::PlayPosition(player_control &pc, int song)
/* play any song ("current" song, or the first song */
/* play any song ("current" song, or the first song */
if
(
queue
.
IsEmpty
())
if
(
queue
.
IsEmpty
())
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
if
(
playing
)
{
if
(
playing
)
{
/* already playing: unpause playback, just in
/* already playing: unpause playback, just in
case it was paused, and return */
case it was paused, and return */
pc
.
SetPause
(
false
);
pc
.
SetPause
(
false
);
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
/* select a song: "current" song, or the first one */
/* select a song: "current" song, or the first one */
...
@@ -80,7 +80,7 @@ playlist::PlayPosition(player_control &pc, int song)
...
@@ -80,7 +80,7 @@ playlist::PlayPosition(player_control &pc, int song)
?
current
?
current
:
0
;
:
0
;
}
else
if
(
!
queue
.
IsValidPosition
(
song
))
}
else
if
(
!
queue
.
IsValidPosition
(
song
))
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
(
queue
.
random
)
{
if
(
queue
.
random
)
{
if
(
song
>=
0
)
if
(
song
>=
0
)
...
@@ -103,10 +103,10 @@ playlist::PlayPosition(player_control &pc, int song)
...
@@ -103,10 +103,10 @@ playlist::PlayPosition(player_control &pc, int song)
error_count
=
0
;
error_count
=
0
;
PlayOrder
(
pc
,
i
);
PlayOrder
(
pc
,
i
);
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
PlayId
(
player_control
&
pc
,
int
id
)
playlist
::
PlayId
(
player_control
&
pc
,
int
id
)
{
{
if
(
id
==
-
1
)
if
(
id
==
-
1
)
...
@@ -114,7 +114,7 @@ playlist::PlayId(player_control &pc, int id)
...
@@ -114,7 +114,7 @@ playlist::PlayId(player_control &pc, int id)
int
song
=
queue
.
IdToPosition
(
id
);
int
song
=
queue
.
IdToPosition
(
id
);
if
(
song
<
0
)
if
(
song
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
PlayPosition
(
pc
,
song
);
return
PlayPosition
(
pc
,
song
);
}
}
...
@@ -189,11 +189,11 @@ playlist::PlayPrevious(player_control &pc)
...
@@ -189,11 +189,11 @@ playlist::PlayPrevious(player_control &pc)
PlayOrder
(
pc
,
order
);
PlayOrder
(
pc
,
order
);
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SeekSongPosition
(
player_control
&
pc
,
unsigned
song
,
float
seek_time
)
playlist
::
SeekSongPosition
(
player_control
&
pc
,
unsigned
song
,
float
seek_time
)
{
{
if
(
!
queue
.
IsValidPosition
(
song
))
if
(
!
queue
.
IsValidPosition
(
song
))
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
const
Song
*
queued_song
=
GetQueuedSong
();
const
Song
*
queued_song
=
GetQueuedSong
();
...
@@ -219,37 +219,37 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
...
@@ -219,37 +219,37 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
if
(
!
pc
.
Seek
(
the_song
,
seek_time
))
{
if
(
!
pc
.
Seek
(
the_song
,
seek_time
))
{
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
return
P
LAYLIST_RESULT_
NOT_PLAYING
;
return
P
laylistResult
::
NOT_PLAYING
;
}
}
queued
=
-
1
;
queued
=
-
1
;
UpdateQueuedSong
(
pc
,
nullptr
);
UpdateQueuedSong
(
pc
,
nullptr
);
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SeekSongId
(
player_control
&
pc
,
unsigned
id
,
float
seek_time
)
playlist
::
SeekSongId
(
player_control
&
pc
,
unsigned
id
,
float
seek_time
)
{
{
int
song
=
queue
.
IdToPosition
(
id
);
int
song
=
queue
.
IdToPosition
(
id
);
if
(
song
<
0
)
if
(
song
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
SeekSongPosition
(
pc
,
song
,
seek_time
);
return
SeekSongPosition
(
pc
,
song
,
seek_time
);
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SeekCurrent
(
player_control
&
pc
,
float
seek_time
,
bool
relative
)
playlist
::
SeekCurrent
(
player_control
&
pc
,
float
seek_time
,
bool
relative
)
{
{
if
(
!
playing
)
if
(
!
playing
)
return
P
LAYLIST_RESULT_
NOT_PLAYING
;
return
P
laylistResult
::
NOT_PLAYING
;
if
(
relative
)
{
if
(
relative
)
{
const
auto
status
=
pc
.
GetStatus
();
const
auto
status
=
pc
.
GetStatus
();
if
(
status
.
state
!=
PlayerState
::
PLAY
&&
if
(
status
.
state
!=
PlayerState
::
PLAY
&&
status
.
state
!=
PlayerState
::
PAUSE
)
status
.
state
!=
PlayerState
::
PAUSE
)
return
P
LAYLIST_RESULT_
NOT_PLAYING
;
return
P
laylistResult
::
NOT_PLAYING
;
seek_time
+=
(
int
)
status
.
elapsed_time
;
seek_time
+=
(
int
)
status
.
elapsed_time
;
}
}
...
...
src/PlaylistEdit.cxx
View file @
c772bc45
...
@@ -56,27 +56,27 @@ playlist::Clear(player_control &pc)
...
@@ -56,27 +56,27 @@ playlist::Clear(player_control &pc)
OnModified
();
OnModified
();
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
AppendFile
(
struct
player_control
&
pc
,
playlist
::
AppendFile
(
struct
player_control
&
pc
,
const
char
*
path_utf8
,
unsigned
*
added_id
)
const
char
*
path_utf8
,
unsigned
*
added_id
)
{
{
Song
*
song
=
Song
::
LoadFile
(
path_utf8
,
nullptr
);
Song
*
song
=
Song
::
LoadFile
(
path_utf8
,
nullptr
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
const
auto
result
=
AppendSong
(
pc
,
song
,
added_id
);
const
auto
result
=
AppendSong
(
pc
,
song
,
added_id
);
song
->
Free
();
song
->
Free
();
return
result
;
return
result
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
AppendSong
(
struct
player_control
&
pc
,
playlist
::
AppendSong
(
struct
player_control
&
pc
,
Song
*
song
,
unsigned
*
added_id
)
Song
*
song
,
unsigned
*
added_id
)
{
{
unsigned
id
;
unsigned
id
;
if
(
queue
.
IsFull
())
if
(
queue
.
IsFull
())
return
P
LAYLIST_RESULT_
TOO_LARGE
;
return
P
laylistResult
::
TOO_LARGE
;
const
Song
*
const
queued_song
=
GetQueuedSong
();
const
Song
*
const
queued_song
=
GetQueuedSong
();
...
@@ -101,10 +101,10 @@ playlist::AppendSong(struct player_control &pc,
...
@@ -101,10 +101,10 @@ playlist::AppendSong(struct player_control &pc,
if
(
added_id
)
if
(
added_id
)
*
added_id
=
id
;
*
added_id
=
id
;
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
AppendURI
(
struct
player_control
&
pc
,
playlist
::
AppendURI
(
struct
player_control
&
pc
,
const
char
*
uri
,
unsigned
*
added_id
)
const
char
*
uri
,
unsigned
*
added_id
)
{
{
...
@@ -117,14 +117,14 @@ playlist::AppendURI(struct player_control &pc,
...
@@ -117,14 +117,14 @@ playlist::AppendURI(struct player_control &pc,
}
else
{
}
else
{
db
=
GetDatabase
(
IgnoreError
());
db
=
GetDatabase
(
IgnoreError
());
if
(
db
==
nullptr
)
if
(
db
==
nullptr
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
song
=
db
->
GetSong
(
uri
,
IgnoreError
());
song
=
db
->
GetSong
(
uri
,
IgnoreError
());
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
}
}
enum
playlist_r
esult
result
=
AppendSong
(
pc
,
song
,
added_id
);
PlaylistR
esult
result
=
AppendSong
(
pc
,
song
,
added_id
);
if
(
db
!=
nullptr
)
if
(
db
!=
nullptr
)
db
->
ReturnSong
(
song
);
db
->
ReturnSong
(
song
);
else
else
...
@@ -133,11 +133,11 @@ playlist::AppendURI(struct player_control &pc,
...
@@ -133,11 +133,11 @@ playlist::AppendURI(struct player_control &pc,
return
result
;
return
result
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SwapPositions
(
player_control
&
pc
,
unsigned
song1
,
unsigned
song2
)
playlist
::
SwapPositions
(
player_control
&
pc
,
unsigned
song1
,
unsigned
song2
)
{
{
if
(
!
queue
.
IsValidPosition
(
song1
)
||
!
queue
.
IsValidPosition
(
song2
))
if
(
!
queue
.
IsValidPosition
(
song1
)
||
!
queue
.
IsValidPosition
(
song2
))
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
const
Song
*
const
queued_song
=
GetQueuedSong
();
const
Song
*
const
queued_song
=
GetQueuedSong
();
...
@@ -161,34 +161,34 @@ playlist::SwapPositions(player_control &pc, unsigned song1, unsigned song2)
...
@@ -161,34 +161,34 @@ playlist::SwapPositions(player_control &pc, unsigned song1, unsigned song2)
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
OnModified
();
OnModified
();
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SwapIds
(
player_control
&
pc
,
unsigned
id1
,
unsigned
id2
)
playlist
::
SwapIds
(
player_control
&
pc
,
unsigned
id1
,
unsigned
id2
)
{
{
int
song1
=
queue
.
IdToPosition
(
id1
);
int
song1
=
queue
.
IdToPosition
(
id1
);
int
song2
=
queue
.
IdToPosition
(
id2
);
int
song2
=
queue
.
IdToPosition
(
id2
);
if
(
song1
<
0
||
song2
<
0
)
if
(
song1
<
0
||
song2
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
SwapPositions
(
pc
,
song1
,
song2
);
return
SwapPositions
(
pc
,
song1
,
song2
);
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SetPriorityRange
(
player_control
&
pc
,
playlist
::
SetPriorityRange
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
,
unsigned
start
,
unsigned
end
,
uint8_t
priority
)
uint8_t
priority
)
{
{
if
(
start
>=
GetLength
())
if
(
start
>=
GetLength
())
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
(
end
>
GetLength
())
if
(
end
>
GetLength
())
end
=
GetLength
();
end
=
GetLength
();
if
(
start
>=
end
)
if
(
start
>=
end
)
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
/* remember "current" and "queued" */
/* remember "current" and "queued" */
...
@@ -207,16 +207,16 @@ playlist::SetPriorityRange(player_control &pc,
...
@@ -207,16 +207,16 @@ playlist::SetPriorityRange(player_control &pc,
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
OnModified
();
OnModified
();
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
SetPriorityId
(
struct
player_control
&
pc
,
playlist
::
SetPriorityId
(
struct
player_control
&
pc
,
unsigned
song_id
,
uint8_t
priority
)
unsigned
song_id
,
uint8_t
priority
)
{
{
int
song_position
=
queue
.
IdToPosition
(
song_id
);
int
song_position
=
queue
.
IdToPosition
(
song_id
);
if
(
song_position
<
0
)
if
(
song_position
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
SetPriorityRange
(
pc
,
song_position
,
song_position
+
1
,
return
SetPriorityRange
(
pc
,
song_position
,
song_position
+
1
,
priority
);
priority
);
...
@@ -269,11 +269,11 @@ playlist::DeleteInternal(player_control &pc,
...
@@ -269,11 +269,11 @@ playlist::DeleteInternal(player_control &pc,
current
--
;
current
--
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
DeletePosition
(
struct
player_control
&
pc
,
unsigned
song
)
playlist
::
DeletePosition
(
struct
player_control
&
pc
,
unsigned
song
)
{
{
if
(
song
>=
queue
.
GetLength
())
if
(
song
>=
queue
.
GetLength
())
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
const
Song
*
queued_song
=
GetQueuedSong
();
const
Song
*
queued_song
=
GetQueuedSong
();
...
@@ -282,20 +282,20 @@ playlist::DeletePosition(struct player_control &pc, unsigned song)
...
@@ -282,20 +282,20 @@ playlist::DeletePosition(struct player_control &pc, unsigned song)
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
OnModified
();
OnModified
();
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
DeleteRange
(
struct
player_control
&
pc
,
unsigned
start
,
unsigned
end
)
playlist
::
DeleteRange
(
struct
player_control
&
pc
,
unsigned
start
,
unsigned
end
)
{
{
if
(
start
>=
queue
.
GetLength
())
if
(
start
>=
queue
.
GetLength
())
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
(
end
>
queue
.
GetLength
())
if
(
end
>
queue
.
GetLength
())
end
=
queue
.
GetLength
();
end
=
queue
.
GetLength
();
if
(
start
>=
end
)
if
(
start
>=
end
)
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
const
Song
*
queued_song
=
GetQueuedSong
();
const
Song
*
queued_song
=
GetQueuedSong
();
...
@@ -306,15 +306,15 @@ playlist::DeleteRange(struct player_control &pc, unsigned start, unsigned end)
...
@@ -306,15 +306,15 @@ playlist::DeleteRange(struct player_control &pc, unsigned start, unsigned end)
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
OnModified
();
OnModified
();
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
DeleteId
(
struct
player_control
&
pc
,
unsigned
id
)
playlist
::
DeleteId
(
struct
player_control
&
pc
,
unsigned
id
)
{
{
int
song
=
queue
.
IdToPosition
(
id
);
int
song
=
queue
.
IdToPosition
(
id
);
if
(
song
<
0
)
if
(
song
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
DeletePosition
(
pc
,
song
);
return
DeletePosition
(
pc
,
song
);
}
}
...
@@ -328,19 +328,19 @@ playlist::DeleteSong(struct player_control &pc, const struct Song &song)
...
@@ -328,19 +328,19 @@ playlist::DeleteSong(struct player_control &pc, const struct Song &song)
DeletePosition
(
pc
,
i
);
DeletePosition
(
pc
,
i
);
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
MoveRange
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
,
int
to
)
playlist
::
MoveRange
(
player_control
&
pc
,
unsigned
start
,
unsigned
end
,
int
to
)
{
{
if
(
!
queue
.
IsValidPosition
(
start
)
||
!
queue
.
IsValidPosition
(
end
-
1
))
if
(
!
queue
.
IsValidPosition
(
start
)
||
!
queue
.
IsValidPosition
(
end
-
1
))
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
((
to
>=
0
&&
to
+
end
-
start
-
1
>=
GetLength
())
||
if
((
to
>=
0
&&
to
+
end
-
start
-
1
>=
GetLength
())
||
(
to
<
0
&&
unsigned
(
abs
(
to
))
>
GetLength
()))
(
to
<
0
&&
unsigned
(
abs
(
to
))
>
GetLength
()))
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
((
int
)
start
==
to
)
if
((
int
)
start
==
to
)
/* nothing happens */
/* nothing happens */
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
const
Song
*
const
queued_song
=
GetQueuedSong
();
const
Song
*
const
queued_song
=
GetQueuedSong
();
...
@@ -353,11 +353,11 @@ playlist::MoveRange(player_control &pc, unsigned start, unsigned end, int to)
...
@@ -353,11 +353,11 @@ playlist::MoveRange(player_control &pc, unsigned start, unsigned end, int to)
if
(
currentSong
<
0
)
if
(
currentSong
<
0
)
/* can't move relative to current song,
/* can't move relative to current song,
because there is no current song */
because there is no current song */
return
P
LAYLIST_RESULT_
BAD_RANGE
;
return
P
laylistResult
::
BAD_RANGE
;
if
(
start
<=
(
unsigned
)
currentSong
&&
(
unsigned
)
currentSong
<
end
)
if
(
start
<=
(
unsigned
)
currentSong
&&
(
unsigned
)
currentSong
<
end
)
/* no-op, can't be moved to offset of itself */
/* no-op, can't be moved to offset of itself */
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
to
=
(
currentSong
+
abs
(
to
))
%
GetLength
();
to
=
(
currentSong
+
abs
(
to
))
%
GetLength
();
if
(
start
<
(
unsigned
)
to
)
if
(
start
<
(
unsigned
)
to
)
to
--
;
to
--
;
...
@@ -378,15 +378,15 @@ playlist::MoveRange(player_control &pc, unsigned start, unsigned end, int to)
...
@@ -378,15 +378,15 @@ playlist::MoveRange(player_control &pc, unsigned start, unsigned end, int to)
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
OnModified
();
OnModified
();
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist
::
MoveId
(
player_control
&
pc
,
unsigned
id1
,
int
to
)
playlist
::
MoveId
(
player_control
&
pc
,
unsigned
id1
,
int
to
)
{
{
int
song
=
queue
.
IdToPosition
(
id1
);
int
song
=
queue
.
IdToPosition
(
id1
);
if
(
song
<
0
)
if
(
song
<
0
)
return
P
LAYLIST_RESULT_
NO_SUCH_SONG
;
return
P
laylistResult
::
NO_SUCH_SONG
;
return
MoveRange
(
pc
,
song
,
song
+
1
,
to
);
return
MoveRange
(
pc
,
song
,
song
+
1
,
to
);
}
}
...
...
src/PlaylistError.hxx
View file @
c772bc45
...
@@ -22,18 +22,18 @@
...
@@ -22,18 +22,18 @@
class
Domain
;
class
Domain
;
enum
playlist_r
esult
{
enum
class
PlaylistR
esult
{
PLAYLIST_RESULT_
SUCCESS
,
SUCCESS
,
PLAYLIST_RESULT_
ERRNO
,
ERRNO
,
PLAYLIST_RESULT_
DENIED
,
DENIED
,
PLAYLIST_RESULT_
NO_SUCH_SONG
,
NO_SUCH_SONG
,
PLAYLIST_RESULT_
NO_SUCH_LIST
,
NO_SUCH_LIST
,
PLAYLIST_RESULT_
LIST_EXISTS
,
LIST_EXISTS
,
PLAYLIST_RESULT_
BAD_NAME
,
BAD_NAME
,
PLAYLIST_RESULT_
BAD_RANGE
,
BAD_RANGE
,
PLAYLIST_RESULT_
NOT_PLAYING
,
NOT_PLAYING
,
PLAYLIST_RESULT_
TOO_LARGE
,
TOO_LARGE
,
PLAYLIST_RESULT_
DISABLED
,
DISABLED
,
};
};
extern
const
Domain
playlist_domain
;
extern
const
Domain
playlist_domain
;
...
...
src/PlaylistFile.cxx
View file @
c772bc45
...
@@ -90,7 +90,7 @@ spl_map(Error &error)
...
@@ -90,7 +90,7 @@ spl_map(Error &error)
{
{
const
AllocatedPath
&
path_fs
=
map_spl_path
();
const
AllocatedPath
&
path_fs
=
map_spl_path
();
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_DISABLED
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
DISABLED
)
,
"Stored playlists are disabled"
);
"Stored playlists are disabled"
);
return
path_fs
;
return
path_fs
;
}
}
...
@@ -99,7 +99,7 @@ static bool
...
@@ -99,7 +99,7 @@ static bool
spl_check_name
(
const
char
*
name_utf8
,
Error
&
error
)
spl_check_name
(
const
char
*
name_utf8
,
Error
&
error
)
{
{
if
(
!
spl_valid_name
(
name_utf8
))
{
if
(
!
spl_valid_name
(
name_utf8
))
{
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_BAD_NAME
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_NAME
)
,
"Bad playlist name"
);
"Bad playlist name"
);
return
false
;
return
false
;
}
}
...
@@ -115,7 +115,7 @@ spl_map_to_fs(const char *name_utf8, Error &error)
...
@@ -115,7 +115,7 @@ spl_map_to_fs(const char *name_utf8, Error &error)
auto
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
auto
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_BAD_NAME
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_NAME
)
,
"Bad playlist name"
);
"Bad playlist name"
);
return
path_fs
;
return
path_fs
;
...
@@ -129,7 +129,7 @@ playlist_errno(Error &error)
...
@@ -129,7 +129,7 @@ playlist_errno(Error &error)
{
{
switch
(
errno
)
{
switch
(
errno
)
{
case
ENOENT
:
case
ENOENT
:
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_NO_SUCH_LIST
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_LIST
)
,
"No such playlist"
);
"No such playlist"
);
break
;
break
;
...
@@ -287,7 +287,7 @@ spl_move_index(const char *utf8path, unsigned src, unsigned dest,
...
@@ -287,7 +287,7 @@ spl_move_index(const char *utf8path, unsigned src, unsigned dest,
return
false
;
return
false
;
if
(
src
>=
contents
.
size
()
||
dest
>=
contents
.
size
())
{
if
(
src
>=
contents
.
size
()
||
dest
>=
contents
.
size
())
{
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_BAD_RANGE
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_RANGE
)
,
"Bad range"
);
"Bad range"
);
return
false
;
return
false
;
}
}
...
@@ -351,7 +351,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error)
...
@@ -351,7 +351,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error)
return
false
;
return
false
;
if
(
pos
>=
contents
.
size
())
{
if
(
pos
>=
contents
.
size
())
{
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_BAD_RANGE
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_RANGE
)
,
"Bad range"
);
"Bad range"
);
return
false
;
return
false
;
}
}
...
@@ -389,7 +389,7 @@ spl_append_song(const char *utf8path, const Song &song, Error &error)
...
@@ -389,7 +389,7 @@ spl_append_song(const char *utf8path, const Song &song, Error &error)
if
(
st
.
st_size
/
off_t
(
MPD_PATH_MAX
+
1
)
>=
(
off_t
)
playlist_max_length
)
{
if
(
st
.
st_size
/
off_t
(
MPD_PATH_MAX
+
1
)
>=
(
off_t
)
playlist_max_length
)
{
fclose
(
file
);
fclose
(
file
);
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_TOO_LARGE
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
TOO_LARGE
)
,
"Stored playlist is too large"
);
"Stored playlist is too large"
);
return
false
;
return
false
;
}
}
...
@@ -430,13 +430,13 @@ spl_rename_internal(Path from_path_fs, Path to_path_fs,
...
@@ -430,13 +430,13 @@ spl_rename_internal(Path from_path_fs, Path to_path_fs,
Error
&
error
)
Error
&
error
)
{
{
if
(
!
FileExists
(
from_path_fs
))
{
if
(
!
FileExists
(
from_path_fs
))
{
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_NO_SUCH_LIST
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_LIST
)
,
"No such playlist"
);
"No such playlist"
);
return
false
;
return
false
;
}
}
if
(
FileExists
(
to_path_fs
))
{
if
(
FileExists
(
to_path_fs
))
{
error
.
Set
(
playlist_domain
,
PLAYLIST_RESULT_LIST_EXISTS
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
LIST_EXISTS
)
,
"Playlist exists already"
);
"Playlist exists already"
);
return
false
;
return
false
;
}
}
...
...
src/PlaylistQueue.cxx
View file @
c772bc45
...
@@ -30,13 +30,13 @@
...
@@ -30,13 +30,13 @@
#include <glib.h>
#include <glib.h>
enum
playlist_r
esult
PlaylistR
esult
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
playlist
&
dest
,
player_control
&
pc
,
playlist
&
dest
,
player_control
&
pc
,
bool
secure
)
bool
secure
)
{
{
enum
playlist_r
esult
result
;
PlaylistR
esult
result
;
Song
*
song
;
Song
*
song
;
char
*
base_uri
=
uri
!=
nullptr
?
g_path_get_dirname
(
uri
)
:
nullptr
;
char
*
base_uri
=
uri
!=
nullptr
?
g_path_get_dirname
(
uri
)
:
nullptr
;
...
@@ -55,7 +55,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -55,7 +55,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
result
=
dest
.
AppendSong
(
pc
,
song
);
result
=
dest
.
AppendSong
(
pc
,
song
);
song
->
Free
();
song
->
Free
();
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
{
if
(
result
!=
P
laylistResult
::
SUCCESS
)
{
g_free
(
base_uri
);
g_free
(
base_uri
);
return
result
;
return
result
;
}
}
...
@@ -63,10 +63,10 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -63,10 +63,10 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
g_free
(
base_uri
);
g_free
(
base_uri
);
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
playlist_open_into_queue
(
const
char
*
uri
,
playlist_open_into_queue
(
const
char
*
uri
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
playlist
&
dest
,
player_control
&
pc
,
playlist
&
dest
,
player_control
&
pc
,
...
@@ -78,9 +78,9 @@ playlist_open_into_queue(const char *uri,
...
@@ -78,9 +78,9 @@ playlist_open_into_queue(const char *uri,
struct
input_stream
*
is
;
struct
input_stream
*
is
;
auto
playlist
=
playlist_open_any
(
uri
,
mutex
,
cond
,
&
is
);
auto
playlist
=
playlist_open_any
(
uri
,
mutex
,
cond
,
&
is
);
if
(
playlist
==
nullptr
)
if
(
playlist
==
nullptr
)
return
P
LAYLIST_RESULT_
NO_SUCH_LIST
;
return
P
laylistResult
::
NO_SUCH_LIST
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
playlist_load_into_queue
(
uri
,
*
playlist
,
playlist_load_into_queue
(
uri
,
*
playlist
,
start_index
,
end_index
,
start_index
,
end_index
,
dest
,
pc
,
secure
);
dest
,
pc
,
secure
);
...
...
src/PlaylistQueue.hxx
View file @
c772bc45
...
@@ -39,7 +39,7 @@ struct player_control;
...
@@ -39,7 +39,7 @@ struct player_control;
* @param start_index the index of the first song
* @param start_index the index of the first song
* @param end_index the index of the last song (excluding)
* @param end_index the index of the last song (excluding)
*/
*/
enum
playlist_r
esult
PlaylistR
esult
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
playlist
&
dest
,
player_control
&
pc
,
playlist
&
dest
,
player_control
&
pc
,
...
@@ -49,7 +49,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -49,7 +49,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
* Opens a playlist with a playlist plugin and append to the specified
* Opens a playlist with a playlist plugin and append to the specified
* play queue.
* play queue.
*/
*/
enum
playlist_r
esult
PlaylistR
esult
playlist_open_into_queue
(
const
char
*
uri
,
playlist_open_into_queue
(
const
char
*
uri
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
playlist
&
dest
,
player_control
&
pc
,
playlist
&
dest
,
player_control
&
pc
,
...
...
src/PlaylistSave.cxx
View file @
c772bc45
...
@@ -64,26 +64,26 @@ playlist_print_uri(FILE *file, const char *uri)
...
@@ -64,26 +64,26 @@ playlist_print_uri(FILE *file, const char *uri)
fprintf
(
file
,
"%s
\n
"
,
path
.
c_str
());
fprintf
(
file
,
"%s
\n
"
,
path
.
c_str
());
}
}
enum
playlist_r
esult
PlaylistR
esult
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
)
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
)
{
{
if
(
map_spl_path
().
IsNull
())
if
(
map_spl_path
().
IsNull
())
return
P
LAYLIST_RESULT_
DISABLED
;
return
P
laylistResult
::
DISABLED
;
if
(
!
spl_valid_name
(
name_utf8
))
if
(
!
spl_valid_name
(
name_utf8
))
return
P
LAYLIST_RESULT_
BAD_NAME
;
return
P
laylistResult
::
BAD_NAME
;
const
auto
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
const
auto
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
return
P
LAYLIST_RESULT_
BAD_NAME
;
return
P
laylistResult
::
BAD_NAME
;
if
(
FileExists
(
path_fs
))
if
(
FileExists
(
path_fs
))
return
P
LAYLIST_RESULT_
LIST_EXISTS
;
return
P
laylistResult
::
LIST_EXISTS
;
FILE
*
file
=
FOpen
(
path_fs
,
FOpenMode
::
WriteText
);
FILE
*
file
=
FOpen
(
path_fs
,
FOpenMode
::
WriteText
);
if
(
file
==
nullptr
)
if
(
file
==
nullptr
)
return
P
LAYLIST_RESULT_
ERRNO
;
return
P
laylistResult
::
ERRNO
;
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
playlist_print_song
(
file
,
queue
.
Get
(
i
));
playlist_print_song
(
file
,
queue
.
Get
(
i
));
...
@@ -91,10 +91,10 @@ spl_save_queue(const char *name_utf8, const queue &queue)
...
@@ -91,10 +91,10 @@ spl_save_queue(const char *name_utf8, const queue &queue)
fclose
(
file
);
fclose
(
file
);
idle_add
(
IDLE_STORED_PLAYLIST
);
idle_add
(
IDLE_STORED_PLAYLIST
);
return
P
LAYLIST_RESULT_
SUCCESS
;
return
P
laylistResult
::
SUCCESS
;
}
}
enum
playlist_r
esult
PlaylistR
esult
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
)
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
)
{
{
return
spl_save_queue
(
name_utf8
,
playlist
.
queue
);
return
spl_save_queue
(
name_utf8
,
playlist
.
queue
);
...
@@ -119,13 +119,13 @@ playlist_load_spl(struct playlist &playlist, player_control &pc,
...
@@ -119,13 +119,13 @@ playlist_load_spl(struct playlist &playlist, player_control &pc,
if
(
memcmp
(
uri_utf8
.
c_str
(),
"file:///"
,
8
)
==
0
)
{
if
(
memcmp
(
uri_utf8
.
c_str
(),
"file:///"
,
8
)
==
0
)
{
const
char
*
path_utf8
=
uri_utf8
.
c_str
()
+
7
;
const
char
*
path_utf8
=
uri_utf8
.
c_str
()
+
7
;
if
(
playlist
.
AppendFile
(
pc
,
path_utf8
)
!=
P
LAYLIST_RESULT_
SUCCESS
)
if
(
playlist
.
AppendFile
(
pc
,
path_utf8
)
!=
P
laylistResult
::
SUCCESS
)
FormatError
(
playlist_domain
,
FormatError
(
playlist_domain
,
"can't add file
\"
%s
\"
"
,
path_utf8
);
"can't add file
\"
%s
\"
"
,
path_utf8
);
continue
;
continue
;
}
}
if
((
playlist
.
AppendURI
(
pc
,
uri_utf8
.
c_str
()))
!=
P
LAYLIST_RESULT_
SUCCESS
)
{
if
((
playlist
.
AppendURI
(
pc
,
uri_utf8
.
c_str
()))
!=
P
laylistResult
::
SUCCESS
)
{
/* for windows compatibility, convert slashes */
/* for windows compatibility, convert slashes */
char
*
temp2
=
g_strdup
(
uri_utf8
.
c_str
());
char
*
temp2
=
g_strdup
(
uri_utf8
.
c_str
());
char
*
p
=
temp2
;
char
*
p
=
temp2
;
...
@@ -135,7 +135,7 @@ playlist_load_spl(struct playlist &playlist, player_control &pc,
...
@@ -135,7 +135,7 @@ playlist_load_spl(struct playlist &playlist, player_control &pc,
p
++
;
p
++
;
}
}
if
(
playlist
.
AppendURI
(
pc
,
temp2
)
!=
P
LAYLIST_RESULT_
SUCCESS
)
if
(
playlist
.
AppendURI
(
pc
,
temp2
)
!=
P
laylistResult
::
SUCCESS
)
FormatError
(
playlist_domain
,
FormatError
(
playlist_domain
,
"can't add file
\"
%s
\"
"
,
temp2
);
"can't add file
\"
%s
\"
"
,
temp2
);
...
...
src/PlaylistSave.hxx
View file @
c772bc45
...
@@ -39,13 +39,13 @@ playlist_print_uri(FILE *fp, const char *uri);
...
@@ -39,13 +39,13 @@ playlist_print_uri(FILE *fp, const char *uri);
/**
/**
* Saves a queue object into a stored playlist file.
* Saves a queue object into a stored playlist file.
*/
*/
enum
playlist_r
esult
PlaylistR
esult
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
);
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
);
/**
/**
* Saves a playlist object into a stored playlist file.
* Saves a playlist object into a stored playlist file.
*/
*/
enum
playlist_r
esult
PlaylistR
esult
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
);
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
);
/**
/**
...
...
src/QueueCommands.cxx
View file @
c772bc45
...
@@ -43,7 +43,7 @@ enum command_return
...
@@ -43,7 +43,7 @@ enum command_return
handle_add
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_add
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
uri
=
argv
[
1
];
char
*
uri
=
argv
[
1
];
enum
playlist_r
esult
result
;
PlaylistR
esult
result
;
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path_utf8
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
...
@@ -86,7 +86,7 @@ handle_addid(Client &client, int argc, char *argv[])
...
@@ -86,7 +86,7 @@ handle_addid(Client &client, int argc, char *argv[])
{
{
char
*
uri
=
argv
[
1
];
char
*
uri
=
argv
[
1
];
unsigned
added_id
;
unsigned
added_id
;
enum
playlist_r
esult
result
;
PlaylistR
esult
result
;
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
if
(
memcmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path_utf8
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
...
@@ -113,7 +113,7 @@ handle_addid(Client &client, int argc, char *argv[])
...
@@ -113,7 +113,7 @@ handle_addid(Client &client, int argc, char *argv[])
result
=
client
.
partition
.
AppendURI
(
uri
,
&
added_id
);
result
=
client
.
partition
.
AppendURI
(
uri
,
&
added_id
);
}
}
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
if
(
result
!=
P
laylistResult
::
SUCCESS
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
if
(
argc
==
3
)
{
if
(
argc
==
3
)
{
...
@@ -121,7 +121,7 @@ handle_addid(Client &client, int argc, char *argv[])
...
@@ -121,7 +121,7 @@ handle_addid(Client &client, int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
result
=
client
.
partition
.
MoveId
(
added_id
,
to
);
result
=
client
.
partition
.
MoveId
(
added_id
,
to
);
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
{
if
(
result
!=
P
laylistResult
::
SUCCESS
)
{
enum
command_return
ret
=
enum
command_return
ret
=
print_playlist_result
(
client
,
result
);
print_playlist_result
(
client
,
result
);
client
.
partition
.
DeleteId
(
added_id
);
client
.
partition
.
DeleteId
(
added_id
);
...
@@ -141,7 +141,7 @@ handle_delete(Client &client, gcc_unused int argc, char *argv[])
...
@@ -141,7 +141,7 @@ handle_delete(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
DeleteRange
(
start
,
end
);
PlaylistR
esult
result
=
client
.
partition
.
DeleteRange
(
start
,
end
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -153,7 +153,7 @@ handle_deleteid(Client &client, gcc_unused int argc, char *argv[])
...
@@ -153,7 +153,7 @@ handle_deleteid(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
DeleteId
(
id
);
PlaylistR
esult
result
=
client
.
partition
.
DeleteId
(
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -221,7 +221,7 @@ handle_playlistinfo(Client &client, int argc, char *argv[])
...
@@ -221,7 +221,7 @@ handle_playlistinfo(Client &client, int argc, char *argv[])
ret
=
playlist_print_info
(
client
,
client
.
playlist
,
start
,
end
);
ret
=
playlist_print_info
(
client
,
client
.
playlist
,
start
,
end
);
if
(
!
ret
)
if
(
!
ret
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
P
LAYLIST_RESULT_
BAD_RANGE
);
P
laylistResult
::
BAD_RANGE
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -237,7 +237,7 @@ handle_playlistid(Client &client, int argc, char *argv[])
...
@@ -237,7 +237,7 @@ handle_playlistid(Client &client, int argc, char *argv[])
bool
ret
=
playlist_print_id
(
client
,
client
.
playlist
,
id
);
bool
ret
=
playlist_print_id
(
client
,
client
.
playlist
,
id
);
if
(
!
ret
)
if
(
!
ret
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
P
LAYLIST_RESULT_
NO_SUCH_SONG
);
P
laylistResult
::
NO_SUCH_SONG
);
}
else
{
}
else
{
playlist_print_info
(
client
,
client
.
playlist
,
playlist_print_info
(
client
,
client
.
playlist
,
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
...
@@ -292,11 +292,11 @@ handle_prio(Client &client, int argc, char *argv[])
...
@@ -292,11 +292,11 @@ handle_prio(Client &client, int argc, char *argv[])
argv
[
i
]))
argv
[
i
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SetPriorityRange
(
start_position
,
client
.
partition
.
SetPriorityRange
(
start_position
,
end_position
,
end_position
,
priority
);
priority
);
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
if
(
result
!=
P
laylistResult
::
SUCCESS
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -322,9 +322,9 @@ handle_prioid(Client &client, int argc, char *argv[])
...
@@ -322,9 +322,9 @@ handle_prioid(Client &client, int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
song_id
,
argv
[
i
]))
if
(
!
check_unsigned
(
client
,
&
song_id
,
argv
[
i
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SetPriorityId
(
song_id
,
priority
);
client
.
partition
.
SetPriorityId
(
song_id
,
priority
);
if
(
result
!=
P
LAYLIST_RESULT_
SUCCESS
)
if
(
result
!=
P
laylistResult
::
SUCCESS
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -342,7 +342,7 @@ handle_move(Client &client, gcc_unused int argc, char *argv[])
...
@@ -342,7 +342,7 @@ handle_move(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
MoveRange
(
start
,
end
,
to
);
client
.
partition
.
MoveRange
(
start
,
end
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -357,7 +357,7 @@ handle_moveid(Client &client, gcc_unused int argc, char *argv[])
...
@@ -357,7 +357,7 @@ handle_moveid(Client &client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
MoveId
(
id
,
to
);
PlaylistR
esult
result
=
client
.
partition
.
MoveId
(
id
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -371,7 +371,7 @@ handle_swap(Client &client, gcc_unused int argc, char *argv[])
...
@@ -371,7 +371,7 @@ handle_swap(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
song2
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
song2
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
PlaylistR
esult
result
=
client
.
partition
.
SwapPositions
(
song1
,
song2
);
client
.
partition
.
SwapPositions
(
song1
,
song2
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -386,6 +386,6 @@ handle_swapid(Client &client, gcc_unused int argc, char *argv[])
...
@@ -386,6 +386,6 @@ handle_swapid(Client &client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_r
esult
result
=
client
.
partition
.
SwapIds
(
id1
,
id2
);
PlaylistR
esult
result
=
client
.
partition
.
SwapIds
(
id1
,
id2
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
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