88#include < Ladybird/FontPlugin.h>
99#include < Ladybird/HelperProcess.h>
1010#include < Ladybird/ImageCodecPlugin.h>
11- #include < Ladybird/Qt/AudioCodecPluginQt.h>
12- #include < Ladybird/Qt/EventLoopImplementationQt.h>
13- #include < Ladybird/Qt/RequestManagerQt.h>
14- #include < Ladybird/Qt/WebSocketClientManagerQt.h>
1511#include < Ladybird/Utilities.h>
1612#include < LibAudio/Loader.h>
1713#include < LibCore/ArgsParser.h>
3329#include < LibWeb/WebSockets/WebSocket.h>
3430#include < LibWebView/RequestServerAdapter.h>
3531#include < LibWebView/WebSocketClientAdapter.h>
36- #include < QCoreApplication>
3732#include < WebContent/ConnectionFromClient.h>
3833#include < WebContent/PageHost.h>
3934#include < WebContent/WebDriverConnection.h>
4035
36+ #if defined(HAVE_QT)
37+ # include < Ladybird/Qt/AudioCodecPluginQt.h>
38+ # include < Ladybird/Qt/EventLoopImplementationQt.h>
39+ # include < Ladybird/Qt/RequestManagerQt.h>
40+ # include < Ladybird/Qt/WebSocketClientManagerQt.h>
41+ # include < QCoreApplication>
42+ #endif
43+
4144static ErrorOr<void > load_content_filters ();
4245static ErrorOr<void > load_autoplay_allowlist ();
46+ static ErrorOr<void > initialize_lagom_networking ();
4347
4448ErrorOr<int > serenity_main (Main::Arguments arguments)
4549{
50+ #if defined(HAVE_QT)
4651 QCoreApplication app (arguments.argc , arguments.argv );
4752
4853 Core::EventLoopManager::install (*new Ladybird::EventLoopManagerQt);
54+ #endif
4955 Core::EventLoop event_loop;
5056
5157 platform_init ();
@@ -56,8 +62,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
5662 Web::Platform::AudioCodecPlugin::install_creation_hook ([](auto loader) {
5763#if defined(HAVE_PULSEAUDIO)
5864 return Web::Platform::AudioCodecPluginAgnostic::create (move (loader));
59- #else
65+ #elif defined(HAVE_QT)
6066 return Ladybird::AudioCodecPluginQt::create (move (loader));
67+ #else
68+ # error "Don't know how to initialize audio in this configuration!"
6169#endif
6270 });
6371
@@ -73,17 +81,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
7381 args_parser.add_option (use_lagom_networking, " Enable Lagom servers for networking" , " use-lagom-networking" , 0 );
7482 args_parser.parse (arguments);
7583
76- if (use_lagom_networking) {
77- auto candidate_request_server_paths = TRY (get_paths_for_helper_process (" RequestServer" sv));
78- auto request_server_client = TRY (launch_request_server_process (candidate_request_server_paths, s_serenity_resource_root));
79- Web::ResourceLoader::initialize (TRY (WebView::RequestServerAdapter::try_create (move (request_server_client))));
80-
81- auto candidate_web_socket_paths = TRY (get_paths_for_helper_process (" WebSocket" sv));
82- auto web_socket_client = TRY (launch_web_socket_process (candidate_web_socket_paths, s_serenity_resource_root));
83- Web::WebSockets::WebSocketClientManager::initialize (TRY (WebView::WebSocketClientManagerAdapter::try_create (move (web_socket_client))));
84- } else {
84+ #if defined(HAVE_QT)
85+ if (!use_lagom_networking) {
8586 Web::ResourceLoader::initialize (Ladybird::RequestManagerQt::create ());
8687 Web::WebSockets::WebSocketClientManager::initialize (Ladybird::WebSocketClientManagerQt::create ());
88+ } else
89+ #endif
90+ {
91+ TRY (initialize_lagom_networking ());
8792 }
8893
8994 Web::HTML::Window::set_internals_object_exposed (is_layout_test_mode);
@@ -168,3 +173,16 @@ static ErrorOr<void> load_autoplay_allowlist()
168173
169174 return {};
170175}
176+
177+ static ErrorOr<void > initialize_lagom_networking ()
178+ {
179+ auto candidate_request_server_paths = TRY (get_paths_for_helper_process (" RequestServer" sv));
180+ auto request_server_client = TRY (launch_request_server_process (candidate_request_server_paths, s_serenity_resource_root));
181+ Web::ResourceLoader::initialize (TRY (WebView::RequestServerAdapter::try_create (move (request_server_client))));
182+
183+ auto candidate_web_socket_paths = TRY (get_paths_for_helper_process (" WebSocket" sv));
184+ auto web_socket_client = TRY (launch_web_socket_process (candidate_web_socket_paths, s_serenity_resource_root));
185+ Web::WebSockets::WebSocketClientManager::initialize (TRY (WebView::WebSocketClientManagerAdapter::try_create (move (web_socket_client))));
186+
187+ return {};
188+ }
0 commit comments