From 56c9548f6471878a16cad90cc028defdae2cc7c4 Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Wed, 8 Aug 2012 12:14:23 +0300 Subject: agent: reset client tokens when notifying on agent connection send SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS --- server/main_channel.c | 17 ++++++++++++++++- server/reds.c | 16 ++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'server') diff --git a/server/main_channel.c b/server/main_channel.c index 00a6b0f4..0d948dec 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -388,7 +388,19 @@ static void main_channel_marshall_mouse_mode(SpiceMarshaller *m, int current_mod void main_channel_push_agent_connected(MainChannel *main_chan) { - red_channel_pipes_add_type(&main_chan->base, SPICE_MSG_MAIN_AGENT_CONNECTED); + if (red_channel_test_remote_cap(&main_chan->base, SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) { + red_channel_pipes_add_type(&main_chan->base, SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS); + } else { + red_channel_pipes_add_type(&main_chan->base, SPICE_MSG_MAIN_AGENT_CONNECTED); + } +} + +static void main_channel_marshall_agent_connected(SpiceMarshaller *m) +{ + SpiceMsgMainAgentConnectedTokens connected; + + connected.num_tokens = REDS_AGENT_WINDOW_SIZE; + spice_marshall_msg_main_agent_connected_tokens(m, &connected); } void main_channel_push_agent_disconnected(MainChannel *main_chan) @@ -729,6 +741,9 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base) case SPICE_MSG_MAIN_UUID: spice_marshall_msg_main_uuid(m, &SPICE_CONTAINEROF(base, UuidPipeItem, base)->msg); break; + case SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS: + main_channel_marshall_agent_connected(m); + break; default: break; }; diff --git a/server/reds.c b/server/reds.c index e3ea154a..8d6dbfb7 100644 --- a/server/reds.c +++ b/server/reds.c @@ -605,15 +605,19 @@ static void reds_reset_vdp(void) * The client tokens' are set only once, when the main channel is initialized. * Instead, it would have been more appropriate to reset them upon AGEN_CONNECT. * The client tokens are tracked as part of the SpiceCharDeviceClientState. Thus, - * in order to be backwartd compatible with the client, we need to track the tokens - * event when the agent is detached. We don't destroy the the char_device state, and + * in order to be backward compatible with the client, we need to track the tokens + * even if the agent is detached. We don't destroy the the char_device state, and * instead we just reset it. - * In addition, there is a misshandling of AGENT_TOKENS message in spice-gtk: it + * In addition, there used to be a misshandling of AGENT_TOKENS message in spice-gtk: it * overrides the amount of tokens, instead of adding the given amount. - * - * TODO: change AGENT_CONNECT msg to contain tokens count. */ - spice_char_device_reset(state->base); + if (red_channel_test_remote_cap(&reds->main_channel->base, + SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) { + spice_char_device_state_destroy(state->base); + state->base = NULL; + } else { + spice_char_device_reset(state->base); + } sif = SPICE_CONTAINEROF(vdagent->base.sif, SpiceCharDeviceInterface, base); if (sif->state) { -- cgit