diff options
author | Jakub Janků <jjanku@redhat.com> | 2019-04-30 11:33:38 +0200 |
---|---|---|
committer | Victor Toso <me@victortoso.com> | 2020-03-09 20:12:47 +0100 |
commit | ab7901ced468330a8cb9a3d74cd8f2d2b8e861f1 (patch) | |
tree | b8c4e2ddb7a66fd9f5b0d6769834b534485a1a3f /src | |
parent | 15f710dadee3e2d9e1b889a7e572dea23055748f (diff) |
virtio: use GObject macro
Use G_DECLARE_FINAL_TYPE().
Rename
struct vdagent_virtio_port --> VirtioPort
Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vdagentd/vdagentd.c | 18 | ||||
-rw-r--r-- | src/vdagentd/virtio-port.c | 16 | ||||
-rw-r--r-- | src/vdagentd/virtio-port.h | 31 |
3 files changed, 25 insertions, 40 deletions
diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c index 5c9a332..9b19bd3 100644 --- a/src/vdagentd/vdagentd.c +++ b/src/vdagentd/vdagentd.c @@ -67,7 +67,7 @@ static gboolean do_daemonize = TRUE; static gboolean want_session_info = TRUE; static struct udscs_server *server = NULL; -static struct vdagent_virtio_port *virtio_port = NULL; +static VirtioPort *virtio_port = NULL; static GHashTable *active_xfers = NULL; static struct session_info *session_info = NULL; static struct vdagentd_uinput *uinput = NULL; @@ -121,7 +121,7 @@ static void virtio_msg_uint16_from_le(uint8_t *_msg, uint32_t size, uint32_t off } /* vdagentd <-> spice-client communication handling */ -static void send_capabilities(struct vdagent_virtio_port *vport, +static void send_capabilities(VirtioPort *vport, uint32_t request) { VDAgentAnnounceCapabilities *caps; @@ -182,7 +182,7 @@ void do_client_mouse(struct vdagentd_uinput **uinputp, VDAgentMouseState *mouse) } } -static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr, +static void do_client_monitors(VirtioPort *vport, int port_nr, VDAgentMessage *message_header, VDAgentMonitorsConfig *new_monitors) { VDAgentReply reply; @@ -213,7 +213,7 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr, (uint8_t *)&reply, sizeof(reply)); } -static void do_client_volume_sync(struct vdagent_virtio_port *vport, int port_nr, +static void do_client_volume_sync(VirtioPort *vport, int port_nr, VDAgentMessage *message_header, VDAgentAudioVolumeSync *avs) { @@ -226,7 +226,7 @@ static void do_client_volume_sync(struct vdagent_virtio_port *vport, int port_nr (uint8_t *)avs, message_header->size); } -static void do_client_capabilities(struct vdagent_virtio_port *vport, +static void do_client_capabilities(VirtioPort *vport, VDAgentMessage *message_header, VDAgentAnnounceCapabilities *caps) { @@ -245,7 +245,7 @@ static void do_client_capabilities(struct vdagent_virtio_port *vport, } } -static void do_client_clipboard(struct vdagent_virtio_port *vport, +static void do_client_clipboard(VirtioPort *vport, VDAgentMessage *message_header, uint8_t *data) { uint32_t msg_type = 0, data_type = 0, size = message_header->size; @@ -317,7 +317,7 @@ static void do_client_clipboard(struct vdagent_virtio_port *vport, /* Send file-xfer status to the client. In the case status is an error, * optional data for the client and log message may be specified. */ -static void send_file_xfer_status(struct vdagent_virtio_port *vport, +static void send_file_xfer_status(VirtioPort *vport, const char *msg, uint32_t id, uint32_t xfer_status, const uint8_t *data, uint32_t data_size) { @@ -349,7 +349,7 @@ static void send_file_xfer_status(struct vdagent_virtio_port *vport, g_free(status); } -static void do_client_file_xfer(struct vdagent_virtio_port *vport, +static void do_client_file_xfer(VirtioPort *vport, VDAgentMessage *message_header, uint8_t *data) { @@ -552,7 +552,7 @@ static gboolean vdagent_message_check_size(const VDAgentMessage *message_header) static VDAgentGraphicsDeviceInfo *device_info = NULL; static size_t device_info_size = 0; static void virtio_port_read_complete( - struct vdagent_virtio_port *vport, + VirtioPort *vport, int port_nr, VDAgentMessage *message_header, uint8_t *data) diff --git a/src/vdagentd/virtio-port.c b/src/vdagentd/virtio-port.c index 668870b..3f6c745 100644 --- a/src/vdagentd/virtio-port.c +++ b/src/vdagentd/virtio-port.c @@ -45,7 +45,7 @@ struct vdagent_virtio_port_chunk_port_data { uint8_t *message_data; }; -struct vdagent_virtio_port { +struct _VirtioPort { VDAgentConnection parent_instance; /* Per chunk port data */ @@ -119,11 +119,11 @@ static void virtio_port_class_init(VirtioPortClass *klass) conn_class->handle_message = vdagent_virtio_port_do_chunk; } -struct vdagent_virtio_port *vdagent_virtio_port_create(const char *portname, +VirtioPort *vdagent_virtio_port_create(const char *portname, vdagent_virtio_port_read_callback read_callback, VDAgentConnErrorCb error_cb) { - struct vdagent_virtio_port *vport; + VirtioPort *vport; GIOStream *io_stream; GError *err = NULL; @@ -174,7 +174,7 @@ struct vdagent_virtio_port *vdagent_virtio_port_create(const char *portname, } void vdagent_virtio_port_write_start( - struct vdagent_virtio_port *vport, + VirtioPort *vport, uint32_t port_nr, uint32_t message_type, uint32_t message_opaque, @@ -204,7 +204,7 @@ void vdagent_virtio_port_write_start( new_wbuf->write_pos += sizeof(*message_header); } -int vdagent_virtio_port_write_append(struct vdagent_virtio_port *vport, +int vdagent_virtio_port_write_append(VirtioPort *vport, const uint8_t *data, uint32_t size) { struct vdagent_virtio_port_buf *wbuf; @@ -235,7 +235,7 @@ int vdagent_virtio_port_write_append(struct vdagent_virtio_port *vport, } void vdagent_virtio_port_write( - struct vdagent_virtio_port *vport, + VirtioPort *vport, uint32_t port_nr, uint32_t message_type, uint32_t message_opaque, @@ -247,7 +247,7 @@ void vdagent_virtio_port_write( vdagent_virtio_port_write_append(vport, data, data_size); } -void vdagent_virtio_port_reset(struct vdagent_virtio_port *vport, int port) +void vdagent_virtio_port_reset(VirtioPort *vport, int port) { if (port >= VDP_END_PORT) { syslog(LOG_ERR, "vdagent_virtio_port_reset port out of range"); @@ -262,7 +262,7 @@ static void vdagent_virtio_port_do_chunk(VDAgentConnection *conn, gpointer chunk_data) { int avail, read, pos = 0; - struct vdagent_virtio_port *vport = VIRTIO_PORT(conn); + VirtioPort *vport = VIRTIO_PORT(conn); VDIChunkHeader *chunk_header = header_data; struct vdagent_virtio_port_chunk_port_data *port = &vport->port_data[chunk_header->port]; diff --git a/src/vdagentd/virtio-port.h b/src/vdagentd/virtio-port.h index 32cf8b7..ec2eea7 100644 --- a/src/vdagentd/virtio-port.h +++ b/src/vdagentd/virtio-port.h @@ -29,59 +29,44 @@ G_BEGIN_DECLS -#define VIRTIO_TYPE_PORT (virtio_port_get_type()) -#define VIRTIO_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), VIRTIO_TYPE_PORT, VirtioPort)) -#define VIRTIO_IS_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), VIRTIO_TYPE_PORT)) -#define VIRTIO_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), VIRTIO_TYPE_PORT, VirtioPortClass)) -#define VIRTIO_IS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), VIRTIO_TYPE_PORT)) -#define VIRTIO_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), VIRTIO_TYPE_PORT, VirtioPortClass)) - -typedef struct vdagent_virtio_port VirtioPort; -typedef struct VirtioPortClass VirtioPortClass; - -struct VirtioPortClass { - VDAgentConnectionClass parent_class; -}; - -GType virtio_port_get_type(void); - -struct vdagent_virtio_port; +#define VIRTIO_TYPE_PORT virtio_port_get_type() +G_DECLARE_FINAL_TYPE(VirtioPort, virtio_port, VIRTIO, PORT, VDAgentConnection) /* Callbacks with this type will be called when a complete message has been received. */ typedef void (*vdagent_virtio_port_read_callback)( - struct vdagent_virtio_port *vport, + VirtioPort *vport, int port_nr, VDAgentMessage *message_header, uint8_t *data); /* Create a vdagent virtio port object for port portname */ -struct vdagent_virtio_port *vdagent_virtio_port_create(const char *portname, +VirtioPort *vdagent_virtio_port_create(const char *portname, vdagent_virtio_port_read_callback read_callback, VDAgentConnErrorCb error_cb); /* Queue a message for delivery, either bit by bit, or all at once */ void vdagent_virtio_port_write_start( - struct vdagent_virtio_port *vport, + VirtioPort *vport, uint32_t port_nr, uint32_t message_type, uint32_t message_opaque, uint32_t data_size); int vdagent_virtio_port_write_append( - struct vdagent_virtio_port *vport, + VirtioPort *vport, const uint8_t *data, uint32_t size); void vdagent_virtio_port_write( - struct vdagent_virtio_port *vport, + VirtioPort *vport, uint32_t port_nr, uint32_t message_type, uint32_t message_opaque, const uint8_t *data, uint32_t data_size); -void vdagent_virtio_port_reset(struct vdagent_virtio_port *vport, int port); +void vdagent_virtio_port_reset(VirtioPort *vport, int port); G_END_DECLS |