mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:02: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
				
			
		|  | @ -42,7 +42,7 @@ In the GUI application process, a `OutOfProcessWebView` widget is placed somewhe | ||||||
| 
 | 
 | ||||||
| Internally, the `OutOfProcessWebView` has a `WebContentClient` object that implements the client side of the **WebContent** IPC protocol. | Internally, the `OutOfProcessWebView` has a `WebContentClient` object that implements the client side of the **WebContent** IPC protocol. | ||||||
| 
 | 
 | ||||||
| The `WebContentClient` speaks to a `WebContent::ClientConnection` in the **WebContent** process. Internally, the `WebContent::ClientConnection` has a `WebContent::PageHost` which hosts the **LibWeb** engine's main `Web::Page` object. | The `WebContentClient` speaks to a `WebContent::ConnectionFromClient` in the **WebContent** process. Internally, the `WebContent::ConnectionFromClient` has a `WebContent::PageHost` which hosts the **LibWeb** engine's main `Web::Page` object. | ||||||
| 
 | 
 | ||||||
| Inside **LibWeb**, a `Web::Page` has a main `Web::Frame`, which may have subframes corresponding to `<frame>` or `<iframe>` HTML elements. Each `Web::Frame` has a `Web::Document`, which is the root node of the DOM tree. | Inside **LibWeb**, a `Web::Page` has a main `Web::Frame`, which may have subframes corresponding to `<frame>` or `<iframe>` HTML elements. Each `Web::Frame` has a `Web::Document`, which is the root node of the DOM tree. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -287,7 +287,7 @@ if (BUILD_LAGOM) | ||||||
| 
 | 
 | ||||||
