mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:22:45 +00:00 
			
		
		
		
	Ladybird: Remove Qt dependency from RequestServer
This requires two parts: Core::System::current_executable_path(), and passing the serenity-resource-root as an argument to the process.
This commit is contained in:
		
							parent
							
								
									bb831a27dd
								
							
						
					
					
						commit
						a1e5a6ac40
					
				
					 6 changed files with 17 additions and 29 deletions
				
			
		|  | @ -87,7 +87,7 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web | |||
|     return new_client; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths) | ||||
| ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root) | ||||
| { | ||||
|     int socket_fds[2] {}; | ||||
|     TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds)); | ||||
|  | @ -120,6 +120,8 @@ ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(Re | |||
|                 path.bytes_as_string_view(), | ||||
|                 "--fd-passing-socket"sv, | ||||
|                 fd_passing_socket_string, | ||||
|                 "--serenity-resource-root"sv, | ||||
|                 serenity_resource_root, | ||||
|             }; | ||||
| 
 | ||||
|             result = Core::System::exec(arguments[0], arguments.span(), Core::System::SearchInPath::Yes); | ||||
|  |  | |||
|  | @ -21,4 +21,4 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(Web | |||
|     WebView::UseJavaScriptBytecode, | ||||
|     Ladybird::UseLagomNetworking); | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths); | ||||
| ErrorOr<NonnullRefPtr<Protocol::RequestClient>> launch_request_server_process(ReadonlySpan<String> candidate_request_server_paths, StringView serenity_resource_root); | ||||
|  |  | |||
|  | @ -11,15 +11,14 @@ set(REQUESTSERVER_SOURCES | |||
|     ${REQUESTSERVER_SOURCE_DIR}/HttpsRequest.cpp | ||||
|     ${REQUESTSERVER_SOURCE_DIR}/HttpsProtocol.cpp | ||||
|     ${REQUESTSERVER_SOURCE_DIR}/Protocol.cpp | ||||
|     ../Utilities.cpp | ||||
|     main.cpp | ||||
| ) | ||||
| 
 | ||||
| qt_add_executable(RequestServer ${REQUESTSERVER_SOURCES}) | ||||
| add_executable(RequestServer ${REQUESTSERVER_SOURCES}) | ||||
| 
 | ||||
| target_include_directories(RequestServer PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) | ||||
| target_include_directories(RequestServer PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) | ||||
| target_link_libraries(RequestServer PRIVATE Qt::Core LibCore LibMain LibCrypto LibFileSystem LibGemini LibHTTP LibIPC LibMain LibTLS LibWebView) | ||||
| target_link_libraries(RequestServer PRIVATE LibCore LibMain LibCrypto LibFileSystem LibGemini LibHTTP LibIPC LibMain LibTLS LibWebView) | ||||
| if (ANDROID) | ||||
|     link_android_libs(RequestServer) | ||||
| endif() | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #include "../Utilities.h" | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <AK/OwnPtr.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
|  | @ -16,17 +15,16 @@ | |||
| #include <LibIPC/SingleServer.h> | ||||
| #include <LibMain/Main.h> | ||||
| #include <LibTLS/Certificate.h> | ||||
| #include <QCoreApplication> | ||||
| #include <RequestServer/ConnectionFromClient.h> | ||||
| #include <RequestServer/GeminiProtocol.h> | ||||
| #include <RequestServer/HttpProtocol.h> | ||||
| #include <RequestServer/HttpsProtocol.h> | ||||
| 
 | ||||
| ErrorOr<String> find_certificates() | ||||
| ErrorOr<String> find_certificates(StringView serenity_resource_root) | ||||
| { | ||||
|     auto cert_path = TRY(String::formatted("{}/res/ladybird/cacert.pem", s_serenity_resource_root)); | ||||
|     auto cert_path = TRY(String::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root)); | ||||
|     if (!FileSystem::exists(cert_path)) { | ||||
|         auto app_dir = ak_deprecated_string_from_qstring(QCoreApplication::applicationDirPath()); | ||||
|         auto app_dir = LexicalPath::dirname(TRY(Core::System::current_executable_path()).to_deprecated_string()); | ||||
| 
 | ||||
|         cert_path = TRY(String::formatted("{}/cacert.pem", LexicalPath(app_dir).parent())); | ||||
|         if (!FileSystem::exists(cert_path)) | ||||
|  | @ -37,19 +35,18 @@ ErrorOr<String> find_certificates() | |||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|     QCoreApplication application(arguments.argc, arguments.argv); | ||||
|     platform_init(); | ||||
| 
 | ||||
|     // Ensure the certificates are read out here.
 | ||||
|     DefaultRootCACertificates::set_default_certificate_path(TRY(find_certificates())); | ||||
|     [[maybe_unused]] auto& certs = DefaultRootCACertificates::the(); | ||||
| 
 | ||||
|     int fd_passing_socket { -1 }; | ||||
|     StringView serenity_resource_root; | ||||
| 
 | ||||
|     Core::ArgsParser args_parser; | ||||
|     args_parser.add_option(fd_passing_socket, "File descriptor of the fd passing socket", "fd-passing-socket", 'c', "fd-passing-socket"); | ||||
|     args_parser.add_option(serenity_resource_root, "Absolute path to directory for serenity resources", "serenity-resource-root", 'r', "serenity-resource-root"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     // Ensure the certificates are read out here.
 | ||||
|     DefaultRootCACertificates::set_default_certificate_path(TRY(find_certificates(serenity_resource_root))); | ||||
|     [[maybe_unused]] auto& certs = DefaultRootCACertificates::the(); | ||||
| 
 | ||||
|     Core::EventLoop event_loop; | ||||
| 
 | ||||
|     [[maybe_unused]] auto gemini = make<RequestServer::GeminiProtocol>(); | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
| 
 | ||||
|     if (use_lagom_networking) { | ||||
|         auto candidate_request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv)); | ||||
|         auto protocol_client = TRY(launch_request_server_process(candidate_request_server_paths)); | ||||
|         auto protocol_client = TRY(launch_request_server_process(candidate_request_server_paths, s_serenity_resource_root)); | ||||
|         Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create(move(protocol_client)))); | ||||
|     } else { | ||||
|         Web::ResourceLoader::initialize(Ladybird::RequestManagerQt::create()); | ||||
|  |  | |||
|  | @ -1,14 +1,5 @@ | |||
| import("//Ladybird/link_qt.gni") | ||||
| 
 | ||||
| link_qt("RequestServer_qt") { | ||||
|   qt_components = [ "Core" ] | ||||
| } | ||||
| 
 | ||||
| executable("RequestServer") { | ||||
|   configs += [ | ||||
|     "//Ladybird:ladybird_config", | ||||
|     ":RequestServer_qt", | ||||
|   ] | ||||
|   configs += [ "//Ladybird:ladybird_config" ] | ||||
|   include_dirs = [ | ||||
|     "//Userland/Libraries", | ||||
|     "//Userland/Services", | ||||
|  | @ -26,7 +17,6 @@ executable("RequestServer") { | |||
|     "//Userland/Libraries/LibTLS", | ||||
|   ] | ||||
|   sources = [ | ||||
|     "../Utilities.cpp", | ||||
|     "//Userland/Services/RequestServer/ConnectionCache.cpp", | ||||
|     "//Userland/Services/RequestServer/ConnectionFromClient.cpp", | ||||
|     "//Userland/Services/RequestServer/GeminiProtocol.cpp", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Kaster
						Andrew Kaster