mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
Userland: Rename IPC ClientConnection => ConnectionFromClient
This was done with CLion's automatic rename feature and with: find . -name ClientConnection.h | rename 's/ClientConnection\.h/ConnectionFromClient.h/' find . -name ClientConnection.cpp | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
This commit is contained in:
parent
efac862570
commit
3a71748e5d
137 changed files with 896 additions and 896 deletions
|
@ -8,7 +8,7 @@ compile_ipc(ConfigServer.ipc ConfigServerEndpoint.h)
|
|||
compile_ipc(ConfigClient.ipc ConfigClientEndpoint.h)
|
||||
|
||||
set(SOURCES
|
||||
ClientConnection.cpp
|
||||
ConnectionFromClient.cpp
|
||||
main.cpp
|
||||
ConfigServerEndpoint.h
|
||||
ConfigClientEndpoint.h
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "ConnectionFromClient.h"
|
||||
#include <ConfigServer/ConfigClientEndpoint.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/FileWatcher.h>
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace ConfigServer {
|
||||
|
||||
static HashMap<int, RefPtr<ClientConnection>> s_connections;
|
||||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
struct CachedDomain {
|
||||
String domain;
|
||||
|
@ -23,7 +23,7 @@ struct CachedDomain {
|
|||
static HashMap<String, NonnullOwnPtr<CachedDomain>> s_cache;
|
||||
static constexpr int s_disk_sync_delay_ms = 5'000;
|
||||
|
||||
static void for_each_monitoring_connection(String const& domain, ClientConnection* excluded_connection, Function<void(ClientConnection&)> callback)
|
||||
static void for_each_monitoring_connection(String const& domain, ConnectionFromClient* excluded_connection, Function<void(ConnectionFromClient&)> callback)
|
||||
{
|
||||
for (auto& it : s_connections) {
|
||||
if (it.value->is_monitoring_domain(domain) && (!excluded_connection || it.value != excluded_connection))
|
||||
|
@ -48,7 +48,7 @@ static Core::ConfigFile& ensure_domain_config(String const& domain)
|
|||
for (auto& group : config->groups()) {
|
||||
for (auto& key : config->keys(group)) {
|
||||
if (!new_config->has_key(group, key)) {
|
||||
for_each_monitoring_connection(domain, nullptr, [&domain, &group, &key](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, nullptr, [&domain, &group, &key](ConnectionFromClient& connection) {
|
||||
connection.async_notify_removed_key(domain, group, key);
|
||||
});
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static Core::ConfigFile& ensure_domain_config(String const& domain)
|
|||
auto old_value = config->read_entry(group, key);
|
||||
auto new_value = new_config->read_entry(group, key);
|
||||
if (old_value != new_value) {
|
||||
for_each_monitoring_connection(domain, nullptr, [&domain, &group, &key, &new_value](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, nullptr, [&domain, &group, &key, &new_value](ConnectionFromClient& connection) {
|
||||
connection.async_notify_changed_string_value(domain, group, key, new_value);
|
||||
});
|
||||
}
|
||||
|
@ -74,25 +74,25 @@ static Core::ConfigFile& ensure_domain_config(String const& domain)
|
|||
return *config;
|
||||
}
|
||||
|
||||
ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ClientConnection<ConfigClientEndpoint, ConfigServerEndpoint>(*this, move(client_socket), client_id)
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id)
|
||||
: IPC::ConnectionFromClient<ConfigClientEndpoint, ConfigServerEndpoint>(*this, move(client_socket), client_id)
|
||||
, m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); }))
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
}
|
||||
|
||||
ClientConnection::~ClientConnection()
|
||||
ConnectionFromClient::~ConnectionFromClient()
|
||||
{
|
||||
}
|
||||
|
||||
void ClientConnection::die()
|
||||
void ConnectionFromClient::die()
|
||||
{
|
||||
s_connections.remove(client_id());
|
||||
m_sync_timer->stop();
|
||||
sync_dirty_domains_to_disk();
|
||||
}
|
||||
|
||||
void ClientConnection::pledge_domains(Vector<String> const& domains)
|
||||
void ConnectionFromClient::pledge_domains(Vector<String> const& domains)
|
||||
{
|
||||
if (m_has_pledged) {
|
||||
did_misbehave("Tried to pledge domains twice.");
|
||||
|
@ -103,7 +103,7 @@ void ClientConnection::pledge_domains(Vector<String> const& domains)
|
|||
m_pledged_domains.set(domain);
|
||||
}
|
||||
|
||||
void ClientConnection::monitor_domain(String const& domain)
|
||||
void ConnectionFromClient::monitor_domain(String const& domain)
|
||||
{
|
||||
if (m_has_pledged && !m_pledged_domains.contains(domain)) {
|
||||
did_misbehave("Attempt to monitor non-pledged domain");
|
||||
|
@ -113,7 +113,7 @@ void ClientConnection::monitor_domain(String const& domain)
|
|||
m_monitored_domains.set(domain);
|
||||
}
|
||||
|
||||
bool ClientConnection::validate_access(String const& domain, String const& group, String const& key)
|
||||
bool ConnectionFromClient::validate_access(String const& domain, String const& group, String const& key)
|
||||
{
|
||||
if (!m_has_pledged)
|
||||
return true;
|
||||
|
@ -123,7 +123,7 @@ bool ClientConnection::validate_access(String const& domain, String const& group
|
|||
return false;
|
||||
}
|
||||
|
||||
void ClientConnection::sync_dirty_domains_to_disk()
|
||||
void ConnectionFromClient::sync_dirty_domains_to_disk()
|
||||
{
|
||||
if (m_dirty_domains.is_empty())
|
||||
return;
|
||||
|
@ -139,7 +139,7 @@ void ClientConnection::sync_dirty_domains_to_disk()
|
|||
}
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ListConfigKeysResponse ClientConnection::list_config_keys(String const& domain, String const& group)
|
||||
Messages::ConfigServer::ListConfigKeysResponse ConnectionFromClient::list_config_keys(String const& domain, String const& group)
|
||||
{
|
||||
if (!validate_access(domain, group, ""))
|
||||
return Vector<String> {};
|
||||
|
@ -147,7 +147,7 @@ Messages::ConfigServer::ListConfigKeysResponse ClientConnection::list_config_key
|
|||
return { config.keys(group) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ListConfigGroupsResponse ClientConnection::list_config_groups(String const& domain)
|
||||
Messages::ConfigServer::ListConfigGroupsResponse ConnectionFromClient::list_config_groups(String const& domain)
|
||||
{
|
||||
if (!validate_access(domain, "", ""))
|
||||
return Vector<String> {};
|
||||
|
@ -155,7 +155,7 @@ Messages::ConfigServer::ListConfigGroupsResponse ClientConnection::list_config_g
|
|||
return { config.groups() };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadStringValueResponse ClientConnection::read_string_value(String const& domain, String const& group, String const& key)
|
||||
Messages::ConfigServer::ReadStringValueResponse ConnectionFromClient::read_string_value(String const& domain, String const& group, String const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -166,7 +166,7 @@ Messages::ConfigServer::ReadStringValueResponse ClientConnection::read_string_va
|
|||
return Optional<String> { config.read_entry(group, key) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadI32ValueResponse ClientConnection::read_i32_value(String const& domain, String const& group, String const& key)
|
||||
Messages::ConfigServer::ReadI32ValueResponse ConnectionFromClient::read_i32_value(String const& domain, String const& group, String const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -177,7 +177,7 @@ Messages::ConfigServer::ReadI32ValueResponse ClientConnection::read_i32_value(St
|
|||
return Optional<i32> { config.read_num_entry(group, key) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadBoolValueResponse ClientConnection::read_bool_value(String const& domain, String const& group, String const& key)
|
||||
Messages::ConfigServer::ReadBoolValueResponse ConnectionFromClient::read_bool_value(String const& domain, String const& group, String const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -188,7 +188,7 @@ Messages::ConfigServer::ReadBoolValueResponse ClientConnection::read_bool_value(
|
|||
return Optional<bool> { config.read_bool_entry(group, key) };
|
||||
}
|
||||
|
||||
void ClientConnection::start_or_restart_sync_timer()
|
||||
void ConnectionFromClient::start_or_restart_sync_timer()
|
||||
{
|
||||
if (m_sync_timer->is_active())
|
||||
m_sync_timer->restart();
|
||||
|
@ -196,7 +196,7 @@ void ClientConnection::start_or_restart_sync_timer()
|
|||
m_sync_timer->start();
|
||||
}
|
||||
|
||||
void ClientConnection::write_string_value(String const& domain, String const& group, String const& key, String const& value)
|
||||
void ConnectionFromClient::write_string_value(String const& domain, String const& group, String const& key, String const& value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -210,12 +210,12 @@ void ClientConnection::write_string_value(String const& domain, String const& gr
|
|||
m_dirty_domains.set(domain);
|
||||
start_or_restart_sync_timer();
|
||||
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ConnectionFromClient& connection) {
|
||||
connection.async_notify_changed_string_value(domain, group, key, value);
|
||||
});
|
||||
}
|
||||
|
||||
void ClientConnection::write_i32_value(String const& domain, String const& group, String const& key, i32 value)
|
||||
void ConnectionFromClient::write_i32_value(String const& domain, String const& group, String const& key, i32 value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -229,12 +229,12 @@ void ClientConnection::write_i32_value(String const& domain, String const& group
|
|||
m_dirty_domains.set(domain);
|
||||
start_or_restart_sync_timer();
|
||||
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ConnectionFromClient& connection) {
|
||||
connection.async_notify_changed_i32_value(domain, group, key, value);
|
||||
});
|
||||
}
|
||||
|
||||
void ClientConnection::write_bool_value(String const& domain, String const& group, String const& key, bool value)
|
||||
void ConnectionFromClient::write_bool_value(String const& domain, String const& group, String const& key, bool value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -248,12 +248,12 @@ void ClientConnection::write_bool_value(String const& domain, String const& grou
|
|||
m_dirty_domains.set(domain);
|
||||
start_or_restart_sync_timer();
|
||||
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key, &value](ConnectionFromClient& connection) {
|
||||
connection.async_notify_changed_bool_value(domain, group, key, value);
|
||||
});
|
||||
}
|
||||
|
||||
void ClientConnection::remove_key(String const& domain, String const& group, String const& key)
|
||||
void ConnectionFromClient::remove_key(String const& domain, String const& group, String const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -266,7 +266,7 @@ void ClientConnection::remove_key(String const& domain, String const& group, Str
|
|||
m_dirty_domains.set(domain);
|
||||
start_or_restart_sync_timer();
|
||||
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key](ClientConnection& connection) {
|
||||
for_each_monitoring_connection(domain, this, [&domain, &group, &key](ConnectionFromClient& connection) {
|
||||
connection.async_notify_removed_key(domain, group, key);
|
||||
});
|
||||
}
|
|
@ -6,24 +6,24 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibIPC/ClientConnection.h>
|
||||
#include <LibIPC/ConnectionFromClient.h>
|
||||
|
||||
#include <ConfigServer/ConfigClientEndpoint.h>
|
||||
#include <ConfigServer/ConfigServerEndpoint.h>
|
||||
|
||||
namespace ConfigServer {
|
||||
|
||||
class ClientConnection final : public IPC::ClientConnection<ConfigClientEndpoint, ConfigServerEndpoint> {
|
||||
C_OBJECT(ClientConnection)
|
||||
class ConnectionFromClient final : public IPC::ConnectionFromClient<ConfigClientEndpoint, ConfigServerEndpoint> {
|
||||
C_OBJECT(ConnectionFromClient)
|
||||
public:
|
||||
~ClientConnection() override;
|
||||
~ConnectionFromClient() override;
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
bool is_monitoring_domain(String const& domain) const { return m_monitored_domains.contains(domain); }
|
||||
|
||||
private:
|
||||
explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
|
||||
|
||||
virtual void pledge_domains(Vector<String> const&) override;
|
||||
virtual void monitor_domain(String const&) override;
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "ConnectionFromClient.h"
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibIPC/MultiServer.h>
|
||||
|
@ -18,6 +18,6 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
auto server = TRY(IPC::MultiServer<ConfigServer::ClientConnection>::try_create());
|
||||
auto server = TRY(IPC::MultiServer<ConfigServer::ConnectionFromClient>::try_create());
|
||||
return event_loop.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue