GUAC-447: Implement paste of Unicode text.
This commit is contained in:
parent
3f19e2b2bb
commit
c180de9444
@ -174,39 +174,44 @@ void guac_rdp_process_cb_data_request(guac_client* client,
|
|||||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||||
rdpChannels* channels = client_data->rdp_inst->context->channels;
|
rdpChannels* channels = client_data->rdp_inst->context->channels;
|
||||||
|
|
||||||
/* If text requested, send clipboard text contents */
|
guac_iconv_write* writer;
|
||||||
if (event->format == CB_FORMAT_TEXT) {
|
char* input = (char*) client_data->clipboard;;
|
||||||
|
char* output = malloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH);
|
||||||
|
|
||||||
/* Get clipboard data */
|
RDP_CB_DATA_RESPONSE_EVENT* data_response;
|
||||||
const char* clipboard =
|
|
||||||
((rdp_guac_client_data*) client->data)->clipboard;
|
|
||||||
|
|
||||||
/* Create new data response */
|
/* Determine output encoding */
|
||||||
RDP_CB_DATA_RESPONSE_EVENT* data_response =
|
switch (event->format) {
|
||||||
(RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
|
|
||||||
CliprdrChannel_Class,
|
|
||||||
CliprdrChannel_DataResponse,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
/* Set data and length */
|
case CB_FORMAT_TEXT:
|
||||||
if (clipboard != NULL) {
|
writer = GUAC_WRITE_CP1252;
|
||||||
data_response->data = (UINT8*) strdup(clipboard);
|
break;
|
||||||
data_response->size = strlen(clipboard) + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data_response->data = (UINT8*) strdup("");
|
|
||||||
data_response->size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send response */
|
case CB_FORMAT_UNICODETEXT:
|
||||||
freerdp_channels_send_event(channels, (wMessage*) data_response);
|
writer = GUAC_WRITE_UTF16;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
guac_client_log_error(client,
|
||||||
|
"Server requested unsupported clipboard data type");
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise ... failure */
|
/* Create new data response */
|
||||||
else
|
data_response = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
|
||||||
guac_client_log_error(client,
|
CliprdrChannel_Class,
|
||||||
"Server requested unsupported clipboard data type");
|
CliprdrChannel_DataResponse,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
/* Set data and size */
|
||||||
|
data_response->data = (BYTE*) output;
|
||||||
|
guac_iconv(GUAC_READ_UTF8, &input, GUAC_RDP_CLIPBOARD_MAX_LENGTH,
|
||||||
|
writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH);
|
||||||
|
data_response->size = ((BYTE*) output) - data_response->data;
|
||||||
|
|
||||||
|
/* Send response */
|
||||||
|
freerdp_channels_send_event(channels, (wMessage*) data_response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user