1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:57:45 +00:00

LibConfig+ConfigServer: Add permissive mode

When in permissive mode, the ConfigServer will not treat reads and
writes to non-pledged domains as errors, but instead turns them into
no-ops: Reads will act as if the key was not found, and writes will do
nothing. Permissive mode must be enabled before pledging any domains.

This is needed to make GUI Widgets nicer to work with in GML Playground:
a few Widgets include reads and writes to LibConfig in order to load
system settings (eg, GUI::Calendar) or to save and restore state
(eg, GUI::DynamicWidgetContainer). Without this change, editing a
layout that includes one of these Widgets will cause GML Playground to
crash when they try to access config domains that are not pledged.

The solution used previously is to make Playground pledge more domains,
but not only does this mean Playground has to know about these cases,
but also that working on a layout file can alter the user's settings in
other arbitrary apps, which is not something we want.

By simply ignoring these config accesses, we avoid those downsides, and
Widgets will simply use the fallback values they already have to provide
to Config::read_foo_value().
This commit is contained in:
Sam Atkins 2024-02-12 17:25:58 +00:00 committed by Tim Flynn
parent 2c327a67bc
commit 5bcb3e2f16
5 changed files with 44 additions and 6 deletions

View file

@ -26,6 +26,7 @@ private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
virtual void pledge_domains(Vector<ByteString> const&) override;
virtual void enable_permissive_mode() override;
virtual void monitor_domain(ByteString const&) override;
virtual Messages::ConfigServer::ListConfigGroupsResponse list_config_groups([[maybe_unused]] ByteString const& domain) override;
virtual Messages::ConfigServer::ListConfigKeysResponse list_config_keys([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group) override;
@ -46,6 +47,7 @@ private:
void start_or_restart_sync_timer();
bool m_has_pledged { false };
bool m_permissive_mode { false };
HashTable<ByteString> m_pledged_domains;
HashTable<ByteString> m_monitored_domains;