|     # Audio |     # Audio | ||||||
|     file(GLOB LIBAUDIO_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibAudio/*.cpp") |     file(GLOB LIBAUDIO_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibAudio/*.cpp") | ||||||
|     list(REMOVE_ITEM LIBAUDIO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../Userland/Libraries/LibAudio/ClientConnection.cpp") |     list(REMOVE_ITEM LIBAUDIO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../Userland/Libraries/LibAudio/ConnectionFromClient.cpp") | ||||||
|     lagom_lib(Audio audio |     lagom_lib(Audio audio | ||||||
|         SOURCES ${LIBAUDIO_SOURCES} |         SOURCES ${LIBAUDIO_SOURCES} | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/Array.h> | #include <AK/Array.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibConfig/Client.h> | #include <LibConfig/Client.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
|  | @ -43,14 +43,14 @@ public: | ||||||
|                 { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png")) }, |                 { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png")) }, | ||||||
|                 { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png")) } } |                 { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png")) } } | ||||||
|         }; |         }; | ||||||
|         auto audio_client = TRY(Audio::ClientConnection::try_create()); |         auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); | ||||||
|         NonnullRefPtr<AudioWidget> audio_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AudioWidget(move(audio_client), move(volume_level_bitmaps)))); |         NonnullRefPtr<AudioWidget> audio_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AudioWidget(move(audio_client), move(volume_level_bitmaps)))); | ||||||
|         TRY(audio_widget->try_initialize_graphical_elements()); |         TRY(audio_widget->try_initialize_graphical_elements()); | ||||||
|         return audio_widget; |         return audio_widget; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     AudioWidget(NonnullRefPtr<Audio::ClientConnection> audio_client, Array<VolumeBitmapPair, 5> volume_level_bitmaps) |     AudioWidget(NonnullRefPtr<Audio::ConnectionFromClient> audio_client, Array<VolumeBitmapPair, 5> volume_level_bitmaps) | ||||||
|         : m_audio_client(move(audio_client)) |         : m_audio_client(move(audio_client)) | ||||||
|         , m_volume_level_bitmaps(move(volume_level_bitmaps)) |         , m_volume_level_bitmaps(move(volume_level_bitmaps)) | ||||||
|         , m_show_percent(Config::read_bool("AudioApplet", "Applet", "ShowPercent", false)) |         , m_show_percent(Config::read_bool("AudioApplet", "Applet", "ShowPercent", false)) | ||||||
|  | @ -222,7 +222,7 @@ private: | ||||||
|             height); |             height); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<Audio::ClientConnection> m_audio_client; |     NonnullRefPtr<Audio::ConnectionFromClient> m_audio_client; | ||||||
|     Array<VolumeBitmapPair, 5> m_volume_level_bitmaps; |     Array<VolumeBitmapPair, 5> m_volume_level_bitmaps; | ||||||
|     bool m_show_percent { false }; |     bool m_show_percent { false }; | ||||||
|     bool m_audio_muted { false }; |     bool m_audio_muted { false }; | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ AudioPlayerLoop::AudioPlayerLoop(TrackManager& track_manager, bool& need_to_writ | ||||||
|     , m_need_to_write_wav(need_to_write_wav) |     , m_need_to_write_wav(need_to_write_wav) | ||||||
|     , m_wav_writer(wav_writer) |     , m_wav_writer(wav_writer) | ||||||
| { | { | ||||||
|     m_audio_client = Audio::ClientConnection::try_create().release_value_but_fixme_should_propagate_errors(); |     m_audio_client = Audio::ConnectionFromClient::try_create().release_value_but_fixme_should_propagate_errors(); | ||||||
|     m_audio_client->on_finish_playing_buffer = [this](int buffer_id) { |     m_audio_client->on_finish_playing_buffer = [this](int buffer_id) { | ||||||
|         (void)buffer_id; |         (void)buffer_id; | ||||||
|         enqueue_audio(); |         enqueue_audio(); | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "Music.h" | #include "Music.h" | ||||||
| #include <LibAudio/Buffer.h> | #include <LibAudio/Buffer.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibAudio/WavWriter.h> | #include <LibAudio/WavWriter.h> | ||||||
| #include <LibCore/Object.h> | #include <LibCore/Object.h> | ||||||
| 
 | 
 | ||||||
|  | @ -31,7 +31,7 @@ private: | ||||||
|     TrackManager& m_track_manager; |     TrackManager& m_track_manager; | ||||||
|     Array<Sample, sample_count> m_buffer; |     Array<Sample, sample_count> m_buffer; | ||||||
|     Optional<Audio::ResampleHelper<double>> m_resampler; |     Optional<Audio::ResampleHelper<double>> m_resampler; | ||||||
|     RefPtr<Audio::ClientConnection> m_audio_client; |     RefPtr<Audio::ConnectionFromClient> m_audio_client; | ||||||
| 
 | 
 | ||||||
|     bool m_should_play_audio = true; |     bool m_should_play_audio = true; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include "TrackManager.h" | #include "TrackManager.h" | ||||||
| #include <AK/Queue.h> | #include <AK/Queue.h> | ||||||
| #include <LibAudio/Buffer.h> | #include <LibAudio/Buffer.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibAudio/WavWriter.h> | #include <LibAudio/WavWriter.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "PlaybackManager.h" | #include "PlaybackManager.h" | ||||||
| 
 | 
 | ||||||
| PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ClientConnection> connection) | PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ConnectionFromClient> connection) | ||||||
|     : m_connection(connection) |     : m_connection(connection) | ||||||
| { | { | ||||||
|     m_timer = Core::Timer::construct(PlaybackManager::update_rate_ms, [&]() { |     m_timer = Core::Timer::construct(PlaybackManager::update_rate_ms, [&]() { | ||||||
|  |  | ||||||
|  | @ -10,13 +10,13 @@ | ||||||
| #include <AK/Queue.h> | #include <AK/Queue.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibAudio/Buffer.h> | #include <LibAudio/Buffer.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibAudio/Loader.h> | #include <LibAudio/Loader.h> | ||||||
| #include <LibCore/Timer.h> | #include <LibCore/Timer.h> | ||||||
| 
 | 
 | ||||||
| class PlaybackManager final { | class PlaybackManager final { | ||||||
| public: | public: | ||||||
|     PlaybackManager(NonnullRefPtr<Audio::ClientConnection>); |     PlaybackManager(NonnullRefPtr<Audio::ConnectionFromClient>); | ||||||
|     ~PlaybackManager() = default; |     ~PlaybackManager() = default; | ||||||
| 
 | 
 | ||||||
|     void play(); |     void play(); | ||||||
|  | @ -34,7 +34,7 @@ public: | ||||||
|     float total_length() const { return m_total_length; } |     float total_length() const { return m_total_length; } | ||||||
|     RefPtr<Audio::Buffer> current_buffer() const { return m_current_buffer; } |     RefPtr<Audio::Buffer> current_buffer() const { return m_current_buffer; } | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<Audio::ClientConnection> connection() const { return m_connection; } |     NonnullRefPtr<Audio::ConnectionFromClient> connection() const { return m_connection; } | ||||||
| 
 | 
 | ||||||
|     Function<void()> on_update; |     Function<void()> on_update; | ||||||
|     Function<void(Audio::Buffer&)> on_load_sample_buffer; |     Function<void(Audio::Buffer&)> on_load_sample_buffer; | ||||||
|  | @ -55,7 +55,7 @@ private: | ||||||
|     size_t m_device_samples_per_buffer { 0 }; |     size_t m_device_samples_per_buffer { 0 }; | ||||||
|     size_t m_source_buffer_size_bytes { 0 }; |     size_t m_source_buffer_size_bytes { 0 }; | ||||||
|     RefPtr<Audio::Loader> m_loader { nullptr }; |     RefPtr<Audio::Loader> m_loader { nullptr }; | ||||||
|     NonnullRefPtr<Audio::ClientConnection> m_connection; |     NonnullRefPtr<Audio::ConnectionFromClient> m_connection; | ||||||
|     RefPtr<Audio::Buffer> m_current_buffer; |     RefPtr<Audio::Buffer> m_current_buffer; | ||||||
|     Queue<i32, always_enqueued_buffer_count + 1> m_enqueued_buffers; |     Queue<i32, always_enqueued_buffer_count + 1> m_enqueued_buffers; | ||||||
|     Optional<Audio::ResampleHelper<double>> m_resampler; |     Optional<Audio::ResampleHelper<double>> m_resampler; | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "Player.h" | #include "Player.h" | ||||||
| 
 | 
 | ||||||
| Player::Player(Audio::ClientConnection& audio_client_connection) | Player::Player(Audio::ConnectionFromClient& audio_client_connection) | ||||||
|     : m_audio_client_connection(audio_client_connection) |     : m_audio_client_connection(audio_client_connection) | ||||||
|     , m_playback_manager(audio_client_connection) |     , m_playback_manager(audio_client_connection) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ public: | ||||||
|         Shuffling, |         Shuffling, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     explicit Player(Audio::ClientConnection& audio_client_connection); |     explicit Player(Audio::ConnectionFromClient& audio_client_connection); | ||||||
|     virtual ~Player() = default; |     virtual ~Player() = default; | ||||||
| 
 | 
 | ||||||
|     void play_file_path(String const& path); |     void play_file_path(String const& path); | ||||||
|  | @ -90,7 +90,7 @@ private: | ||||||
|     LoopMode m_loop_mode; |     LoopMode m_loop_mode; | ||||||
|     ShuffleMode m_shuffle_mode; |     ShuffleMode m_shuffle_mode; | ||||||
| 
 | 
 | ||||||
|     Audio::ClientConnection& m_audio_client_connection; |     Audio::ConnectionFromClient& m_audio_client_connection; | ||||||
|     PlaybackManager m_playback_manager; |     PlaybackManager m_playback_manager; | ||||||
| 
 | 
 | ||||||
|     String m_loaded_filename; |     String m_loaded_filename; | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| 
 | 
 | ||||||
| SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ClientConnection& connection) | SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionFromClient& connection) | ||||||
|     : Player(connection) |     : Player(connection) | ||||||
|     , m_window(window) |     , m_window(window) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include "Player.h" | #include "Player.h" | ||||||
| #include "VisualizationWidget.h" | #include "VisualizationWidget.h" | ||||||
| #include <AK/NonnullRefPtr.h> | #include <AK/NonnullRefPtr.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibGUI/Splitter.h> | #include <LibGUI/Splitter.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| 
 | 
 | ||||||
|  | @ -50,7 +50,7 @@ protected: | ||||||
|     void keydown_event(GUI::KeyEvent&) override; |     void keydown_event(GUI::KeyEvent&) override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ClientConnection&); |     SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ConnectionFromClient&); | ||||||
| 
 | 
 | ||||||
|     void sync_previous_next_buttons(); |     void sync_previous_next_buttons(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| #include "Player.h" | #include "Player.h" | ||||||
| #include "SampleWidget.h" | #include "SampleWidget.h" | ||||||
| #include "SoundPlayerWidgetAdvancedView.h" | #include "SoundPlayerWidgetAdvancedView.h" | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibGUI/Action.h> | #include <LibGUI/Action.h> | ||||||
| #include <LibGUI/ActionGroup.h> | #include <LibGUI/ActionGroup.h> | ||||||
|  | @ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||||
|     TRY(Core::System::pledge("stdio recvfd sendfd rpath thread unix")); |     TRY(Core::System::pledge("stdio recvfd sendfd rpath thread unix")); | ||||||
| 
 | 
 | ||||||
|     auto app = TRY(GUI::Application::try_create(arguments)); |     auto app = TRY(GUI::Application::try_create(arguments)); | ||||||
|     auto audio_client = TRY(Audio::ClientConnection::try_create()); |     auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio recvfd sendfd rpath thread")); |     TRY(Core::System::pledge("stdio recvfd sendfd rpath thread")); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibGUI/BoxLayout.h> | #include <LibGUI/BoxLayout.h> | ||||||
| #include <LibGUI/ImageWidget.h> | #include <LibGUI/ImageWidget.h> | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ compile_ipc(LanguageClient.ipc LanguageClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|         CodeComprehensionEngine.cpp |         CodeComprehensionEngine.cpp | ||||||
|         ClientConnection.cpp |         ConnectionFromClient.cpp | ||||||
|         FileDB.cpp) |         FileDB.cpp) | ||||||
| set(GENERATED_SOURCES | set(GENERATED_SOURCES | ||||||
|         LanguageClientEndpoint.h |         LanguageClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers { | namespace LanguageServers { | ||||||
| 
 | 
 | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| 
 | 
 | ||||||
| class CodeComprehensionEngine { | class CodeComprehensionEngine { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include <AK/Debug.h> | #include <AK/Debug.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
|  | @ -13,21 +13,21 @@ | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers { | namespace LanguageServers { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|     : IPC::ClientConnection<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket), 1) |     : IPC::ConnectionFromClient<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket), 1) | ||||||
| { | { | ||||||
|     s_connections.set(1, *this); |     s_connections.set(1, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
|     exit(0); |     exit(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::greet(String const& project_root) | void ConnectionFromClient::greet(String const& project_root) | ||||||
| { | { | ||||||
|     m_filedb.set_project_root(project_root); |     m_filedb.set_project_root(project_root); | ||||||
|     if (unveil(project_root.characters(), "r") < 0) { |     if (unveil(project_root.characters(), "r") < 0) { | ||||||
|  | @ -40,7 +40,7 @@ void ClientConnection::greet(String const& project_root) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::file_opened(String const& filename, IPC::File const& file) | void ConnectionFromClient::file_opened(String const& filename, IPC::File const& file) | ||||||
| { | { | ||||||
|     if (m_filedb.is_open(filename)) { |     if (m_filedb.is_open(filename)) { | ||||||
|         return; |         return; | ||||||
|  | @ -49,7 +49,7 @@ void ClientConnection::file_opened(String const& filename, IPC::File const& file | ||||||
|     m_autocomplete_engine->file_opened(filename); |     m_autocomplete_engine->file_opened(filename); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::file_edit_insert_text(String const& filename, String const& text, i32 start_line, i32 start_column) | void ConnectionFromClient::file_edit_insert_text(String const& filename, String const& text, i32 start_line, i32 start_column) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename); | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text); | ||||||
|  | @ -58,7 +58,7 @@ void ClientConnection::file_edit_insert_text(String const& filename, String cons | ||||||
|     m_autocomplete_engine->on_edit(filename); |     m_autocomplete_engine->on_edit(filename); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::file_edit_remove_text(String const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) | void ConnectionFromClient::file_edit_remove_text(String const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename); | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column); | ||||||
|  | @ -66,7 +66,7 @@ void ClientConnection::file_edit_remove_text(String const& filename, i32 start_l | ||||||
|     m_autocomplete_engine->on_edit(filename); |     m_autocomplete_engine->on_edit(filename); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation const& location) | void ConnectionFromClient::auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation const& location) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "AutoCompleteSuggestions for: {} {}:{}", location.file, location.line, location.column); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "AutoCompleteSuggestions for: {} {}:{}", location.file, location.line, location.column); | ||||||
| 
 | 
 | ||||||
|  | @ -81,7 +81,7 @@ void ClientConnection::auto_complete_suggestions(GUI::AutocompleteProvider::Proj | ||||||
|     async_auto_complete_suggestions(move(suggestions)); |     async_auto_complete_suggestions(move(suggestions)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::set_file_content(String const& filename, String const& content) | void ConnectionFromClient::set_file_content(String const& filename, String const& content) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename); | ||||||
|     auto document = m_filedb.get(filename); |     auto document = m_filedb.get(filename); | ||||||
|  | @ -95,7 +95,7 @@ void ClientConnection::set_file_content(String const& filename, String const& co | ||||||
|     m_autocomplete_engine->on_edit(filename); |     m_autocomplete_engine->on_edit(filename); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocation const& location) | void ConnectionFromClient::find_declaration(GUI::AutocompleteProvider::ProjectLocation const& location) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "FindDeclaration: {} {}:{}", location.file, location.line, location.column); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "FindDeclaration: {} {}:{}", location.file, location.line, location.column); | ||||||
|     auto document = m_filedb.get(location.file); |     auto document = m_filedb.get(location.file); | ||||||
|  | @ -115,7 +115,7 @@ void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocati | ||||||
|     async_declaration_location(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column }); |     async_declaration_location(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation const& location) | void ConnectionFromClient::get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation const& location) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "GetParametersHint: {} {}:{}", location.file, location.line, location.column); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "GetParametersHint: {} {}:{}", location.file, location.line, location.column); | ||||||
|     auto document = m_filedb.get(location.file); |     auto document = m_filedb.get(location.file); | ||||||
|  | @ -140,7 +140,7 @@ void ClientConnection::get_parameters_hint(GUI::AutocompleteProvider::ProjectLoc | ||||||
|     async_parameters_hint_result(params->params, params->current_index); |     async_parameters_hint_result(params->params, params->current_index); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::get_tokens_info(String const& filename) | void ConnectionFromClient::get_tokens_info(String const& filename) | ||||||
| { | { | ||||||
|     dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename); |     dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename); | ||||||
|     auto document = m_filedb.get(filename); |     auto document = m_filedb.get(filename); | ||||||
|  | @ -12,17 +12,17 @@ | ||||||
| #include "FileDB.h" | #include "FileDB.h" | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/LexicalPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| #include <Userland/DevTools/HackStudio/LanguageServers/LanguageClientEndpoint.h> | #include <Userland/DevTools/HackStudio/LanguageServers/LanguageClientEndpoint.h> | ||||||
| #include <Userland/DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h> | #include <Userland/DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers { | namespace LanguageServers { | ||||||
| 
 | 
 | ||||||
| class ClientConnection : public IPC::ClientConnection<LanguageClientEndpoint, LanguageServerEndpoint> { | class ConnectionFromClient : public IPC::ConnectionFromClient<LanguageClientEndpoint, LanguageServerEndpoint> { | ||||||
| public: | public: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); | ||||||
|     ~ClientConnection() override = default; |     ~ConnectionFromClient() override = default; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|  | @ -7,16 +7,16 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "CppComprehensionEngine.h" | #include "CppComprehensionEngine.h" | ||||||
| #include <DevTools/HackStudio/LanguageServers/ClientConnection.h> | #include <DevTools/HackStudio/LanguageServers/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers::Cpp { | namespace LanguageServers::Cpp { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public LanguageServers::ClientConnection { | class ConnectionFromClient final : public LanguageServers::ConnectionFromClient { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) |     ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|         : LanguageServers::ClientConnection(move(socket)) |         : LanguageServers::ConnectionFromClient(move(socket)) | ||||||
|     { |     { | ||||||
|         m_autocomplete_engine = make<CppComprehensionEngine>(m_filedb); |         m_autocomplete_engine = make<CppComprehensionEngine>(m_filedb); | ||||||
|         m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { |         m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { | ||||||
|  | @ -27,6 +27,6 @@ private: | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual ~ClientConnection() override = default; |     virtual ~ConnectionFromClient() override = default; | ||||||
| }; | }; | ||||||
| } | } | ||||||
|  | @ -16,7 +16,7 @@ | ||||||
| #include <LibCpp/Parser.h> | #include <LibCpp/Parser.h> | ||||||
| #include <LibCpp/Preprocessor.h> | #include <LibCpp/Preprocessor.h> | ||||||
| #include <LibRegex/Regex.h> | #include <LibRegex/Regex.h> | ||||||
| #include <Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h> | #include <Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers::Cpp { | namespace LanguageServers::Cpp { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "Tests.h" | #include "Tests.h" | ||||||
| #include <LibCore/ArgsParser.h> | #include <LibCore/ArgsParser.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
|  | @ -34,7 +34,7 @@ ErrorOr<int> mode_server() | ||||||
|     Core::EventLoop event_loop; |     Core::EventLoop event_loop; | ||||||
|     TRY(Core::System::pledge("stdio unix recvfd rpath")); |     TRY(Core::System::pledge("stdio unix recvfd rpath")); | ||||||
| 
 | 
 | ||||||
|     auto client = TRY(IPC::take_over_accepted_client_from_system_server<LanguageServers::Cpp::ClientConnection>()); |     auto client = TRY(IPC::take_over_accepted_client_from_system_server<LanguageServers::Cpp::ConnectionFromClient>()); | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio recvfd rpath")); |     TRY(Core::System::pledge("stdio recvfd rpath")); | ||||||
|     TRY(Core::System::unveil("/usr/include", "r")); |     TRY(Core::System::unveil("/usr/include", "r")); | ||||||
|  |  | ||||||
|  | @ -7,17 +7,17 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "ShellComprehensionEngine.h" | #include "ShellComprehensionEngine.h" | ||||||
| #include <DevTools/HackStudio/LanguageServers/ClientConnection.h> | #include <DevTools/HackStudio/LanguageServers/ConnectionFromClient.h> | ||||||
| #include <LibCpp/Parser.h> | #include <LibCpp/Parser.h> | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers::Shell { | namespace LanguageServers::Shell { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public LanguageServers::ClientConnection { | class ConnectionFromClient final : public LanguageServers::ConnectionFromClient { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) |     ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|         : LanguageServers::ClientConnection(move(socket)) |         : LanguageServers::ConnectionFromClient(move(socket)) | ||||||
|     { |     { | ||||||
|         m_autocomplete_engine = make<ShellComprehensionEngine>(m_filedb); |         m_autocomplete_engine = make<ShellComprehensionEngine>(m_filedb); | ||||||
|         m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { |         m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { | ||||||
|  | @ -27,6 +27,6 @@ private: | ||||||
|             async_todo_entries_in_document(filename, move(todo_entries)); |             async_todo_entries_in_document(filename, move(todo_entries)); | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
|     virtual ~ClientConnection() override = default; |     virtual ~ConnectionFromClient() override = default; | ||||||
| }; | }; | ||||||
| } | } | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| #include <AK/Assertions.h> | #include <AK/Assertions.h> | ||||||
| #include <AK/HashTable.h> | #include <AK/HashTable.h> | ||||||
| #include <LibRegex/Regex.h> | #include <LibRegex/Regex.h> | ||||||
| #include <Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h> | #include <Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace LanguageServers::Shell { | namespace LanguageServers::Shell { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
| #include <LibCore/LocalServer.h> | #include <LibCore/LocalServer.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
|  | @ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     Core::EventLoop event_loop; |     Core::EventLoop event_loop; | ||||||
|     TRY(Core::System::pledge("stdio unix rpath recvfd")); |     TRY(Core::System::pledge("stdio unix rpath recvfd")); | ||||||
| 
 | 
 | ||||||
|     auto client = TRY(IPC::take_over_accepted_client_from_system_server<LanguageServers::Shell::ClientConnection>()); |     auto client = TRY(IPC::take_over_accepted_client_from_system_server<LanguageServers::Shell::ConnectionFromClient>()); | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio rpath recvfd")); |     TRY(Core::System::pledge("stdio rpath recvfd")); | ||||||
|     TRY(Core::System::unveil("/etc/passwd", "r")); |     TRY(Core::System::unveil("/etc/passwd", "r")); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     Buffer.cpp |     Buffer.cpp | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     Loader.cpp |     Loader.cpp | ||||||
|     WavLoader.cpp |     WavLoader.cpp | ||||||
|     FlacLoader.cpp |     FlacLoader.cpp | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <LibAudio/Buffer.h> | #include <LibAudio/Buffer.h> | ||||||
| #include <LibAudio/ClientConnection.h> | #include <LibAudio/ConnectionFromClient.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| namespace Audio { | namespace Audio { | ||||||
|  | @ -14,12 +14,12 @@ namespace Audio { | ||||||
| // Real-time audio may be improved with a lower value.
 | // Real-time audio may be improved with a lower value.
 | ||||||
| static timespec g_enqueue_wait_time { 0, 10'000'000 }; | static timespec g_enqueue_wait_time { 0, 10'000'000 }; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|     : IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint>(*this, move(socket)) |     : IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint>(*this, move(socket)) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::enqueue(Buffer const& buffer) | void ConnectionFromClient::enqueue(Buffer const& buffer) | ||||||
| { | { | ||||||
|     for (;;) { |     for (;;) { | ||||||
|         auto success = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); |         auto success = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); | ||||||
|  | @ -29,35 +29,35 @@ void ClientConnection::enqueue(Buffer const& buffer) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::async_enqueue(Buffer const& buffer) | void ConnectionFromClient::async_enqueue(Buffer const& buffer) | ||||||
| { | { | ||||||
|     async_enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); |     async_enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool ClientConnection::try_enqueue(Buffer const& buffer) | bool ConnectionFromClient::try_enqueue(Buffer const& buffer) | ||||||
| { | { | ||||||
|     return enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); |     return enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::finished_playing_buffer(i32 buffer_id) | void ConnectionFromClient::finished_playing_buffer(i32 buffer_id) | ||||||
| { | { | ||||||
|     if (on_finish_playing_buffer) |     if (on_finish_playing_buffer) | ||||||
|         on_finish_playing_buffer(buffer_id); |         on_finish_playing_buffer(buffer_id); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::main_mix_muted_state_changed(bool muted) | void ConnectionFromClient::main_mix_muted_state_changed(bool muted) | ||||||
| { | { | ||||||
|     if (on_main_mix_muted_state_change) |     if (on_main_mix_muted_state_change) | ||||||
|         on_main_mix_muted_state_change(muted); |         on_main_mix_muted_state_change(muted); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::main_mix_volume_changed(double volume) | void ConnectionFromClient::main_mix_volume_changed(double volume) | ||||||
| { | { | ||||||
|     if (on_main_mix_volume_change) |     if (on_main_mix_volume_change) | ||||||
|         on_main_mix_volume_change(volume); |         on_main_mix_volume_change(volume); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::client_volume_changed(double volume) | void ConnectionFromClient::client_volume_changed(double volume) | ||||||
| { | { | ||||||
|     if (on_client_volume_change) |     if (on_client_volume_change) | ||||||
|         on_client_volume_change(volume); |         on_client_volume_change(volume); | ||||||
|  | @ -14,10 +14,10 @@ namespace Audio { | ||||||
| 
 | 
 | ||||||
| class Buffer; | class Buffer; | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint> |     : public IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint> | ||||||
|     , public AudioClientEndpoint { |     , public AudioClientEndpoint { | ||||||
|     IPC_CLIENT_CONNECTION(ClientConnection, "/tmp/portal/audio") |     IPC_CLIENT_CONNECTION(ConnectionFromClient, "/tmp/portal/audio") | ||||||
| public: | public: | ||||||
|     void enqueue(Buffer const&); |     void enqueue(Buffer const&); | ||||||
|     bool try_enqueue(Buffer const&); |     bool try_enqueue(Buffer const&); | ||||||
|  | @ -29,7 +29,7 @@ public: | ||||||
|     Function<void(double volume)> on_client_volume_change; |     Function<void(double volume)> on_client_volume_change; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>); |     ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); | ||||||
| 
 | 
 | ||||||
|     virtual void finished_playing_buffer(i32) override; |     virtual void finished_playing_buffer(i32) override; | ||||||
|     virtual void main_mix_muted_state_changed(bool) override; |     virtual void main_mix_muted_state_changed(bool) override; | ||||||
|  | @ -17,14 +17,14 @@ NonnullRefPtr<T> new_client_connection(Args&&... args) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename ClientEndpoint, typename ServerEndpoint> | template<typename ClientEndpoint, typename ServerEndpoint> | ||||||
| class ClientConnection : public Connection<ServerEndpoint, ClientEndpoint> | class ConnectionFromClient : public Connection<ServerEndpoint, ClientEndpoint> | ||||||
|     , public ServerEndpoint::Stub |     , public ServerEndpoint::Stub | ||||||
|     , public ClientEndpoint::template Proxy<ServerEndpoint> { |     , public ClientEndpoint::template Proxy<ServerEndpoint> { | ||||||
| public: | public: | ||||||
|     using ServerStub = typename ServerEndpoint::Stub; |     using ServerStub = typename ServerEndpoint::Stub; | ||||||
|     using IPCProxy = typename ClientEndpoint::template Proxy<ServerEndpoint>; |     using IPCProxy = typename ClientEndpoint::template Proxy<ServerEndpoint>; | ||||||
| 
 | 
 | ||||||
|     ClientConnection(ServerStub& stub, NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) |     ConnectionFromClient(ServerStub& stub, NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ||||||
|         : IPC::Connection<ServerEndpoint, ClientEndpoint>(stub, move(socket)) |         : IPC::Connection<ServerEndpoint, ClientEndpoint>(stub, move(socket)) | ||||||
|         , ClientEndpoint::template Proxy<ServerEndpoint>(*this, {}) |         , ClientEndpoint::template Proxy<ServerEndpoint>(*this, {}) | ||||||
|         , m_client_id(client_id) |         , m_client_id(client_id) | ||||||
|  | @ -36,7 +36,7 @@ public: | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual ~ClientConnection() override |     virtual ~ConnectionFromClient() override | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -69,5 +69,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename ClientEndpoint, typename ServerEndpoint> | template<typename ClientEndpoint, typename ServerEndpoint> | ||||||
| struct AK::Formatter<IPC::ClientConnection<ClientEndpoint, ServerEndpoint>> : Formatter<Core::Object> { | struct AK::Formatter<IPC::ConnectionFromClient<ClientEndpoint, ServerEndpoint>> : Formatter<Core::Object> { | ||||||
| }; | }; | ||||||
|  | @ -8,11 +8,11 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/Error.h> | #include <AK/Error.h> | ||||||
| #include <LibCore/LocalServer.h> | #include <LibCore/LocalServer.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace IPC { | namespace IPC { | ||||||
| 
 | 
 | ||||||
| template<typename ClientConnectionType> | template<typename ConnectionFromClientType> | ||||||
| class MultiServer { | class MultiServer { | ||||||
| public: | public: | ||||||
|     static ErrorOr<NonnullOwnPtr<MultiServer>> try_create(Optional<String> socket_path = {}) |     static ErrorOr<NonnullOwnPtr<MultiServer>> try_create(Optional<String> socket_path = {}) | ||||||
|  | @ -28,7 +28,7 @@ private: | ||||||
|     { |     { | ||||||
|         m_server->on_accept = [&](auto client_socket) { |         m_server->on_accept = [&](auto client_socket) { | ||||||
|             auto client_id = ++m_next_client_id; |             auto client_id = ++m_next_client_id; | ||||||
|             (void)IPC::new_client_connection<ClientConnectionType>(move(client_socket), client_id); |             (void)IPC::new_client_connection<ConnectionFromClientType>(move(client_socket), client_id); | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,15 +8,15 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibCore/SystemServerTakeover.h> | #include <LibCore/SystemServerTakeover.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace IPC { | namespace IPC { | ||||||
| 
 | 
 | ||||||
| template<typename ClientConnectionType> | template<typename ConnectionFromClientType> | ||||||
| ErrorOr<NonnullRefPtr<ClientConnectionType>> take_over_accepted_client_from_system_server() | ErrorOr<NonnullRefPtr<ConnectionFromClientType>> take_over_accepted_client_from_system_server() | ||||||
| { | { | ||||||
|     auto socket = TRY(Core::take_over_socket_from_system_server()); |     auto socket = TRY(Core::take_over_socket_from_system_server()); | ||||||
|     return IPC::new_client_connection<ClientConnectionType>(move(socket)); |     return IPC::new_client_connection<ConnectionFromClientType>(move(socket)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(AudioServer.ipc AudioServerEndpoint.h) | ||||||
| compile_ipc(AudioClient.ipc AudioClientEndpoint.h) | compile_ipc(AudioClient.ipc AudioClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     Mixer.cpp |     Mixer.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     AudioServerEndpoint.h |     AudioServerEndpoint.h | ||||||
|  |  | ||||||
|  | @ -1,166 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |  | ||||||
|  * |  | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #include "ClientConnection.h" |  | ||||||
| #include "Mixer.h" |  | ||||||
| #include <AudioServer/AudioClientEndpoint.h> |  | ||||||
| #include <LibAudio/Buffer.h> |  | ||||||
| 
 |  | ||||||
| namespace AudioServer { |  | ||||||
| 
 |  | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; |  | ||||||
| 
 |  | ||||||
| void ClientConnection::for_each(Function<void(ClientConnection&)> callback) |  | ||||||
| { |  | ||||||
|     NonnullRefPtrVector<ClientConnection> connections; |  | ||||||
|     for (auto& it : s_connections) |  | ||||||
|         connections.append(*it.value); |  | ||||||
|     for (auto& connection : connections) |  | ||||||
|         callback(connection); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id, Mixer& mixer) |  | ||||||
|     : IPC::ClientConnection<AudioClientEndpoint, AudioServerEndpoint>(*this, move(client_socket), client_id) |  | ||||||
|     , m_mixer(mixer) |  | ||||||
| { |  | ||||||
|     s_connections.set(client_id, *this); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| ClientConnection::~ClientConnection() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::die() |  | ||||||
| { |  | ||||||
|     s_connections.remove(client_id()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id) |  | ||||||
| { |  | ||||||
|     async_finished_playing_buffer(buffer_id); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::did_change_main_mix_muted_state(Badge<Mixer>, bool muted) |  | ||||||
| { |  | ||||||
|     async_main_mix_muted_state_changed(muted); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::did_change_main_mix_volume(Badge<Mixer>, double volume) |  | ||||||
| { |  | ||||||
|     async_main_mix_volume_changed(volume); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::did_change_client_volume(Badge<ClientAudioStream>, double volume) |  | ||||||
| { |  | ||||||
|     async_client_volume_changed(volume); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetMainMixVolumeResponse ClientConnection::get_main_mix_volume() |  | ||||||
| { |  | ||||||
|     return m_mixer.main_volume(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_main_mix_volume(double volume) |  | ||||||
| { |  | ||||||
|     m_mixer.set_main_volume(volume); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetSampleRateResponse ClientConnection::get_sample_rate() |  | ||||||
| { |  | ||||||
|     return { m_mixer.audiodevice_get_sample_rate() }; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_sample_rate(u32 sample_rate) |  | ||||||
| { |  | ||||||
|     m_mixer.audiodevice_set_sample_rate(sample_rate); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetSelfVolumeResponse ClientConnection::get_self_volume() |  | ||||||
| { |  | ||||||
|     return m_queue->volume().target(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_self_volume(double volume) |  | ||||||
| { |  | ||||||
|     if (m_queue) |  | ||||||
|         m_queue->set_volume(volume); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::EnqueueBufferResponse ClientConnection::enqueue_buffer(Core::AnonymousBuffer const& buffer, i32 buffer_id, int sample_count) |  | ||||||
| { |  | ||||||
|     if (!m_queue) |  | ||||||
|         m_queue = m_mixer.create_queue(*this); |  | ||||||
| 
 |  | ||||||
|     if (m_queue->is_full()) |  | ||||||
|         return false; |  | ||||||
| 
 |  | ||||||
|     // There's not a big allocation to worry about here.
 |  | ||||||
|     m_queue->enqueue(MUST(Audio::Buffer::create_with_anonymous_buffer(buffer, buffer_id, sample_count))); |  | ||||||
|     return true; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetRemainingSamplesResponse ClientConnection::get_remaining_samples() |  | ||||||
| { |  | ||||||
|     int remaining = 0; |  | ||||||
|     if (m_queue) |  | ||||||
|         remaining = m_queue->get_remaining_samples(); |  | ||||||
| 
 |  | ||||||
|     return remaining; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetPlayedSamplesResponse ClientConnection::get_played_samples() |  | ||||||
| { |  | ||||||
|     int played = 0; |  | ||||||
|     if (m_queue) |  | ||||||
|         played = m_queue->get_played_samples(); |  | ||||||
| 
 |  | ||||||
|     return played; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_paused(bool paused) |  | ||||||
| { |  | ||||||
|     if (m_queue) |  | ||||||
|         m_queue->set_paused(paused); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::clear_buffer(bool paused) |  | ||||||
| { |  | ||||||
|     if (m_queue) |  | ||||||
|         m_queue->clear(paused); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::GetPlayingBufferResponse ClientConnection::get_playing_buffer() |  | ||||||
| { |  | ||||||
|     int id = -1; |  | ||||||
|     if (m_queue) |  | ||||||
|         id = m_queue->get_playing_buffer(); |  | ||||||
|     return id; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::IsMainMixMutedResponse ClientConnection::is_main_mix_muted() |  | ||||||
| { |  | ||||||
|     return m_mixer.is_muted(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_main_mix_muted(bool muted) |  | ||||||
| { |  | ||||||
|     m_mixer.set_muted(muted); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::AudioServer::IsSelfMutedResponse ClientConnection::is_self_muted() |  | ||||||
| { |  | ||||||
|     if (m_queue) |  | ||||||
|         return m_queue->is_muted(); |  | ||||||
| 
 |  | ||||||
|     return false; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_self_muted(bool muted) |  | ||||||
| { |  | ||||||
|     if (m_queue) |  | ||||||
|         m_queue->set_muted(muted); |  | ||||||
| } |  | ||||||
| } |  | ||||||
							
								
								
									
										166
									
								
								Userland/Services/AudioServer/ConnectionFromClient.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								Userland/Services/AudioServer/ConnectionFromClient.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,166 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | ||||||
|  |  * | ||||||
|  |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "ConnectionFromClient.h" | ||||||
|  | #include "Mixer.h" | ||||||
|  | #include <AudioServer/AudioClientEndpoint.h> | ||||||
|  | #include <LibAudio/Buffer.h> | ||||||
|  | 
 | ||||||
|  | namespace AudioServer { | ||||||
|  | 
 | ||||||
|  | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::for_each(Function<void(ConnectionFromClient&)> callback) | ||||||
|  | { | ||||||
|  |     NonnullRefPtrVector<ConnectionFromClient> connections; | ||||||
|  |     for (auto& it : s_connections) | ||||||
|  |         connections.append(*it.value); | ||||||
|  |     for (auto& connection : connections) | ||||||
|  |         callback(connection); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id, Mixer& mixer) | ||||||
|  |     : IPC::ConnectionFromClient<AudioClientEndpoint, AudioServerEndpoint>(*this, move(client_socket), client_id) | ||||||
|  |     , m_mixer(mixer) | ||||||
|  | { | ||||||
|  |     s_connections.set(client_id, *this); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ConnectionFromClient::~ConnectionFromClient() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::die() | ||||||
|  | { | ||||||
|  |     s_connections.remove(client_id()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id) | ||||||
|  | { | ||||||
|  |     async_finished_playing_buffer(buffer_id); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::did_change_main_mix_muted_state(Badge<Mixer>, bool muted) | ||||||
|  | { | ||||||
|  |     async_main_mix_muted_state_changed(muted); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::did_change_main_mix_volume(Badge<Mixer>, double volume) | ||||||
|  | { | ||||||
|  |     async_main_mix_volume_changed(volume); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::did_change_client_volume(Badge<ClientAudioStream>, double volume) | ||||||
|  | { | ||||||
|  |     async_client_volume_changed(volume); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetMainMixVolumeResponse ConnectionFromClient::get_main_mix_volume() | ||||||
|  | { | ||||||
|  |     return m_mixer.main_volume(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_main_mix_volume(double volume) | ||||||
|  | { | ||||||
|  |     m_mixer.set_main_volume(volume); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetSampleRateResponse ConnectionFromClient::get_sample_rate() | ||||||
|  | { | ||||||
|  |     return { m_mixer.audiodevice_get_sample_rate() }; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_sample_rate(u32 sample_rate) | ||||||
|  | { | ||||||
|  |     m_mixer.audiodevice_set_sample_rate(sample_rate); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetSelfVolumeResponse ConnectionFromClient::get_self_volume() | ||||||
|  | { | ||||||
|  |     return m_queue->volume().target(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_self_volume(double volume) | ||||||
|  | { | ||||||
|  |     if (m_queue) | ||||||
|  |         m_queue->set_volume(volume); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::EnqueueBufferResponse ConnectionFromClient::enqueue_buffer(Core::AnonymousBuffer const& buffer, i32 buffer_id, int sample_count) | ||||||
|  | { | ||||||
|  |     if (!m_queue) | ||||||
|  |         m_queue = m_mixer.create_queue(*this); | ||||||
|  | 
 | ||||||
|  |     if (m_queue->is_full()) | ||||||
|  |         return false; | ||||||
|  | 
 | ||||||
|  |     // There's not a big allocation to worry about here.
 | ||||||
|  |     m_queue->enqueue(MUST(Audio::Buffer::create_with_anonymous_buffer(buffer, buffer_id, sample_count))); | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetRemainingSamplesResponse ConnectionFromClient::get_remaining_samples() | ||||||
|  | { | ||||||
|  |     int remaining = 0; | ||||||
|  |     if (m_queue) | ||||||
|  |         remaining = m_queue->get_remaining_samples(); | ||||||
|  | 
 | ||||||
|  |     return remaining; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetPlayedSamplesResponse ConnectionFromClient::get_played_samples() | ||||||
|  | { | ||||||
|  |     int played = 0; | ||||||
|  |     if (m_queue) | ||||||
|  |         played = m_queue->get_played_samples(); | ||||||
|  | 
 | ||||||
|  |     return played; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_paused(bool paused) | ||||||
|  | { | ||||||
|  |     if (m_queue) | ||||||
|  |         m_queue->set_paused(paused); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::clear_buffer(bool paused) | ||||||
|  | { | ||||||
|  |     if (m_queue) | ||||||
|  |         m_queue->clear(paused); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::GetPlayingBufferResponse ConnectionFromClient::get_playing_buffer() | ||||||
|  | { | ||||||
|  |     int id = -1; | ||||||
|  |     if (m_queue) | ||||||
|  |         id = m_queue->get_playing_buffer(); | ||||||
|  |     return id; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::IsMainMixMutedResponse ConnectionFromClient::is_main_mix_muted() | ||||||
|  | { | ||||||
|  |     return m_mixer.is_muted(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_main_mix_muted(bool muted) | ||||||
|  | { | ||||||
|  |     m_mixer.set_muted(muted); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::AudioServer::IsSelfMutedResponse ConnectionFromClient::is_self_muted() | ||||||
|  | { | ||||||
|  |     if (m_queue) | ||||||
|  |         return m_queue->is_muted(); | ||||||
|  | 
 | ||||||
|  |     return false; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_self_muted(bool muted) | ||||||
|  | { | ||||||
|  |     if (m_queue) | ||||||
|  |         m_queue->set_muted(muted); | ||||||
|  | } | ||||||
|  | } | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AudioServer/AudioClientEndpoint.h> | #include <AudioServer/AudioClientEndpoint.h> | ||||||
| #include <AudioServer/AudioServerEndpoint.h> | #include <AudioServer/AudioServerEndpoint.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace Audio { | namespace Audio { | ||||||
| class Buffer; | class Buffer; | ||||||
|  | @ -20,10 +20,10 @@ namespace AudioServer { | ||||||
| class ClientAudioStream; | class ClientAudioStream; | ||||||
| class Mixer; | class Mixer; | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public IPC::ClientConnection<AudioClientEndpoint, AudioServerEndpoint> { | class ConnectionFromClient final : public IPC::ConnectionFromClient<AudioClientEndpoint, AudioServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection) |     C_OBJECT(ConnectionFromClient) | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id); |     void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id); | ||||||
|     void did_change_client_volume(Badge<ClientAudioStream>, double volume); |     void did_change_client_volume(Badge<ClientAudioStream>, double volume); | ||||||
|  | @ -32,10 +32,10 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|     static void for_each(Function<void(ClientConnection&)>); |     static void for_each(Function<void(ConnectionFromClient&)>); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id, Mixer& mixer); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id, Mixer& mixer); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override; |     virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override; | ||||||
|     virtual void set_main_mix_volume(double) override; |     virtual void set_main_mix_volume(double) override; | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| #include <AK/Array.h> | #include <AK/Array.h> | ||||||
| #include <AK/MemoryStream.h> | #include <AK/MemoryStream.h> | ||||||
| #include <AK/NumericLimits.h> | #include <AK/NumericLimits.h> | ||||||
| #include <AudioServer/ClientConnection.h> | #include <AudioServer/ConnectionFromClient.h> | ||||||
| #include <AudioServer/Mixer.h> | #include <AudioServer/Mixer.h> | ||||||
| #include <LibCore/ConfigFile.h> | #include <LibCore/ConfigFile.h> | ||||||
| #include <LibCore/Timer.h> | #include <LibCore/Timer.h> | ||||||
|  | @ -48,7 +48,7 @@ Mixer::~Mixer() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<ClientAudioStream> Mixer::create_queue(ClientConnection& client) | NonnullRefPtr<ClientAudioStream> Mixer::create_queue(ConnectionFromClient& client) | ||||||
| { | { | ||||||
|     auto queue = adopt_ref(*new ClientAudioStream(client)); |     auto queue = adopt_ref(*new ClientAudioStream(client)); | ||||||
|     m_pending_mutex.lock(); |     m_pending_mutex.lock(); | ||||||
|  | @ -149,7 +149,7 @@ void Mixer::set_main_volume(double volume) | ||||||
|     m_config->write_num_entry("Master", "Volume", static_cast<int>(volume * 100)); |     m_config->write_num_entry("Master", "Volume", static_cast<int>(volume * 100)); | ||||||
|     request_setting_sync(); |     request_setting_sync(); | ||||||
| 
 | 
 | ||||||
|     ClientConnection::for_each([&](ClientConnection& client) { |     ConnectionFromClient::for_each([&](ConnectionFromClient& client) { | ||||||
|         client.did_change_main_mix_volume({}, main_volume()); |         client.did_change_main_mix_volume({}, main_volume()); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -163,7 +163,7 @@ void Mixer::set_muted(bool muted) | ||||||
|     m_config->write_bool_entry("Master", "Mute", m_muted); |     m_config->write_bool_entry("Master", "Mute", m_muted); | ||||||
|     request_setting_sync(); |     request_setting_sync(); | ||||||
| 
 | 
 | ||||||
|     ClientConnection::for_each([muted](ClientConnection& client) { |     ConnectionFromClient::for_each([muted](ConnectionFromClient& client) { | ||||||
|         client.did_change_main_mix_muted_state({}, muted); |         client.did_change_main_mix_muted_state({}, muted); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -199,7 +199,7 @@ void Mixer::request_setting_sync() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientAudioStream::ClientAudioStream(ClientConnection& client) | ClientAudioStream::ClientAudioStream(ConnectionFromClient& client) | ||||||
|     : m_client(client) |     : m_client(client) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "FadingProperty.h" | #include "FadingProperty.h" | ||||||
| #include <AK/Atomic.h> | #include <AK/Atomic.h> | ||||||
| #include <AK/Badge.h> | #include <AK/Badge.h> | ||||||
|  | @ -30,11 +30,11 @@ namespace AudioServer { | ||||||
| // This is to prevent clipping when two streams with low headroom (e.g. normalized & compressed) are playing.
 | // This is to prevent clipping when two streams with low headroom (e.g. normalized & compressed) are playing.
 | ||||||
| constexpr double SAMPLE_HEADROOM = 0.7; | constexpr double SAMPLE_HEADROOM = 0.7; | ||||||
| 
 | 
 | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| 
 | 
 | ||||||
| class ClientAudioStream : public RefCounted<ClientAudioStream> { | class ClientAudioStream : public RefCounted<ClientAudioStream> { | ||||||
| public: | public: | ||||||
|     explicit ClientAudioStream(ClientConnection&); |     explicit ClientAudioStream(ConnectionFromClient&); | ||||||
|     ~ClientAudioStream() { } |     ~ClientAudioStream() { } | ||||||
| 
 | 
 | ||||||
|     bool is_full() const { return m_queue.size() >= 3; } |     bool is_full() const { return m_queue.size() >= 3; } | ||||||
|  | @ -64,7 +64,7 @@ public: | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     ClientConnection* client() { return m_client.ptr(); } |     ConnectionFromClient* client() { return m_client.ptr(); } | ||||||
| 
 | 
 | ||||||
|     void clear(bool paused = false) |     void clear(bool paused = false) | ||||||
|     { |     { | ||||||
|  | @ -105,7 +105,7 @@ private: | ||||||
|     bool m_paused { false }; |     bool m_paused { false }; | ||||||
|     bool m_muted { false }; |     bool m_muted { false }; | ||||||
| 
 | 
 | ||||||
|     WeakPtr<ClientConnection> m_client; |     WeakPtr<ConnectionFromClient> m_client; | ||||||
|     FadingProperty<double> m_volume { 1 }; |     FadingProperty<double> m_volume { 1 }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -114,7 +114,7 @@ class Mixer : public Core::Object { | ||||||
| public: | public: | ||||||
|     virtual ~Mixer() override; |     virtual ~Mixer() override; | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<ClientAudioStream> create_queue(ClientConnection&); |     NonnullRefPtr<ClientAudioStream> create_queue(ConnectionFromClient&); | ||||||
| 
 | 
 | ||||||
|     // To the outside world, we pretend that the target volume is already reached, even though it may be still fading.
 |     // To the outside world, we pretend that the target volume is already reached, even though it may be still fading.
 | ||||||
|     double main_volume() const { return m_main_volume.target(); } |     double main_volume() const { return m_main_volume.target(); } | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     server->on_accept = [&](NonnullOwnPtr<Core::Stream::LocalSocket> client_socket) { |     server->on_accept = [&](NonnullOwnPtr<Core::Stream::LocalSocket> client_socket) { | ||||||
|         static int s_next_client_id = 0; |         static int s_next_client_id = 0; | ||||||
|         int client_id = ++s_next_client_id; |         int client_id = ++s_next_client_id; | ||||||
|         (void)IPC::new_client_connection<AudioServer::ClientConnection>(move(client_socket), client_id, *mixer); |         (void)IPC::new_client_connection<AudioServer::ConnectionFromClient>(move(client_socket), client_id, *mixer); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio recvfd thread accept cpath rpath wpath")); |     TRY(Core::System::pledge("stdio recvfd thread accept cpath rpath wpath")); | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(ClipboardServer.ipc ClipboardServerEndpoint.h) | ||||||
| compile_ipc(ClipboardClient.ipc ClipboardClientEndpoint.h) | compile_ipc(ClipboardClient.ipc ClipboardClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     ClipboardClientEndpoint.h |     ClipboardClientEndpoint.h | ||||||
|     ClipboardServerEndpoint.h |     ClipboardServerEndpoint.h | ||||||
|     Storage.cpp |     Storage.cpp | ||||||
|  |  | ||||||
|  | @ -1,53 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> |  | ||||||
|  * |  | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #include <Clipboard/ClientConnection.h> |  | ||||||
| #include <Clipboard/ClipboardClientEndpoint.h> |  | ||||||
| #include <Clipboard/Storage.h> |  | ||||||
| 
 |  | ||||||
| namespace Clipboard { |  | ||||||
| 
 |  | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; |  | ||||||
| 
 |  | ||||||
| void ClientConnection::for_each_client(Function<void(ClientConnection&)> callback) |  | ||||||
| { |  | ||||||
|     for (auto& it : s_connections) { |  | ||||||
|         callback(*it.value); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) |  | ||||||
|     : IPC::ClientConnection<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, move(socket), client_id) |  | ||||||
| { |  | ||||||
|     s_connections.set(client_id, *this); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| ClientConnection::~ClientConnection() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::die() |  | ||||||
| { |  | ||||||
|     s_connections.remove(client_id()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::set_clipboard_data(Core::AnonymousBuffer const& data, String const& mime_type, IPC::Dictionary const& metadata) |  | ||||||
| { |  | ||||||
|     Storage::the().set_data(data, mime_type, metadata.entries()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Messages::ClipboardServer::GetClipboardDataResponse ClientConnection::get_clipboard_data() |  | ||||||
| { |  | ||||||
|     auto& storage = Storage::the(); |  | ||||||
|     return { storage.buffer(), storage.mime_type(), storage.metadata() }; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void ClientConnection::notify_about_clipboard_change() |  | ||||||
| { |  | ||||||
|     async_clipboard_data_changed(Storage::the().mime_type()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
							
								
								
									
										53
									
								
								Userland/Services/Clipboard/ConnectionFromClient.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								Userland/Services/Clipboard/ConnectionFromClient.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,53 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | ||||||
|  |  * | ||||||
|  |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include <Clipboard/ClipboardClientEndpoint.h> | ||||||
|  | #include <Clipboard/ConnectionFromClient.h> | ||||||
|  | #include <Clipboard/Storage.h> | ||||||
|  | 
 | ||||||
|  | namespace Clipboard { | ||||||
|  | 
 | ||||||
|  | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::for_each_client(Function<void(ConnectionFromClient&)> callback) | ||||||
|  | { | ||||||
|  |     for (auto& it : s_connections) { | ||||||
|  |         callback(*it.value); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ||||||
|  |     : IPC::ConnectionFromClient<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, move(socket), client_id) | ||||||
|  | { | ||||||
|  |     s_connections.set(client_id, *this); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ConnectionFromClient::~ConnectionFromClient() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::die() | ||||||
|  | { | ||||||
|  |     s_connections.remove(client_id()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, String const& mime_type, IPC::Dictionary const& metadata) | ||||||
|  | { | ||||||
|  |     Storage::the().set_data(data, mime_type, metadata.entries()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data() | ||||||
|  | { | ||||||
|  |     auto& storage = Storage::the(); | ||||||
|  |     return { storage.buffer(), storage.mime_type(), storage.metadata() }; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ConnectionFromClient::notify_about_clipboard_change() | ||||||
|  | { | ||||||
|  |     async_clipboard_data_changed(Storage::the().mime_type()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -9,25 +9,25 @@ | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <Clipboard/ClipboardClientEndpoint.h> | #include <Clipboard/ClipboardClientEndpoint.h> | ||||||
| #include <Clipboard/ClipboardServerEndpoint.h> | #include <Clipboard/ClipboardServerEndpoint.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace Clipboard { | namespace Clipboard { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<ClipboardClientEndpoint, ClipboardServerEndpoint> { |     : public IPC::ConnectionFromClient<ClipboardClientEndpoint, ClipboardServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     virtual ~ClientConnection() override; |     virtual ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|     static void for_each_client(Function<void(ClientConnection&)>); |     static void for_each_client(Function<void(ConnectionFromClient&)>); | ||||||
| 
 | 
 | ||||||
|     void notify_about_clipboard_change(); |     void notify_about_clipboard_change(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override; |     virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override; | ||||||
|     virtual void set_clipboard_data(Core::AnonymousBuffer const&, String const&, IPC::Dictionary const&) override; |     virtual void set_clipboard_data(Core::AnonymousBuffer const&, String const&, IPC::Dictionary const&) override; | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <Clipboard/ClientConnection.h> | #include <Clipboard/ConnectionFromClient.h> | ||||||
| #include <Clipboard/Storage.h> | #include <Clipboard/Storage.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
|  | @ -17,10 +17,10 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     Core::EventLoop event_loop; |     Core::EventLoop event_loop; | ||||||
|     TRY(Core::System::unveil(nullptr, nullptr)); |     TRY(Core::System::unveil(nullptr, nullptr)); | ||||||
| 
 | 
 | ||||||
|     auto server = TRY(IPC::MultiServer<Clipboard::ClientConnection>::try_create()); |     auto server = TRY(IPC::MultiServer<Clipboard::ConnectionFromClient>::try_create()); | ||||||
| 
 | 
 | ||||||
|     Clipboard::Storage::the().on_content_change = [&] { |     Clipboard::Storage::the().on_content_change = [&] { | ||||||
|         Clipboard::ClientConnection::for_each_client([&](auto& client) { |         Clipboard::ConnectionFromClient::for_each_client([&](auto& client) { | ||||||
|             client.notify_about_clipboard_change(); |             client.notify_about_clipboard_change(); | ||||||
|         }); |         }); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(ConfigServer.ipc ConfigServerEndpoint.h) | ||||||
| compile_ipc(ConfigClient.ipc ConfigClientEndpoint.h) | compile_ipc(ConfigClient.ipc ConfigClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     ConfigServerEndpoint.h |     ConfigServerEndpoint.h | ||||||
|     ConfigClientEndpoint.h |     ConfigClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include <ConfigServer/ConfigClientEndpoint.h> | #include <ConfigServer/ConfigClientEndpoint.h> | ||||||
| #include <LibCore/ConfigFile.h> | #include <LibCore/ConfigFile.h> | ||||||
| #include <LibCore/FileWatcher.h> | #include <LibCore/FileWatcher.h> | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace ConfigServer { | namespace ConfigServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| struct CachedDomain { | struct CachedDomain { | ||||||
|     String domain; |     String domain; | ||||||
|  | @ -23,7 +23,7 @@ struct CachedDomain { | ||||||
| static HashMap<String, NonnullOwnPtr<CachedDomain>> s_cache; | static HashMap<String, NonnullOwnPtr<CachedDomain>> s_cache; | ||||||
| static constexpr int s_disk_sync_delay_ms = 5'000; | 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) { |     for (auto& it : s_connections) { | ||||||
|         if (it.value->is_monitoring_domain(domain) && (!excluded_connection || it.value != excluded_connection)) |         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& group : config->groups()) { | ||||||
|             for (auto& key : config->keys(group)) { |             for (auto& key : config->keys(group)) { | ||||||
|                 if (!new_config->has_key(group, key)) { |                 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); |                         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 old_value = config->read_entry(group, key); | ||||||
|                 auto new_value = new_config->read_entry(group, key); |                 auto new_value = new_config->read_entry(group, key); | ||||||
|                 if (old_value != new_value) { |                 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); |                         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; |     return *config; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ||||||
|     : IPC::ClientConnection<ConfigClientEndpoint, ConfigServerEndpoint>(*this, move(client_socket), 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(); })) |     , 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); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
|     m_sync_timer->stop(); |     m_sync_timer->stop(); | ||||||
|     sync_dirty_domains_to_disk(); |     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) { |     if (m_has_pledged) { | ||||||
|         did_misbehave("Tried to pledge domains twice."); |         did_misbehave("Tried to pledge domains twice."); | ||||||
|  | @ -103,7 +103,7 @@ void ClientConnection::pledge_domains(Vector<String> const& domains) | ||||||
|         m_pledged_domains.set(domain); |         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)) { |     if (m_has_pledged && !m_pledged_domains.contains(domain)) { | ||||||
|         did_misbehave("Attempt to monitor non-pledged 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); |     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) |     if (!m_has_pledged) | ||||||
|         return true; |         return true; | ||||||
|  | @ -123,7 +123,7 @@ bool ClientConnection::validate_access(String const& domain, String const& group | ||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::sync_dirty_domains_to_disk() | void ConnectionFromClient::sync_dirty_domains_to_disk() | ||||||
| { | { | ||||||
|     if (m_dirty_domains.is_empty()) |     if (m_dirty_domains.is_empty()) | ||||||
|         return; |         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, "")) |     if (!validate_access(domain, group, "")) | ||||||
|         return Vector<String> {}; |         return Vector<String> {}; | ||||||
|  | @ -147,7 +147,7 @@ Messages::ConfigServer::ListConfigKeysResponse ClientConnection::list_config_key | ||||||
|     return { config.keys(group) }; |     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, "", "")) |     if (!validate_access(domain, "", "")) | ||||||
|         return Vector<String> {}; |         return Vector<String> {}; | ||||||
|  | @ -155,7 +155,7 @@ Messages::ConfigServer::ListConfigGroupsResponse ClientConnection::list_config_g | ||||||
|     return { config.groups() }; |     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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return nullptr; |         return nullptr; | ||||||
|  | @ -166,7 +166,7 @@ Messages::ConfigServer::ReadStringValueResponse ClientConnection::read_string_va | ||||||
|     return Optional<String> { config.read_entry(group, key) }; |     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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return nullptr; |         return nullptr; | ||||||
|  | @ -177,7 +177,7 @@ Messages::ConfigServer::ReadI32ValueResponse ClientConnection::read_i32_value(St | ||||||
|     return Optional<i32> { config.read_num_entry(group, key) }; |     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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return nullptr; |         return nullptr; | ||||||
|  | @ -188,7 +188,7 @@ Messages::ConfigServer::ReadBoolValueResponse ClientConnection::read_bool_value( | ||||||
|     return Optional<bool> { config.read_bool_entry(group, key) }; |     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()) |     if (m_sync_timer->is_active()) | ||||||
|         m_sync_timer->restart(); |         m_sync_timer->restart(); | ||||||
|  | @ -196,7 +196,7 @@ void ClientConnection::start_or_restart_sync_timer() | ||||||
|         m_sync_timer->start(); |         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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return; |         return; | ||||||
|  | @ -210,12 +210,12 @@ void ClientConnection::write_string_value(String const& domain, String const& gr | ||||||
|     m_dirty_domains.set(domain); |     m_dirty_domains.set(domain); | ||||||
|     start_or_restart_sync_timer(); |     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); |         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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return; |         return; | ||||||
|  | @ -229,12 +229,12 @@ void ClientConnection::write_i32_value(String const& domain, String const& group | ||||||
|     m_dirty_domains.set(domain); |     m_dirty_domains.set(domain); | ||||||
|     start_or_restart_sync_timer(); |     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); |         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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return; |         return; | ||||||
|  | @ -248,12 +248,12 @@ void ClientConnection::write_bool_value(String const& domain, String const& grou | ||||||
|     m_dirty_domains.set(domain); |     m_dirty_domains.set(domain); | ||||||
|     start_or_restart_sync_timer(); |     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); |         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)) |     if (!validate_access(domain, group, key)) | ||||||
|         return; |         return; | ||||||
|  | @ -266,7 +266,7 @@ void ClientConnection::remove_key(String const& domain, String const& group, Str | ||||||
|     m_dirty_domains.set(domain); |     m_dirty_domains.set(domain); | ||||||
|     start_or_restart_sync_timer(); |     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); |         connection.async_notify_removed_key(domain, group, key); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -6,24 +6,24 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| #include <ConfigServer/ConfigClientEndpoint.h> | #include <ConfigServer/ConfigClientEndpoint.h> | ||||||
| #include <ConfigServer/ConfigServerEndpoint.h> | #include <ConfigServer/ConfigServerEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace ConfigServer { | namespace ConfigServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public IPC::ClientConnection<ConfigClientEndpoint, ConfigServerEndpoint> { | class ConnectionFromClient final : public IPC::ConnectionFromClient<ConfigClientEndpoint, ConfigServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection) |     C_OBJECT(ConnectionFromClient) | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|     bool is_monitoring_domain(String const& domain) const { return m_monitored_domains.contains(domain); } |     bool is_monitoring_domain(String const& domain) const { return m_monitored_domains.contains(domain); } | ||||||
| 
 | 
 | ||||||
| private: | 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 pledge_domains(Vector<String> const&) override; | ||||||
|     virtual void monitor_domain(String const&) override; |     virtual void monitor_domain(String const&) override; | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include <LibCore/StandardPaths.h> | #include <LibCore/StandardPaths.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibIPC/MultiServer.h> | #include <LibIPC/MultiServer.h> | ||||||
|  | @ -18,6 +18,6 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
| 
 | 
 | ||||||
|     Core::EventLoop event_loop; |     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(); |     return event_loop.exec(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(FileSystemAccessServer.ipc FileSystemAccessServerEndpoint.h) | ||||||
| compile_ipc(FileSystemAccessClient.ipc FileSystemAccessClientEndpoint.h) | compile_ipc(FileSystemAccessClient.ipc FileSystemAccessClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     FileSystemAccessServerEndpoint.h |     FileSystemAccessServerEndpoint.h | ||||||
|     FileSystemAccessClientEndpoint.h |     FileSystemAccessClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
| #include <LibGUI/WindowServerConnection.h> | #include <LibGUI/WindowServerConnection.h> | ||||||
| // clang-format on
 | // clang-format on
 | ||||||
| #include <AK/Debug.h> | #include <AK/Debug.h> | ||||||
| #include <FileSystemAccessServer/ClientConnection.h> | #include <FileSystemAccessServer/ConnectionFromClient.h> | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
| #include <LibCore/IODevice.h> | #include <LibCore/IODevice.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
|  | @ -18,25 +18,25 @@ | ||||||
| 
 | 
 | ||||||
| namespace FileSystemAccessServer { | namespace FileSystemAccessServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, NonnullRefPtr<ClientConnection>> s_connections; | static HashMap<int, NonnullRefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|     : IPC::ClientConnection<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>(*this, move(socket), 1) |     : IPC::ConnectionFromClient<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>(*this, move(socket), 1) | ||||||
| { | { | ||||||
|     s_connections.set(1, *this); |     s_connections.set(1, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
|     GUI::Application::the()->quit(); |     GUI::Application::the()->quit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| RefPtr<GUI::Window> ClientConnection::create_dummy_child_window(i32 window_server_client_id, i32 parent_window_id) | RefPtr<GUI::Window> ConnectionFromClient::create_dummy_child_window(i32 window_server_client_id, i32 parent_window_id) | ||||||
| { | { | ||||||
|     auto window = GUI::Window::construct(); |     auto window = GUI::Window::construct(); | ||||||
|     window->set_opacity(0); |     window->set_opacity(0); | ||||||
|  | @ -49,7 +49,7 @@ RefPtr<GUI::Window> ClientConnection::create_dummy_child_window(i32 window_serve | ||||||
|     return window; |     return window; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::request_file_handler(i32 window_server_client_id, i32 parent_window_id, String const& path, Core::OpenMode const& requested_access, ShouldPrompt prompt) | void ConnectionFromClient::request_file_handler(i32 window_server_client_id, i32 parent_window_id, String const& path, Core::OpenMode const& requested_access, ShouldPrompt prompt) | ||||||
| { | { | ||||||
|     VERIFY(path.starts_with("/"sv)); |     VERIFY(path.starts_with("/"sv)); | ||||||
| 
 | 
 | ||||||
|  | @ -110,17 +110,17 @@ void ClientConnection::request_file_handler(i32 window_server_client_id, i32 par | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::request_file_read_only_approved(i32 window_server_client_id, i32 parent_window_id, String const& path) | void ConnectionFromClient::request_file_read_only_approved(i32 window_server_client_id, i32 parent_window_id, String const& path) | ||||||
| { | { | ||||||
|     request_file_handler(window_server_client_id, parent_window_id, path, Core::OpenMode::ReadOnly, ShouldPrompt::No); |     request_file_handler(window_server_client_id, parent_window_id, path, Core::OpenMode::ReadOnly, ShouldPrompt::No); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::request_file(i32 window_server_client_id, i32 parent_window_id, String const& path, Core::OpenMode const& requested_access) | void ConnectionFromClient::request_file(i32 window_server_client_id, i32 parent_window_id, String const& path, Core::OpenMode const& requested_access) | ||||||
| { | { | ||||||
|     request_file_handler(window_server_client_id, parent_window_id, path, requested_access, ShouldPrompt::Yes); |     request_file_handler(window_server_client_id, parent_window_id, path, requested_access, ShouldPrompt::Yes); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::prompt_open_file(i32 window_server_client_id, i32 parent_window_id, String const& window_title, String const& path_to_view, Core::OpenMode const& requested_access) | void ConnectionFromClient::prompt_open_file(i32 window_server_client_id, i32 parent_window_id, String const& window_title, String const& path_to_view, Core::OpenMode const& requested_access) | ||||||
| { | { | ||||||
|     auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly); |     auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly); | ||||||
|     VERIFY(relevant_permissions != Core::OpenMode::NotOpen); |     VERIFY(relevant_permissions != Core::OpenMode::NotOpen); | ||||||
|  | @ -132,7 +132,7 @@ void ClientConnection::prompt_open_file(i32 window_server_client_id, i32 parent_ | ||||||
|     prompt_helper(user_picked_file, requested_access); |     prompt_helper(user_picked_file, requested_access); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::prompt_save_file(i32 window_server_client_id, i32 parent_window_id, String const& name, String const& ext, String const& path_to_view, Core::OpenMode const& requested_access) | void ConnectionFromClient::prompt_save_file(i32 window_server_client_id, i32 parent_window_id, String const& name, String const& ext, String const& path_to_view, Core::OpenMode const& requested_access) | ||||||
| { | { | ||||||
|     auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly); |     auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly); | ||||||
|     VERIFY(relevant_permissions != Core::OpenMode::NotOpen); |     VERIFY(relevant_permissions != Core::OpenMode::NotOpen); | ||||||
|  | @ -144,7 +144,7 @@ void ClientConnection::prompt_save_file(i32 window_server_client_id, i32 parent_ | ||||||
|     prompt_helper(user_picked_file, requested_access); |     prompt_helper(user_picked_file, requested_access); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::prompt_helper(Optional<String> const& user_picked_file, Core::OpenMode const& requested_access) | void ConnectionFromClient::prompt_helper(Optional<String> const& user_picked_file, Core::OpenMode const& requested_access) | ||||||
| { | { | ||||||
|     if (user_picked_file.has_value()) { |     if (user_picked_file.has_value()) { | ||||||
|         VERIFY(user_picked_file->starts_with("/"sv)); |         VERIFY(user_picked_file->starts_with("/"sv)); | ||||||
|  | @ -169,7 +169,7 @@ void ClientConnection::prompt_helper(Optional<String> const& user_picked_file, C | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::FileSystemAccessServer::ExposeWindowServerClientIdResponse ClientConnection::expose_window_server_client_id() | Messages::FileSystemAccessServer::ExposeWindowServerClientIdResponse ConnectionFromClient::expose_window_server_client_id() | ||||||
| { | { | ||||||
|     return GUI::WindowServerConnection::the().expose_client_id(); |     return GUI::WindowServerConnection::the().expose_client_id(); | ||||||
| } | } | ||||||
|  | @ -11,21 +11,21 @@ | ||||||
| #include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h> | #include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h> | ||||||
| #include <LibCore/Forward.h> | #include <LibCore/Forward.h> | ||||||
| #include <LibGUI/Forward.h> | #include <LibGUI/Forward.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace FileSystemAccessServer { | namespace FileSystemAccessServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint> { |     : public IPC::ConnectionFromClient<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); | ||||||
| 
 | 
 | ||||||
|     virtual void request_file_read_only_approved(i32, i32, String const&) override; |     virtual void request_file_read_only_approved(i32, i32, String const&) override; | ||||||
|     virtual void request_file(i32, i32, String const&, Core::OpenMode const&) override; |     virtual void request_file(i32, i32, String const&, Core::OpenMode const&) override; | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <FileSystemAccessServer/ClientConnection.h> | #include <FileSystemAccessServer/ConnectionFromClient.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibIPC/SingleServer.h> | #include <LibIPC/SingleServer.h> | ||||||
|  | @ -17,6 +17,6 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     auto app = GUI::Application::construct(0, nullptr); |     auto app = GUI::Application::construct(0, nullptr); | ||||||
|     app->set_quit_when_last_window_deleted(false); |     app->set_quit_when_last_window_deleted(false); | ||||||
| 
 | 
 | ||||||
|     auto client = TRY(IPC::take_over_accepted_client_from_system_server<FileSystemAccessServer::ClientConnection>()); |     auto client = TRY(IPC::take_over_accepted_client_from_system_server<FileSystemAccessServer::ConnectionFromClient>()); | ||||||
|     return app->exec(); |     return app->exec(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ compile_ipc(ImageDecoderServer.ipc ImageDecoderServerEndpoint.h) | ||||||
| compile_ipc(ImageDecoderClient.ipc ImageDecoderClientEndpoint.h) | compile_ipc(ImageDecoderClient.ipc ImageDecoderClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     ImageDecoderServerEndpoint.h |     ImageDecoderServerEndpoint.h | ||||||
|     ImageDecoderClientEndpoint.h |     ImageDecoderClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -5,28 +5,28 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/Debug.h> | #include <AK/Debug.h> | ||||||
| #include <ImageDecoder/ClientConnection.h> | #include <ImageDecoder/ConnectionFromClient.h> | ||||||
| #include <ImageDecoder/ImageDecoderClientEndpoint.h> | #include <ImageDecoder/ImageDecoderClientEndpoint.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/ImageDecoder.h> | #include <LibGfx/ImageDecoder.h> | ||||||
| 
 | 
 | ||||||
| namespace ImageDecoder { | namespace ImageDecoder { | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|     : IPC::ClientConnection<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>(*this, move(socket), 1) |     : IPC::ConnectionFromClient<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>(*this, move(socket), 1) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     Core::EventLoop::current().quit(0); |     Core::EventLoop::current().quit(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::decode_image(Core::AnonymousBuffer const& encoded_buffer) | Messages::ImageDecoderServer::DecodeImageResponse ConnectionFromClient::decode_image(Core::AnonymousBuffer const& encoded_buffer) | ||||||
| { | { | ||||||
|     if (!encoded_buffer.is_valid()) { |     if (!encoded_buffer.is_valid()) { | ||||||
|         dbgln_if(IMAGE_DECODER_DEBUG, "Encoded data is invalid"); |         dbgln_if(IMAGE_DECODER_DEBUG, "Encoded data is invalid"); | ||||||
|  | @ -10,22 +10,22 @@ | ||||||
| #include <ImageDecoder/Forward.h> | #include <ImageDecoder/Forward.h> | ||||||
| #include <ImageDecoder/ImageDecoderClientEndpoint.h> | #include <ImageDecoder/ImageDecoderClientEndpoint.h> | ||||||
| #include <ImageDecoder/ImageDecoderServerEndpoint.h> | #include <ImageDecoder/ImageDecoderServerEndpoint.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace ImageDecoder { | namespace ImageDecoder { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint> { |     : public IPC::ConnectionFromClient<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&) override; |     virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&) override; | ||||||
| }; | }; | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace WebContent { | namespace WebContent { | ||||||
| 
 | 
 | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| class PageHost; | class PageHost; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <ImageDecoder/ClientConnection.h> | #include <ImageDecoder/ConnectionFromClient.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibIPC/SingleServer.h> | #include <LibIPC/SingleServer.h> | ||||||
|  | @ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     TRY(Core::System::pledge("stdio recvfd sendfd unix")); |     TRY(Core::System::pledge("stdio recvfd sendfd unix")); | ||||||
|     TRY(Core::System::unveil(nullptr, nullptr)); |     TRY(Core::System::unveil(nullptr, nullptr)); | ||||||
| 
 | 
 | ||||||
|     auto client = TRY(IPC::take_over_accepted_client_from_system_server<ImageDecoder::ClientConnection>()); |     auto client = TRY(IPC::take_over_accepted_client_from_system_server<ImageDecoder::ConnectionFromClient>()); | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio recvfd sendfd")); |     TRY(Core::System::pledge("stdio recvfd sendfd")); | ||||||
|     return event_loop.exec(); |     return event_loop.exec(); | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(InspectorServer.ipc InspectorServerEndpoint.h) | ||||||
| compile_ipc(InspectorClient.ipc InspectorClientEndpoint.h) | compile_ipc(InspectorClient.ipc InspectorClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     InspectableProcess.cpp |     InspectableProcess.cpp | ||||||
|     InspectorServerEndpoint.h |     InspectorServerEndpoint.h | ||||||
|  |  | ||||||
|  | @ -6,28 +6,28 @@ | ||||||
| 
 | 
 | ||||||
| #include "InspectableProcess.h" | #include "InspectableProcess.h" | ||||||
| #include <AK/JsonObject.h> | #include <AK/JsonObject.h> | ||||||
| #include <InspectorServer/ClientConnection.h> | #include <InspectorServer/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace InspectorServer { | namespace InspectorServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ||||||
|     : IPC::ClientConnection<InspectorClientEndpoint, InspectorServerEndpoint>(*this, move(socket), client_id) |     : IPC::ConnectionFromClient<InspectorClientEndpoint, InspectorServerEndpoint>(*this, move(socket), client_id) | ||||||
| { | { | ||||||
|     s_connections.set(client_id, *this); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::InspectorServer::GetAllObjectsResponse ClientConnection::get_all_objects(pid_t pid) | Messages::InspectorServer::GetAllObjectsResponse ConnectionFromClient::get_all_objects(pid_t pid) | ||||||
| { | { | ||||||
|     auto process = InspectableProcess::from_pid(pid); |     auto process = InspectableProcess::from_pid(pid); | ||||||
|     if (!process) |     if (!process) | ||||||
|  | @ -40,7 +40,7 @@ Messages::InspectorServer::GetAllObjectsResponse ClientConnection::get_all_objec | ||||||
|     return response; |     return response; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::InspectorServer::SetInspectedObjectResponse ClientConnection::set_inspected_object(pid_t pid, u64 object_id) | Messages::InspectorServer::SetInspectedObjectResponse ConnectionFromClient::set_inspected_object(pid_t pid, u64 object_id) | ||||||
| { | { | ||||||
|     auto process = InspectableProcess::from_pid(pid); |     auto process = InspectableProcess::from_pid(pid); | ||||||
|     if (!process) |     if (!process) | ||||||
|  | @ -53,7 +53,7 @@ Messages::InspectorServer::SetInspectedObjectResponse ClientConnection::set_insp | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::InspectorServer::SetObjectPropertyResponse ClientConnection::set_object_property(pid_t pid, u64 object_id, String const& name, String const& value) | Messages::InspectorServer::SetObjectPropertyResponse ConnectionFromClient::set_object_property(pid_t pid, u64 object_id, String const& name, String const& value) | ||||||
| { | { | ||||||
|     auto process = InspectableProcess::from_pid(pid); |     auto process = InspectableProcess::from_pid(pid); | ||||||
|     if (!process) |     if (!process) | ||||||
|  | @ -68,7 +68,7 @@ Messages::InspectorServer::SetObjectPropertyResponse ClientConnection::set_objec | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::InspectorServer::IdentifyResponse ClientConnection::identify(pid_t pid) | Messages::InspectorServer::IdentifyResponse ConnectionFromClient::identify(pid_t pid) | ||||||
| { | { | ||||||
|     auto process = InspectableProcess::from_pid(pid); |     auto process = InspectableProcess::from_pid(pid); | ||||||
|     if (!process) |     if (!process) | ||||||
|  | @ -81,7 +81,7 @@ Messages::InspectorServer::IdentifyResponse ClientConnection::identify(pid_t pid | ||||||
|     return response; |     return response; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::InspectorServer::IsInspectableResponse ClientConnection::is_inspectable(pid_t pid) | Messages::InspectorServer::IsInspectableResponse ConnectionFromClient::is_inspectable(pid_t pid) | ||||||
| { | { | ||||||
|     auto process = InspectableProcess::from_pid(pid); |     auto process = InspectableProcess::from_pid(pid); | ||||||
|     if (!process) |     if (!process) | ||||||
|  | @ -9,21 +9,21 @@ | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <InspectorServer/InspectorClientEndpoint.h> | #include <InspectorServer/InspectorClientEndpoint.h> | ||||||
| #include <InspectorServer/InspectorServerEndpoint.h> | #include <InspectorServer/InspectorServerEndpoint.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace InspectorServer { | namespace InspectorServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<InspectorClientEndpoint, InspectorServerEndpoint> { |     : public IPC::ConnectionFromClient<InspectorClientEndpoint, InspectorServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::InspectorServer::GetAllObjectsResponse get_all_objects(pid_t) override; |     virtual Messages::InspectorServer::GetAllObjectsResponse get_all_objects(pid_t) override; | ||||||
|     virtual Messages::InspectorServer::SetInspectedObjectResponse set_inspected_object(pid_t, u64 object_id) override; |     virtual Messages::InspectorServer::SetInspectedObjectResponse set_inspected_object(pid_t, u64 object_id) override; | ||||||
|  | @ -8,6 +8,6 @@ | ||||||
| 
 | 
 | ||||||
| namespace SymbolServer { | namespace SymbolServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -5,11 +5,11 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "InspectableProcess.h" | #include "InspectableProcess.h" | ||||||
| #include <InspectorServer/ClientConnection.h> | #include <InspectorServer/ConnectionFromClient.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
| #include <LibCore/LocalServer.h> | #include <LibCore/LocalServer.h> | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <LibIPC/MultiServer.h> | #include <LibIPC/MultiServer.h> | ||||||
| #include <LibMain/Main.h> | #include <LibMain/Main.h> | ||||||
| 
 | 
 | ||||||
|  | @ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::pledge("stdio unix accept")); |     TRY(Core::System::pledge("stdio unix accept")); | ||||||
| 
 | 
 | ||||||
|     auto server = TRY(IPC::MultiServer<InspectorServer::ClientConnection>::try_create("/tmp/portal/inspector")); |     auto server = TRY(IPC::MultiServer<InspectorServer::ConnectionFromClient>::try_create("/tmp/portal/inspector")); | ||||||
| 
 | 
 | ||||||
|     auto inspectables_server = TRY(Core::LocalServer::try_create()); |     auto inspectables_server = TRY(Core::LocalServer::try_create()); | ||||||
|     TRY(inspectables_server->take_over_from_system_server("/tmp/portal/inspectables")); |     TRY(inspectables_server->take_over_from_system_server("/tmp/portal/inspectables")); | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(LaunchServer.ipc LaunchServerEndpoint.h) | ||||||
| compile_ipc(LaunchClient.ipc LaunchClientEndpoint.h) | compile_ipc(LaunchClient.ipc LaunchClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     Launcher.cpp |     Launcher.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     LaunchClientEndpoint.h |     LaunchClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "Launcher.h" | #include "Launcher.h" | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
|  | @ -12,23 +12,23 @@ | ||||||
| 
 | 
 | ||||||
| namespace LaunchServer { | namespace LaunchServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ||||||
|     : IPC::ClientConnection<LaunchClientEndpoint, LaunchServerEndpoint>(*this, move(client_socket), client_id) |     : IPC::ConnectionFromClient<LaunchClientEndpoint, LaunchServerEndpoint>(*this, move(client_socket), client_id) | ||||||
| { | { | ||||||
|     s_connections.set(client_id, *this); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::LaunchServer::OpenUrlResponse ClientConnection::open_url(URL const& url, String const& handler_name) | Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const& url, String const& handler_name) | ||||||
| { | { | ||||||
|     if (!m_allowlist.is_empty()) { |     if (!m_allowlist.is_empty()) { | ||||||
|         bool allowed = false; |         bool allowed = false; | ||||||
|  | @ -51,17 +51,17 @@ Messages::LaunchServer::OpenUrlResponse ClientConnection::open_url(URL const& ur | ||||||
|     return Launcher::the().open_url(url, handler_name); |     return Launcher::the().open_url(url, handler_name); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::LaunchServer::GetHandlersForUrlResponse ClientConnection::get_handlers_for_url(URL const& url) | Messages::LaunchServer::GetHandlersForUrlResponse ConnectionFromClient::get_handlers_for_url(URL const& url) | ||||||
| { | { | ||||||
|     return Launcher::the().handlers_for_url(url); |     return Launcher::the().handlers_for_url(url); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse ClientConnection::get_handlers_with_details_for_url(URL const& url) | Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse ConnectionFromClient::get_handlers_with_details_for_url(URL const& url) | ||||||
| { | { | ||||||
|     return Launcher::the().handlers_with_details_for_url(url); |     return Launcher::the().handlers_with_details_for_url(url); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::add_allowed_url(URL const& url) | void ConnectionFromClient::add_allowed_url(URL const& url) | ||||||
| { | { | ||||||
|     if (m_allowlist_is_sealed) { |     if (m_allowlist_is_sealed) { | ||||||
|         did_misbehave("Got request to add more allowed handlers after list was sealed"); |         did_misbehave("Got request to add more allowed handlers after list was sealed"); | ||||||
|  | @ -76,7 +76,7 @@ void ClientConnection::add_allowed_url(URL const& url) | ||||||
|     m_allowlist.empend(String(), false, Vector<URL> { url }); |     m_allowlist.empend(String(), false, Vector<URL> { url }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::add_allowed_handler_with_any_url(String const& handler_name) | void ConnectionFromClient::add_allowed_handler_with_any_url(String const& handler_name) | ||||||
| { | { | ||||||
|     if (m_allowlist_is_sealed) { |     if (m_allowlist_is_sealed) { | ||||||
|         did_misbehave("Got request to add more allowed handlers after list was sealed"); |         did_misbehave("Got request to add more allowed handlers after list was sealed"); | ||||||
|  | @ -91,7 +91,7 @@ void ClientConnection::add_allowed_handler_with_any_url(String const& handler_na | ||||||
|     m_allowlist.empend(handler_name, true, Vector<URL>()); |     m_allowlist.empend(handler_name, true, Vector<URL>()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::add_allowed_handler_with_only_specific_urls(String const& handler_name, Vector<URL> const& urls) | void ConnectionFromClient::add_allowed_handler_with_only_specific_urls(String const& handler_name, Vector<URL> const& urls) | ||||||
| { | { | ||||||
|     if (m_allowlist_is_sealed) { |     if (m_allowlist_is_sealed) { | ||||||
|         did_misbehave("Got request to add more allowed handlers after list was sealed"); |         did_misbehave("Got request to add more allowed handlers after list was sealed"); | ||||||
|  | @ -111,7 +111,7 @@ void ClientConnection::add_allowed_handler_with_only_specific_urls(String const& | ||||||
|     m_allowlist.empend(handler_name, false, urls); |     m_allowlist.empend(handler_name, false, urls); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::seal_allowlist() | void ConnectionFromClient::seal_allowlist() | ||||||
| { | { | ||||||
|     if (m_allowlist_is_sealed) { |     if (m_allowlist_is_sealed) { | ||||||
|         did_misbehave("Got more than one request to seal the allowed handlers list"); |         did_misbehave("Got more than one request to seal the allowed handlers list"); | ||||||
|  | @ -8,19 +8,19 @@ | ||||||
| 
 | 
 | ||||||
| #include <LaunchServer/LaunchClientEndpoint.h> | #include <LaunchServer/LaunchClientEndpoint.h> | ||||||
| #include <LaunchServer/LaunchServerEndpoint.h> | #include <LaunchServer/LaunchServerEndpoint.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| 
 | 
 | ||||||
| namespace LaunchServer { | namespace LaunchServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public IPC::ClientConnection<LaunchClientEndpoint, LaunchServerEndpoint> { | class ConnectionFromClient final : public IPC::ConnectionFromClient<LaunchClientEndpoint, LaunchServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection) |     C_OBJECT(ConnectionFromClient) | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, String const&) override; |     virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, String const&) override; | ||||||
|     virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL const&) override; |     virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL const&) override; | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "Launcher.h" | #include "Launcher.h" | ||||||
| #include <LibCore/ConfigFile.h> | #include <LibCore/ConfigFile.h> | ||||||
| #include <LibCore/EventLoop.h> | #include <LibCore/EventLoop.h> | ||||||
|  | @ -15,7 +15,7 @@ | ||||||
| ErrorOr<int> serenity_main(Main::Arguments) | ErrorOr<int> serenity_main(Main::Arguments) | ||||||
| { | { | ||||||
|     Core::EventLoop event_loop; |     Core::EventLoop event_loop; | ||||||
|     auto server = TRY(IPC::MultiServer<LaunchServer::ClientConnection>::try_create()); |     auto server = TRY(IPC::MultiServer<LaunchServer::ConnectionFromClient>::try_create()); | ||||||
| 
 | 
 | ||||||
|     auto launcher = LaunchServer::Launcher(); |     auto launcher = LaunchServer::Launcher(); | ||||||
|     launcher.load_handlers(); |     launcher.load_handlers(); | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ set(SOURCES | ||||||
|     LookupServer.cpp |     LookupServer.cpp | ||||||
|     LookupServerEndpoint.h |     LookupServerEndpoint.h | ||||||
|     LookupClientEndpoint.h |     LookupClientEndpoint.h | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     MulticastDNS.cpp |     MulticastDNS.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -4,31 +4,31 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "DNSPacket.h" | #include "DNSPacket.h" | ||||||
| #include "LookupServer.h" | #include "LookupServer.h" | ||||||
| #include <AK/IPv4Address.h> | #include <AK/IPv4Address.h> | ||||||
| 
 | 
 | ||||||
| namespace LookupServer { | namespace LookupServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ||||||
|     : IPC::ClientConnection<LookupClientEndpoint, LookupServerEndpoint>(*this, move(socket), client_id) |     : IPC::ConnectionFromClient<LookupClientEndpoint, LookupServerEndpoint>(*this, move(socket), client_id) | ||||||
| { | { | ||||||
|     s_connections.set(client_id, *this); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::LookupServer::LookupNameResponse ClientConnection::lookup_name(String const& name) | Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(String const& name) | ||||||
| { | { | ||||||
|     auto maybe_answers = LookupServer::the().lookup(name, DNSRecordType::A); |     auto maybe_answers = LookupServer::the().lookup(name, DNSRecordType::A); | ||||||
|     if (maybe_answers.is_error()) { |     if (maybe_answers.is_error()) { | ||||||
|  | @ -43,7 +43,7 @@ Messages::LookupServer::LookupNameResponse ClientConnection::lookup_name(String | ||||||
|     return { 0, move(addresses) }; |     return { 0, move(addresses) }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::LookupServer::LookupAddressResponse ClientConnection::lookup_address(String const& address) | Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_address(String const& address) | ||||||
| { | { | ||||||
|     if (address.length() != 4) |     if (address.length() != 4) | ||||||
|         return { 1, String() }; |         return { 1, String() }; | ||||||
|  | @ -7,23 +7,23 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <LookupServer/LookupClientEndpoint.h> | #include <LookupServer/LookupClientEndpoint.h> | ||||||
| #include <LookupServer/LookupServerEndpoint.h> | #include <LookupServer/LookupServerEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace LookupServer { | namespace LookupServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<LookupClientEndpoint, LookupServerEndpoint> { |     : public IPC::ConnectionFromClient<LookupClientEndpoint, LookupServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     virtual ~ClientConnection() override; |     virtual ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::LookupServer::LookupNameResponse lookup_name(String const&) override; |     virtual Messages::LookupServer::LookupNameResponse lookup_name(String const&) override; | ||||||
|     virtual Messages::LookupServer::LookupAddressResponse lookup_address(String const&) override; |     virtual Messages::LookupServer::LookupAddressResponse lookup_address(String const&) override; | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "LookupServer.h" | #include "LookupServer.h" | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "DNSPacket.h" | #include "DNSPacket.h" | ||||||
| #include <AK/Debug.h> | #include <AK/Debug.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
|  | @ -72,7 +72,7 @@ LookupServer::LookupServer() | ||||||
|     } |     } | ||||||
|     m_mdns = MulticastDNS::construct(this); |     m_mdns = MulticastDNS::construct(this); | ||||||
| 
 | 
 | ||||||
|     m_server = MUST(IPC::MultiServer<ClientConnection>::try_create()); |     m_server = MUST(IPC::MultiServer<ConnectionFromClient>::try_create()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LookupServer::load_etc_hosts() | void LookupServer::load_etc_hosts() | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "DNSName.h" | #include "DNSName.h" | ||||||
| #include "DNSPacket.h" | #include "DNSPacket.h" | ||||||
| #include "DNSServer.h" | #include "DNSServer.h" | ||||||
|  | @ -34,7 +34,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& hostname, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes); |     ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& hostname, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes); | ||||||
| 
 | 
 | ||||||
|     OwnPtr<IPC::MultiServer<ClientConnection>> m_server; |     OwnPtr<IPC::MultiServer<ConnectionFromClient>> m_server; | ||||||
|     RefPtr<DNSServer> m_dns_server; |     RefPtr<DNSServer> m_dns_server; | ||||||
|     RefPtr<MulticastDNS> m_mdns; |     RefPtr<MulticastDNS> m_mdns; | ||||||
|     Vector<String> m_nameservers; |     Vector<String> m_nameservers; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(NotificationServer.ipc NotificationServerEndpoint.h) | ||||||
| compile_ipc(NotificationClient.ipc NotificationClientEndpoint.h) | compile_ipc(NotificationClient.ipc NotificationClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     NotificationWindow.cpp |     NotificationWindow.cpp | ||||||
|     NotificationServerEndpoint.h |     NotificationServerEndpoint.h | ||||||
|  |  | ||||||
|  | @ -4,37 +4,37 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include "NotificationWindow.h" | #include "NotificationWindow.h" | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <NotificationServer/NotificationClientEndpoint.h> | #include <NotificationServer/NotificationClientEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace NotificationServer { | namespace NotificationServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> client_socket, int client_id) | ||||||
|     : IPC::ClientConnection<NotificationClientEndpoint, NotificationServerEndpoint>(*this, move(client_socket), client_id) |     : IPC::ConnectionFromClient<NotificationClientEndpoint, NotificationServerEndpoint>(*this, move(client_socket), client_id) | ||||||
| { | { | ||||||
|     s_connections.set(client_id, *this); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::show_notification(String const& text, String const& title, Gfx::ShareableBitmap const& icon) | void ConnectionFromClient::show_notification(String const& text, String const& title, Gfx::ShareableBitmap const& icon) | ||||||
| { | { | ||||||
|     auto window = NotificationWindow::construct(client_id(), text, title, icon); |     auto window = NotificationWindow::construct(client_id(), text, title, icon); | ||||||
|     window->show(); |     window->show(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::close_notification() | void ConnectionFromClient::close_notification() | ||||||
| { | { | ||||||
|     auto window = NotificationWindow::get_window_by_id(client_id()); |     auto window = NotificationWindow::get_window_by_id(client_id()); | ||||||
|     if (window) { |     if (window) { | ||||||
|  | @ -42,7 +42,7 @@ void ClientConnection::close_notification() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::NotificationServer::UpdateNotificationIconResponse ClientConnection::update_notification_icon(Gfx::ShareableBitmap const& icon) | Messages::NotificationServer::UpdateNotificationIconResponse ConnectionFromClient::update_notification_icon(Gfx::ShareableBitmap const& icon) | ||||||
| { | { | ||||||
|     auto window = NotificationWindow::get_window_by_id(client_id()); |     auto window = NotificationWindow::get_window_by_id(client_id()); | ||||||
|     if (window) { |     if (window) { | ||||||
|  | @ -51,7 +51,7 @@ Messages::NotificationServer::UpdateNotificationIconResponse ClientConnection::u | ||||||
|     return !!window; |     return !!window; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::NotificationServer::UpdateNotificationTextResponse ClientConnection::update_notification_text(String const& text, String const& title) | Messages::NotificationServer::UpdateNotificationTextResponse ConnectionFromClient::update_notification_text(String const& text, String const& title) | ||||||
| { | { | ||||||
|     auto window = NotificationWindow::get_window_by_id(client_id()); |     auto window = NotificationWindow::get_window_by_id(client_id()); | ||||||
|     if (window) { |     if (window) { | ||||||
|  | @ -61,7 +61,7 @@ Messages::NotificationServer::UpdateNotificationTextResponse ClientConnection::u | ||||||
|     return !!window; |     return !!window; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::NotificationServer::IsShowingResponse ClientConnection::is_showing() | Messages::NotificationServer::IsShowingResponse ConnectionFromClient::is_showing() | ||||||
| { | { | ||||||
|     auto window = NotificationWindow::get_window_by_id(client_id()); |     auto window = NotificationWindow::get_window_by_id(client_id()); | ||||||
|     return !!window; |     return !!window; | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <WindowServer/ScreenLayout.h> | #include <WindowServer/ScreenLayout.h> | ||||||
| 
 | 
 | ||||||
| // Must be included after WindowServer/ScreenLayout.h
 | // Must be included after WindowServer/ScreenLayout.h
 | ||||||
|  | @ -15,15 +15,15 @@ | ||||||
| 
 | 
 | ||||||
| namespace NotificationServer { | namespace NotificationServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final : public IPC::ClientConnection<NotificationClientEndpoint, NotificationServerEndpoint> { | class ConnectionFromClient final : public IPC::ConnectionFromClient<NotificationClientEndpoint, NotificationServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection) |     C_OBJECT(ConnectionFromClient) | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual void show_notification(String const&, String const&, Gfx::ShareableBitmap const&) override; |     virtual void show_notification(String const&, String const&, Gfx::ShareableBitmap const&) override; | ||||||
|     virtual void close_notification() override; |     virtual void close_notification() override; | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ClientConnection.h" | #include "ConnectionFromClient.h" | ||||||
| #include <LibCore/System.h> | #include <LibCore/System.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibIPC/MultiServer.h> | #include <LibIPC/MultiServer.h> | ||||||
|  | @ -15,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||||
|     TRY(Core::System::pledge("stdio recvfd sendfd accept rpath unix")); |     TRY(Core::System::pledge("stdio recvfd sendfd accept rpath unix")); | ||||||
| 
 | 
 | ||||||
|     auto app = TRY(GUI::Application::try_create(arguments)); |     auto app = TRY(GUI::Application::try_create(arguments)); | ||||||
|     auto server = TRY(IPC::MultiServer<NotificationServer::ClientConnection>::try_create()); |     auto server = TRY(IPC::MultiServer<NotificationServer::ConnectionFromClient>::try_create()); | ||||||
| 
 | 
 | ||||||
|     TRY(Core::System::unveil("/res", "r")); |     TRY(Core::System::unveil("/res", "r")); | ||||||
|     TRY(Core::System::unveil(nullptr, nullptr)); |     TRY(Core::System::unveil(nullptr, nullptr)); | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ compile_ipc(RequestServer.ipc RequestServerEndpoint.h) | ||||||
| compile_ipc(RequestClient.ipc RequestClientEndpoint.h) | compile_ipc(RequestClient.ipc RequestClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     ConnectionCache.cpp |     ConnectionCache.cpp | ||||||
|     Request.cpp |     Request.cpp | ||||||
|     RequestClientEndpoint.h |     RequestClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/Badge.h> | #include <AK/Badge.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/Protocol.h> | #include <RequestServer/Protocol.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
| #include <RequestServer/RequestClientEndpoint.h> | #include <RequestServer/RequestClientEndpoint.h> | ||||||
|  | @ -13,32 +13,32 @@ | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket) | ||||||
|     : IPC::ClientConnection<RequestClientEndpoint, RequestServerEndpoint>(*this, move(socket), 1) |     : IPC::ConnectionFromClient<RequestClientEndpoint, RequestServerEndpoint>(*this, move(socket), 1) | ||||||
| { | { | ||||||
|     s_connections.set(1, *this); |     s_connections.set(1, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
|     if (s_connections.is_empty()) |     if (s_connections.is_empty()) | ||||||
|         Core::EventLoop::current().quit(0); |         Core::EventLoop::current().quit(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::RequestServer::IsSupportedProtocolResponse ClientConnection::is_supported_protocol(String const& protocol) | Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_supported_protocol(String const& protocol) | ||||||
| { | { | ||||||
|     bool supported = Protocol::find_by_name(protocol.to_lowercase()); |     bool supported = Protocol::find_by_name(protocol.to_lowercase()); | ||||||
|     return supported; |     return supported; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::RequestServer::StartRequestResponse ClientConnection::start_request(String const& method, URL const& url, IPC::Dictionary const& request_headers, ByteBuffer const& request_body) | Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_request(String const& method, URL const& url, IPC::Dictionary const& request_headers, ByteBuffer const& request_body) | ||||||
| { | { | ||||||
|     if (!url.is_valid()) { |     if (!url.is_valid()) { | ||||||
|         dbgln("StartRequest: Invalid URL requested: '{}'", url); |         dbgln("StartRequest: Invalid URL requested: '{}'", url); | ||||||
|  | @ -60,7 +60,7 @@ Messages::RequestServer::StartRequestResponse ClientConnection::start_request(St | ||||||
|     return { id, IPC::File(fd, IPC::File::CloseAfterSending) }; |     return { id, IPC::File(fd, IPC::File::CloseAfterSending) }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::RequestServer::StopRequestResponse ClientConnection::stop_request(i32 request_id) | Messages::RequestServer::StopRequestResponse ConnectionFromClient::stop_request(i32 request_id) | ||||||
| { | { | ||||||
|     auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr)); |     auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr)); | ||||||
|     bool success = false; |     bool success = false; | ||||||
|  | @ -72,7 +72,7 @@ Messages::RequestServer::StopRequestResponse ClientConnection::stop_request(i32 | ||||||
|     return success; |     return success; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::did_receive_headers(Badge<Request>, Request& request) | void ConnectionFromClient::did_receive_headers(Badge<Request>, Request& request) | ||||||
| { | { | ||||||
|     IPC::Dictionary response_headers; |     IPC::Dictionary response_headers; | ||||||
|     for (auto& it : request.response_headers()) |     for (auto& it : request.response_headers()) | ||||||
|  | @ -81,7 +81,7 @@ void ClientConnection::did_receive_headers(Badge<Request>, Request& request) | ||||||
|     async_headers_became_available(request.id(), move(response_headers), request.status_code()); |     async_headers_became_available(request.id(), move(response_headers), request.status_code()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::did_finish_request(Badge<Request>, Request& request, bool success) | void ConnectionFromClient::did_finish_request(Badge<Request>, Request& request, bool success) | ||||||
| { | { | ||||||
|     VERIFY(request.total_size().has_value()); |     VERIFY(request.total_size().has_value()); | ||||||
| 
 | 
 | ||||||
|  | @ -90,17 +90,17 @@ void ClientConnection::did_finish_request(Badge<Request>, Request& request, bool | ||||||
|     m_requests.remove(request.id()); |     m_requests.remove(request.id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::did_progress_request(Badge<Request>, Request& request) | void ConnectionFromClient::did_progress_request(Badge<Request>, Request& request) | ||||||
| { | { | ||||||
|     async_request_progress(request.id(), request.total_size(), request.downloaded_size()); |     async_request_progress(request.id(), request.total_size(), request.downloaded_size()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::did_request_certificates(Badge<Request>, Request& request) | void ConnectionFromClient::did_request_certificates(Badge<Request>, Request& request) | ||||||
| { | { | ||||||
|     async_certificate_requested(request.id()); |     async_certificate_requested(request.id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::RequestServer::SetCertificateResponse ClientConnection::set_certificate(i32 request_id, String const& certificate, String const& key) | Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certificate(i32 request_id, String const& certificate, String const& key) | ||||||
| { | { | ||||||
|     auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr)); |     auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr)); | ||||||
|     bool success = false; |     bool success = false; | ||||||
|  | @ -111,7 +111,7 @@ Messages::RequestServer::SetCertificateResponse ClientConnection::set_certificat | ||||||
|     return success; |     return success; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) | void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) | ||||||
| { | { | ||||||
|     if (!url.is_valid()) { |     if (!url.is_valid()) { | ||||||
|         dbgln("EnsureConnection: Invalid URL requested: '{}'", url); |         dbgln("EnsureConnection: Invalid URL requested: '{}'", url); | ||||||
|  | @ -7,19 +7,19 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <RequestServer/Forward.h> | #include <RequestServer/Forward.h> | ||||||
| #include <RequestServer/RequestClientEndpoint.h> | #include <RequestServer/RequestClientEndpoint.h> | ||||||
| #include <RequestServer/RequestServerEndpoint.h> | #include <RequestServer/RequestServerEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<RequestClientEndpoint, RequestServerEndpoint> { |     : public IPC::ConnectionFromClient<RequestClientEndpoint, RequestServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     ~ClientConnection() override; |     ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|  | @ -29,7 +29,7 @@ public: | ||||||
|     void did_request_certificates(Badge<Request>, Request&); |     void did_request_certificates(Badge<Request>, Request&); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(String const&) override; |     virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(String const&) override; | ||||||
|     virtual Messages::RequestServer::StartRequestResponse start_request(String const&, URL const&, IPC::Dictionary const&, ByteBuffer const&) override; |     virtual Messages::RequestServer::StartRequestResponse start_request(String const&, URL const&, IPC::Dictionary const&, ByteBuffer const&) override; | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| class Request; | class Request; | ||||||
| class GeminiProtocol; | class GeminiProtocol; | ||||||
| class HttpRequest; | class HttpRequest; | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ GeminiProtocol::~GeminiProtocol() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| OwnPtr<Request> GeminiProtocol::start_request(ClientConnection& client, const String&, const URL& url, const HashMap<String, String>&, ReadonlyBytes) | OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, const String&, const URL& url, const HashMap<String, String>&, ReadonlyBytes) | ||||||
| { | { | ||||||
|     Gemini::GeminiRequest request; |     Gemini::GeminiRequest request; | ||||||
|     request.set_url(url); |     request.set_url(url); | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ public: | ||||||
|     GeminiProtocol(); |     GeminiProtocol(); | ||||||
|     virtual ~GeminiProtocol() override; |     virtual ~GeminiProtocol() override; | ||||||
| 
 | 
 | ||||||
|     virtual OwnPtr<Request> start_request(ClientConnection&, const String& method, const URL&, const HashMap<String, String>&, ReadonlyBytes body) override; |     virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>&, ReadonlyBytes body) override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| GeminiRequest::GeminiRequest(ClientConnection& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
|     : Request(client, move(output_stream)) |     : Request(client, move(output_stream)) | ||||||
|     , m_job(move(job)) |     , m_job(move(job)) | ||||||
| { | { | ||||||
|  | @ -57,7 +57,7 @@ GeminiRequest::~GeminiRequest() | ||||||
|     m_job->cancel(); |     m_job->cancel(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullOwnPtr<GeminiRequest> GeminiRequest::create_with_job(Badge<GeminiProtocol>, ClientConnection& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | NonnullOwnPtr<GeminiRequest> GeminiRequest::create_with_job(Badge<GeminiProtocol>, ConnectionFromClient& client, NonnullRefPtr<Gemini::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
| { | { | ||||||
|     return adopt_own(*new GeminiRequest(client, move(job), move(output_stream))); |     return adopt_own(*new GeminiRequest(client, move(job), move(output_stream))); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,14 +16,14 @@ namespace RequestServer { | ||||||
| class GeminiRequest final : public Request { | class GeminiRequest final : public Request { | ||||||
| public: | public: | ||||||
|     virtual ~GeminiRequest() override; |     virtual ~GeminiRequest() override; | ||||||
|     static NonnullOwnPtr<GeminiRequest> create_with_job(Badge<GeminiProtocol>, ClientConnection&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&); |     static NonnullOwnPtr<GeminiRequest> create_with_job(Badge<GeminiProtocol>, ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     Gemini::Job const& job() const { return *m_job; } |     Gemini::Job const& job() const { return *m_job; } | ||||||
| 
 | 
 | ||||||
|     virtual URL url() const override { return m_job->url(); } |     virtual URL url() const override { return m_job->url(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit GeminiRequest(ClientConnection&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&); |     explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     virtual void set_certificate(String certificate, String key) override; |     virtual void set_certificate(String certificate, String key) override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,8 +14,8 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| #include <LibHTTP/HttpRequest.h> | #include <LibHTTP/HttpRequest.h> | ||||||
| #include <RequestServer/ClientConnection.h> |  | ||||||
| #include <RequestServer/ConnectionCache.h> | #include <RequestServer/ConnectionCache.h> | ||||||
|  | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
| 
 | 
 | ||||||
| namespace RequestServer::Detail { | namespace RequestServer::Detail { | ||||||
|  | @ -61,7 +61,7 @@ void init(TSelf* self, TJob job) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename TBadgedProtocol, typename TPipeResult> | template<typename TBadgedProtocol, typename TPipeResult> | ||||||
| OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ClientConnection& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body, TPipeResult&& pipe_result) | OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body, TPipeResult&& pipe_result) | ||||||
| { | { | ||||||
|     using TJob = typename TBadgedProtocol::Type::JobType; |     using TJob = typename TBadgedProtocol::Type::JobType; | ||||||
|     using TRequest = typename TBadgedProtocol::Type::RequestType; |     using TRequest = typename TBadgedProtocol::Type::RequestType; | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/HttpCommon.h> | #include <RequestServer/HttpCommon.h> | ||||||
| #include <RequestServer/HttpProtocol.h> | #include <RequestServer/HttpProtocol.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
|  | @ -22,7 +22,7 @@ HttpProtocol::HttpProtocol() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| OwnPtr<Request> HttpProtocol::start_request(ClientConnection& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) | OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) | ||||||
| { | { | ||||||
|     return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); |     return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| #include <LibHTTP/Job.h> | #include <LibHTTP/Job.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/HttpRequest.h> | #include <RequestServer/HttpRequest.h> | ||||||
| #include <RequestServer/Protocol.h> | #include <RequestServer/Protocol.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
|  | @ -27,7 +27,7 @@ public: | ||||||
|     HttpProtocol(); |     HttpProtocol(); | ||||||
|     ~HttpProtocol() override = default; |     ~HttpProtocol() override = default; | ||||||
| 
 | 
 | ||||||
|     virtual OwnPtr<Request> start_request(ClientConnection&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; |     virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| HttpRequest::HttpRequest(ClientConnection& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | HttpRequest::HttpRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
|     : Request(client, move(output_stream)) |     : Request(client, move(output_stream)) | ||||||
|     , m_job(job) |     , m_job(job) | ||||||
| { | { | ||||||
|  | @ -25,7 +25,7 @@ HttpRequest::~HttpRequest() | ||||||
|     m_job->cancel(); |     m_job->cancel(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullOwnPtr<HttpRequest> HttpRequest::create_with_job(Badge<HttpProtocol>&&, ClientConnection& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | NonnullOwnPtr<HttpRequest> HttpRequest::create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::Job> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
| { | { | ||||||
|     return adopt_own(*new HttpRequest(client, move(job), move(output_stream))); |     return adopt_own(*new HttpRequest(client, move(job), move(output_stream))); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ namespace RequestServer { | ||||||
| class HttpRequest final : public Request { | class HttpRequest final : public Request { | ||||||
| public: | public: | ||||||
|     virtual ~HttpRequest() override; |     virtual ~HttpRequest() override; | ||||||
|     static NonnullOwnPtr<HttpRequest> create_with_job(Badge<HttpProtocol>&&, ClientConnection&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&); |     static NonnullOwnPtr<HttpRequest> create_with_job(Badge<HttpProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     HTTP::Job& job() { return m_job; } |     HTTP::Job& job() { return m_job; } | ||||||
|     HTTP::Job const& job() const { return m_job; } |     HTTP::Job const& job() const { return m_job; } | ||||||
|  | @ -25,7 +25,7 @@ public: | ||||||
|     virtual URL url() const override { return m_job->url(); } |     virtual URL url() const override { return m_job->url(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit HttpRequest(ClientConnection&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&); |     explicit HttpRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::Job>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<HTTP::Job> m_job; |     NonnullRefPtr<HTTP::Job> m_job; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/HttpCommon.h> | #include <RequestServer/HttpCommon.h> | ||||||
| #include <RequestServer/HttpsProtocol.h> | #include <RequestServer/HttpsProtocol.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
|  | @ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| OwnPtr<Request> HttpsProtocol::start_request(ClientConnection& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) | OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) | ||||||
| { | { | ||||||
|     return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); |     return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| #include <LibHTTP/HttpsJob.h> | #include <LibHTTP/HttpsJob.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/HttpsRequest.h> | #include <RequestServer/HttpsRequest.h> | ||||||
| #include <RequestServer/Protocol.h> | #include <RequestServer/Protocol.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
|  | @ -27,7 +27,7 @@ public: | ||||||
|     HttpsProtocol(); |     HttpsProtocol(); | ||||||
|     ~HttpsProtocol() override = default; |     ~HttpsProtocol() override = default; | ||||||
| 
 | 
 | ||||||
|     virtual OwnPtr<Request> start_request(ClientConnection&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; |     virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
| 
 | 
 | ||||||
| HttpsRequest::HttpsRequest(ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | HttpsRequest::HttpsRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
|     : Request(client, move(output_stream)) |     : Request(client, move(output_stream)) | ||||||
|     , m_job(job) |     , m_job(job) | ||||||
| { | { | ||||||
|  | @ -30,7 +30,7 @@ HttpsRequest::~HttpsRequest() | ||||||
|     m_job->cancel(); |     m_job->cancel(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullOwnPtr<HttpsRequest> HttpsRequest::create_with_job(Badge<HttpsProtocol>&&, ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | NonnullOwnPtr<HttpsRequest> HttpsRequest::create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
| { | { | ||||||
|     return adopt_own(*new HttpsRequest(client, move(job), move(output_stream))); |     return adopt_own(*new HttpsRequest(client, move(job), move(output_stream))); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ namespace RequestServer { | ||||||
| class HttpsRequest final : public Request { | class HttpsRequest final : public Request { | ||||||
| public: | public: | ||||||
|     virtual ~HttpsRequest() override; |     virtual ~HttpsRequest() override; | ||||||
|     static NonnullOwnPtr<HttpsRequest> create_with_job(Badge<HttpsProtocol>&&, ClientConnection&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&); |     static NonnullOwnPtr<HttpsRequest> create_with_job(Badge<HttpsProtocol>&&, ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     HTTP::HttpsJob& job() { return m_job; } |     HTTP::HttpsJob& job() { return m_job; } | ||||||
|     HTTP::HttpsJob const& job() const { return m_job; } |     HTTP::HttpsJob const& job() const { return m_job; } | ||||||
|  | @ -24,7 +24,7 @@ public: | ||||||
|     virtual URL url() const override { return m_job->url(); } |     virtual URL url() const override { return m_job->url(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit HttpsRequest(ClientConnection&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&); |     explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
|     virtual void set_certificate(String certificate, String key) override; |     virtual void set_certificate(String certificate, String key) override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ public: | ||||||
|     virtual ~Protocol(); |     virtual ~Protocol(); | ||||||
| 
 | 
 | ||||||
|     const String& name() const { return m_name; } |     const String& name() const { return m_name; } | ||||||
|     virtual OwnPtr<Request> start_request(ClientConnection&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) = 0; |     virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) = 0; | ||||||
| 
 | 
 | ||||||
|     static Protocol* find_by_name(const String&); |     static Protocol* find_by_name(const String&); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  * SPDX-License-Identifier: BSD-2-Clause | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/Request.h> | #include <RequestServer/Request.h> | ||||||
| 
 | 
 | ||||||
| namespace RequestServer { | namespace RequestServer { | ||||||
|  | @ -12,7 +12,7 @@ namespace RequestServer { | ||||||
| // FIXME: What about rollover?
 | // FIXME: What about rollover?
 | ||||||
| static i32 s_next_id = 1; | static i32 s_next_id = 1; | ||||||
| 
 | 
 | ||||||
| Request::Request(ClientConnection& client, NonnullOwnPtr<Core::Stream::File>&& output_stream) | Request::Request(ConnectionFromClient& client, NonnullOwnPtr<Core::Stream::File>&& output_stream) | ||||||
|     : m_client(client) |     : m_client(client) | ||||||
|     , m_id(s_next_id++) |     , m_id(s_next_id++) | ||||||
|     , m_output_stream(move(output_stream)) |     , m_output_stream(move(output_stream)) | ||||||
|  |  | ||||||
|  | @ -44,10 +44,10 @@ public: | ||||||
|     const Core::Stream::File& output_stream() const { return *m_output_stream; } |     const Core::Stream::File& output_stream() const { return *m_output_stream; } | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|     explicit Request(ClientConnection&, NonnullOwnPtr<Core::Stream::File>&&); |     explicit Request(ConnectionFromClient&, NonnullOwnPtr<Core::Stream::File>&&); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     ClientConnection& m_client; |     ConnectionFromClient& m_client; | ||||||
|     i32 m_id { 0 }; |     i32 m_id { 0 }; | ||||||
|     int m_request_fd { -1 }; // Passed to client.
 |     int m_request_fd { -1 }; // Passed to client.
 | ||||||
|     Optional<u32> m_status_code; |     Optional<u32> m_status_code; | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| #include <LibIPC/SingleServer.h> | #include <LibIPC/SingleServer.h> | ||||||
| #include <LibMain/Main.h> | #include <LibMain/Main.h> | ||||||
| #include <LibTLS/Certificate.h> | #include <LibTLS/Certificate.h> | ||||||
| #include <RequestServer/ClientConnection.h> | #include <RequestServer/ConnectionFromClient.h> | ||||||
| #include <RequestServer/GeminiProtocol.h> | #include <RequestServer/GeminiProtocol.h> | ||||||
| #include <RequestServer/HttpProtocol.h> | #include <RequestServer/HttpProtocol.h> | ||||||
| #include <RequestServer/HttpsProtocol.h> | #include <RequestServer/HttpsProtocol.h> | ||||||
|  | @ -46,7 +46,7 @@ ErrorOr<int> serenity_main(Main::Arguments) | ||||||
|     [[maybe_unused]] auto http = make<RequestServer::HttpProtocol>(); |     [[maybe_unused]] auto http = make<RequestServer::HttpProtocol>(); | ||||||
|     [[maybe_unused]] auto https = make<RequestServer::HttpsProtocol>(); |     [[maybe_unused]] auto https = make<RequestServer::HttpsProtocol>(); | ||||||
| 
 | 
 | ||||||
|     auto client = TRY(IPC::take_over_accepted_client_from_system_server<RequestServer::ClientConnection>()); |     auto client = TRY(IPC::take_over_accepted_client_from_system_server<RequestServer::ConnectionFromClient>()); | ||||||
| 
 | 
 | ||||||
|     auto result = event_loop.exec(); |     auto result = event_loop.exec(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ compile_ipc(SQLServer.ipc SQLServerEndpoint.h) | ||||||
| compile_ipc(SQLClient.ipc SQLClientEndpoint.h) | compile_ipc(SQLClient.ipc SQLClientEndpoint.h) | ||||||
| 
 | 
 | ||||||
| set(SOURCES | set(SOURCES | ||||||
|     ClientConnection.cpp |     ConnectionFromClient.cpp | ||||||
|     DatabaseConnection.cpp |     DatabaseConnection.cpp | ||||||
|     main.cpp |     main.cpp | ||||||
|     SQLClientEndpoint.h |     SQLClientEndpoint.h | ||||||
|  |  | ||||||
|  | @ -7,15 +7,15 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibSQL/Result.h> | #include <LibSQL/Result.h> | ||||||
| #include <SQLServer/ClientConnection.h> | #include <SQLServer/ConnectionFromClient.h> | ||||||
| #include <SQLServer/DatabaseConnection.h> | #include <SQLServer/DatabaseConnection.h> | ||||||
| #include <SQLServer/SQLStatement.h> | #include <SQLServer/SQLStatement.h> | ||||||
| 
 | 
 | ||||||
| namespace SQLServer { | namespace SQLServer { | ||||||
| 
 | 
 | ||||||
| static HashMap<int, RefPtr<ClientConnection>> s_connections; | static HashMap<int, RefPtr<ConnectionFromClient>> s_connections; | ||||||
| 
 | 
 | ||||||
| RefPtr<ClientConnection> ClientConnection::client_connection_for(int client_id) | RefPtr<ConnectionFromClient> ConnectionFromClient::client_connection_for(int client_id) | ||||||
| { | { | ||||||
|     if (s_connections.contains(client_id)) |     if (s_connections.contains(client_id)) | ||||||
|         return *s_connections.get(client_id).value(); |         return *s_connections.get(client_id).value(); | ||||||
|  | @ -23,31 +23,31 @@ RefPtr<ClientConnection> ClientConnection::client_connection_for(int client_id) | ||||||
|     return nullptr; |     return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket, int client_id) | ||||||
|     : IPC::ClientConnection<SQLClientEndpoint, SQLServerEndpoint>(*this, move(socket), client_id) |     : IPC::ConnectionFromClient<SQLClientEndpoint, SQLServerEndpoint>(*this, move(socket), client_id) | ||||||
| { | { | ||||||
|     s_connections.set(client_id, *this); |     s_connections.set(client_id, *this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ClientConnection::~ClientConnection() | ConnectionFromClient::~ConnectionFromClient() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::die() | void ConnectionFromClient::die() | ||||||
| { | { | ||||||
|     s_connections.remove(client_id()); |     s_connections.remove(client_id()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::SQLServer::ConnectResponse ClientConnection::connect(String const& database_name) | Messages::SQLServer::ConnectResponse ConnectionFromClient::connect(String const& database_name) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "ClientConnection::connect(database_name: {})", database_name); |     dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::connect(database_name: {})", database_name); | ||||||
|     auto database_connection = DatabaseConnection::construct(database_name, client_id()); |     auto database_connection = DatabaseConnection::construct(database_name, client_id()); | ||||||
|     return { database_connection->connection_id() }; |     return { database_connection->connection_id() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::disconnect(int connection_id) | void ConnectionFromClient::disconnect(int connection_id) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "ClientConnection::disconnect(connection_id: {})", connection_id); |     dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::disconnect(connection_id: {})", connection_id); | ||||||
|     auto database_connection = DatabaseConnection::connection_for(connection_id); |     auto database_connection = DatabaseConnection::connection_for(connection_id); | ||||||
|     if (database_connection) |     if (database_connection) | ||||||
|         database_connection->disconnect(); |         database_connection->disconnect(); | ||||||
|  | @ -55,13 +55,13 @@ void ClientConnection::disconnect(int connection_id) | ||||||
|         dbgln("Database connection has disappeared"); |         dbgln("Database connection has disappeared"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Messages::SQLServer::SqlStatementResponse ClientConnection::sql_statement(int connection_id, String const& sql) | Messages::SQLServer::SqlStatementResponse ConnectionFromClient::sql_statement(int connection_id, String const& sql) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "ClientConnection::sql_statement(connection_id: {}, sql: '{}')", connection_id, sql); |     dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::sql_statement(connection_id: {}, sql: '{}')", connection_id, sql); | ||||||
|     auto database_connection = DatabaseConnection::connection_for(connection_id); |     auto database_connection = DatabaseConnection::connection_for(connection_id); | ||||||
|     if (database_connection) { |     if (database_connection) { | ||||||
|         auto statement_id = database_connection->sql_statement(sql); |         auto statement_id = database_connection->sql_statement(sql); | ||||||
|         dbgln_if(SQLSERVER_DEBUG, "ClientConnection::sql_statement -> statement_id = {}", statement_id); |         dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::sql_statement -> statement_id = {}", statement_id); | ||||||
|         return { statement_id }; |         return { statement_id }; | ||||||
|     } else { |     } else { | ||||||
|         dbgln("Database connection has disappeared"); |         dbgln("Database connection has disappeared"); | ||||||
|  | @ -69,9 +69,9 @@ Messages::SQLServer::SqlStatementResponse ClientConnection::sql_statement(int co | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClientConnection::statement_execute(int statement_id) | void ConnectionFromClient::statement_execute(int statement_id) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "ClientConnection::statement_execute_query(statement_id: {})", statement_id); |     dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::statement_execute_query(statement_id: {})", statement_id); | ||||||
|     auto statement = SQLStatement::statement_for(statement_id); |     auto statement = SQLStatement::statement_for(statement_id); | ||||||
|     if (statement && statement->connection()->client_id() == client_id()) { |     if (statement && statement->connection()->client_id() == client_id()) { | ||||||
|         statement->execute(); |         statement->execute(); | ||||||
|  | @ -7,25 +7,25 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <LibIPC/ClientConnection.h> | #include <LibIPC/ConnectionFromClient.h> | ||||||
| #include <SQLServer/SQLClientEndpoint.h> | #include <SQLServer/SQLClientEndpoint.h> | ||||||
| #include <SQLServer/SQLServerEndpoint.h> | #include <SQLServer/SQLServerEndpoint.h> | ||||||
| 
 | 
 | ||||||
| namespace SQLServer { | namespace SQLServer { | ||||||
| 
 | 
 | ||||||
| class ClientConnection final | class ConnectionFromClient final | ||||||
|     : public IPC::ClientConnection<SQLClientEndpoint, SQLServerEndpoint> { |     : public IPC::ConnectionFromClient<SQLClientEndpoint, SQLServerEndpoint> { | ||||||
|     C_OBJECT(ClientConnection); |     C_OBJECT(ConnectionFromClient); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     virtual ~ClientConnection() override; |     virtual ~ConnectionFromClient() override; | ||||||
| 
 | 
 | ||||||
|     virtual void die() override; |     virtual void die() override; | ||||||
| 
 | 
 | ||||||
|     static RefPtr<ClientConnection> client_connection_for(int client_id); |     static RefPtr<ConnectionFromClient> client_connection_for(int client_id); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); |     explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); | ||||||
| 
 | 
 | ||||||
|     virtual Messages::SQLServer::ConnectResponse connect(String const&) override; |     virtual Messages::SQLServer::ConnectResponse connect(String const&) override; | ||||||
|     virtual Messages::SQLServer::SqlStatementResponse sql_statement(int, String const&) override; |     virtual Messages::SQLServer::SqlStatementResponse sql_statement(int, String const&) override; | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/LexicalPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <SQLServer/ClientConnection.h> | #include <SQLServer/ConnectionFromClient.h> | ||||||
| #include <SQLServer/DatabaseConnection.h> | #include <SQLServer/DatabaseConnection.h> | ||||||
| #include <SQLServer/SQLStatement.h> | #include <SQLServer/SQLStatement.h> | ||||||
| 
 | 
 | ||||||
|  | @ -30,7 +30,7 @@ DatabaseConnection::DatabaseConnection(String database_name, int client_id) | ||||||
|     , m_client_id(client_id) |     , m_client_id(client_id) | ||||||
| { | { | ||||||
|     if (LexicalPath path(m_database_name); (path.title() != m_database_name) || (path.dirname() != ".")) { |     if (LexicalPath path(m_database_name); (path.title() != m_database_name) || (path.dirname() != ".")) { | ||||||
|         auto client_connection = ClientConnection::client_connection_for(m_client_id); |         auto client_connection = ConnectionFromClient::client_connection_for(m_client_id); | ||||||
|         client_connection->async_connection_error(m_connection_id, (int)SQL::SQLErrorCode::InvalidDatabaseName, m_database_name); |         client_connection->async_connection_error(m_connection_id, (int)SQL::SQLErrorCode::InvalidDatabaseName, m_database_name); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -39,7 +39,7 @@ DatabaseConnection::DatabaseConnection(String database_name, int client_id) | ||||||
|     s_connections.set(m_connection_id, *this); |     s_connections.set(m_connection_id, *this); | ||||||
|     deferred_invoke([this]() { |     deferred_invoke([this]() { | ||||||
|         m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name)); |         m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name)); | ||||||
|         auto client_connection = ClientConnection::client_connection_for(m_client_id); |         auto client_connection = ConnectionFromClient::client_connection_for(m_client_id); | ||||||
|         if (auto maybe_error = m_database->open(); maybe_error.is_error()) { |         if (auto maybe_error = m_database->open(); maybe_error.is_error()) { | ||||||
|             client_connection->async_connection_error(m_connection_id, (int)SQL::SQLErrorCode::InternalError, maybe_error.error().string_literal()); |             client_connection->async_connection_error(m_connection_id, (int)SQL::SQLErrorCode::InternalError, maybe_error.error().string_literal()); | ||||||
|             return; |             return; | ||||||
|  | @ -59,7 +59,7 @@ void DatabaseConnection::disconnect() | ||||||
|     deferred_invoke([this]() { |     deferred_invoke([this]() { | ||||||
|         m_database = nullptr; |         m_database = nullptr; | ||||||
|         s_connections.remove(m_connection_id); |         s_connections.remove(m_connection_id); | ||||||
|         auto client_connection = ClientConnection::client_connection_for(client_id()); |         auto client_connection = ConnectionFromClient::client_connection_for(client_id()); | ||||||
|         if (client_connection) |         if (client_connection) | ||||||
|             client_connection->async_disconnected(m_connection_id); |             client_connection->async_disconnected(m_connection_id); | ||||||
|         else |         else | ||||||
|  | @ -70,7 +70,7 @@ void DatabaseConnection::disconnect() | ||||||
| int DatabaseConnection::sql_statement(String const& sql) | int DatabaseConnection::sql_statement(String const& sql) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::sql_statement(connection_id {}, database '{}', sql '{}'", connection_id(), m_database_name, sql); |     dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::sql_statement(connection_id {}, database '{}', sql '{}'", connection_id(), m_database_name, sql); | ||||||
|     auto client_connection = ClientConnection::client_connection_for(client_id()); |     auto client_connection = ConnectionFromClient::client_connection_for(client_id()); | ||||||
|     if (!client_connection) { |     if (!client_connection) { | ||||||
|         warnln("Cannot notify client of database disconnection. Client disconnected"); |         warnln("Cannot notify client of database disconnection. Client disconnected"); | ||||||
|         return -1; |         return -1; | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| namespace SQLServer { | namespace SQLServer { | ||||||
| class ClientConnection; | class ConnectionFromClient; | ||||||
| class DatabaseConnection; | class DatabaseConnection; | ||||||
| class SQLStatement; | class SQLStatement; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibCore/Object.h> | #include <LibCore/Object.h> | ||||||
| #include <LibSQL/AST/Parser.h> | #include <LibSQL/AST/Parser.h> | ||||||
| #include <SQLServer/ClientConnection.h> | #include <SQLServer/ConnectionFromClient.h> | ||||||
| #include <SQLServer/DatabaseConnection.h> | #include <SQLServer/DatabaseConnection.h> | ||||||
| #include <SQLServer/SQLStatement.h> | #include <SQLServer/SQLStatement.h> | ||||||
| 
 | 
 | ||||||
|  | @ -37,7 +37,7 @@ void SQLStatement::report_error(SQL::Result result) | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "SQLStatement::report_error(statement_id {}, error {}", statement_id(), result.error_string()); |     dbgln_if(SQLSERVER_DEBUG, "SQLStatement::report_error(statement_id {}, error {}", statement_id(), result.error_string()); | ||||||
| 
 | 
 | ||||||
|     auto client_connection = ClientConnection::client_connection_for(connection()->client_id()); |     auto client_connection = ConnectionFromClient::client_connection_for(connection()->client_id()); | ||||||
| 
 | 
 | ||||||
|     s_statements.remove(statement_id()); |     s_statements.remove(statement_id()); | ||||||
|     remove_from_parent(); |     remove_from_parent(); | ||||||
|  | @ -54,7 +54,7 @@ void SQLStatement::report_error(SQL::Result result) | ||||||
| void SQLStatement::execute() | void SQLStatement::execute() | ||||||
| { | { | ||||||
|     dbgln_if(SQLSERVER_DEBUG, "SQLStatement::execute(statement_id {}", statement_id()); |     dbgln_if(SQLSERVER_DEBUG, "SQLStatement::execute(statement_id {}", statement_id()); | ||||||
|     auto client_connection = ClientConnection::client_connection_for(connection()->client_id()); |     auto client_connection = ConnectionFromClient::client_connection_for(connection()->client_id()); | ||||||
|     if (!client_connection) { |     if (!client_connection) { | ||||||
|         warnln("Cannot yield next result. Client disconnected"); |         warnln("Cannot yield next result. Client disconnected"); | ||||||
|         return; |         return; | ||||||
|  | @ -75,7 +75,7 @@ void SQLStatement::execute() | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         auto client_connection = ClientConnection::client_connection_for(connection()->client_id()); |         auto client_connection = ConnectionFromClient::client_connection_for(connection()->client_id()); | ||||||
|         if (!client_connection) { |         if (!client_connection) { | ||||||
|             warnln("Cannot return statement execution results. Client disconnected"); |             warnln("Cannot return statement execution results. Client disconnected"); | ||||||
|             return; |             return; | ||||||
|  | @ -122,7 +122,7 @@ bool SQLStatement::should_send_result_rows() const | ||||||
| void SQLStatement::next() | void SQLStatement::next() | ||||||
| { | { | ||||||
|     VERIFY(!m_result->is_empty()); |     VERIFY(!m_result->is_empty()); | ||||||
|     auto client_connection = ClientConnection::client_connection_for(connection()->client_id()); |     auto client_connection = ConnectionFromClient::client_connection_for(connection()->client_id()); | ||||||
|     if (!client_connection) { |     if (!client_connection) { | ||||||
|         warnln("Cannot yield next result. Client disconnected"); |         warnln("Cannot yield next result. Client disconnected"); | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Itamar
						Itamar