diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-12-20 07:12:21 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-23 23:26:21 +0100 |
commit | 69beda23c3ad15b7b65c6f2fdcfbe22d18b84c8e (patch) | |
tree | df70f5944b80730d522760be673668a65ea776a3 /Userland/Services/ConfigServer | |
parent | 49f697ed563c26a90732b17f6649fb23cc44057b (diff) | |
download | serenity-69beda23c3ad15b7b65c6f2fdcfbe22d18b84c8e.zip |
LibConfig+LibCore+ConfigServer: Support u32 configuration entries
Diffstat (limited to 'Userland/Services/ConfigServer')
4 files changed, 35 insertions, 0 deletions
diff --git a/Userland/Services/ConfigServer/ConfigClient.ipc b/Userland/Services/ConfigServer/ConfigClient.ipc index db5a2a411a..39ea54622f 100644 --- a/Userland/Services/ConfigServer/ConfigClient.ipc +++ b/Userland/Services/ConfigServer/ConfigClient.ipc @@ -2,6 +2,7 @@ endpoint ConfigClient { notify_changed_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, DeprecatedString value) =| notify_changed_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, i32 value) =| + notify_changed_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, u32 value) =| notify_changed_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, bool value) =| notify_removed_key(DeprecatedString domain, DeprecatedString group, DeprecatedString key) =| notify_removed_group(DeprecatedString domain, DeprecatedString group) =| diff --git a/Userland/Services/ConfigServer/ConfigServer.ipc b/Userland/Services/ConfigServer/ConfigServer.ipc index 4a7bd1a428..e441b0d633 100644 --- a/Userland/Services/ConfigServer/ConfigServer.ipc +++ b/Userland/Services/ConfigServer/ConfigServer.ipc @@ -9,10 +9,12 @@ endpoint ConfigServer read_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<DeprecatedString> value) read_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<i32> value) + read_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<u32> value) read_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<bool> value) write_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, DeprecatedString value) => () write_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, i32 value) => () + write_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, u32 value) => () write_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, bool value) => () remove_key_entry(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => () remove_group_entry(DeprecatedString domain, DeprecatedString group) => () diff --git a/Userland/Services/ConfigServer/ConnectionFromClient.cpp b/Userland/Services/ConfigServer/ConnectionFromClient.cpp index ccc7ba188c..1e3c77b6f7 100644 --- a/Userland/Services/ConfigServer/ConnectionFromClient.cpp +++ b/Userland/Services/ConfigServer/ConnectionFromClient.cpp @@ -173,6 +173,17 @@ Messages::ConfigServer::ReadI32ValueResponse ConnectionFromClient::read_i32_valu return Optional<i32> { config.read_num_entry(group, key) }; } +Messages::ConfigServer::ReadU32ValueResponse ConnectionFromClient::read_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key) +{ + if (!validate_access(domain, group, key)) + return nullptr; + + auto& config = ensure_domain_config(domain); + if (!config.has_key(group, key)) + return Optional<u32> {}; + return Optional<u32> { config.read_num_entry<u32>(group, key) }; +} + Messages::ConfigServer::ReadBoolValueResponse ConnectionFromClient::read_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key) { if (!validate_access(domain, group, key)) @@ -230,6 +241,25 @@ void ConnectionFromClient::write_i32_value(DeprecatedString const& domain, Depre }); } +void ConnectionFromClient::write_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, u32 value) +{ + if (!validate_access(domain, group, key)) + return; + + auto& config = ensure_domain_config(domain); + + if (config.has_key(group, key) && config.read_num_entry<u32>(group, key) == value) + return; + + config.write_num_entry(group, key, value); + m_dirty_domains.set(domain); + start_or_restart_sync_timer(); + + for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ConnectionFromClient& connection) { + connection.async_notify_changed_u32_value(domain, group, key, value); + }); +} + void ConnectionFromClient::write_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value) { if (!validate_access(domain, group, key)) diff --git a/Userland/Services/ConfigServer/ConnectionFromClient.h b/Userland/Services/ConfigServer/ConnectionFromClient.h index c500ce3ccd..415a3d2f9f 100644 --- a/Userland/Services/ConfigServer/ConnectionFromClient.h +++ b/Userland/Services/ConfigServer/ConnectionFromClient.h @@ -31,9 +31,11 @@ private: virtual Messages::ConfigServer::ListConfigKeysResponse list_config_keys([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group) override; virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override; virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override; + virtual Messages::ConfigServer::ReadU32ValueResponse read_u32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override; virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override; virtual void write_string_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] DeprecatedString const& value) override; virtual void write_i32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] i32 value) override; + virtual void write_u32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] u32 value) override; virtual void write_bool_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] bool value) override; virtual void remove_key_entry([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override; virtual void remove_group_entry([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group) override; |