mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
SpiceAgent: Implement ClipboardGrab
messages
This commit is contained in:
parent
79c73dd260
commit
8202f13169
3 changed files with 119 additions and 0 deletions
|
@ -52,4 +52,37 @@ ErrorOr<String> AnnounceCapabilitiesMessage::debug_description()
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
ErrorOr<ClipboardGrabMessage> ClipboardGrabMessage::read_from_stream(AK::Stream& stream)
|
||||
{
|
||||
auto types = Vector<ClipboardDataType>();
|
||||
while (!stream.is_eof()) {
|
||||
auto value = TRY(stream.read_value<u32>());
|
||||
if (value >= to_underlying(ClipboardDataType::__End)) {
|
||||
return Error::from_string_literal("Unsupported clipboard type");
|
||||
}
|
||||
|
||||
types.append(static_cast<ClipboardDataType>(value));
|
||||
}
|
||||
|
||||
return ClipboardGrabMessage(types);
|
||||
}
|
||||
|
||||
ErrorOr<void> ClipboardGrabMessage::write_to_stream(AK::Stream& stream)
|
||||
{
|
||||
for (auto type : types()) {
|
||||
TRY(stream.write_value(type));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<String> ClipboardGrabMessage::debug_description()
|
||||
{
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_append("ClipboardGrabMessage { "sv));
|
||||
TRY(builder.try_appendff("types = {}", types()));
|
||||
TRY(builder.try_append(" }"sv));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue