2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
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
|
|
|
|
2021-05-21 20:35:29 +02:00
|
|
|
#include <fmt/format.h>
|
2009-03-03 17:01:42 +01:00
|
|
|
|
2021-05-21 20:35:29 +02:00
|
|
|
#include <cassert>
|
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
|
2023-03-14 20:20:19 +01:00
|
|
|
fmt::print(fp, " file://");
|
2009-03-03 17:01:42 +01:00
|
|
|
#endif
|
2023-03-12 09:11:45 +01:00
|
|
|
std::set<std::string, std::less<>> protocols;
|
2024-07-11 20:48:18 +02:00
|
|
|
|
|
|
|
for (const auto &plugin : GetAllInputPlugins()) {
|
|
|
|
plugin.ForeachSupportedUri([&](const char* uri) {
|
2019-04-17 20:47:55 +02:00
|
|
|
protocols.emplace(uri);
|
|
|
|
});
|
2024-07-11 20:48:18 +02:00
|
|
|
}
|
2019-08-09 15:54:13 +02:00
|
|
|
|
2024-07-10 19:21:10 +02:00
|
|
|
for (const DecoderPlugin &plugin : GetAllDecoderPlugins()) {
|
2020-09-21 13:01:51 +02:00
|
|
|
if (plugin.protocols != nullptr)
|
|
|
|
protocols.merge(plugin.protocols());
|
2024-07-10 19:21:10 +02:00
|
|
|
};
|
2020-09-21 13:01:51 +02:00
|
|
|
|
2020-02-01 06:03:57 +01:00
|
|
|
for (const auto& protocol : protocols) {
|
2023-03-14 20:20:19 +01:00
|
|
|
fmt::print(fp, " {}", protocol);
|
2019-04-17 20:47:55 +02:00
|
|
|
}
|
2023-03-14 20:20:19 +01:00
|
|
|
fmt::print(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
|
|
|
{
|
2023-03-12 09:11:45 +01:00
|
|
|
std::set<std::string, std::less<>> protocols;
|
2024-07-11 20:48:18 +02:00
|
|
|
|
|
|
|
for (const auto &plugin : GetEnabledInputPlugins()) {
|
|
|
|
plugin.ForeachSupportedUri([&](const char* uri) {
|
2019-04-17 20:47:55 +02:00
|
|
|
protocols.emplace(uri);
|
|
|
|
});
|
2024-07-11 20:48:18 +02:00
|
|
|
}
|
2019-04-17 20:47:55 +02:00
|
|
|
|
2024-07-10 19:21:10 +02:00
|
|
|
for (const auto &plugin : GetEnabledDecoderPlugins()) {
|
2020-09-21 13:01:51 +02:00
|
|
|
if (plugin.protocols != nullptr)
|
|
|
|
protocols.merge(plugin.protocols());
|
2024-07-10 19:21:10 +02:00
|
|
|
}
|
2020-09-21 13:01:51 +02:00
|
|
|
|
2020-02-01 06:03:57 +01:00
|
|
|
for (const auto& protocol : protocols) {
|
2021-05-21 20:35:29 +02:00
|
|
|
r.Fmt(FMT_STRING("handler: {}\n"), protocol);
|
2019-04-17 20:47:55 +02:00
|
|
|
}
|
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));
|
|
|
|
|
2024-07-11 20:48:18 +02:00
|
|
|
for (const auto &plugin : GetEnabledInputPlugins()) {
|
|
|
|
if (plugin.SupportsUri(uri))
|
2019-07-29 11:08:47 +02:00
|
|
|
return true;
|
2024-07-11 20:48:18 +02:00
|
|
|
}
|
2004-05-13 20:46:38 +02:00
|
|
|
|
2024-07-11 15:50:37 +02:00
|
|
|
for (const auto &plugin : GetEnabledDecoderPlugins()) {
|
|
|
|
if (plugin.SupportsUri(uri))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2004-05-13 20:46:38 +02:00
|
|
|
}
|