2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2021-01-01 19:54:25 +01:00
|
|
|
* Copyright 2003-2021 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2013-01-03 17:34:51 +01:00
|
|
|
#include "ls.hxx"
|
2018-10-24 20:25:32 +02:00
|
|
|
#include "input/Registry.hxx"
|
|
|
|
#include "input/InputPlugin.hxx"
|
2020-09-21 13:01:51 +02:00
|
|
|
#include "decoder/DecoderList.hxx"
|
|
|
|
#include "decoder/DecoderPlugin.hxx"
|
2015-08-06 22:10:25 +02:00
|
|
|
#include "client/Response.hxx"
|
2019-08-09 15:54:13 +02:00
|
|
|
#include "util/UriExtract.hxx"
|
2013-01-03 10:33:04 +01:00
|
|
|
|
2020-03-12 23:20:59 +01:00
|
|
|
#include <cassert>
|
2009-03-03 17:01:42 +01:00
|
|
|
|
2019-04-17 20:47:55 +02:00
|
|
|
#include <string>
|
|
|
|
|
2009-03-03 17:01:42 +01:00
|
|
|
void print_supported_uri_schemes_to_fp(FILE *fp)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_UN
|
2012-06-12 22:29:04 +02:00
|
|
|
fprintf(fp, " file://");
|
2009-03-03 17:01:42 +01:00
|
|
|
#endif
|
2019-04-17 20:47:55 +02:00
|
|
|
std::set<std::string> protocols;
|
2018-10-24 20:25:32 +02:00
|
|
|
input_plugins_for_each(plugin)
|
2019-04-17 20:47:55 +02:00
|
|
|
plugin->ForeachSupportedUri([&](const char* uri) {
|
|
|
|
protocols.emplace(uri);
|
|
|
|
});
|
2019-08-09 15:54:13 +02:00
|
|
|
|
2020-09-21 13:01:51 +02:00
|
|
|
decoder_plugins_for_each([&protocols](const auto &plugin){
|
|
|
|
if (plugin.protocols != nullptr)
|
|
|
|
protocols.merge(plugin.protocols());
|
|
|
|
});
|
|
|
|
|
2020-02-01 06:03:57 +01:00
|
|
|
for (const auto& protocol : protocols) {
|
2019-04-17 20:47:55 +02:00
|
|
|
fprintf(fp, " %s", protocol.c_str());
|
|
|
|
}
|
2009-03-03 22:07:34 +01:00
|
|
|
fprintf(fp,"\n");
|
2009-03-03 17:01:42 +01:00
|
|
|
}
|
|
|
|
|
2015-08-06 22:10:25 +02:00
|
|
|
void
|
|
|
|
print_supported_uri_schemes(Response &r)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2019-04-17 20:47:55 +02:00
|
|
|
std::set<std::string> protocols;
|
2018-10-24 20:25:32 +02:00
|
|
|
input_plugins_for_each_enabled(plugin)
|
2019-04-17 20:47:55 +02:00
|
|
|
plugin->ForeachSupportedUri([&](const char* uri) {
|
|
|
|
protocols.emplace(uri);
|
|
|
|
});
|
|
|
|
|
2020-09-21 13:01:51 +02:00
|
|
|
decoder_plugins_for_each_enabled([&protocols](const auto &plugin){
|
|
|
|
if (plugin.protocols != nullptr)
|
|
|
|
protocols.merge(plugin.protocols());
|
|
|
|
});
|
|
|
|
|
2020-02-01 06:03:57 +01:00
|
|
|
for (const auto& protocol : protocols) {
|
2019-04-17 20:47:55 +02:00
|
|
|
r.Format("handler: %s\n", protocol.c_str());
|
|
|
|
}
|
2004-06-03 01:22:37 +02:00
|
|
|
}
|
|
|
|
|
2017-05-08 14:44:49 +02:00
|
|
|
bool
|
|
|
|
uri_supported_scheme(const char *uri) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2009-01-04 17:46:42 +01:00
|
|
|
assert(uri_has_scheme(uri));
|
|
|
|
|
2018-10-24 20:25:32 +02:00
|
|
|
input_plugins_for_each_enabled(plugin)
|
2019-07-29 11:08:47 +02:00
|
|
|
if (plugin->SupportsUri(uri))
|
|
|
|
return true;
|
2004-05-13 20:46:38 +02:00
|
|
|
|
2020-09-21 13:01:51 +02:00
|
|
|
return decoder_plugins_try([uri](const auto &plugin){
|
|
|
|
return plugin.SupportsUri(uri);
|
|
|
|
});
|
2004-05-13 20:46:38 +02:00
|
|
|
}
|