diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-26 19:05:50 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-26 23:41:38 +0200 |
commit | edf784340999b6e8f44241e04e6d6f8afc27be29 (patch) | |
tree | e2008782c0bbc1e7bbfff08202e717febbb2ac13 /Userland/Libraries/LibConfig/Client.h | |
parent | 9509f2ff87e10f87f4710749562e35be016a8a21 (diff) | |
download | serenity-edf784340999b6e8f44241e04e6d6f8afc27be29.zip |
ConfigServer+LibConfig: Add way for clients to listen for config changes
This patch adds a Config::Listener abstract class that anyone can
inherit from and receive notifications when configuration values change.
We don't yet monitor file system changes, so these only work for changes
made by ConfigServer itself.
In order to receive these notifications, clients must monitor the domain
by calling monitor_domain(). Only pledged domains can be monitored.
Note that the client initiating the change does not get notified.
Diffstat (limited to 'Userland/Libraries/LibConfig/Client.h')
-rw-r--r-- | Userland/Libraries/LibConfig/Client.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibConfig/Client.h b/Userland/Libraries/LibConfig/Client.h index 395a3188fc..ce6efdbf3f 100644 --- a/Userland/Libraries/LibConfig/Client.h +++ b/Userland/Libraries/LibConfig/Client.h @@ -22,6 +22,7 @@ class Client final public: void pledge_domains(Vector<String> const&); + void monitor_domain(String const&); String read_string(StringView domain, StringView group, StringView key, StringView fallback); i32 read_i32(StringView domain, StringView group, StringView key, i32 fallback); @@ -38,6 +39,10 @@ private: : IPC::ServerConnection<ConfigClientEndpoint, ConfigServerEndpoint>(*this, "/tmp/portal/config") { } + + 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; }; inline String read_string(StringView domain, StringView group, StringView key, StringView fallback = {}) @@ -80,4 +85,9 @@ inline void pledge_domains(String const& domains) Client::the().pledge_domains({ domains }); } +inline void monitor_domain(String const& domain) +{ + Client::the().monitor_domain(domain); +} + } |