diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-11-14 16:50:07 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2014-01-31 12:46:22 +0100 |
commit | ae17559dd08f5ec174fc17d23646c174ac8f6dcf (patch) | |
tree | 080364bc4f34dc4cb91c1a7e2151aa831ed4d496 | |
parent | 29022fdc3b70d9cd4a89d5505be989b94aa466b3 (diff) | |
download | vd_agent-ae17559dd08f5ec174fc17d23646c174ac8f6dcf.tar.gz vd_agent-ae17559dd08f5ec174fc17d23646c174ac8f6dcf.tar.xz vd_agent-ae17559dd08f5ec174fc17d23646c174ac8f6dcf.zip |
Add a virtio_write_clipboard() function
Make it easier later to send customized clipboard message
-rw-r--r-- | src/vdagentd.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/src/vdagentd.c b/src/vdagentd.c index cfb7acc..eed183b 100644 --- a/src/vdagentd.c +++ b/src/vdagentd.c @@ -382,6 +382,34 @@ size_error: return 0; } +static void virtio_write_clipboard(uint8_t selection, uint32_t msg_type, + uint32_t data_type, const uint8_t *data, uint32_t data_size) +{ + uint32_t size = data_size; + + if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size, + VD_AGENT_CAP_CLIPBOARD_SELECTION)) { + size += 4; + } + if (data_type != -1) { + size += 4; + } + + vdagent_virtio_port_write_start(virtio_port, VDP_CLIENT_PORT, msg_type, + 0, size); + + if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size, + VD_AGENT_CAP_CLIPBOARD_SELECTION)) { + uint8_t sel[4] = { selection, 0, 0, 0 }; + vdagent_virtio_port_write_append(virtio_port, sel, 4); + } + if (data_type != -1) { + vdagent_virtio_port_write_append(virtio_port, (uint8_t*)&data_type, 4); + } + + vdagent_virtio_port_write_append(virtio_port, data, data_size); +} + /* vdagentd <-> vdagent communication handling */ int do_agent_clipboard(struct udscs_connection *conn, struct udscs_message_header *header, const uint8_t *data) @@ -439,27 +467,7 @@ int do_agent_clipboard(struct udscs_connection *conn, return -1; } - if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size, - VD_AGENT_CAP_CLIPBOARD_SELECTION)) { - size += 4; - } - if (data_type != -1) { - size += 4; - } - - vdagent_virtio_port_write_start(virtio_port, VDP_CLIENT_PORT, msg_type, - 0, size); - - if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size, - VD_AGENT_CAP_CLIPBOARD_SELECTION)) { - uint8_t sel[4] = { selection, 0, 0, 0 }; - vdagent_virtio_port_write_append(virtio_port, sel, 4); - } - if (data_type != -1) { - vdagent_virtio_port_write_append(virtio_port, (uint8_t*)&data_type, 4); - } - - vdagent_virtio_port_write_append(virtio_port, data, header->size); + virtio_write_clipboard(selection, msg_type, data_type, data, header->size); return 0; |