> > This commit removes what remains of IncomingHandlerInterface. The > remaining function pointers were pointing to RedChannel vfuncs. > Moreover the IncomingHandlerInterface abstraction is unused, ie the > codebase only has a single implementation for it, so we can directly > call the relevant methods and make them static instead. > > Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> > --- > server/red-channel-client-private.h | 1 - > server/red-channel-client.c | 21 ++++++++++++--------- > server/red-channel.c | 10 ---------- > server/red-channel.h | 13 ------------- > 4 files changed, 12 insertions(+), 33 deletions(-) > > diff --git a/server/red-channel-client-private.h > b/server/red-channel-client-private.h > index 5d29f32..77766d0 100644 > --- a/server/red-channel-client-private.h > +++ b/server/red-channel-client-private.h > @@ -50,7 +50,6 @@ typedef struct OutgoingHandler { > } OutgoingHandler; > > typedef struct IncomingHandler { > - IncomingHandlerInterface *cb; > void *opaque; > uint8_t header_buf[MAX_HEADER_SIZE]; > SpiceDataHeaderOpaque header; > diff --git a/server/red-channel-client.c b/server/red-channel-client.c > index fc82faa..1e071cc 100644 > --- a/server/red-channel-client.c > +++ b/server/red-channel-client.c > @@ -269,8 +269,6 @@ static void red_channel_client_constructed(GObject > *object) > RedChannelClient *self = RED_CHANNEL_CLIENT(object); > > self->priv->incoming.opaque = self; > - self->priv->incoming.cb = > red_channel_get_incoming_handler(self->priv->channel); > - > self->priv->outgoing.opaque = self; > self->priv->outgoing.pos = 0; > self->priv->outgoing.size = 0; > @@ -1103,15 +1101,17 @@ static int red_peer_receive(RedsStream *stream, > uint8_t *buf, uint32_t size) > return pos - buf; > } > > -static uint8_t *red_channel_client_parse(IncomingHandler *handler, uint8_t > *message, size_t message_size, > +static uint8_t *red_channel_client_parse(RedChannelClient *rcc, uint8_t > *message, size_t message_size, > uint16_t message_type, > size_t *size_out, > message_destructor_t > *free_message) > { > + RedChannel *channel = red_channel_client_get_channel(rcc); > + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel); > uint8_t *parsed_message; > > - if (handler->cb->parser) { > - parsed_message = handler->cb->parser(message, message + > message_size, message_type, > - SPICE_VERSION_MINOR, size_out, > free_message); > + if (klass->parser) { > + parsed_message = klass->parser(message, message + message_size, > message_type, > + SPICE_VERSION_MINOR, size_out, > free_message); > } else { > parsed_message = message; > *size_out = message_size; > @@ -1142,6 +1142,9 @@ static void red_peer_handle_incoming(RedsStream > *stream, IncomingHandler *handle > uint8_t *parsed; > size_t parsed_size; > message_destructor_t parsed_free = NULL; > + RedChannel *channel = > red_channel_client_get_channel(handler->opaque); > + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel); > + > if (handler->header_pos < handler->header.header_size) { > bytes_read = red_peer_receive(stream, > handler->header.data + > handler->header_pos, > @@ -1186,7 +1189,7 @@ static void red_peer_handle_incoming(RedsStream > *stream, IncomingHandler *handle > } > } > > - parsed = red_channel_client_parse(handler, > + parsed = red_channel_client_parse(handler->opaque, > handler->msg, msg_size, > msg_type, > &parsed_size, &parsed_free); > @@ -1198,8 +1201,8 @@ static void red_peer_handle_incoming(RedsStream > *stream, IncomingHandler *handle > red_channel_client_disconnect(handler->opaque); > return; > } > - ret_handle = handler->cb->handle_message(handler->opaque, msg_type, > - parsed_size, parsed); > + ret_handle = klass->handle_message(handler->opaque, msg_type, > + parsed_size, parsed); > if (parsed_free != NULL) { > parsed_free(parsed); > } > diff --git a/server/red-channel.c b/server/red-channel.c > index f7cf589..0f73c7e 100644 > --- a/server/red-channel.c > +++ b/server/red-channel.c > @@ -91,8 +91,6 @@ struct RedChannelPrivate > RedChannelCapabilities local_caps; > uint32_t migration_flags; > > - IncomingHandlerInterface incoming_cb; > - > ClientCbs client_cbs; > // TODO: when different channel_clients are in different threads > // from Channel -> need to protect! > @@ -218,9 +216,6 @@ red_channel_constructed(GObject *object) > klass->alloc_recv_buf && klass->release_recv_buf); > spice_assert(klass->handle_migrate_data || > !(self->priv->migration_flags & > SPICE_MIGRATE_NEED_DATA_TRANSFER)); > - > - self->priv->incoming_cb.handle_message = > (handle_message_proc)klass->handle_message; > - self->priv->incoming_cb.parser = klass->parser; > } > > static void red_channel_client_default_connect(RedChannel *channel, > RedClient *client, > @@ -760,11 +755,6 @@ void red_channel_send_item(RedChannel *self, > RedChannelClient *rcc, RedPipeItem > klass->send_item(rcc, item); > } > > -IncomingHandlerInterface* red_channel_get_incoming_handler(RedChannel *self) > -{ > - return &self->priv->incoming_cb; > -} > - > void red_channel_reset_thread_id(RedChannel *self) > { > self->priv->thread_id = pthread_self(); > diff --git a/server/red-channel.h b/server/red-channel.h > index 25ae1a2..80910e3 100644 > --- a/server/red-channel.h > +++ b/server/red-channel.h > @@ -59,15 +59,6 @@ struct SpiceDataHeaderOpaque { > get_msg_size_proc get_msg_size; > }; > > -typedef int (*handle_message_proc)(void *opaque, > - uint16_t type, uint32_t size, uint8_t > *msg); > - > -typedef struct IncomingHandlerInterface { > - // 'parser' is optional and will not be used if NULL > - spice_parse_channel_func_t parser; > - handle_message_proc handle_message; > -} IncomingHandlerInterface; > - > typedef struct RedChannel RedChannel; > typedef struct RedChannelClient RedChannelClient; > typedef struct RedClient RedClient; > @@ -275,10 +266,6 @@ void red_channel_send_item(RedChannel *self, > RedChannelClient *rcc, RedPipeItem > void red_channel_reset_thread_id(RedChannel *self); > StatNodeRef red_channel_get_stat_node(RedChannel *channel); > > -/* FIXME: does this even need to be in RedChannel? It's really only used in > - * RedChannelClient. Needs refactoring */ > -IncomingHandlerInterface* red_channel_get_incoming_handler(RedChannel > *self); > - > const RedChannelCapabilities* red_channel_get_local_capabilities(RedChannel > *self); > > /* Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx> Frediano _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel