mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +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
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