Read support for clipboard.
This commit is contained in:
parent
e691bfb51b
commit
f57e4f05ab
@ -41,10 +41,14 @@
|
|||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
|
|
||||||
void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event);
|
void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event);
|
||||||
void guac_rdp_process_cb_monitor_ready(guac_client* client);
|
void guac_rdp_process_cb_monitor_ready(guac_client* client, RDP_EVENT* event);
|
||||||
void guac_rdp_process_cb_format_list(guac_client* client);
|
|
||||||
void guac_rdp_process_cb_data_request(guac_client* client);
|
void guac_rdp_process_cb_format_list(guac_client* client,
|
||||||
void guac_rdp_process_cb_data_response(guac_client* client);
|
RDP_CB_FORMAT_LIST_EVENT* event);
|
||||||
|
|
||||||
|
void guac_rdp_process_cb_data_request(guac_client* client, RDP_EVENT* event);
|
||||||
|
void guac_rdp_process_cb_data_response(guac_client* client,
|
||||||
|
RDP_CB_DATA_RESPONSE_EVENT* event);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -51,19 +51,21 @@ void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event) {
|
|||||||
switch (event->event_type) {
|
switch (event->event_type) {
|
||||||
|
|
||||||
case RDP_EVENT_TYPE_CB_MONITOR_READY:
|
case RDP_EVENT_TYPE_CB_MONITOR_READY:
|
||||||
guac_rdp_process_cb_monitor_ready(client);
|
guac_rdp_process_cb_monitor_ready(client, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RDP_EVENT_TYPE_CB_FORMAT_LIST:
|
case RDP_EVENT_TYPE_CB_FORMAT_LIST:
|
||||||
guac_rdp_process_cb_format_list(client);
|
guac_rdp_process_cb_format_list(client,
|
||||||
|
(RDP_CB_FORMAT_LIST_EVENT*) event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RDP_EVENT_TYPE_CB_DATA_REQUEST:
|
case RDP_EVENT_TYPE_CB_DATA_REQUEST:
|
||||||
guac_rdp_process_cb_data_request(client);
|
guac_rdp_process_cb_data_request(client, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RDP_EVENT_TYPE_CB_DATA_RESPONSE:
|
case RDP_EVENT_TYPE_CB_DATA_RESPONSE:
|
||||||
guac_rdp_process_cb_data_response(client);
|
guac_rdp_process_cb_data_response(client,
|
||||||
|
(RDP_CB_DATA_RESPONSE_EVENT*) event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -74,31 +76,79 @@ void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdp_process_cb_monitor_ready(guac_client* client) {
|
void guac_rdp_process_cb_monitor_ready(guac_client* client, RDP_EVENT* event) {
|
||||||
|
|
||||||
rdpChannels* channels =
|
rdpChannels* channels =
|
||||||
((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;
|
((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;
|
||||||
|
|
||||||
RDP_EVENT* event = freerdp_event_new(
|
RDP_CB_FORMAT_LIST_EVENT* format_list =
|
||||||
|
(RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(
|
||||||
RDP_EVENT_CLASS_CLIPRDR,
|
RDP_EVENT_CLASS_CLIPRDR,
|
||||||
RDP_EVENT_TYPE_CB_FORMAT_LIST,
|
RDP_EVENT_TYPE_CB_FORMAT_LIST,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
((RDP_CB_FORMAT_LIST_EVENT*) event)->num_formats = 0;
|
/* Received notification of clipboard support. */
|
||||||
|
|
||||||
freerdp_channels_send_event(channels, event);
|
/* Respond with supported format list */
|
||||||
|
format_list->formats = (uint32*) malloc(sizeof(uint32));
|
||||||
|
format_list->formats[0] = CB_FORMAT_TEXT;
|
||||||
|
format_list->num_formats = 1;
|
||||||
|
|
||||||
|
freerdp_channels_send_event(channels, (RDP_EVENT*) format_list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdp_process_cb_format_list(guac_client* client) {
|
void guac_rdp_process_cb_format_list(guac_client* client,
|
||||||
|
RDP_CB_FORMAT_LIST_EVENT* event) {
|
||||||
|
|
||||||
|
rdpChannels* channels =
|
||||||
|
((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;
|
||||||
|
|
||||||
|
/* Received notification of available data */
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i=0; i<event->num_formats; i++) {
|
||||||
|
|
||||||
|
/* If plain text available, request it */
|
||||||
|
if (event->formats[i] == CB_FORMAT_TEXT) {
|
||||||
|
|
||||||
|
/* Create new data request */
|
||||||
|
RDP_CB_DATA_REQUEST_EVENT* data_request =
|
||||||
|
(RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(
|
||||||
|
RDP_EVENT_CLASS_CLIPRDR,
|
||||||
|
RDP_EVENT_TYPE_CB_DATA_REQUEST,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
/* We want plain text */
|
||||||
|
data_request->format = CB_FORMAT_TEXT;
|
||||||
|
|
||||||
|
/* Send request */
|
||||||
|
freerdp_channels_send_event(channels, (RDP_EVENT*) data_request);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, no supported data available */
|
||||||
|
guac_client_log_info(client, "Ignoring unsupported clipboard data");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void guac_rdp_process_cb_data_request(guac_client* client, RDP_EVENT* event) {
|
||||||
/* STUB */
|
/* STUB */
|
||||||
|
guac_client_log_info(client, "data_request");
|
||||||
}
|
}
|
||||||
|
|
||||||
void guac_rdp_process_cb_data_request(guac_client* client) {
|
void guac_rdp_process_cb_data_response(guac_client* client,
|
||||||
/* STUB */
|
RDP_CB_DATA_RESPONSE_EVENT* event) {
|
||||||
}
|
|
||||||
|
/* Received clipboard data */
|
||||||
void guac_rdp_process_cb_data_response(guac_client* client) {
|
if (event->data[event->size - 1] == '\0')
|
||||||
/* STUB */
|
guac_protocol_send_clipboard(client->socket, (char*) event->data);
|
||||||
|
else
|
||||||
|
guac_client_log_error(client,
|
||||||
|
"Clipboard data missing null terminator");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user