ConfigServer: Add methods to list groups and keys

Applications that make use of LibConfig anyway have now a way of listing
the groups and keys without resorting to using Core::ConfigFile
directly.
This commit is contained in:
faxe1008 2021-11-16 20:04:41 +01:00 committed by Andreas Kling
parent 2266b4acdb
commit 116d89eec6
Notes: sideshowbarker 2024-07-18 01:01:32 +09:00
3 changed files with 21 additions and 0 deletions

View file

@ -135,6 +135,22 @@ void ClientConnection::sync_dirty_domains_to_disk()
}
}
Messages::ConfigServer::ListConfigKeysResponse ClientConnection::list_config_keys(String const& domain, String const& group)
{
if (!validate_access(domain, group, ""))
return Vector<String> {};
auto& config = ensure_domain_config(domain);
return { config.keys(group) };
}
Messages::ConfigServer::ListConfigGroupsResponse ClientConnection::list_config_groups(String const& domain)
{
if (!validate_access(domain, "", ""))
return Vector<String> {};
auto& config = ensure_domain_config(domain);
return { config.groups() };
}
Messages::ConfigServer::ReadStringValueResponse ClientConnection::read_string_value(String const& domain, String const& group, String const& key)
{
if (!validate_access(domain, group, key))

View file

@ -27,6 +27,8 @@ private:
virtual void pledge_domains(Vector<String> const&) override;
virtual void monitor_domain(String const&) override;
virtual Messages::ConfigServer::ListConfigGroupsResponse list_config_groups([[maybe_unused]] String const& domain) override;
virtual Messages::ConfigServer::ListConfigKeysResponse list_config_keys([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group) override;
virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;

View file

@ -4,6 +4,9 @@ endpoint ConfigServer
monitor_domain(String domain) =|
list_config_groups(String domain) => (Vector<String> groups)
list_config_keys(String domain, String group) => (Vector<String> keys)
read_string_value(String domain, String group, String key) => (Optional<String> value)
read_i32_value(String domain, String group, String key) => (Optional<i32> value)
read_bool_value(String domain, String group, String key) => (Optional<bool> value)