mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
SpiceAgent: Implement ClipboardRequest
messages
This commit is contained in:
parent
8202f13169
commit
9c4538a9a8
3 changed files with 50 additions and 0 deletions
|
@ -85,4 +85,30 @@ ErrorOr<String> ClipboardGrabMessage::debug_description()
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<ClipboardRequestMessage> ClipboardRequestMessage::read_from_stream(AK::Stream& stream)
|
||||||
|
{
|
||||||
|
auto value = TRY(stream.read_value<u32>());
|
||||||
|
if (value >= to_underlying(ClipboardDataType::__End)) {
|
||||||
|
return Error::from_string_literal("Unsupported clipboard type");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto type = static_cast<ClipboardDataType>(value);
|
||||||
|
return ClipboardRequestMessage(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> ClipboardRequestMessage::write_to_stream(AK::Stream& stream)
|
||||||
|
{
|
||||||
|
TRY(stream.write_value(data_type()));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<String> ClipboardRequestMessage::debug_description()
|
||||||
|
{
|
||||||
|
StringBuilder builder;
|
||||||
|
TRY(builder.try_append("ClipboardRequest { "sv));
|
||||||
|
TRY(builder.try_appendff("data_type = {}", data_type()));
|
||||||
|
TRY(builder.try_append(" }"sv));
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,26 @@ private:
|
||||||
Vector<ClipboardDataType> m_types;
|
Vector<ClipboardDataType> m_types;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Request clipboard data with the specified type.
|
||||||
|
class ClipboardRequestMessage : public Message {
|
||||||
|
public:
|
||||||
|
ClipboardRequestMessage(ClipboardDataType data_type)
|
||||||
|
: Message(Type::ClipboardRequest)
|
||||||
|
, m_data_type(data_type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static ErrorOr<ClipboardRequestMessage> read_from_stream(AK::Stream& stream);
|
||||||
|
|
||||||
|
ErrorOr<void> write_to_stream(AK::Stream& stream);
|
||||||
|
ErrorOr<String> debug_description() override;
|
||||||
|
|
||||||
|
ClipboardDataType data_type() { return m_data_type; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ClipboardDataType m_data_type;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
|
@ -74,6 +74,10 @@ ErrorOr<void> SpiceAgent::on_message_received()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dbgln_if(SPICE_AGENT_DEBUG, "The spice server has notified us of new clipboard data of type: {}", data_type);
|
dbgln_if(SPICE_AGENT_DEBUG, "The spice server has notified us of new clipboard data of type: {}", data_type);
|
||||||
|
dbgln_if(SPICE_AGENT_DEBUG, "Sending a request for data of type: {}", data_type);
|
||||||
|
|
||||||
|
auto request_message = ClipboardRequestMessage(data_type);
|
||||||
|
TRY(this->send_message(request_message));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue