2009-10-13 18:53:33 +02:00
|
|
|
/*
|
2014-01-13 22:30:36 +01:00
|
|
|
* Copyright (C) 2003-2014 The Music Player Daemon Project
|
2009-10-13 18:53:33 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2014-01-23 23:30:12 +01:00
|
|
|
#include "Print.hxx"
|
2013-01-02 18:38:32 +01:00
|
|
|
#include "PlaylistAny.hxx"
|
|
|
|
#include "PlaylistSong.hxx"
|
2013-09-05 09:37:54 +02:00
|
|
|
#include "SongEnumerator.hxx"
|
2014-01-23 23:30:12 +01:00
|
|
|
#include "SongPrint.hxx"
|
2014-01-24 16:18:21 +01:00
|
|
|
#include "input/InputStream.hxx"
|
2014-01-07 21:39:47 +01:00
|
|
|
#include "DetachedSong.hxx"
|
2013-10-21 10:26:53 +02:00
|
|
|
#include "fs/Traits.hxx"
|
2014-01-23 23:30:12 +01:00
|
|
|
#include "thread/Cond.hxx"
|
2013-10-17 09:43:55 +02:00
|
|
|
|
2014-01-23 23:30:12 +01:00
|
|
|
static void
|
|
|
|
playlist_provider_print(Client &client, const char *uri,
|
|
|
|
SongEnumerator &e, bool detail)
|
2009-10-13 18:53:33 +02:00
|
|
|
{
|
2013-10-21 10:26:53 +02:00
|
|
|
const std::string base_uri = uri != nullptr
|
2013-12-04 22:53:43 +01:00
|
|
|
? PathTraitsUTF8::GetParent(uri)
|
2013-10-21 10:26:53 +02:00
|
|
|
: std::string(".");
|
2009-10-13 18:53:33 +02:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
DetachedSong *song;
|
2014-01-23 23:30:12 +01:00
|
|
|
while ((song = e.NextSong()) != nullptr) {
|
|
|
|
if (playlist_check_translate_song(*song, base_uri.c_str(),
|
|
|
|
false)) {
|
|
|
|
if (detail)
|
|
|
|
song_print_info(client, *song);
|
|
|
|
else
|
|
|
|
song_print_uri(client, *song);
|
2012-02-09 23:44:33 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
delete song;
|
2009-10-13 18:53:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 23:30:12 +01:00
|
|
|
bool
|
|
|
|
playlist_file_print(Client &client, const char *uri, bool detail)
|
2009-11-06 01:07:42 +01:00
|
|
|
{
|
2013-01-27 17:20:50 +01:00
|
|
|
Mutex mutex;
|
|
|
|
Cond cond;
|
2011-09-14 21:46:41 +02:00
|
|
|
|
2013-10-23 22:08:59 +02:00
|
|
|
InputStream *is;
|
2014-01-23 23:30:12 +01:00
|
|
|
SongEnumerator *playlist = playlist_open_any(uri, mutex, cond, &is);
|
2013-10-02 08:13:28 +02:00
|
|
|
if (playlist == nullptr)
|
2014-01-23 23:30:12 +01:00
|
|
|
return false;
|
2010-06-01 09:10:58 +02:00
|
|
|
|
2014-01-23 23:30:12 +01:00
|
|
|
playlist_provider_print(client, uri, *playlist, detail);
|
2013-09-05 09:37:54 +02:00
|
|
|
delete playlist;
|
2010-06-01 09:10:58 +02:00
|
|
|
|
2013-10-02 08:13:28 +02:00
|
|
|
if (is != nullptr)
|
2013-09-05 00:06:31 +02:00
|
|
|
is->Close();
|
2009-12-26 02:10:38 +01:00
|
|
|
|
2014-01-23 23:30:12 +01:00
|
|
|
return true;
|
2009-11-06 01:07:42 +01:00
|
|
|
}
|