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