mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 02:42:44 +00:00 
			
		
		
		
	 83d3720842
			
		
	
	
		83d3720842
		
	
	
	
	
		
			
			After opening a domain configuration and putting into our configuration cache, we now monitor the underlying file for changes and send out notifications to monitoring clients as needed. This patch has three FIXME's: - We create a new Core::FileWatcher for each domain. - We don't yet detect removed keys. - We don't know the type of key, so we assume everything is a string. There are a number of ways we can solve those problems but let's not hold up this patch while we wait for solutions. :^)
		
			
				
	
	
		
			45 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibIPC/ClientConnection.h>
 | |
| 
 | |
| #include <ConfigServer/ConfigClientEndpoint.h>
 | |
| #include <ConfigServer/ConfigServerEndpoint.h>
 | |
| 
 | |
| namespace ConfigServer {
 | |
| 
 | |
| class ClientConnection final : public IPC::ClientConnection<ConfigClientEndpoint, ConfigServerEndpoint> {
 | |
|     C_OBJECT(ClientConnection)
 | |
| public:
 | |
|     ~ClientConnection() override;
 | |
| 
 | |
|     virtual void die() override;
 | |
| 
 | |
|     bool is_monitoring_domain(String const& domain) const { return m_monitored_domains.contains(domain); }
 | |
| 
 | |
| private:
 | |
|     explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
 | |
| 
 | |
|     virtual void pledge_domains(Vector<String> const&) override;
 | |
|     virtual void monitor_domain(String const&) override;
 | |
|     virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
 | |
|     virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
 | |
|     virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
 | |
|     virtual void write_string_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key, [[maybe_unused]] String const& value) override;
 | |
|     virtual void write_i32_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key, [[maybe_unused]] i32 value) override;
 | |
|     virtual void write_bool_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key, [[maybe_unused]] bool value) override;
 | |
| 
 | |
|     bool validate_access(String const& domain, String const& group, String const& key);
 | |
| 
 | |
|     bool m_has_pledged { false };
 | |
|     HashTable<String> m_pledged_domains;
 | |
| 
 | |
|     HashTable<String> m_monitored_domains;
 | |
| };
 | |
| 
 | |
| }
 |