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-07 21:39:47 +01:00
|
|
|
#include "DetachedSong.hxx"
|
2014-02-02 14:37:52 +01:00
|
|
|
#include "SongLoader.hxx"
|
2013-10-21 10:26:53 +02:00
|
|
|
#include "fs/Traits.hxx"
|
2014-02-07 20:27:24 +01:00
|
|
|
#include "thread/Mutex.hxx"
|
2014-01-23 23:30:12 +01:00
|
|
|
#include "thread/Cond.hxx"
|
2014-02-07 20:22:26 +01:00
|
|
|
#include "client/Client.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-02-02 14:37:52 +01:00
|
|
|
const SongLoader loader(client);
|
|
|
|
|
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(),
|
2014-02-02 14:37:52 +01:00
|
|
|
loader)) {
|
2014-01-23 23:30:12 +01:00
|
|
|
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
|
|
|
|
2014-02-07 20:22:26 +01:00
|
|
|
SongEnumerator *playlist = playlist_open_any(uri,
|
|
|
|
#ifdef ENABLE_DATABASE
|
|
|
|
client.GetStorage(),
|
|
|
|
#endif
|
|
|
|
mutex, cond);
|
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;
|
2014-01-23 23:30:12 +01:00
|
|
|
return true;
|
2009-11-06 01:07:42 +01:00
|
|
|
}
|