2020-06-17 17:31:42 +02:00
|
|
|
/*
|
2021-11-23 10:31:08 +01:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2020-06-17 17:31:42 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-17 17:31:42 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-09-07 20:30:31 +02:00
|
|
|
#include "EventLoopPluginSerenity.h"
|
2020-06-17 17:31:42 +02:00
|
|
|
#include <LibCore/EventLoop.h>
|
|
|
|
|
#include <LibCore/LocalServer.h>
|
2021-11-23 10:59:50 +01:00
|
|
|
#include <LibCore/System.h>
|
2021-12-06 18:11:05 +01:00
|
|
|
#include <LibIPC/SingleServer.h>
|
2021-11-23 10:31:08 +01:00
|
|
|
#include <LibMain/Main.h>
|
2022-04-30 11:21:21 +02:00
|
|
|
#include <LibWeb/ImageDecoding.h>
|
2022-04-30 12:06:30 +02:00
|
|
|
#include <LibWeb/Loader/ResourceLoader.h>
|
2022-09-07 20:30:31 +02:00
|
|
|
#include <LibWeb/Platform/EventLoopPlugin.h>
|
2022-04-30 11:26:21 +02:00
|
|
|
#include <LibWeb/WebSockets/WebSocket.h>
|
2022-04-30 11:21:21 +02:00
|
|
|
#include <LibWebView/ImageDecoderClientAdapter.h>
|
2022-04-30 12:06:30 +02:00
|
|
|
#include <LibWebView/RequestServerAdapter.h>
|
2022-04-30 11:26:21 +02:00
|
|
|
#include <LibWebView/WebSocketClientAdapter.h>
|
2022-02-25 12:18:30 +02:00
|
|
|
#include <WebContent/ConnectionFromClient.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2021-11-23 10:31:08 +01:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments)
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
|
|
|
|
Core::EventLoop event_loop;
|
2021-12-29 13:10:12 -05:00
|
|
|
TRY(Core::System::pledge("stdio recvfd sendfd accept unix rpath"));
|
2021-11-23 10:59:50 +01:00
|
|
|
TRY(Core::System::unveil("/res", "r"));
|
2022-01-20 12:27:56 -05:00
|
|
|
TRY(Core::System::unveil("/etc/timezone", "r"));
|
2022-07-24 15:11:06 +02:00
|
|
|
TRY(Core::System::unveil("/tmp/user/%uid/portal/request", "rw"));
|
2022-07-24 15:29:26 +02:00
|
|
|
TRY(Core::System::unveil("/tmp/user/%uid/portal/image", "rw"));
|
2022-07-24 13:16:18 +02:00
|
|
|
TRY(Core::System::unveil("/tmp/user/%uid/portal/websocket", "rw"));
|
2021-11-23 10:59:50 +01:00
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2022-09-07 20:30:31 +02:00
|
|
|
Web::Platform::EventLoopPlugin::install(*new WebContent::EventLoopPluginSerenity);
|
|
|
|
|
|
2022-04-30 11:21:21 +02:00
|
|
|
Web::ImageDecoding::Decoder::initialize(WebView::ImageDecoderClientAdapter::create());
|
2022-04-30 11:26:21 +02:00
|
|
|
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create()));
|
2022-04-30 12:06:30 +02:00
|
|
|
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
|
2022-04-30 11:21:21 +02:00
|
|
|
|
2022-02-25 12:18:30 +02:00
|
|
|
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebContent::ConnectionFromClient>());
|
2020-06-17 17:31:42 +02:00
|
|
|
return event_loop.exec();
|
|
|
|
|
}
|