mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:02:44 +00:00 
			
		
		
		
	Ladybird: Implement SQLServer for Ladybird :^)
This adds a SQLServer binary for Ladybird to make use of Serenity's SQL implementation. This has to use the same IPC socket handling that was used to make WebContent and WebDriver work out-of-process. Unlike Serenity, Ladybird creates a new SQLServer instance for each Ladybird instance. In the future, we should try to make sure there is only one SQLServer instance at a time, and allow multiple Ladybird instances to communicate with it.
This commit is contained in:
		
							parent
							
								
									a0cd260410
								
							
						
					
					
						commit
						2cb3ae132a
					
				
					 6 changed files with 127 additions and 10 deletions
				
			
		
							
								
								
									
										41
									
								
								Ladybird/SQLServer/main.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Ladybird/SQLServer/main.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #define AK_DONT_REPLACE_STD | ||||
| 
 | ||||
| #include <AK/DeprecatedString.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/Directory.h> | ||||
| #include <LibCore/EventLoop.h> | ||||
| #include <LibCore/StandardPaths.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibCore/SystemServerTakeover.h> | ||||
| #include <LibMain/Main.h> | ||||
| #include <QSocketNotifier> | ||||
| #include <SQLServer/ConnectionFromClient.h> | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|     int sql_server_fd_passing_socket { -1 }; | ||||
| 
 | ||||
|     Core::ArgsParser args_parser; | ||||
|     args_parser.add_option(sql_server_fd_passing_socket, "File descriptor of the passing socket for the SQLServer connection", "sql-server-fd-passing-socket", 's', "sql_server_fd_passing_socket"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     VERIFY(sql_server_fd_passing_socket >= 0); | ||||
| 
 | ||||
|     auto database_path = DeprecatedString::formatted("{}/Ladybird", Core::StandardPaths::data_directory()); | ||||
|     TRY(Core::Directory::create(database_path, Core::Directory::CreateDirectories::Yes)); | ||||
| 
 | ||||
|     Core::EventLoop loop; | ||||
| 
 | ||||
|     auto socket = TRY(Core::take_over_socket_from_system_server("SQLServer"sv)); | ||||
|     auto client = TRY(SQLServer::ConnectionFromClient::try_create(move(socket), 1)); | ||||
|     client->set_fd_passing_socket(TRY(Core::Stream::LocalSocket::adopt_fd(sql_server_fd_passing_socket))); | ||||
|     client->set_database_path(move(database_path)); | ||||
| 
 | ||||
|     return loop.exec(); | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn