mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-22 12:47:04 +00:00
[client] spice: initial agent support
This commit is contained in:
parent
65c1e0391c
commit
daf854c692
@ -95,6 +95,8 @@ struct Spice
|
|||||||
short family;
|
short family;
|
||||||
union SpiceAddr addr;
|
union SpiceAddr addr;
|
||||||
|
|
||||||
|
bool hasAgent;
|
||||||
|
uint32_t agentTokens;
|
||||||
uint32_t sessionID;
|
uint32_t sessionID;
|
||||||
uint32_t channelID;
|
uint32_t channelID;
|
||||||
struct SpiceChannel scMain;
|
struct SpiceChannel scMain;
|
||||||
@ -124,6 +126,9 @@ bool spice_on_common_read (struct SpiceChannel * channel, SpiceDataHeader
|
|||||||
bool spice_on_main_channel_read ();
|
bool spice_on_main_channel_read ();
|
||||||
bool spice_on_inputs_channel_read();
|
bool spice_on_inputs_channel_read();
|
||||||
|
|
||||||
|
bool spice_agent_connect();
|
||||||
|
void spice_agent_disconnect();
|
||||||
|
|
||||||
bool spice_read (const struct SpiceChannel * channel, void * buffer, const ssize_t size);
|
bool spice_read (const struct SpiceChannel * channel, void * buffer, const ssize_t size);
|
||||||
ssize_t spice_write (const struct SpiceChannel * channel, const void * buffer, const ssize_t size);
|
ssize_t spice_write (const struct SpiceChannel * channel, const void * buffer, const ssize_t size);
|
||||||
bool spice_write_msg(struct SpiceChannel * channel, uint32_t type, const void * buffer, const ssize_t size);
|
bool spice_write_msg(struct SpiceChannel * channel, uint32_t type, const void * buffer, const ssize_t size);
|
||||||
@ -398,6 +403,16 @@ bool spice_on_main_channel_read()
|
|||||||
}
|
}
|
||||||
|
|
||||||
spice.sessionID = msg.session_id;
|
spice.sessionID = msg.session_id;
|
||||||
|
|
||||||
|
spice.agentTokens = msg.agent_tokens;
|
||||||
|
if (msg.agent_connected)
|
||||||
|
{
|
||||||
|
spice.hasAgent = true;
|
||||||
|
spice_agent_connect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
spice.hasAgent = false;
|
||||||
|
|
||||||
if (msg.current_mouse_mode != SPICE_MOUSE_MODE_CLIENT && !spice_mouse_mode(false))
|
if (msg.current_mouse_mode != SPICE_MOUSE_MODE_CLIENT && !spice_mouse_mode(false))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("failed to set mouse mode");
|
DEBUG_ERROR("failed to set mouse mode");
|
||||||
@ -450,6 +465,7 @@ bool spice_on_main_channel_read()
|
|||||||
if (!spice_connect_channel(&spice.scInputs))
|
if (!spice_connect_channel(&spice.scInputs))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("failed to connect inputs channel");
|
DEBUG_ERROR("failed to connect inputs channel");
|
||||||
|
spice_disconnect();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,6 +474,29 @@ bool spice_on_main_channel_read()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (header.type == SPICE_MSG_MAIN_AGENT_CONNECTED)
|
||||||
|
{
|
||||||
|
spice.hasAgent = true;
|
||||||
|
spice_agent_connect();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (header.type == SPICE_MSG_MAIN_AGENT_DISCONNECTED)
|
||||||
|
{
|
||||||
|
uint32_t error;
|
||||||
|
if (!spice_read(channel, &error, sizeof(error)))
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("failed to read agent disconnect error code");
|
||||||
|
spice_disconnect();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_INFO("Spice agent disconnected, error: %u", error);
|
||||||
|
spice.hasAgent = false;
|
||||||
|
spice_agent_disconnect();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_WARN("main channel unhandled message type %u", header.type);
|
DEBUG_WARN("main channel unhandled message type %u", header.type);
|
||||||
spice_discard(channel, header.size);
|
spice_discard(channel, header.size);
|
||||||
return true;
|
return true;
|
||||||
@ -699,6 +738,30 @@ void spice_disconnect_channel(struct SpiceChannel * channel)
|
|||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
bool spice_agent_connect()
|
||||||
|
{
|
||||||
|
DEBUG_INFO("Spice agent available, sending start");
|
||||||
|
|
||||||
|
if (!spice_write_msg(&spice.scMain, SPICE_MSGC_MAIN_AGENT_START, &spice.agentTokens, sizeof(spice.agentTokens)))
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("failed to send agent start message");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo, agent setup
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
void spice_agent_disconnect()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
ssize_t spice_write(const struct SpiceChannel * channel, const void * buffer, const ssize_t size)
|
ssize_t spice_write(const struct SpiceChannel * channel, const void * buffer, const ssize_t size)
|
||||||
{
|
{
|
||||||
if (!channel->connected)
|
if (!channel->connected)
|
||||||
|
Loading…
Reference in New Issue
Block a user