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
fe8e77e5
Commit
fe8e77e5
authored
Jan 04, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: add "playlist" attribute
Reduce access to the global variable "g_playlist".
parent
b0833084
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
63 deletions
+83
-63
Client.hxx
src/Client.hxx
+3
-1
ClientInternal.hxx
src/ClientInternal.hxx
+3
-1
ClientNew.cxx
src/ClientNew.cxx
+5
-4
Listen.cxx
src/Listen.cxx
+3
-1
PlayerCommands.cxx
src/PlayerCommands.cxx
+36
-29
PlaylistCommands.cxx
src/PlaylistCommands.cxx
+3
-3
QueueCommands.cxx
src/QueueCommands.cxx
+30
-24
No files found.
src/Client.hxx
View file @
fe8e77e5
...
@@ -27,13 +27,15 @@
...
@@ -27,13 +27,15 @@
#include <stdarg.h>
#include <stdarg.h>
struct
sockaddr
;
struct
sockaddr
;
struct
playlist
;
struct
player_control
;
struct
player_control
;
class
Client
;
class
Client
;
void
client_manager_init
(
void
);
void
client_manager_init
(
void
);
void
client_manager_deinit
(
void
);
void
client_manager_deinit
(
void
);
void
client_new
(
struct
player_control
*
player_control
,
void
client_new
(
struct
playlist
&
playlist
,
struct
player_control
*
player_control
,
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
);
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
);
gcc_pure
gcc_pure
...
...
src/ClientInternal.hxx
View file @
fe8e77e5
...
@@ -46,6 +46,7 @@ struct deferred_buffer {
...
@@ -46,6 +46,7 @@ struct deferred_buffer {
class
Client
{
class
Client
{
public
:
public
:
struct
playlist
&
playlist
;
struct
player_control
*
player_control
;
struct
player_control
*
player_control
;
GIOChannel
*
channel
;
GIOChannel
*
channel
;
...
@@ -99,7 +100,8 @@ public:
...
@@ -99,7 +100,8 @@ public:
*/
*/
std
::
list
<
ClientMessage
>
messages
;
std
::
list
<
ClientMessage
>
messages
;
Client
(
struct
player_control
*
player_control
,
Client
(
struct
playlist
&
playlist
,
struct
player_control
*
player_control
,
int
fd
,
int
uid
,
int
num
);
int
fd
,
int
uid
,
int
num
);
~
Client
();
~
Client
();
...
...
src/ClientNew.cxx
View file @
fe8e77e5
...
@@ -45,9 +45,10 @@ extern "C" {
...
@@ -45,9 +45,10 @@ extern "C" {
static
const
char
GREETING
[]
=
"OK MPD "
PROTOCOL_VERSION
"
\n
"
;
static
const
char
GREETING
[]
=
"OK MPD "
PROTOCOL_VERSION
"
\n
"
;
Client
::
Client
(
struct
player_control
*
_player_control
,
Client
::
Client
(
struct
playlist
&
_playlist
,
struct
player_control
*
_player_control
,
int
fd
,
int
_uid
,
int
_num
)
int
fd
,
int
_uid
,
int
_num
)
:
player_control
(
_player_control
),
:
play
list
(
_playlist
),
play
er_control
(
_player_control
),
input
(
fifo_buffer_new
(
4096
)),
input
(
fifo_buffer_new
(
4096
)),
permission
(
getDefaultPermissions
()),
permission
(
getDefaultPermissions
()),
uid
(
_uid
),
uid
(
_uid
),
...
@@ -93,7 +94,7 @@ Client::~Client()
...
@@ -93,7 +94,7 @@ Client::~Client()
}
}
void
void
client_new
(
struct
player_control
*
player_control
,
client_new
(
struct
play
list
&
playlist
,
struct
play
er_control
*
player_control
,
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
)
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
)
{
{
static
unsigned
int
next_client_num
;
static
unsigned
int
next_client_num
;
...
@@ -133,7 +134,7 @@ client_new(struct player_control *player_control,
...
@@ -133,7 +134,7 @@ client_new(struct player_control *player_control,
return
;
return
;
}
}
Client
*
client
=
new
Client
(
player_control
,
fd
,
uid
,
Client
*
client
=
new
Client
(
play
list
,
play
er_control
,
fd
,
uid
,
next_client_num
++
);
next_client_num
++
);
(
void
)
send
(
fd
,
GREETING
,
sizeof
(
GREETING
)
-
1
,
0
);
(
void
)
send
(
fd
,
GREETING
,
sizeof
(
GREETING
)
-
1
,
0
);
...
...
src/Listen.cxx
View file @
fe8e77e5
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "config.h"
#include "Listen.hxx"
#include "Listen.hxx"
#include "Main.hxx"
#include "Main.hxx"
#include "Playlist.hxx"
#include "Client.hxx"
#include "Client.hxx"
extern
"C"
{
extern
"C"
{
...
@@ -46,7 +47,8 @@ static void
...
@@ -46,7 +47,8 @@ static void
listen_callback
(
int
fd
,
const
struct
sockaddr
*
address
,
listen_callback
(
int
fd
,
const
struct
sockaddr
*
address
,
size_t
address_length
,
int
uid
,
G_GNUC_UNUSED
void
*
ctx
)
size_t
address_length
,
int
uid
,
G_GNUC_UNUSED
void
*
ctx
)
{
{
client_new
(
global_player_control
,
fd
,
address
,
address_length
,
uid
);
client_new
(
g_playlist
,
global_player_control
,
fd
,
address
,
address_length
,
uid
);
}
}
static
bool
static
bool
...
...
src/PlayerCommands.cxx
View file @
fe8e77e5
...
@@ -65,7 +65,8 @@ handle_play(Client *client, int argc, char *argv[])
...
@@ -65,7 +65,8 @@ 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
;
result
=
playlist_play
(
&
g_playlist
,
client
->
player_control
,
song
);
result
=
playlist_play
(
&
client
->
playlist
,
client
->
player_control
,
song
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -78,15 +79,16 @@ handle_playid(Client *client, int argc, char *argv[])
...
@@ -78,15 +79,16 @@ 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
;
result
=
playlist_play_id
(
&
g_playlist
,
client
->
player_control
,
id
);
result
=
playlist_play_id
(
&
client
->
playlist
,
client
->
player_control
,
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_stop
(
G_GNUC_UNUSED
Client
*
client
,
handle_stop
(
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist_stop
(
&
g_
playlist
,
client
->
player_control
);
playlist_stop
(
&
client
->
playlist
,
client
->
player_control
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -94,7 +96,7 @@ enum command_return
...
@@ -94,7 +96,7 @@ enum command_return
handle_currentsong
(
Client
*
client
,
handle_currentsong
(
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist_print_current
(
client
,
&
g_
playlist
);
playlist_print_current
(
client
,
&
client
->
playlist
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -138,6 +140,7 @@ handle_status(Client *client,
...
@@ -138,6 +140,7 @@ handle_status(Client *client,
break
;
break
;
}
}
const
playlist
&
playlist
=
client
->
playlist
;
client_printf
(
client
,
client_printf
(
client
,
"volume: %i
\n
"
"volume: %i
\n
"
COMMAND_STATUS_REPEAT
": %i
\n
"
COMMAND_STATUS_REPEAT
": %i
\n
"
...
@@ -151,23 +154,23 @@ handle_status(Client *client,
...
@@ -151,23 +154,23 @@ handle_status(Client *client,
COMMAND_STATUS_MIXRAMPDELAY
": %f
\n
"
COMMAND_STATUS_MIXRAMPDELAY
": %f
\n
"
COMMAND_STATUS_STATE
": %s
\n
"
,
COMMAND_STATUS_STATE
": %s
\n
"
,
volume_level_get
(),
volume_level_get
(),
playlist_get_repeat
(
&
g_
playlist
),
playlist_get_repeat
(
&
playlist
),
playlist_get_random
(
&
g_
playlist
),
playlist_get_random
(
&
playlist
),
playlist_get_single
(
&
g_
playlist
),
playlist_get_single
(
&
playlist
),
playlist_get_consume
(
&
g_
playlist
),
playlist_get_consume
(
&
playlist
),
playlist_get_version
(
&
g_
playlist
),
playlist_get_version
(
&
playlist
),
playlist_get_length
(
&
g_
playlist
),
playlist_get_length
(
&
playlist
),
(
int
)(
pc_get_cross_fade
(
client
->
player_control
)
+
0.5
),
(
int
)(
pc_get_cross_fade
(
client
->
player_control
)
+
0.5
),
pc_get_mixramp_db
(
client
->
player_control
),
pc_get_mixramp_db
(
client
->
player_control
),
pc_get_mixramp_delay
(
client
->
player_control
),
pc_get_mixramp_delay
(
client
->
player_control
),
state
);
state
);
song
=
playlist_get_current_song
(
&
g_
playlist
);
song
=
playlist_get_current_song
(
&
playlist
);
if
(
song
>=
0
)
{
if
(
song
>=
0
)
{
client_printf
(
client
,
client_printf
(
client
,
COMMAND_STATUS_SONG
": %i
\n
"
COMMAND_STATUS_SONG
": %i
\n
"
COMMAND_STATUS_SONGID
": %u
\n
"
,
COMMAND_STATUS_SONGID
": %u
\n
"
,
song
,
playlist_get_song_id
(
&
g_
playlist
,
song
));
song
,
playlist_get_song_id
(
&
playlist
,
song
));
}
}
if
(
player_status
.
state
!=
PLAYER_STATE_STOP
)
{
if
(
player_status
.
state
!=
PLAYER_STATE_STOP
)
{
...
@@ -200,37 +203,39 @@ handle_status(Client *client,
...
@@ -200,37 +203,39 @@ handle_status(Client *client,
g_free
(
error
);
g_free
(
error
);
}
}
song
=
playlist_get_next_song
(
&
g_
playlist
);
song
=
playlist_get_next_song
(
&
playlist
);
if
(
song
>=
0
)
{
if
(
song
>=
0
)
{
client_printf
(
client
,
client_printf
(
client
,
COMMAND_STATUS_NEXTSONG
": %i
\n
"
COMMAND_STATUS_NEXTSONG
": %i
\n
"
COMMAND_STATUS_NEXTSONGID
": %u
\n
"
,
COMMAND_STATUS_NEXTSONGID
": %u
\n
"
,
song
,
playlist_get_song_id
(
&
g_
playlist
,
song
));
song
,
playlist_get_song_id
(
&
playlist
,
song
));
}
}
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_next
(
G_GNUC_UNUSED
Client
*
client
,
handle_next
(
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist
&
playlist
=
client
->
playlist
;
/* single mode is not considered when this is user who
/* single mode is not considered when this is user who
* wants to change song. */
* wants to change song. */
const
bool
single
=
g_
playlist
.
queue
.
single
;
const
bool
single
=
playlist
.
queue
.
single
;
g_
playlist
.
queue
.
single
=
false
;
playlist
.
queue
.
single
=
false
;
playlist_next
(
&
g_
playlist
,
client
->
player_control
);
playlist_next
(
&
playlist
,
client
->
player_control
);
g_
playlist
.
queue
.
single
=
single
;
playlist
.
queue
.
single
=
single
;
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_previous
(
G_GNUC_UNUSED
Client
*
client
,
handle_previous
(
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist_previous
(
&
g_
playlist
,
client
->
player_control
);
playlist_previous
(
&
client
->
playlist
,
client
->
player_control
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -241,7 +246,7 @@ handle_repeat(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -241,7 +246,7 @@ handle_repeat(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_set_repeat
(
&
g_
playlist
,
client
->
player_control
,
status
);
playlist_set_repeat
(
&
client
->
playlist
,
client
->
player_control
,
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -252,7 +257,7 @@ handle_single(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -252,7 +257,7 @@ handle_single(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_set_single
(
&
g_
playlist
,
client
->
player_control
,
status
);
playlist_set_single
(
&
client
->
playlist
,
client
->
player_control
,
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -263,7 +268,7 @@ handle_consume(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -263,7 +268,7 @@ handle_consume(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_set_consume
(
&
g_
playlist
,
status
);
playlist_set_consume
(
&
client
->
playlist
,
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -274,7 +279,7 @@ handle_random(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -274,7 +279,7 @@ handle_random(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_set_random
(
&
g_
playlist
,
client
->
player_control
,
status
);
playlist_set_random
(
&
client
->
playlist
,
client
->
player_control
,
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -297,7 +302,7 @@ handle_seek(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -297,7 +302,7 @@ handle_seek(Client *client, G_GNUC_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
;
result
=
playlist_seek_song
(
&
g_
playlist
,
client
->
player_control
,
result
=
playlist_seek_song
(
&
client
->
playlist
,
client
->
player_control
,
song
,
seek_time
);
song
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -313,7 +318,8 @@ handle_seekid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -313,7 +318,8 @@ handle_seekid(Client *client, G_GNUC_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
;
result
=
playlist_seek_song_id
(
&
g_playlist
,
client
->
player_control
,
result
=
playlist_seek_song_id
(
&
client
->
playlist
,
client
->
player_control
,
id
,
seek_time
);
id
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -328,7 +334,8 @@ handle_seekcur(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -328,7 +334,8 @@ handle_seekcur(Client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
playlist_seek_current
(
&
g_playlist
,
client
->
player_control
,
playlist_seek_current
(
&
client
->
playlist
,
client
->
player_control
,
seek_time
,
relative
);
seek_time
,
relative
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
...
src/PlaylistCommands.cxx
View file @
fe8e77e5
...
@@ -56,7 +56,7 @@ handle_save(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -56,7 +56,7 @@ handle_save(Client *client, G_GNUC_UNUSED int argc, char *argv[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
result
=
spl_save_playlist
(
argv
[
1
],
&
g_
playlist
);
result
=
spl_save_playlist
(
argv
[
1
],
&
client
->
playlist
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -75,13 +75,13 @@ handle_load(Client *client, int argc, char *argv[])
...
@@ -75,13 +75,13 @@ handle_load(Client *client, int argc, char *argv[])
result
=
playlist_open_into_queue
(
argv
[
1
],
result
=
playlist_open_into_queue
(
argv
[
1
],
start_index
,
end_index
,
start_index
,
end_index
,
&
g_
playlist
,
&
client
->
playlist
,
client
->
player_control
,
true
);
client
->
player_control
,
true
);
if
(
result
!=
PLAYLIST_RESULT_NO_SUCH_LIST
)
if
(
result
!=
PLAYLIST_RESULT_NO_SUCH_LIST
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
if
(
playlist_load_spl
(
&
g_
playlist
,
client
->
player_control
,
if
(
playlist_load_spl
(
&
client
->
playlist
,
client
->
player_control
,
argv
[
1
],
start_index
,
end_index
,
argv
[
1
],
start_index
,
end_index
,
&
error
))
&
error
))
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
...
...
src/QueueCommands.cxx
View file @
fe8e77e5
...
@@ -49,7 +49,7 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -49,7 +49,7 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
result
=
playlist_append_file
(
&
g_
playlist
,
result
=
playlist_append_file
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
path
,
path
,
NULL
);
NULL
);
...
@@ -63,7 +63,7 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -63,7 +63,7 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
result
=
playlist_append_uri
(
&
g_
playlist
,
result
=
playlist_append_uri
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
uri
,
NULL
);
uri
,
NULL
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
...
@@ -89,7 +89,7 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -89,7 +89,7 @@ handle_addid(Client *client, int argc, char *argv[])
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
result
=
playlist_append_file
(
&
g_
playlist
,
result
=
playlist_append_file
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
path
,
path
,
&
added_id
);
&
added_id
);
...
@@ -100,7 +100,7 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -100,7 +100,7 @@ handle_addid(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
result
=
playlist_append_uri
(
&
g_
playlist
,
result
=
playlist_append_uri
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
uri
,
&
added_id
);
uri
,
&
added_id
);
}
}
...
@@ -112,12 +112,14 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -112,12 +112,14 @@ handle_addid(Client *client, int argc, char *argv[])
unsigned
to
;
unsigned
to
;
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
result
=
playlist_move_id
(
&
g_playlist
,
client
->
player_control
,
result
=
playlist_move_id
(
&
client
->
playlist
,
client
->
player_control
,
added_id
,
to
);
added_id
,
to
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
enum
command_return
ret
=
enum
command_return
ret
=
print_playlist_result
(
client
,
result
);
print_playlist_result
(
client
,
result
);
playlist_delete_id
(
&
g_playlist
,
client
->
player_control
,
playlist_delete_id
(
&
client
->
playlist
,
client
->
player_control
,
added_id
);
added_id
);
return
ret
;
return
ret
;
}
}
...
@@ -136,7 +138,8 @@ handle_delete(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -136,7 +138,8 @@ handle_delete(Client *client, G_GNUC_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
;
result
=
playlist_delete_range
(
&
g_playlist
,
client
->
player_control
,
result
=
playlist_delete_range
(
&
client
->
playlist
,
client
->
player_control
,
start
,
end
);
start
,
end
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -150,7 +153,8 @@ handle_deleteid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -150,7 +153,8 @@ handle_deleteid(Client *client, G_GNUC_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
;
result
=
playlist_delete_id
(
&
g_playlist
,
client
->
player_control
,
id
);
result
=
playlist_delete_id
(
&
client
->
playlist
,
client
->
player_control
,
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -158,7 +162,7 @@ enum command_return
...
@@ -158,7 +162,7 @@ enum command_return
handle_playlist
(
Client
*
client
,
handle_playlist
(
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist_print_uris
(
client
,
&
g_
playlist
);
playlist_print_uris
(
client
,
&
client
->
playlist
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -166,11 +170,12 @@ enum command_return
...
@@ -166,11 +170,12 @@ enum command_return
handle_shuffle
(
G_GNUC_UNUSED
Client
*
client
,
handle_shuffle
(
G_GNUC_UNUSED
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
unsigned
start
=
0
,
end
=
queue_length
(
&
g_
playlist
.
queue
);
unsigned
start
=
0
,
end
=
queue_length
(
&
client
->
playlist
.
queue
);
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_shuffle
(
&
g_playlist
,
client
->
player_control
,
start
,
end
);
playlist_shuffle
(
&
client
->
playlist
,
client
->
player_control
,
start
,
end
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -178,7 +183,7 @@ enum command_return
...
@@ -178,7 +183,7 @@ enum command_return
handle_clear
(
G_GNUC_UNUSED
Client
*
client
,
handle_clear
(
G_GNUC_UNUSED
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
playlist_clear
(
&
g_
playlist
,
client
->
player_control
);
playlist_clear
(
&
client
->
playlist
,
client
->
player_control
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -190,7 +195,7 @@ handle_plchanges(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -190,7 +195,7 @@ handle_plchanges(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_print_changes_info
(
client
,
&
g_
playlist
,
version
);
playlist_print_changes_info
(
client
,
&
client
->
playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -202,7 +207,7 @@ handle_plchangesposid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -202,7 +207,7 @@ handle_plchangesposid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_print_changes_position
(
client
,
&
g_
playlist
,
version
);
playlist_print_changes_position
(
client
,
&
client
->
playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -215,7 +220,7 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
...
@@ -215,7 +220,7 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
ret
=
playlist_print_info
(
client
,
&
g_
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
,
PLAYLIST_RESULT_BAD_RANGE
);
PLAYLIST_RESULT_BAD_RANGE
);
...
@@ -231,12 +236,12 @@ handle_playlistid(Client *client, int argc, char *argv[])
...
@@ -231,12 +236,12 @@ handle_playlistid(Client *client, 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
;
bool
ret
=
playlist_print_id
(
client
,
&
g_
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
,
PLAYLIST_RESULT_NO_SUCH_SONG
);
PLAYLIST_RESULT_NO_SUCH_SONG
);
}
else
{
}
else
{
playlist_print_info
(
client
,
&
g_
playlist
,
0
,
G_MAXUINT
);
playlist_print_info
(
client
,
&
client
->
playlist
,
0
,
G_MAXUINT
);
}
}
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
...
@@ -252,7 +257,7 @@ handle_playlist_match(Client *client, int argc, char *argv[],
...
@@ -252,7 +257,7 @@ handle_playlist_match(Client *client, int argc, char *argv[],
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
playlist_print_find
(
client
,
&
g_
playlist
,
filter
);
playlist_print_find
(
client
,
&
client
->
playlist
,
filter
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -289,7 +294,7 @@ handle_prio(Client *client, int argc, char *argv[])
...
@@ -289,7 +294,7 @@ handle_prio(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
playlist_set_priority
(
&
g_
playlist
,
playlist_set_priority
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
start_position
,
end_position
,
start_position
,
end_position
,
priority
);
priority
);
...
@@ -320,7 +325,7 @@ handle_prioid(Client *client, int argc, char *argv[])
...
@@ -320,7 +325,7 @@ handle_prioid(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
playlist_set_priority_id
(
&
g_
playlist
,
playlist_set_priority_id
(
&
client
->
playlist
,
client
->
player_control
,
client
->
player_control
,
song_id
,
priority
);
song_id
,
priority
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
...
@@ -341,7 +346,7 @@ handle_move(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -341,7 +346,7 @@ handle_move(Client *client, G_GNUC_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
;
result
=
playlist_move_range
(
&
g_
playlist
,
client
->
player_control
,
result
=
playlist_move_range
(
&
client
->
playlist
,
client
->
player_control
,
start
,
end
,
to
);
start
,
end
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -357,7 +362,7 @@ handle_moveid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -357,7 +362,7 @@ handle_moveid(Client *client, G_GNUC_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
;
result
=
playlist_move_id
(
&
g_
playlist
,
client
->
player_control
,
result
=
playlist_move_id
(
&
client
->
playlist
,
client
->
player_control
,
id
,
to
);
id
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -372,7 +377,7 @@ handle_swap(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -372,7 +377,7 @@ handle_swap(Client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
!
check_unsigned
(
client
,
&
song2
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
song2
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
result
=
playlist_swap_songs
(
&
g_
playlist
,
client
->
player_control
,
result
=
playlist_swap_songs
(
&
client
->
playlist
,
client
->
player_control
,
song1
,
song2
);
song1
,
song2
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -387,7 +392,8 @@ handle_swapid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -387,7 +392,8 @@ handle_swapid(Client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
result
=
playlist_swap_songs_id
(
&
g_playlist
,
client
->
player_control
,
result
=
playlist_swap_songs_id
(
&
client
->
playlist
,
client
->
player_control
,
id1
,
id2
);
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