mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
server: add discard all option to agent message filter
This commit is contained in:
parent
66cf0e28b3
commit
3accb60240
@ -22,10 +22,12 @@
|
||||
#include "red_common.h"
|
||||
#include "agent-msg-filter.h"
|
||||
|
||||
void agent_msg_filter_init(struct AgentMsgFilter *filter, int copy_paste)
|
||||
void agent_msg_filter_init(struct AgentMsgFilter *filter,
|
||||
int copy_paste, int discard_all)
|
||||
{
|
||||
memset(filter, 0, sizeof(*filter));
|
||||
filter->copy_paste_enabled = copy_paste;
|
||||
filter->discard_all = discard_all;
|
||||
}
|
||||
|
||||
int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
|
||||
@ -61,19 +63,23 @@ data_to_read:
|
||||
return AGENT_MSG_FILTER_PROTO_ERROR;
|
||||
}
|
||||
|
||||
switch (msg_header.type) {
|
||||
case VD_AGENT_CLIPBOARD:
|
||||
case VD_AGENT_CLIPBOARD_GRAB:
|
||||
case VD_AGENT_CLIPBOARD_REQUEST:
|
||||
case VD_AGENT_CLIPBOARD_RELEASE:
|
||||
if (filter->copy_paste_enabled) {
|
||||
if (filter->discard_all) {
|
||||
filter->result = AGENT_MSG_FILTER_DISCARD;
|
||||
} else {
|
||||
switch (msg_header.type) {
|
||||
case VD_AGENT_CLIPBOARD:
|
||||
case VD_AGENT_CLIPBOARD_GRAB:
|
||||
case VD_AGENT_CLIPBOARD_REQUEST:
|
||||
case VD_AGENT_CLIPBOARD_RELEASE:
|
||||
if (filter->copy_paste_enabled) {
|
||||
filter->result = AGENT_MSG_FILTER_OK;
|
||||
} else {
|
||||
filter->result = AGENT_MSG_FILTER_DISCARD;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
filter->result = AGENT_MSG_FILTER_OK;
|
||||
} else {
|
||||
filter->result = AGENT_MSG_FILTER_DISCARD;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
filter->result = AGENT_MSG_FILTER_OK;
|
||||
}
|
||||
|
||||
filter->msg_data_to_read = msg_header.size;
|
||||
|
||||
@ -32,13 +32,14 @@ enum {
|
||||
};
|
||||
|
||||
typedef struct AgentMsgFilter {
|
||||
struct VDAgentMessage msg_header;
|
||||
int msg_data_to_read;
|
||||
int result;
|
||||
int copy_paste_enabled;
|
||||
int discard_all;
|
||||
} AgentMsgFilter;
|
||||
|
||||
void agent_msg_filter_init(struct AgentMsgFilter *filter, int copy_paste);
|
||||
void agent_msg_filter_init(struct AgentMsgFilter *filter,
|
||||
int copy_paste, int discard_all);
|
||||
int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
|
||||
uint8_t *data, uint32_t len);
|
||||
|
||||
|
||||
@ -576,7 +576,7 @@ static void reds_reset_vdp()
|
||||
ring_add(&state->read_bufs, &state->current_read_buf->link);
|
||||
state->current_read_buf = NULL;
|
||||
}
|
||||
agent_msg_filter_init(&state->read_filter, agent_copypaste);
|
||||
agent_msg_filter_init(&state->read_filter, agent_copypaste, FALSE);
|
||||
state->client_agent_started = FALSE;
|
||||
}
|
||||
|
||||
@ -595,7 +595,8 @@ void reds_disconnect()
|
||||
reds->disconnecting = TRUE;
|
||||
reds->link_id = 0;
|
||||
|
||||
agent_msg_filter_init(&reds->agent_state.write_filter, agent_copypaste);
|
||||
agent_msg_filter_init(&reds->agent_state.write_filter, agent_copypaste,
|
||||
FALSE);
|
||||
if (reds->agent_state.connected) {
|
||||
SpiceCharDeviceInterface *sif;
|
||||
sif = SPICE_CONTAINEROF(vdagent->base.sif, SpiceCharDeviceInterface, base);
|
||||
@ -3416,8 +3417,8 @@ static void init_vd_agent_resources()
|
||||
ring_init(&state->internal_bufs);
|
||||
ring_init(&state->write_queue);
|
||||
ring_init(&state->read_bufs);
|
||||
agent_msg_filter_init(&state->write_filter, agent_copypaste);
|
||||
agent_msg_filter_init(&state->read_filter, agent_copypaste);
|
||||
agent_msg_filter_init(&state->write_filter, agent_copypaste, FALSE);
|
||||
agent_msg_filter_init(&state->read_filter, agent_copypaste, FALSE);
|
||||
|
||||
state->read_state = VDI_PORT_READ_STATE_READ_HADER;
|
||||
state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user