From 7cf2839a262a38e00f110bee1102020c658ac476 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 2 May 2021 04:39:36 +0200 Subject: Userland: Get rid of the OwnPtr<...> boilerplate code for IPC handlers --- .../Services/LaunchServer/ClientConnection.cpp | 37 ++++++++++------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'Userland/Services/LaunchServer/ClientConnection.cpp') diff --git a/Userland/Services/LaunchServer/ClientConnection.cpp b/Userland/Services/LaunchServer/ClientConnection.cpp index 07ecdc764f..c5ab40e6dd 100644 --- a/Userland/Services/LaunchServer/ClientConnection.cpp +++ b/Userland/Services/LaunchServer/ClientConnection.cpp @@ -28,12 +28,12 @@ void ClientConnection::die() s_connections.remove(client_id()); } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::Greet&) +Messages::LaunchServer::GreetResponse ClientConnection::handle(const Messages::LaunchServer::Greet&) { - return make(); + return {}; } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::OpenURL& request) +Messages::LaunchServer::OpenURLResponse ClientConnection::handle(const Messages::LaunchServer::OpenURL& request) { if (!m_allowlist.is_empty()) { bool allowed = false; @@ -47,30 +47,27 @@ OwnPtr ClientConnection::handle(const M if (!allowed) { // You are not on the list, go home! did_misbehave(String::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", request.handler_name(), request.url()).characters()); - return {}; + return nullptr; } } URL url(request.url()); - auto result = Launcher::the().open_url(url, request.handler_name()); - return make(result); + return Launcher::the().open_url(url, request.handler_name()); } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::GetHandlersForURL& request) +Messages::LaunchServer::GetHandlersForURLResponse ClientConnection::handle(const Messages::LaunchServer::GetHandlersForURL& request) { URL url(request.url()); - auto result = Launcher::the().handlers_for_url(url); - return make(result); + return Launcher::the().handlers_for_url(url); } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::GetHandlersWithDetailsForURL& request) +Messages::LaunchServer::GetHandlersWithDetailsForURLResponse ClientConnection::handle(const Messages::LaunchServer::GetHandlersWithDetailsForURL& request) { URL url(request.url()); - auto result = Launcher::the().handlers_with_details_for_url(url); - return make(result); + return Launcher::the().handlers_with_details_for_url(url); } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::AddAllowedURL& request) +Messages::LaunchServer::AddAllowedURLResponse ClientConnection::handle(const Messages::LaunchServer::AddAllowedURL& request) { if (m_allowlist_is_sealed) { did_misbehave("Got request to add more allowed handlers after list was sealed"); @@ -84,10 +81,10 @@ OwnPtr ClientConnection::handle(c m_allowlist.empend(String(), false, Vector { request.url() }); - return make(); + return {}; } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithAnyURL& request) +Messages::LaunchServer::AddAllowedHandlerWithAnyURLResponse ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithAnyURL& request) { if (m_allowlist_is_sealed) { did_misbehave("Got request to add more allowed handlers after list was sealed"); @@ -101,10 +98,10 @@ OwnPtr ClientConnec m_allowlist.empend(request.handler_name(), true, Vector()); - return make(); + return {}; } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLs& request) +Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLsResponse ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLs& request) { if (m_allowlist_is_sealed) { did_misbehave("Got request to add more allowed handlers after list was sealed"); @@ -123,17 +120,17 @@ OwnPtr Cl m_allowlist.empend(request.handler_name(), false, request.urls()); - return make(); + return {}; } -OwnPtr ClientConnection::handle(const Messages::LaunchServer::SealAllowlist&) +Messages::LaunchServer::SealAllowlistResponse ClientConnection::handle(const Messages::LaunchServer::SealAllowlist&) { if (m_allowlist_is_sealed) { did_misbehave("Got more than one request to seal the allowed handlers list"); return {}; } - return make(); + return {}; } } -- cgit v1.2.3