diff options
author | faxe1008 <fabianblatz@gmail.com> | 2021-11-16 20:04:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-18 09:08:51 +0100 |
commit | 116d89eec643bf6734576f2d21e6e14f493c6b32 (patch) | |
tree | 2b03e6e007a336e85785769575ed88090a5ae1a8 | |
parent | 2266b4acdb02f96afc9239a45dcbd74c9ad01163 (diff) | |
download | serenity-116d89eec643bf6734576f2d21e6e14f493c6b32.zip |
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.
-rw-r--r-- | Userland/Services/ConfigServer/ClientConnection.cpp | 16 | ||||
-rw-r--r-- | Userland/Services/ConfigServer/ClientConnection.h | 2 | ||||
-rw-r--r-- | Userland/Services/ConfigServer/ConfigServer.ipc | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Services/ConfigServer/ClientConnection.cpp b/Userland/Services/ConfigServer/ClientConnection.cpp index e0ad17c0ee..d52e2bf237 100644 --- a/Userland/Services/ConfigServer/ClientConnection.cpp +++ b/Userland/Services/ConfigServer/ClientConnection.cpp @@ -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)) diff --git a/Userland/Services/ConfigServer/ClientConnection.h b/Userland/Services/ConfigServer/ClientConnection.h index 24332b7a02..60b8c34a3a 100644 --- a/Userland/Services/ConfigServer/ClientConnection.h +++ b/Userland/Services/ConfigServer/ClientConnection.h @@ -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; diff --git a/Userland/Services/ConfigServer/ConfigServer.ipc b/Userland/Services/ConfigServer/ConfigServer.ipc index a0e65fe213..e7bd355cb1 100644 --- a/Userland/Services/ConfigServer/ConfigServer.ipc +++ b/Userland/Services/ConfigServer/ConfigServer.ipc @@ -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) |