mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
LibConfig+LibCore+ConfigServer: Support u32 configuration entries
This commit is contained in:
parent
49f697ed56
commit
69beda23c3
10 changed files with 88 additions and 16 deletions
|
@ -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) =|
|
||||
|
|
|
@ -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) => ()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue