From 7652a2986b0d0ad55b2776685130f1c68d7108c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 6 Aug 2015 22:10:25 +0200 Subject: client/Response: new Client wrapper class for writing responses --- src/playlist/Print.cxx | 21 ++++++++++++--------- src/playlist/Print.hxx | 9 ++++++--- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/playlist') diff --git a/src/playlist/Print.cxx b/src/playlist/Print.cxx index 3de9807b7..13e45d160 100644 --- a/src/playlist/Print.cxx +++ b/src/playlist/Print.cxx @@ -28,48 +28,51 @@ #include "fs/Traits.hxx" #include "thread/Mutex.hxx" #include "thread/Cond.hxx" -#include "client/Client.hxx" +#include "Partition.hxx" +#include "Instance.hxx" static void -playlist_provider_print(Client &client, const char *uri, +playlist_provider_print(Response &r, Partition &partition, + const SongLoader &loader, + const char *uri, SongEnumerator &e, bool detail) { const std::string base_uri = uri != nullptr ? PathTraitsUTF8::GetParent(uri) : std::string("."); - const SongLoader loader(client); - DetachedSong *song; while ((song = e.NextSong()) != nullptr) { if (playlist_check_translate_song(*song, base_uri.c_str(), loader) && detail) - song_print_info(client, *song); + song_print_info(r, partition, *song); else /* fallback if no detail was requested or no detail was available */ - song_print_uri(client, *song); + song_print_uri(r, partition, *song); delete song; } } bool -playlist_file_print(Client &client, const char *uri, bool detail) +playlist_file_print(Response &r, Partition &partition, + const SongLoader &loader, + const char *uri, bool detail) { Mutex mutex; Cond cond; SongEnumerator *playlist = playlist_open_any(uri, #ifdef ENABLE_DATABASE - client.GetStorage(), + partition.instance.storage, #endif mutex, cond); if (playlist == nullptr) return false; - playlist_provider_print(client, uri, *playlist, detail); + playlist_provider_print(r, partition, loader, uri, *playlist, detail); delete playlist; return true; } diff --git a/src/playlist/Print.hxx b/src/playlist/Print.hxx index 02096bdc2..3b356d4ce 100644 --- a/src/playlist/Print.hxx +++ b/src/playlist/Print.hxx @@ -20,17 +20,20 @@ #ifndef MPD_PLAYLIST__PRINT_HXX #define MPD_PLAYLIST__PRINT_HXX -class Client; +class Response; +class SongLoader; +struct Partition; /** * Send the playlist file to the client. * - * @param client the client which requested the playlist * @param uri the URI of the playlist file in UTF-8 encoding * @param detail true if all details should be printed * @return true on success, false if the playlist does not exist */ bool -playlist_file_print(Client &client, const char *uri, bool detail); +playlist_file_print(Response &r, Partition &partition, + const SongLoader &loader, + const char *uri, bool detail); #endif -- cgit v1.2.3