db_print: print absolute URI of playlist entries
The protocol mandates that playlist URIs are absolute (i.e. full URI relative to the music directory, not relative to the parent directory). This adds the parameter "directory" to the "playlist" visitor method.
This commit is contained in:
parent
b43bf4dd74
commit
49b84f9229
@ -73,21 +73,35 @@ print_visitor_song_info(struct song *song, void *data,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
print_playlist_in_directory(struct client *client,
|
||||
const struct directory *directory,
|
||||
const char *name_utf8)
|
||||
{
|
||||
if (directory_is_root(directory))
|
||||
client_printf(client, "playlist: %s\n", name_utf8);
|
||||
else
|
||||
client_printf(client, "playlist: %s/%s\n",
|
||||
directory_get_path(directory), name_utf8);
|
||||
}
|
||||
|
||||
static bool
|
||||
print_visitor_playlist(const struct playlist_metadata *playlist, void *ctx,
|
||||
print_visitor_playlist(const struct playlist_metadata *playlist,
|
||||
const struct directory *directory, void *ctx,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
struct client *client = ctx;
|
||||
client_printf(client, "playlist: %s\n", playlist->name);
|
||||
print_playlist_in_directory(client, directory, playlist->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
print_visitor_playlist_info(const struct playlist_metadata *playlist,
|
||||
const struct directory *directory,
|
||||
void *ctx, G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
struct client *client = ctx;
|
||||
client_printf(client, "playlist: %s\n", playlist->name);
|
||||
print_playlist_in_directory(client, directory, playlist->name);
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
struct tm tm;
|
||||
|
@ -43,9 +43,11 @@ struct db_visitor {
|
||||
/**
|
||||
* Visit a playlist. Optional method.
|
||||
*
|
||||
* @param directory the directory the playlist resides in
|
||||
* @return true to continue the operation, false on error (set error_r)
|
||||
*/
|
||||
bool (*playlist)(const struct playlist_metadata *playlist, void *ctx,
|
||||
bool (*playlist)(const struct playlist_metadata *playlist,
|
||||
const struct directory *directory, void *ctx,
|
||||
GError **error_r);
|
||||
};
|
||||
|
||||
|
@ -188,7 +188,7 @@ directory_walk(const struct directory *directory, bool recursive,
|
||||
const struct playlist_vector *pv = &directory->playlists;
|
||||
for (const struct playlist_metadata *i = pv->head;
|
||||
i != NULL; i = i->next)
|
||||
if (!visitor->playlist(i, ctx, error_r))
|
||||
if (!visitor->playlist(i, directory, ctx, error_r))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user