diff options
author | Hans de Goede <hdegoede@redhat.com> | 2011-03-30 15:52:29 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2011-03-31 13:34:28 +0200 |
commit | 28397955ad6abdf838a145767c71aff5e2667bb9 (patch) | |
tree | 83da26885bc95be6be48cd679286e049d35e7b79 | |
parent | 40396a5a88de0e9f17cf708c2755ec7f049587ac (diff) |
udscs: Allow passing 2 arguments per message type
-rw-r--r-- | udscs.c | 30 | ||||
-rw-r--r-- | udscs.h | 9 | ||||
-rw-r--r-- | vdagent-x11.c | 19 | ||||
-rw-r--r-- | vdagent.c | 4 | ||||
-rw-r--r-- | vdagentd-proto.h | 4 | ||||
-rw-r--r-- | vdagentd.c | 20 |
6 files changed, 45 insertions, 41 deletions
@@ -358,8 +358,8 @@ void udscs_client_handle_fds(struct udscs_connection **connp, fd_set *readfds, udscs_do_write(connp); } -int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t opaque, - const uint8_t *data, uint32_t size) +int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, + uint32_t arg2, const uint8_t *data, uint32_t size) { struct udscs_buf *wbuf, *new_wbuf; struct udscs_message_header header; @@ -378,7 +378,8 @@ int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t opaque, } header.type = type; - header.opaque = opaque; + header.arg1 = arg1; + header.arg2 = arg2; header.size = size; memcpy(new_wbuf->buf, &header, sizeof(header)); @@ -386,12 +387,12 @@ int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t opaque, if (conn->logfile) { if (type < conn->no_types) - fprintf(conn->logfile, "%p sent %s, opaque: %u, size %u\n", - conn, conn->type_to_string[type], opaque, size); + fprintf(conn->logfile, "%p sent %s, arg1: %u, arg2: %u, size %u\n", + conn, conn->type_to_string[type], arg1, arg2, size); else fprintf(conn->logfile, - "%p sent invalid message %u, opaque: %u, size %u\n", - conn, type, opaque, size); + "%p sent invalid message %u, arg1: %u, arg2: %u, size %u\n", + conn, type, arg1, arg2, size); } if (!conn->write_buf) { @@ -410,14 +411,14 @@ int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t opaque, } int udscs_server_write_all(struct udscs_server *server, - uint32_t type, uint32_t opaque, + uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size) { struct udscs_connection *conn; conn = server->connections_head.next; while (conn) { - if (udscs_write(conn, type, opaque, data, size)) + if (udscs_write(conn, type, arg1, arg2, data, size)) return -1; conn = conn->next; } @@ -450,14 +451,15 @@ static void udscs_read_complete(struct udscs_connection **connp) if (conn->logfile) { if (conn->header.type < conn->no_types) - fprintf(conn->logfile, "%p received %s, opaque: %u, size %u\n", + fprintf(conn->logfile, + "%p received %s, arg1: %u, arg2: %u, size %u\n", conn, conn->type_to_string[conn->header.type], - conn->header.opaque, conn->header.size); + conn->header.arg1, conn->header.arg2, conn->header.size); else fprintf(conn->logfile, - "%p received invalid message %u, opaque: %u, size %u\n", - conn, conn->header.type, conn->header.opaque, - conn->header.size); + "%p received invalid message %u, arg1: %u, arg2: %u, size %u\n", + conn, conn->header.type, conn->header.arg1, conn->header.arg2, + conn->header.size); } if (conn->read_callback) { @@ -31,7 +31,8 @@ struct udscs_connection; struct udscs_server; struct udscs_message_header { uint32_t type; - uint32_t opaque; + uint32_t arg1; + uint32_t arg2; uint32_t size; }; @@ -101,13 +102,13 @@ void udscs_client_handle_fds(struct udscs_connection **connp, fd_set *readfds, /* Queue a message for delivery to the client connected through conn. Returns 0 on success -1 on error (only happens when malloc fails) */ -int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t opaque, - const uint8_t *data, uint32_t size); +int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, + uint32_t arg2, const uint8_t *data, uint32_t size); /* Like udscs_write, but then send the message to all clients connected to the server */ int udscs_server_write_all(struct udscs_server *server, - uint32_t type, uint32_t opaque, + uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size); /* Call func for all clients connected to the server, passing through priv to all func calls. Returns the total of the return values from all diff --git a/vdagent-x11.c b/vdagent-x11.c index 728568c..786fa7e 100644 --- a/vdagent-x11.c +++ b/vdagent-x11.c @@ -269,7 +269,7 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11, "client clipboard request pending on clipboard ownership " "change, clearing\n"); udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, - VD_AGENT_CLIPBOARD_NONE, NULL, 0); + VD_AGENT_CLIPBOARD_NONE, 0, NULL, 0); x11->clipboard_request_target = None; } x11->clipboard_data_size = 0; @@ -279,7 +279,8 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11, /* When going from owner_guest to owner_none we need to send a clipboard release message to the client */ if (x11->clipboard_owner == owner_guest) - udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_RELEASE, 0, NULL, 0); + udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_RELEASE, 0, 0, + NULL, 0); x11->clipboard_type_count = 0; } @@ -477,7 +478,7 @@ static void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11) res.width = x11->width; res.height = x11->height; - udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, 0, + udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, 0, 0, (uint8_t *)&res, sizeof(res)); } @@ -706,7 +707,7 @@ static void vdagent_x11_handle_selection_notify(struct vdagent_x11 *x11, len = 0; } - udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, type, data, len); + udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, type, 0, data, len); x11->clipboard_request_target = None; vdagent_x11_get_selection_free(x11, data, incr); } @@ -784,7 +785,7 @@ static void vdagent_x11_handle_targets_notify(struct vdagent_x11 *x11, } if (x11->clipboard_type_count) { - udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_GRAB, 0, + udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_GRAB, 0, 0, (uint8_t *)x11->clipboard_agent_types, x11->clipboard_type_count * sizeof(uint32_t)); vdagent_x11_set_clipboard_owner(x11, owner_guest); @@ -883,7 +884,7 @@ static void vdagent_x11_handle_selection_request(struct vdagent_x11 *x11) return; } - udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_REQUEST, type, NULL, 0); + udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_REQUEST, type, 0, NULL, 0); } static void vdagent_x11_handle_property_delete_notify(struct vdagent_x11 *x11, @@ -999,14 +1000,14 @@ void vdagent_x11_clipboard_request(struct vdagent_x11 *x11, uint32_t type) fprintf(x11->errfile, "received clipboard req while not owning guest clipboard\n"); udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, - VD_AGENT_CLIPBOARD_NONE, NULL, 0); + VD_AGENT_CLIPBOARD_NONE, 0, NULL, 0); return; } target = vdagent_x11_type_to_target(x11, type); if (target == None) { udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, - VD_AGENT_CLIPBOARD_NONE, NULL, 0); + VD_AGENT_CLIPBOARD_NONE, 0, NULL, 0); return; } @@ -1014,7 +1015,7 @@ void vdagent_x11_clipboard_request(struct vdagent_x11 *x11, uint32_t type) fprintf(x11->errfile, "XConvertSelection request is already pending\n"); udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, - VD_AGENT_CLIPBOARD_NONE, NULL, 0); + VD_AGENT_CLIPBOARD_NONE, 0, NULL, 0); return; } x11->clipboard_request_target = target; @@ -50,7 +50,7 @@ void daemon_read_complete(struct udscs_connection **connp, free(data); break; case VDAGENTD_CLIPBOARD_REQUEST: - vdagent_x11_clipboard_request(x11, header->opaque); + vdagent_x11_clipboard_request(x11, header->arg1); free(data); break; case VDAGENTD_CLIPBOARD_GRAB: @@ -59,7 +59,7 @@ void daemon_read_complete(struct udscs_connection **connp, free(data); break; case VDAGENTD_CLIPBOARD_DATA: - vdagent_x11_clipboard_data(x11, header->opaque, data, header->size); + vdagent_x11_clipboard_data(x11, header->arg1, data, header->size); /* vdagent_x11_clipboard_data takes ownership of the data (or frees it immediately) */ break; diff --git a/vdagentd-proto.h b/vdagentd-proto.h index 0f3c478..6636573 100644 --- a/vdagentd-proto.h +++ b/vdagentd-proto.h @@ -30,8 +30,8 @@ enum { VDAGENTD_MONITORS_CONFIG, /* daemon -> client, VDAgentMonitorsConfig followed by num_monitors VDAgentMonConfig-s */ VDAGENTD_CLIPBOARD_GRAB, /* data is array of supported types */ - VDAGENTD_CLIPBOARD_REQUEST, /* opaque = type */ - VDAGENTD_CLIPBOARD_DATA, /* opaque = type, data = data */ + VDAGENTD_CLIPBOARD_REQUEST, /* arg1 = type */ + VDAGENTD_CLIPBOARD_DATA, /* arg1 = type, data = data */ VDAGENTD_CLIPBOARD_RELEASE, /* no data */ VDAGENTD_NO_MESSAGES /* Must always be last */ }; @@ -118,7 +118,7 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr, memcpy(mon_config, new_monitors, size); /* Send monitor config to currently connected agents */ - udscs_server_write_all(server, VDAGENTD_MONITORS_CONFIG, 0, + udscs_server_write_all(server, VDAGENTD_MONITORS_CONFIG, 0, 0, (uint8_t *)mon_config, size); /* Acknowledge reception of monitors config to spice server / client */ @@ -153,7 +153,7 @@ static void do_client_capabilities(struct vdagent_virtio_port *vport, static void do_client_clipboard(struct vdagent_virtio_port *vport, VDAgentMessage *message_header, uint8_t *message_data) { - uint32_t type = 0, opaque = 0, size = 0; + uint32_t type = 0, arg1 = 0, size = 0; uint8_t *data = NULL; if (!active_session_conn) { @@ -173,13 +173,13 @@ static void do_client_clipboard(struct vdagent_virtio_port *vport, case VD_AGENT_CLIPBOARD_REQUEST: { VDAgentClipboardRequest *req = (VDAgentClipboardRequest *)message_data; type = VDAGENTD_CLIPBOARD_REQUEST; - opaque = req->type; + arg1 = req->type; break; } case VD_AGENT_CLIPBOARD: { VDAgentClipboard *clipboard = (VDAgentClipboard *)message_data; type = VDAGENTD_CLIPBOARD_DATA; - opaque = clipboard->type; + arg1 = clipboard->type; size = message_header->size - sizeof(VDAgentClipboard); data = clipboard->data; break; @@ -189,7 +189,7 @@ static void do_client_clipboard(struct vdagent_virtio_port *vport, break; } - udscs_write(active_session_conn, type, opaque, data, size); + udscs_write(active_session_conn, type, arg1, 0, data, size); } int virtio_port_read_complete( @@ -297,7 +297,7 @@ void do_agent_clipboard(struct udscs_connection *conn, agent_owns_clipboard = 1; break; case VDAGENTD_CLIPBOARD_REQUEST: { - VDAgentClipboardRequest req = { .type = header->opaque }; + VDAgentClipboardRequest req = { .type = header->arg1 }; vdagent_virtio_port_write(virtio_port, VDP_CLIENT_PORT, VD_AGENT_CLIPBOARD_REQUEST, 0, (uint8_t *)&req, sizeof(req)); @@ -313,7 +313,7 @@ void do_agent_clipboard(struct udscs_connection *conn, "out of memory allocating clipboard (write)\n"); return; } - clipboard->type = header->opaque; + clipboard->type = header->arg1; memcpy(clipboard->data, data, header->size); vdagent_virtio_port_write(virtio_port, VDP_CLIENT_PORT, @@ -335,7 +335,7 @@ error: if (header->type == VDAGENTD_CLIPBOARD_REQUEST) { /* Let the agent know no answer is coming */ udscs_write(conn, VDAGENTD_CLIPBOARD_DATA, - VD_AGENT_CLIPBOARD_NONE, NULL, 0); + VD_AGENT_CLIPBOARD_NONE, 0, NULL, 0); } } @@ -449,8 +449,8 @@ void agent_connect(struct udscs_connection *conn) update_active_session_connection(); if (mon_config) - udscs_write(conn, VDAGENTD_MONITORS_CONFIG, 0, (uint8_t *)mon_config, - sizeof(VDAgentMonitorsConfig) + + udscs_write(conn, VDAGENTD_MONITORS_CONFIG, 0, 0, + (uint8_t *)mon_config, sizeof(VDAgentMonitorsConfig) + mon_config->num_of_monitors * sizeof(VDAgentMonConfig)); } |