Add "General.GetRPCCommands" RPC command

This commit is contained in:
badaix 2025-02-04 21:11:32 +01:00 committed by Johannes Pohl
parent 9570018cf4
commit a72c6948b1
7 changed files with 106 additions and 20 deletions

View file

@ -1,6 +1,6 @@
/***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
Copyright (C) 2014-2025 Johannes Pohl
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
@ -55,7 +55,7 @@ public:
virtual void execute(const jsonrpcpp::request_ptr& request, AuthInfo& authinfo, const OnResponse& on_response) = 0;
/// @return true if the user has the permission for the request
bool hasPermission(const AuthInfo& authinfo) const;
virtual bool hasPermission(const AuthInfo& authinfo) const;
/// @return the name of the method
const std::string& method() const;
@ -312,6 +312,23 @@ public:
};
/// "General.GetRpcCommands" request
class GeneralGetRpcCommands : public Request
{
public:
/// c'tor
explicit GeneralGetRpcCommands(const Server& server);
void execute(const jsonrpcpp::request_ptr& request, AuthInfo& authinfo, const OnResponse& on_response) override;
bool hasPermission(const AuthInfo& authinfo) const override;
/// Set available @p requests
void setCommands(std::vector<std::shared_ptr<Request>> requests);
private:
std::vector<std::shared_ptr<Request>> requests_;
};
#if 0
/// "Server.GetToken" request
class ServerGetTokenRequest : public Request