GUAC-447: Implement paste of Unicode text.

This commit is contained in:
Michael Jumper 2014-04-02 15:35:09 -07:00
parent 3f19e2b2bb
commit c180de9444

View File

@ -174,40 +174,45 @@ 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; /* Determine output encoding */
switch (event->format) {
case CB_FORMAT_TEXT:
writer = GUAC_WRITE_CP1252;
break;
case CB_FORMAT_UNICODETEXT:
writer = GUAC_WRITE_UTF16;
break;
default:
guac_client_log_error(client,
"Server requested unsupported clipboard data type");
return;
}
/* Create new data response */ /* Create new data response */
RDP_CB_DATA_RESPONSE_EVENT* data_response = data_response = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
(RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
CliprdrChannel_Class, CliprdrChannel_Class,
CliprdrChannel_DataResponse, CliprdrChannel_DataResponse,
NULL, NULL); NULL, NULL);
/* Set data and length */ /* Set data and size */
if (clipboard != NULL) { data_response->data = (BYTE*) output;
data_response->data = (UINT8*) strdup(clipboard); guac_iconv(GUAC_READ_UTF8, &input, GUAC_RDP_CLIPBOARD_MAX_LENGTH,
data_response->size = strlen(clipboard) + 1; writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH);
} data_response->size = ((BYTE*) output) - data_response->data;
else {
data_response->data = (UINT8*) strdup("");
data_response->size = 1;
}
/* Send response */ /* Send response */
freerdp_channels_send_event(channels, (wMessage*) data_response); freerdp_channels_send_event(channels, (wMessage*) 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, void guac_rdp_process_cb_data_response(guac_client* client,