mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
LibDesktop: Make allowlist APIs return ErrorOr<void>
This makes it very smooth to use TRY() when setting up these lists, as you can see in the rest of this commit. :^)
This commit is contained in:
parent
4a64bb80ea
commit
b6f49924be
8 changed files with 34 additions and 76 deletions
|
@ -54,11 +54,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// Connect to LaunchServer immediately and let it know that we won't ask for anything other than opening
|
||||
// the user's downloads directory.
|
||||
// FIXME: This should go away with a standalone download manager at some point.
|
||||
if (!Desktop::Launcher::add_allowed_url(URL::create_with_file_protocol(Core::StandardPaths::downloads_directory()))
|
||||
|| !Desktop::Launcher::seal_allowlist()) {
|
||||
warnln("Failed to set up allowed launch URLs");
|
||||
return 1;
|
||||
}
|
||||
TRY(Desktop::Launcher::add_allowed_url(URL::create_with_file_protocol(Core::StandardPaths::downloads_directory())));
|
||||
TRY(Desktop::Launcher::seal_allowlist());
|
||||
|
||||
TRY(Core::System::unveil("/home", "rwc"));
|
||||
TRY(Core::System::unveil("/res", "r"));
|
||||
|
|
|
@ -24,13 +24,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto app = TRY(GUI::Application::try_create(arguments));
|
||||
|
||||
if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
|
||||
"/bin/Help",
|
||||
{ URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") })
|
||||
|| !Desktop::Launcher::seal_allowlist()) {
|
||||
warnln("Failed to set up allowed launch URLs");
|
||||
return 1;
|
||||
}
|
||||
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") }));
|
||||
TRY(Desktop::Launcher::seal_allowlist());
|
||||
|
||||
TRY(Core::System::pledge("stdio recvfd sendfd thread rpath cpath wpath", nullptr));
|
||||
|
||||
|
|
|
@ -38,21 +38,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto app = TRY(GUI::Application::try_create(arguments));
|
||||
|
||||
if (!Desktop::Launcher::add_allowed_handler_with_any_url("/bin/ImageViewer")) {
|
||||
warnln("Failed to set up allowed launch URLs");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
|
||||
"/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/ImageViewer.md") })) {
|
||||
warnln("Failed to set up allowed launch URLs");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!Desktop::Launcher::seal_allowlist()) {
|
||||
warnln("Failed to seal allowed launch URLs");
|
||||
return 1;
|
||||
}
|
||||
TRY(Desktop::Launcher::add_allowed_handler_with_any_url("/bin/ImageViewer"));
|
||||
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/ImageViewer.md") }));
|
||||
TRY(Desktop::Launcher::seal_allowlist());
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("filetype-image");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue