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
2a1bef22
Commit
2a1bef22
authored
Feb 04, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist_print: added wrappers for printing the queue
Hide the details of the playlist behind wrapper functions.
parent
cbea8a2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
31 deletions
+164
-31
command.c
src/command.c
+13
-31
playlist_print.c
src/playlist_print.c
+85
-0
playlist_print.h
src/playlist_print.h
+66
-0
No files found.
src/command.c
View file @
2a1bef22
...
@@ -421,12 +421,7 @@ static enum command_return
...
@@ -421,12 +421,7 @@ static enum command_return
handle_currentsong
(
struct
client
*
client
,
handle_currentsong
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
int
song
=
getPlaylistCurrentSong
(
&
g_playlist
);
playlist_print_current
(
client
,
&
g_playlist
);
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
);
if
(
song
>=
0
)
queue_print_info
(
client
,
queue
,
song
,
song
+
1
);
return
PLAYLIST_RESULT_SUCCESS
;
return
PLAYLIST_RESULT_SUCCESS
;
}
}
...
@@ -642,9 +637,7 @@ static enum command_return
...
@@ -642,9 +637,7 @@ static enum command_return
handle_playlist
(
struct
client
*
client
,
handle_playlist
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
);
playlist_print_uris
(
client
,
&
g_playlist
);
queue_print_uris
(
client
,
queue
,
0
,
queue_length
(
queue
));
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -766,12 +759,11 @@ static enum command_return
...
@@ -766,12 +759,11 @@ static enum command_return
handle_plchanges
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
handle_plchanges
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
{
uint32_t
version
;
uint32_t
version
;
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
);
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
queue_print_changes_info
(
client
,
queue
,
version
);
playlist_print_changes_info
(
client
,
&
g_playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -779,12 +771,11 @@ static enum command_return
...
@@ -779,12 +771,11 @@ static enum command_return
handle_plchangesposid
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
handle_plchangesposid
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
{
uint32_t
version
;
uint32_t
version
;
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
);
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
queue_print_changes_position
(
client
,
queue
,
version
);
playlist_print_changes_position
(
client
,
&
g_playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -792,46 +783,37 @@ static enum command_return
...
@@ -792,46 +783,37 @@ static enum command_return
handle_playlistinfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistinfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
start
=
0
,
end
=
UINT_MAX
;
unsigned
start
=
0
,
end
=
UINT_MAX
;
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
)
;
bool
ret
;
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
],
need_range
))
argv
[
1
],
need_range
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
end
>
queue_length
(
queue
))
ret
=
playlist_print_info
(
client
,
&
g_playlist
,
start
,
end
);
end
=
queue_length
(
queue
);
if
(
!
ret
)
if
(
start
>
end
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_BAD_RANGE
);
PLAYLIST_RESULT_BAD_RANGE
);
queue_print_info
(
client
,
queue
,
start
,
end
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
static
enum
command_return
static
enum
command_return
handle_playlistid
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistid
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
int
id
=
-
1
,
start
;
int
id
=
-
1
;
unsigned
end
;
const
struct
queue
*
queue
=
playlist_get_queue
(
&
g_playlist
);
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
],
need_positive
))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
id
>=
0
)
{
if
(
id
>=
0
)
{
start
=
queue_id_to_position
(
queue
,
id
);
bool
ret
=
playlist_print_id
(
client
,
&
g_playlist
,
id
);
if
(
start
<
0
)
if
(
!
ret
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_NO_SUCH_SONG
);
PLAYLIST_RESULT_NO_SUCH_SONG
);
end
=
start
+
1
;
}
else
{
}
else
{
start
=
0
;
playlist_print_info
(
client
,
&
g_playlist
,
0
,
UINT_MAX
);
end
=
queue_length
(
queue
);
}
}
queue_print_info
(
client
,
queue
,
start
,
end
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -924,7 +906,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
...
@@ -924,7 +906,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
queue_find
(
client
,
playlist_get_queue
(
&
g_playlist
)
,
list
);
playlist_print_find
(
client
,
&
g_playlist
,
list
);
locate_item_list_free
(
list
);
locate_item_list_free
(
list
);
...
@@ -945,7 +927,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
...
@@ -945,7 +927,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
queue_search
(
client
,
playlist_get_queue
(
&
g_playlist
)
,
list
);
playlist_print_search
(
client
,
&
g_playlist
,
list
);
locate_item_list_free
(
list
);
locate_item_list_free
(
list
);
...
...
src/playlist_print.c
View file @
2a1bef22
...
@@ -17,12 +17,97 @@
...
@@ -17,12 +17,97 @@
*/
*/
#include "playlist_print.h"
#include "playlist_print.h"
#include "queue_print.h"
#include "stored_playlist.h"
#include "stored_playlist.h"
#include "song_print.h"
#include "song_print.h"
#include "song.h"
#include "song.h"
#include "database.h"
#include "database.h"
#include "client.h"
#include "client.h"
void
playlist_print_uris
(
struct
client
*
client
,
const
struct
playlist
*
playlist
)
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
queue_print_uris
(
client
,
queue
,
0
,
queue_length
(
queue
));
}
bool
playlist_print_info
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
)
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
if
(
end
>
queue_length
(
queue
))
/* correct the "end" offset */
end
=
queue_length
(
queue
);
if
(
start
>
end
)
/* an invalid "start" offset is fatal */
return
false
;
queue_print_info
(
client
,
queue
,
start
,
end
);
return
true
;
}
bool
playlist_print_id
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
unsigned
id
)
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
int
position
;
position
=
queue_id_to_position
(
queue
,
id
);
if
(
position
<
0
)
/* no such song */
return
false
;
return
playlist_print_info
(
client
,
playlist
,
position
,
position
+
1
);
}
bool
playlist_print_current
(
struct
client
*
client
,
const
struct
playlist
*
playlist
)
{
int
current_position
=
getPlaylistCurrentSong
(
playlist
);
if
(
current_position
<
0
)
return
false
;
queue_print_info
(
client
,
&
playlist
->
queue
,
current_position
,
current_position
+
1
);
return
true
;
}
void
playlist_print_find
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
const
struct
locate_item_list
*
list
)
{
queue_find
(
client
,
&
playlist
->
queue
,
list
);
}
void
playlist_print_search
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
const
struct
locate_item_list
*
list
)
{
queue_search
(
client
,
&
playlist
->
queue
,
list
);
}
void
playlist_print_changes_info
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
uint32_t
version
)
{
queue_print_changes_info
(
client
,
&
playlist
->
queue
,
version
);
}
void
playlist_print_changes_position
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
uint32_t
version
)
{
queue_print_changes_position
(
client
,
&
playlist
->
queue
,
version
);
}
bool
bool
spl_print
(
struct
client
*
client
,
const
char
*
name_utf8
,
bool
detail
)
spl_print
(
struct
client
*
client
,
const
char
*
name_utf8
,
bool
detail
)
{
{
...
...
src/playlist_print.h
View file @
2a1bef22
...
@@ -20,8 +20,74 @@
...
@@ -20,8 +20,74 @@
#define PLAYLIST_PRINT_H
#define PLAYLIST_PRINT_H
#include <stdbool.h>
#include <stdbool.h>
#include <stdint.h>
struct
client
;
struct
client
;
struct
playlist
;
struct
locate_item_list
;
/**
* Sends the whole playlist to the client, song URIs only.
*/
void
playlist_print_uris
(
struct
client
*
client
,
const
struct
playlist
*
playlist
);
/**
* Sends a range of the playlist to the client, including all known
* information about the songs. The "end" offset is decreased
* automatically if it is too large; passing UINT_MAX is allowed.
* This function however fails when the start offset is invalid.
*/
bool
playlist_print_info
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
);
/**
* Sends the song with the specified id to the client.
*
* @return true on suite, false if there is no such song
*/
bool
playlist_print_id
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
unsigned
id
);
/**
* Sends the current song to the client.
*
* @return true on success, false if there is no current song
*/
bool
playlist_print_current
(
struct
client
*
client
,
const
struct
playlist
*
playlist
);
/**
* Find songs in the playlist.
*/
void
playlist_print_find
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
const
struct
locate_item_list
*
list
);
/**
* Search for songs in the playlist.
*/
void
playlist_print_search
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
const
struct
locate_item_list
*
list
);
/**
* Print detailed changes since the specified playlist version.
*/
void
playlist_print_changes_info
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
uint32_t
version
);
/**
* Print changes since the specified playlist version, position only.
*/
void
playlist_print_changes_position
(
struct
client
*
client
,
const
struct
playlist
*
playlist
,
uint32_t
version
);
/**
/**
* Send the stored playlist to the client.
* Send the stored playlist to the client.
...
...
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