Merge branch 'protocol_features' of https://github.com/jcorporation/MPD
This commit is contained in:
@@ -156,6 +156,7 @@ static constexpr struct command commands[] = {
|
||||
{ "previous", PERMISSION_PLAYER, 0, 0, handle_previous },
|
||||
{ "prio", PERMISSION_PLAYER, 2, -1, handle_prio },
|
||||
{ "prioid", PERMISSION_PLAYER, 2, -1, handle_prioid },
|
||||
{ "protocol", PERMISSION_NONE, 0, -1, handle_protocol },
|
||||
{ "random", PERMISSION_PLAYER, 1, 1, handle_random },
|
||||
{ "rangeid", PERMISSION_ADD, 2, 2, handle_rangeid },
|
||||
{ "readcomments", PERMISSION_READ, 1, 1, handle_read_comments },
|
||||
|
@@ -112,3 +112,67 @@ handle_tagtypes(Client &client, Request request, Response &r)
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static ProtocolFeature
|
||||
ParseProtocolFeature(Request request)
|
||||
{
|
||||
if (request.empty())
|
||||
throw ProtocolError(ACK_ERROR_ARG, "Not enough arguments");
|
||||
|
||||
ProtocolFeature result = ProtocolFeature::None();
|
||||
|
||||
for (const char *name : request) {
|
||||
auto type = protocol_feature_parse_i(name);
|
||||
if (type == PF_NUM_OF_ITEM_TYPES)
|
||||
throw ProtocolError(ACK_ERROR_ARG, "Unknown protcol feature");
|
||||
|
||||
result |= type;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_protocol(Client &client, Request request, Response &r)
|
||||
{
|
||||
if (request.empty()) {
|
||||
protocol_features_print(client, r);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
const char *cmd = request.shift();
|
||||
if (StringIsEqual(cmd, "all")) {
|
||||
if (!request.empty()) {
|
||||
r.Error(ACK_ERROR_ARG, "Too many arguments");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
client.AllProtocolFeatures();
|
||||
return CommandResult::OK;
|
||||
} else if (StringIsEqual(cmd, "clear")) {
|
||||
if (!request.empty()) {
|
||||
r.Error(ACK_ERROR_ARG, "Too many arguments");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
client.ClearProtocolFeatures();
|
||||
return CommandResult::OK;
|
||||
} else if (StringIsEqual(cmd, "enable")) {
|
||||
client.SetProtocolFeatures(ParseProtocolFeature(request), true);
|
||||
return CommandResult::OK;
|
||||
} else if (StringIsEqual(cmd, "disable")) {
|
||||
client.SetProtocolFeatures(ParseProtocolFeature(request), false);
|
||||
return CommandResult::OK;
|
||||
} else if (StringIsEqual(cmd, "available")) {
|
||||
if (!request.empty()) {
|
||||
r.Error(ACK_ERROR_ARG, "Too many arguments");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
protocol_features_print_all(r);
|
||||
return CommandResult::OK;
|
||||
} else {
|
||||
r.Error(ACK_ERROR_ARG, "Unknown sub command");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
}
|
||||
|
@@ -25,4 +25,7 @@ handle_password(Client &client, Request request, Response &response);
|
||||
CommandResult
|
||||
handle_tagtypes(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_protocol(Client &client, Request request, Response &response);
|
||||
|
||||
#endif
|
||||
|
@@ -160,7 +160,7 @@ handle_lsinfo_relative(Client &client, Response &r, const char *uri)
|
||||
(void)client;
|
||||
#endif
|
||||
|
||||
if (isRootDirectory(uri)) {
|
||||
if (!client.ProtocolFeatureEnabled(PF_HIDE_PLAYLISTS_IN_ROOT) && isRootDirectory(uri)) {
|
||||
try {
|
||||
print_spl_list(r, ListPlaylistFiles());
|
||||
} catch (...) {
|
||||
|
Reference in New Issue
Block a user