diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2016-03-23 12:48:39 +0000 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@redhat.com> | 2016-03-29 11:44:58 -0500 |
commit | abdf484c697a3efb328b9c4b2eb0a6b03f8e9884 (patch) | |
tree | e2ddd4f19d87adf0b1bcb65d87a182ebf6426340 /server/char-device.h | |
parent | 6f4aa2c217783958e433f3615006a04d9467c88a (diff) |
Move SpiceCharDeviceCallbacks into RedCharDeviceClassreview-2016-03-29
This structure holding virtual function pointers was kept until now as a
RedCharDevice member in order to make the GObject conversion easier.
Now that all RedCharDevice children are converted to GObject, it can be
moved into RedCharDeviceClass.
Diffstat (limited to 'server/char-device.h')
-rw-r--r-- | server/char-device.h | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/server/char-device.h b/server/char-device.h index d0fc63c7..207c6d5e 100644 --- a/server/char-device.h +++ b/server/char-device.h @@ -24,6 +24,8 @@ #include "red-channel.h" #include "migration-protocol.h" +typedef void SpiceCharDeviceMsgToClient; + #define RED_TYPE_CHAR_DEVICE red_char_device_get_type() #define RED_CHAR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), RED_TYPE_CHAR_DEVICE, RedCharDevice)) @@ -47,15 +49,40 @@ struct SpiceCharDeviceState struct RedCharDeviceClass { GObjectClass parent_class; + + /* + * Messages that are addressed to the client can be queued in case we have + * multiple clients and some of them don't have enough tokens. + */ + + /* reads from the device till reaching a msg that should be sent to the client, + * or till the reading fails */ + SpiceCharDeviceMsgToClient* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin, + void *opaque); + SpiceCharDeviceMsgToClient* (*ref_msg_to_client)(SpiceCharDeviceMsgToClient *msg, + void *opaque); + void (*unref_msg_to_client)(SpiceCharDeviceMsgToClient *msg, + void *opaque); + void (*send_msg_to_client)(SpiceCharDeviceMsgToClient *msg, + RedClient *client, + void *opaque); /* after this call, the message is unreferenced */ + + /* The cb is called when a predefined number of write buffers were consumed by the + * device */ + void (*send_tokens_to_client)(RedClient *client, uint32_t tokens, void *opaque); + + /* The cb is called when a server (self) message that was addressed to the device, + * has been completely written to it */ + void (*on_free_self_token)(void *opaque); + + /* This cb is called if it is recommanded that a client will be removed + * due to slow flow or due to some other error. + * The called instance should disconnect the client, or at least the corresponding channel */ + void (*remove_client)(RedClient *client, void *opaque); }; GType red_char_device_get_type(void) G_GNUC_CONST; -typedef struct SpiceCharDeviceCallbacks SpiceCharDeviceCallbacks; -void red_char_device_set_callbacks(RedCharDevice *dev, - SpiceCharDeviceCallbacks *cbs, - gpointer opaque); - /* * Shared code for char devices, mainly for flow control. * @@ -127,40 +154,6 @@ typedef struct SpiceCharDeviceWriteBuffer { uint32_t refs; } SpiceCharDeviceWriteBuffer; -typedef void SpiceCharDeviceMsgToClient; - -struct SpiceCharDeviceCallbacks { - /* - * Messages that are addressed to the client can be queued in case we have - * multiple clients and some of them don't have enough tokens. - */ - - /* reads from the device till reaching a msg that should be sent to the client, - * or till the reading fails */ - SpiceCharDeviceMsgToClient* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin, - void *opaque); - SpiceCharDeviceMsgToClient* (*ref_msg_to_client)(SpiceCharDeviceMsgToClient *msg, - void *opaque); - void (*unref_msg_to_client)(SpiceCharDeviceMsgToClient *msg, - void *opaque); - void (*send_msg_to_client)(SpiceCharDeviceMsgToClient *msg, - RedClient *client, - void *opaque); /* after this call, the message is unreferenced */ - - /* The cb is called when a predefined number of write buffers were consumed by the - * device */ - void (*send_tokens_to_client)(RedClient *client, uint32_t tokens, void *opaque); - - /* The cb is called when a server (self) message that was addressed to the device, - * has been completely written to it */ - void (*on_free_self_token)(void *opaque); - - /* This cb is called if it is recommanded that a client will be removed - * due to slow flow or due to some other error. - * The called instance should disconnect the client, or at least the corresponding channel */ - void (*remove_client)(RedClient *client, void *opaque); -}; - void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState *dev, SpiceCharDeviceInstance *sin); void spice_char_device_state_destroy(SpiceCharDeviceState *dev); |