main.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2022, Maciej <sppmacd@pm.me>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "NetworkSettingsWidget.h"
  7. #include <LibCore/ArgsParser.h>
  8. #include <LibCore/System.h>
  9. #include <LibGUI/Application.h>
  10. #include <LibGUI/Icon.h>
  11. #include <LibGUI/SettingsWindow.h>
  12. #include <LibMain/Main.h>
  13. ErrorOr<int> serenity_main(Main::Arguments args)
  14. {
  15. TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd unix proc exec"));
  16. TRY(Core::System::unveil("/bin/Escalator", "x"));
  17. TRY(Core::System::unveil("/etc/Network.ini", "r"));
  18. TRY(Core::System::unveil("/sys/kernel/net/adapters", "r"));
  19. TRY(Core::System::unveil("/res", "r"));
  20. TRY(Core::System::unveil("/tmp/session/%sid/portal/clipboard", "rw"));
  21. TRY(Core::System::unveil("/tmp/portal/window", "rw"));
  22. TRY(Core::System::unveil(nullptr, nullptr));
  23. StringView adapter;
  24. Core::ArgsParser parser;
  25. parser.add_positional_argument(adapter, "Adapter to display settings for", "adapter", Core::ArgsParser::Required::No);
  26. parser.parse(args);
  27. auto app = TRY(GUI::Application::create(args));
  28. TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd proc exec"));
  29. auto app_icon = GUI::Icon::default_icon("network"sv);
  30. auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No));
  31. auto network_settings_widget = TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"_string, "network"sv));
  32. if (!adapter.is_null()) {
  33. network_settings_widget->switch_adapter(adapter);
  34. }
  35. window->set_icon(app_icon.bitmap_for_size(16));
  36. window->show();
  37. return app->exec();
  38. }