char-device: Allow send_msg_to_client callback to be NULL

Mostly of the callback dealing with sent messages and tokens
can be NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Frediano Ziglio 2019-09-24 13:08:08 +01:00
parent 8ec691f056
commit 5bcfc2b5d5
4 changed files with 6 additions and 16 deletions

View File

@ -114,9 +114,11 @@ red_char_device_send_msg_to_client(RedCharDevice *dev,
RedPipeItem *msg,
RedCharDeviceClientOpaque *client)
{
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
klass->send_msg_to_client(dev, msg, client);
if (klass->send_msg_to_client != NULL) {
klass->send_msg_to_client(dev, msg, client);
}
}
static void

View File

@ -63,7 +63,8 @@ struct RedCharDeviceClass
* or till the reading fails */
RedPipeItem* (*read_one_msg_from_device)(RedCharDevice *self,
SpiceCharDeviceInstance *sin);
/* after this call, the message is unreferenced */
/* After this call, the message is unreferenced.
* Can be NULL. */
void (*send_msg_to_client)(RedCharDevice *self,
RedPipeItem *msg,
RedCharDeviceClientOpaque *client);

View File

@ -566,11 +566,6 @@ handle_msg_cursor_move(StreamDevice *dev, SpiceCharDeviceInstance *sin)
return true;
}
static void
stream_device_send_msg_to_client(RedCharDevice *self, RedPipeItem *msg, RedClient *client)
{
}
static void
stream_device_remove_client(RedCharDevice *self, RedClient *client)
{
@ -779,7 +774,6 @@ stream_device_class_init(StreamDeviceClass *klass)
object_class->finalize = stream_device_finalize;
char_dev_class->read_one_msg_from_device = stream_device_read_msg_from_dev;
char_dev_class->send_msg_to_client = stream_device_send_msg_to_client;
char_dev_class->remove_client = stream_device_remove_client;
char_dev_class->port_event = stream_device_port_event;
}

View File

@ -376,12 +376,6 @@ static RedPipeItem *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self,
return NULL;
}
static void spicevmc_chardev_send_msg_to_client(RedCharDevice *self,
RedPipeItem *msg,
RedClient *client)
{
}
static void red_port_init_item_free(struct RedPipeItem *base)
{
RedPortInitPipeItem *item = SPICE_UPCAST(RedPortInitPipeItem, base);
@ -912,7 +906,6 @@ red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass *klass)
object_class->dispose = red_char_device_spicevmc_dispose;
char_dev_class->read_one_msg_from_device = spicevmc_chardev_read_msg_from_dev;
char_dev_class->send_msg_to_client = spicevmc_chardev_send_msg_to_client;
char_dev_class->remove_client = spicevmc_char_dev_remove_client;
char_dev_class->port_event = spicevmc_port_event;
char_dev_class->on_free_self_token = spicevmc_on_free_self_token;