mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-01 13:10:43 +00:00
Use and introduce channel client cast macros
In anticipation of porting to GObject, use casting macros (e.g. MAIN_CHANNEL_CLIENT()) to cast RedChannelClient types. This will help reduce the changeset slightly porting to GObject and thus make it easier to review those upcoming changes. Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
21c6da814a
commit
8f9fd3a826
@ -97,14 +97,14 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
|
||||
spice_return_val_if_fail(!num_caps || caps, NULL);
|
||||
|
||||
CursorChannelClient *ccc =
|
||||
(CursorChannelClient*)red_channel_client_create(sizeof(CursorChannelClient),
|
||||
CURSOR_CHANNEL_CLIENT(red_channel_client_create(sizeof(CursorChannelClient),
|
||||
RED_CHANNEL(cursor),
|
||||
client, stream,
|
||||
FALSE,
|
||||
num_common_caps,
|
||||
common_caps,
|
||||
num_caps,
|
||||
caps);
|
||||
caps));
|
||||
spice_return_val_if_fail(ccc != NULL, NULL);
|
||||
COMMON_GRAPHICS_CHANNEL(cursor)->during_target_migrate = mig_target;
|
||||
|
||||
|
||||
@ -350,12 +350,12 @@ DisplayChannelClient *dcc_new(DisplayChannel *display,
|
||||
{
|
||||
DisplayChannelClient *dcc;
|
||||
|
||||
dcc = (DisplayChannelClient*)red_channel_client_create(
|
||||
dcc = DISPLAY_CHANNEL_CLIENT(red_channel_client_create(
|
||||
sizeof(DisplayChannelClient),
|
||||
&COMMON_GRAPHICS_CHANNEL(display)->base,
|
||||
client, stream, TRUE,
|
||||
num_common_caps, common_caps,
|
||||
num_caps, caps);
|
||||
num_caps, caps));
|
||||
|
||||
display->common.during_target_migrate = mig_target;
|
||||
dcc->priv->id = display->common.qxl->id;
|
||||
|
||||
@ -46,13 +46,13 @@ RedChannelClient* inputs_channel_client_create(RedChannel *channel,
|
||||
uint32_t *caps)
|
||||
{
|
||||
InputsChannelClient* icc =
|
||||
(InputsChannelClient*)red_channel_client_create(sizeof(InputsChannelClient),
|
||||
INPUTS_CHANNEL_CLIENT(red_channel_client_create(sizeof(InputsChannelClient),
|
||||
channel, client,
|
||||
stream,
|
||||
monitor_latency,
|
||||
num_common_caps,
|
||||
common_caps, num_caps,
|
||||
caps);
|
||||
caps));
|
||||
if (icc) {
|
||||
icc->priv->motion_count = 0;
|
||||
}
|
||||
@ -63,7 +63,7 @@ void inputs_channel_client_send_migrate_data(RedChannelClient *rcc,
|
||||
SpiceMarshaller *m,
|
||||
RedPipeItem *item)
|
||||
{
|
||||
InputsChannelClient *icc = SPICE_CONTAINEROF(rcc, InputsChannelClient, base);
|
||||
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, item);
|
||||
|
||||
|
||||
@ -45,4 +45,6 @@ enum {
|
||||
RED_PIPE_ITEM_MIGRATE_DATA,
|
||||
};
|
||||
|
||||
#define INPUTS_CHANNEL_CLIENT(rcc) ((InputsChannelClient*)rcc)
|
||||
|
||||
#endif /* _INPUTS_CHANNEL_CLIENT_H_ */
|
||||
|
||||
@ -273,7 +273,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
|
||||
void *message)
|
||||
{
|
||||
InputsChannel *inputs_channel = (InputsChannel *)red_channel_client_get_channel(rcc);
|
||||
InputsChannelClient *icc = (InputsChannelClient *)rcc;
|
||||
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
|
||||
uint32_t i;
|
||||
RedsState *reds = red_channel_get_server(&inputs_channel->base);
|
||||
|
||||
@ -547,7 +547,7 @@ static int inputs_channel_handle_migrate_data(RedChannelClient *rcc,
|
||||
uint32_t size,
|
||||
void *message)
|
||||
{
|
||||
InputsChannelClient *icc = (InputsChannelClient*)rcc;
|
||||
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
|
||||
InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
|
||||
SpiceMigrateDataHeader *header;
|
||||
SpiceMigrateDataInputs *mig_data;
|
||||
|
||||
@ -384,7 +384,7 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc,
|
||||
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size)
|
||||
{
|
||||
uint64_t roundtrip;
|
||||
RedChannelClient* rcc = (RedChannelClient*)mcc;
|
||||
RedChannelClient* rcc = RED_CHANNEL_CLIENT(mcc);
|
||||
|
||||
roundtrip = g_get_monotonic_time() - ping->timestamp;
|
||||
|
||||
@ -559,10 +559,10 @@ MainChannelClient *main_channel_client_create(MainChannel *main_chan, RedClient
|
||||
int num_common_caps, uint32_t *common_caps,
|
||||
int num_caps, uint32_t *caps)
|
||||
{
|
||||
MainChannelClient *mcc = (MainChannelClient*)
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(
|
||||
red_channel_client_create(sizeof(MainChannelClient), &main_chan->base,
|
||||
client, stream, FALSE, num_common_caps,
|
||||
common_caps, num_caps, caps);
|
||||
common_caps, num_caps, caps));
|
||||
spice_assert(mcc != NULL);
|
||||
mcc->priv->connection_id = connection_id;
|
||||
mcc->priv->bitrate_per_sec = ~0;
|
||||
@ -599,7 +599,7 @@ uint64_t main_channel_client_get_roundtrip_ms(MainChannelClient *mcc)
|
||||
void main_channel_client_migrate(RedChannelClient *rcc)
|
||||
{
|
||||
RedChannel *channel = red_channel_client_get_channel(rcc);
|
||||
reds_on_main_channel_migrate(channel->reds, SPICE_CONTAINEROF(rcc, MainChannelClient, base));
|
||||
reds_on_main_channel_migrate(channel->reds, MAIN_CHANNEL_CLIENT(rcc));
|
||||
red_channel_client_default_migrate(rcc);
|
||||
}
|
||||
|
||||
@ -671,7 +671,7 @@ static void main_channel_marshall_ping(RedChannelClient *rcc,
|
||||
SpiceMarshaller *m,
|
||||
RedPingPipeItem *item)
|
||||
{
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
SpiceMsgPing ping;
|
||||
int size_left = item->size;
|
||||
|
||||
@ -870,7 +870,7 @@ static void main_channel_marshall_agent_connected(SpiceMarshaller *m,
|
||||
|
||||
void main_channel_client_send_item(RedChannelClient *rcc, RedPipeItem *base)
|
||||
{
|
||||
MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
|
||||
|
||||
/* In semi-seamless migration (dest side), the connection is started from scratch, and
|
||||
|
||||
@ -105,4 +105,6 @@ typedef struct MainMultiMediaTimeItemInfo {
|
||||
RedPipeItem *main_multi_media_time_item_new(RedChannelClient *rcc,
|
||||
void *data, int num);
|
||||
|
||||
#define MAIN_CHANNEL_CLIENT(rcc) ((MainChannelClient*)rcc)
|
||||
|
||||
#endif /* __MAIN_CHANNEL_CLIENT_H__ */
|
||||
|
||||
@ -48,7 +48,7 @@ RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t c
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
MainChannelClient *mcc = (MainChannelClient*) rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_get_connection_id(mcc) == connection_id) {
|
||||
return red_channel_client_get_client(rcc);
|
||||
}
|
||||
@ -102,7 +102,7 @@ static int main_channel_handle_migrate_data(RedChannelClient *rcc,
|
||||
uint32_t size, void *message)
|
||||
{
|
||||
RedChannel *channel = red_channel_client_get_channel(rcc);
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
SpiceMigrateDataHeader *header = (SpiceMigrateDataHeader *)message;
|
||||
|
||||
/* not supported with multi-clients */
|
||||
@ -157,7 +157,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
|
||||
{
|
||||
RedChannel *channel = red_channel_client_get_channel(rcc);
|
||||
MainChannel *main_chan = SPICE_CONTAINEROF(channel, MainChannel, base);
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
|
||||
switch (type) {
|
||||
case SPICE_MSGC_MAIN_AGENT_START: {
|
||||
@ -226,7 +226,7 @@ static uint8_t *main_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
|
||||
{
|
||||
RedChannel *channel = red_channel_client_get_channel(rcc);
|
||||
MainChannel *main_chan = SPICE_CONTAINEROF(channel, MainChannel, base);
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
|
||||
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
|
||||
return reds_get_agent_data_buffer(channel->reds, mcc, size);
|
||||
@ -338,7 +338,7 @@ static int main_channel_connect_semi_seamless(MainChannel *main_channel)
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_channel, link, next, rcc) {
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_connect_semi_seamless(mcc))
|
||||
main_channel->num_clients_mig_wait++;
|
||||
}
|
||||
@ -353,7 +353,7 @@ static int main_channel_connect_seamless(MainChannel *main_channel)
|
||||
spice_assert(g_list_length(main_channel->base.clients) == 1);
|
||||
|
||||
FOREACH_CLIENT(main_channel, link, next, rcc) {
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
main_channel_client_connect_seamless(mcc);
|
||||
main_channel->num_clients_mig_wait++;
|
||||
}
|
||||
@ -393,7 +393,7 @@ void main_channel_migrate_cancel_wait(MainChannel *main_chan)
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
main_channel_client_migrate_cancel_wait(mcc);
|
||||
}
|
||||
main_chan->num_clients_mig_wait = 0;
|
||||
@ -413,7 +413,7 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
|
||||
}
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
MainChannelClient *mcc = (MainChannelClient*)rcc;
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_migrate_src_complete(mcc, success))
|
||||
semi_seamless_count++;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ void red_channel_client_on_input(void *opaque, int n)
|
||||
|
||||
int red_channel_client_get_out_msg_size(void *opaque)
|
||||
{
|
||||
RedChannelClient *rcc = (RedChannelClient *)opaque;
|
||||
RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
|
||||
|
||||
return rcc->priv->send_data.size;
|
||||
}
|
||||
@ -136,7 +136,7 @@ int red_channel_client_get_out_msg_size(void *opaque)
|
||||
void red_channel_client_prepare_out_msg(void *opaque, struct iovec *vec,
|
||||
int *vec_size, int pos)
|
||||
{
|
||||
RedChannelClient *rcc = (RedChannelClient *)opaque;
|
||||
RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
|
||||
|
||||
*vec_size = spice_marshaller_fill_iovec(rcc->priv->send_data.marshaller,
|
||||
vec, IOV_MAX, pos);
|
||||
@ -144,7 +144,7 @@ void red_channel_client_prepare_out_msg(void *opaque, struct iovec *vec,
|
||||
|
||||
void red_channel_client_on_out_block(void *opaque)
|
||||
{
|
||||
RedChannelClient *rcc = (RedChannelClient *)opaque;
|
||||
RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
|
||||
|
||||
rcc->priv->send_data.blocked = TRUE;
|
||||
rcc->priv->channel->core->watch_update_mask(rcc->priv->stream->watch,
|
||||
@ -313,7 +313,7 @@ static void red_channel_client_restore_main_sender(RedChannelClient *rcc)
|
||||
|
||||
void red_channel_client_on_out_msg_done(void *opaque)
|
||||
{
|
||||
RedChannelClient *rcc = (RedChannelClient *)opaque;
|
||||
RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
|
||||
int fd;
|
||||
|
||||
rcc->priv->send_data.size = 0;
|
||||
@ -529,7 +529,7 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
|
||||
|
||||
static void red_channel_client_event(int fd, int event, void *data)
|
||||
{
|
||||
RedChannelClient *rcc = (RedChannelClient *)data;
|
||||
RedChannelClient *rcc = RED_CHANNEL_CLIENT(data);
|
||||
|
||||
red_channel_client_ref(rcc);
|
||||
if (event & SPICE_WATCH_EVENT_READ) {
|
||||
|
||||
@ -66,6 +66,8 @@ typedef struct SmartCardChannelClient {
|
||||
SmartCardChannelClientPrivate priv[1];
|
||||
} SmartCardChannelClient;
|
||||
|
||||
#define SMARTCARD_CHANNEL_CLIENT(rcc) ((SmartCardChannelClient*)rcc)
|
||||
|
||||
G_DEFINE_TYPE(RedCharDeviceSmartcard, red_char_device_smartcard, RED_TYPE_CHAR_DEVICE)
|
||||
|
||||
#define RED_CHAR_DEVICE_SMARTCARD_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RED_TYPE_CHAR_DEVICE_SMARTCARD, RedCharDeviceSmartcardPrivate))
|
||||
@ -387,7 +389,7 @@ static uint8_t *smartcard_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
|
||||
uint16_t type,
|
||||
uint32_t size)
|
||||
{
|
||||
SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
|
||||
/* todo: only one reader is actually supported. When we fix the code to support
|
||||
* multiple readers, we will porbably associate different devices to
|
||||
@ -420,7 +422,7 @@ static void smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc,
|
||||
uint32_t size,
|
||||
uint8_t *msg)
|
||||
{
|
||||
SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
|
||||
/* todo: only one reader is actually supported. When we fix the code to support
|
||||
* multiple readers, we will porbably associate different devices to
|
||||
@ -472,7 +474,7 @@ static void smartcard_channel_send_migrate_data(RedChannelClient *rcc,
|
||||
RedCharDeviceSmartcard *dev;
|
||||
SpiceMarshaller *m2;
|
||||
|
||||
scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
dev = scc->priv->smartcard;
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, item);
|
||||
spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_MAGIC);
|
||||
@ -517,7 +519,7 @@ static void smartcard_channel_send_item(RedChannelClient *rcc, RedPipeItem *item
|
||||
|
||||
static void smartcard_channel_on_disconnect(RedChannelClient *rcc)
|
||||
{
|
||||
SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
|
||||
if (scc->priv->smartcard) {
|
||||
RedCharDeviceSmartcard *dev = scc->priv->smartcard;
|
||||
@ -665,7 +667,7 @@ static int smartcard_channel_client_handle_migrate_data(RedChannelClient *rcc,
|
||||
SpiceMigrateDataHeader *header;
|
||||
SpiceMigrateDataSmartcard *mig_data;
|
||||
|
||||
scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
header = (SpiceMigrateDataHeader *)message;
|
||||
mig_data = (SpiceMigrateDataSmartcard *)(header + 1);
|
||||
if (size < sizeof(SpiceMigrateDataHeader) + sizeof(SpiceMigrateDataSmartcard)) {
|
||||
@ -706,7 +708,7 @@ static int smartcard_channel_handle_message(RedChannelClient *rcc,
|
||||
uint8_t *msg)
|
||||
{
|
||||
VSCMsgHeader* vheader = (VSCMsgHeader*)msg;
|
||||
SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
|
||||
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
|
||||
if (type != SPICE_MSGC_SMARTCARD_DATA) {
|
||||
/* Handles seamless migration protocol. Also handles ack's,
|
||||
@ -760,13 +762,13 @@ static void smartcard_connect_client(RedChannel *channel, RedClient *client,
|
||||
|
||||
SmartCardChannelClient *scc;
|
||||
|
||||
scc = (SmartCardChannelClient *)red_channel_client_create(sizeof(SmartCardChannelClient),
|
||||
channel,
|
||||
client,
|
||||
stream,
|
||||
FALSE,
|
||||
num_common_caps, common_caps,
|
||||
num_caps, caps);
|
||||
scc = SMARTCARD_CHANNEL_CLIENT(red_channel_client_create(sizeof(SmartCardChannelClient),
|
||||
channel,
|
||||
client,
|
||||
stream,
|
||||
FALSE,
|
||||
num_common_caps, common_caps,
|
||||
num_caps, caps));
|
||||
if (!scc) {
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user