mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 17:16:04 +00:00
SpiceAgent: Add a new spice agent service :^)
A SPICE agent communicates with the host OS to provide nifty features like clipboard sharing :^) This patch implements only plain-text clipboard sharing. See: github.com/freedesktop/spice-protocol/blob/master/spice/vd_agent.h
This commit is contained in:
parent
42c5df7256
commit
d4bb6a1a1e
Notes:
sideshowbarker
2024-07-18 09:05:12 +09:00
Author: https://github.com/X-yl
Commit: d4bb6a1a1e
Pull-request: https://github.com/SerenityOS/serenity/pull/8690
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/ccapitalK
Reviewed-by: https://github.com/tomuta
8 changed files with 432 additions and 0 deletions
47
Userland/Services/SpiceAgent/main.cpp
Normal file
47
Userland/Services/SpiceAgent/main.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Kyle Pereira <kyle@xylepereira.me>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "SpiceAgent.h"
|
||||
#include <AK/Format.h>
|
||||
#include <LibC/fcntl.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibIPC/ServerConnection.h>
|
||||
|
||||
static constexpr auto SPICE_DEVICE = "/dev/hvc0p1";
|
||||
|
||||
int main()
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
|
||||
if (pledge("unix rpath wpath stdio sendfd recvfd", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 = open(SPICE_DEVICE, O_RDWR);
|
||||
if (serial_port_fd < 0) {
|
||||
dbgln("Couldn't open spice serial port!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto conn = ClipboardServerConnection::construct();
|
||||
auto agent = SpiceAgent(serial_port_fd, conn);
|
||||
|
||||
return loop.exec();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue