diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-28 13:49:24 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-28 23:14:19 +0100 |
commit | 16746efcf8892027fc21523ec39b0903751c031e (patch) | |
tree | e3817e4f32fc4b5e968f16ff97d685c58d7473b4 /Userland/Services/SpiceAgent | |
parent | 83056efc1af1a9e8bffcb14404d12498e54fc17b (diff) | |
download | serenity-16746efcf8892027fc21523ec39b0903751c031e.zip |
SpiceAgent: Port to LibMain :^)
Diffstat (limited to 'Userland/Services/SpiceAgent')
-rw-r--r-- | Userland/Services/SpiceAgent/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Services/SpiceAgent/main.cpp | 37 |
2 files changed, 11 insertions, 28 deletions
diff --git a/Userland/Services/SpiceAgent/CMakeLists.txt b/Userland/Services/SpiceAgent/CMakeLists.txt index e39f2668ee..d7eac78e65 100644 --- a/Userland/Services/SpiceAgent/CMakeLists.txt +++ b/Userland/Services/SpiceAgent/CMakeLists.txt @@ -10,5 +10,5 @@ set(SOURCES ) serenity_bin(SpiceAgent) -target_link_libraries(SpiceAgent LibGfx LibCore LibIPC) +target_link_libraries(SpiceAgent LibGfx LibCore LibIPC LibMain) add_dependencies(SpiceAgent Clipboard) diff --git a/Userland/Services/SpiceAgent/main.cpp b/Userland/Services/SpiceAgent/main.cpp index f2540f7226..e94fb99669 100644 --- a/Userland/Services/SpiceAgent/main.cpp +++ b/Userland/Services/SpiceAgent/main.cpp @@ -5,42 +5,25 @@ */ #include "SpiceAgent.h" -#include <AK/Format.h> #include <LibC/fcntl.h> -#include <LibC/unistd.h> +#include <LibCore/System.h> #include <LibIPC/ServerConnection.h> +#include <LibMain/Main.h> -static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"; +static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"sv; -int main() +ErrorOr<int> serenity_main(Main::Arguments) { Core::EventLoop loop; - if (pledge("unix rpath wpath stdio sendfd recvfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("unix rpath wpath stdio sendfd recvfd", nullptr)); + TRY(Core::System::unveil(SPICE_DEVICE, "rw")); + TRY(Core::System::unveil("/tmp/portal/clipboard", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); - if (unveil(SPICE_DEVICE, "rw") < 0) { - perror("unveil"); - return 1; - } - if (unveil("/tmp/portal/clipboard", "rw") < 0) { - perror("unveil"); - return 1; - } - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + int serial_port_fd = TRY(Core::System::open(SPICE_DEVICE, O_RDWR)); - int serial_port_fd = open(SPICE_DEVICE, O_RDWR); - if (serial_port_fd < 0) { - dbgln("Couldn't open spice serial port!"); - return 1; - } - - auto conn = ClipboardServerConnection::construct(); + auto conn = TRY(ClipboardServerConnection::try_create()); auto agent = SpiceAgent(serial_port_fd, conn); return loop.exec(); |