mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 23:49:04 +00:00
Improve Reds/RedMainChannel interface
Instead of exporting 2 methods to get number of channels, and to fill channel information, and use that from the main channel code, it's better to do everything in one go in reds.c, and call that single method from the main channel code. Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
b0cc5bfcbd
commit
8e5bacd8b1
@ -340,9 +340,7 @@ static void main_channel_marshall_channels(RedChannelClient *rcc,
|
||||
SpiceMsgChannels* channels_info;
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_CHANNELS_LIST, item);
|
||||
channels_info = (SpiceMsgChannels *)spice_malloc(sizeof(SpiceMsgChannels)
|
||||
+ reds_get_n_channels(rcc->channel->reds) * sizeof(SpiceChannelId));
|
||||
reds_fill_channels(rcc->channel->reds, channels_info);
|
||||
channels_info = reds_msg_channels_new(rcc->channel->reds);
|
||||
spice_marshall_msg_main_channels_list(m, channels_info);
|
||||
free(channels_info);
|
||||
}
|
||||
|
||||
@ -977,12 +977,6 @@ void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mou
|
||||
red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_dev), char_dev_buf);
|
||||
}
|
||||
|
||||
int reds_get_n_channels(RedsState *reds)
|
||||
{
|
||||
return reds ? reds->num_of_channels : 0;
|
||||
}
|
||||
|
||||
|
||||
static int reds_get_n_clients(RedsState *reds)
|
||||
{
|
||||
return reds ? reds->num_clients : 0;
|
||||
@ -1005,7 +999,7 @@ static int channel_supports_multiple_clients(RedChannel *channel)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
|
||||
static void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
|
||||
{
|
||||
RingItem *now;
|
||||
int used_channels = 0;
|
||||
@ -1028,6 +1022,20 @@ void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
|
||||
}
|
||||
}
|
||||
|
||||
SpiceMsgChannels *reds_msg_channels_new(RedsState *reds)
|
||||
{
|
||||
SpiceMsgChannels* channels_info;
|
||||
|
||||
spice_assert(reds != NULL);
|
||||
|
||||
channels_info = (SpiceMsgChannels *)spice_malloc(sizeof(SpiceMsgChannels)
|
||||
+ reds->num_of_channels * sizeof(SpiceChannelId));
|
||||
|
||||
reds_fill_channels(reds, channels_info);
|
||||
|
||||
return channels_info;
|
||||
}
|
||||
|
||||
void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens)
|
||||
{
|
||||
RedCharDevice *dev_state = RED_CHAR_DEVICE(reds->agent_dev);
|
||||
|
||||
@ -79,8 +79,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client);
|
||||
// Temporary (?) for splitting main channel
|
||||
typedef struct MainMigrateData MainMigrateData;
|
||||
void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m);
|
||||
void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info);
|
||||
int reds_get_n_channels(RedsState *reds);
|
||||
SpiceMsgChannels *reds_msg_channels_new(RedsState *reds);
|
||||
|
||||
/* callbacks from main channel messages */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user