Write support in clipboard.
This commit is contained in:
parent
61ee76bf16
commit
11303e0813
@ -44,6 +44,7 @@ int rdp_guac_client_free_handler(guac_client* client);
|
||||
int rdp_guac_client_handle_messages(guac_client* client);
|
||||
int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask);
|
||||
int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed);
|
||||
int rdp_guac_client_clipboard_handler(guac_client* client, char* data);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -46,7 +46,9 @@ void guac_rdp_process_cb_monitor_ready(guac_client* client, RDP_EVENT* event);
|
||||
void guac_rdp_process_cb_format_list(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_request(guac_client* client,
|
||||
RDP_CB_DATA_REQUEST_EVENT* event);
|
||||
|
||||
void guac_rdp_process_cb_data_response(guac_client* client,
|
||||
RDP_CB_DATA_RESPONSE_EVENT* event);
|
||||
|
||||
|
@ -199,6 +199,7 @@ boolean rdp_freerdp_post_connect(freerdp* instance) {
|
||||
client->handle_messages = rdp_guac_client_handle_messages;
|
||||
client->mouse_handler = rdp_guac_client_mouse_handler;
|
||||
client->key_handler = rdp_guac_client_key_handler;
|
||||
client->clipboard_handler = rdp_guac_client_clipboard_handler;
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -409,3 +409,28 @@ int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
|
||||
|
||||
}
|
||||
|
||||
int rdp_guac_client_clipboard_handler(guac_client* client, char* data) {
|
||||
|
||||
rdpChannels* channels =
|
||||
((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;
|
||||
|
||||
RDP_CB_FORMAT_LIST_EVENT* format_list =
|
||||
(RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(
|
||||
RDP_EVENT_CLASS_CLIPRDR,
|
||||
RDP_EVENT_TYPE_CB_FORMAT_LIST,
|
||||
NULL, NULL);
|
||||
|
||||
/* Store data in client */
|
||||
((rdp_guac_client_data*) client->data)->clipboard = strdup(data);
|
||||
|
||||
/* Notify server that text data is now available */
|
||||
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);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event) {
|
||||
break;
|
||||
|
||||
case RDP_EVENT_TYPE_CB_DATA_REQUEST:
|
||||
guac_rdp_process_cb_data_request(client, event);
|
||||
guac_rdp_process_cb_data_request(client,
|
||||
(RDP_CB_DATA_REQUEST_EVENT*) event);
|
||||
break;
|
||||
|
||||
case RDP_EVENT_TYPE_CB_DATA_RESPONSE:
|
||||
@ -135,9 +136,40 @@ void guac_rdp_process_cb_format_list(guac_client* client,
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_process_cb_data_request(guac_client* client, RDP_EVENT* event) {
|
||||
/* STUB */
|
||||
guac_client_log_info(client, "data_request");
|
||||
void guac_rdp_process_cb_data_request(guac_client* client,
|
||||
RDP_CB_DATA_REQUEST_EVENT* event) {
|
||||
|
||||
rdpChannels* channels =
|
||||
((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;
|
||||
|
||||
/* If text requested, send clipboard text contents */
|
||||
if (event->format == CB_FORMAT_TEXT) {
|
||||
|
||||
/* Get clipboard data */
|
||||
const char* clipboard =
|
||||
((rdp_guac_client_data*) client->data)->clipboard;
|
||||
|
||||
/* Create new data response */
|
||||
RDP_CB_DATA_RESPONSE_EVENT* data_response =
|
||||
(RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
|
||||
RDP_EVENT_CLASS_CLIPRDR,
|
||||
RDP_EVENT_TYPE_CB_DATA_RESPONSE,
|
||||
NULL, NULL);
|
||||
|
||||
/* Set data and length */
|
||||
data_response->data = (uint8*) strdup(clipboard);
|
||||
data_response->size = strlen(clipboard) + 1;
|
||||
|
||||
/* Send response */
|
||||
freerdp_channels_send_event(channels, (RDP_EVENT*) data_response);
|
||||
|
||||
}
|
||||
|
||||
/* Otherwise ... failure */
|
||||
else
|
||||
guac_client_log_error(client,
|
||||
"Server requested unsupported clipboard data type");
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_process_cb_data_response(guac_client* client,
|
||||
|
Loading…
Reference in New Issue
Block a user