mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 07:29:32 +00:00
channel: Remove IncomingHandlerInterface
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@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
99641c6874
commit
f93fe59c21
@ -50,7 +50,6 @@ typedef struct OutgoingHandler {
|
||||
} OutgoingHandler;
|
||||
|
||||
typedef struct IncomingHandler {
|
||||
IncomingHandlerInterface *cb;
|
||||
void *opaque;
|
||||
uint8_t header_buf[MAX_HEADER_SIZE];
|
||||
SpiceDataHeaderOpaque header;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -93,8 +93,6 @@ struct RedChannelPrivate
|
||||
|
||||
void *data;
|
||||
|
||||
IncomingHandlerInterface incoming_cb;
|
||||
|
||||
ClientCbs client_cbs;
|
||||
// TODO: when different channel_clients are in different threads
|
||||
// from Channel -> need to protect!
|
||||
@ -220,9 +218,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,
|
||||
@ -764,11 +759,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();
|
||||
|
||||
@ -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);
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user