[vdagent-linux v2 4/5] virtio: use GObject macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use G_DECLARE_FINAL_TYPE().

Rename
struct vdagent_virtio_port --> VirtioPort

Signed-off-by: Jakub Janků <jjanku@xxxxxxxxxx>
---
 src/vdagentd/vdagentd.c    | 18 +++++++++---------
 src/vdagentd/virtio-port.c | 16 ++++++++--------
 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 0565881..11f77e8 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;
@@ -120,7 +120,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;
@@ -179,7 +179,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;
@@ -210,7 +210,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)
 {
@@ -223,7 +223,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)
 {
@@ -241,7 +241,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;
@@ -295,7 +295,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)
 {
@@ -327,7 +327,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)
 {
@@ -524,7 +524,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 ad9d27b..a415d46 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;
@@ -234,7 +234,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,
@@ -246,7 +246,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");
@@ -261,7 +261,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..cac2a74 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
 
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]