diff options
author | faxe1008 <fabianblatz@gmail.com> | 2021-11-08 11:43:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-13 12:55:46 +0100 |
commit | b97f9f8e17e81475daa43bc1a4aee12424f8ae34 (patch) | |
tree | 161d808b47a0859685b2e6e11500a8e79316474f /Userland/Libraries/LibConfig | |
parent | a4a89a63cba44951ffdf5b3ece8e65fdf8fa7c94 (diff) | |
download | serenity-b97f9f8e17e81475daa43bc1a4aee12424f8ae34.zip |
LibConfig: Add removal/notifcation for keys
Diffstat (limited to 'Userland/Libraries/LibConfig')
-rw-r--r-- | Userland/Libraries/LibConfig/Client.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibConfig/Client.h | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibConfig/Listener.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibConfig/Listener.h | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibConfig/Client.cpp b/Userland/Libraries/LibConfig/Client.cpp index 2a53ecee8f..bae912a9e3 100644 --- a/Userland/Libraries/LibConfig/Client.cpp +++ b/Userland/Libraries/LibConfig/Client.cpp @@ -60,6 +60,11 @@ void Client::write_bool(StringView domain, StringView group, StringView key, boo async_write_bool_value(domain, group, key, value); } +void Client::remove_key(StringView domain, StringView group, StringView key) +{ + async_remove_key(domain, group, key); +} + void Client::notify_changed_string_value(String const& domain, String const& group, String const& key, String const& value) { Listener::for_each([&](auto& listener) { @@ -81,4 +86,11 @@ void Client::notify_changed_bool_value(String const& domain, String const& group }); } +void Client::notify_removed_key(const String& domain, const String& group, const String& key) +{ + Listener::for_each([&](auto& listener) { + listener.config_key_was_removed(domain, group, key); + }); +} + } diff --git a/Userland/Libraries/LibConfig/Client.h b/Userland/Libraries/LibConfig/Client.h index ce6efdbf3f..04e33fb94f 100644 --- a/Userland/Libraries/LibConfig/Client.h +++ b/Userland/Libraries/LibConfig/Client.h @@ -31,6 +31,7 @@ public: void write_string(StringView domain, StringView group, StringView key, StringView value); void write_i32(StringView domain, StringView group, StringView key, i32 value); void write_bool(StringView domain, StringView group, StringView key, bool value); + void remove_key(StringView domain, StringView group, StringView key); static Client& the(); @@ -43,6 +44,7 @@ private: void notify_changed_string_value(String const& domain, String const& group, String const& key, String const& value) override; void notify_changed_i32_value(String const& domain, String const& group, String const& key, i32 value) override; void notify_changed_bool_value(String const& domain, String const& group, String const& key, bool value) override; + void notify_removed_key(String const& domain, String const& group, String const& key) override; }; inline String read_string(StringView domain, StringView group, StringView key, StringView fallback = {}) @@ -75,6 +77,11 @@ inline void write_bool(StringView domain, StringView group, StringView key, bool Client::the().write_bool(domain, group, key, value); } +inline void remove_key(StringView domain, StringView group, StringView key) +{ + Client::the().remove_key(domain, group, key); +} + inline void pledge_domains(Vector<String> const& domains) { Client::the().pledge_domains(domains); diff --git a/Userland/Libraries/LibConfig/Listener.cpp b/Userland/Libraries/LibConfig/Listener.cpp index dbf452cded..31e5afc93d 100644 --- a/Userland/Libraries/LibConfig/Listener.cpp +++ b/Userland/Libraries/LibConfig/Listener.cpp @@ -41,4 +41,8 @@ void Listener::config_bool_did_change(String const&, String const&, String const { } +void Listener::config_key_was_removed(String const&, String const&, String const&) +{ +} + } diff --git a/Userland/Libraries/LibConfig/Listener.h b/Userland/Libraries/LibConfig/Listener.h index 239a7d1561..b59c907e41 100644 --- a/Userland/Libraries/LibConfig/Listener.h +++ b/Userland/Libraries/LibConfig/Listener.h @@ -19,6 +19,7 @@ public: virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value); virtual void config_i32_did_change(String const& domain, String const& group, String const& key, i32 value); virtual void config_bool_did_change(String const& domain, String const& group, String const& key, bool value); + virtual void config_key_was_removed(String const& domain, String const& group, String const& key); protected: Listener(); |