GUAC-608: Migrate RDP to common clipboard code for inbound data.

This commit is contained in:
Michael Jumper 2014-04-08 15:31:56 -07:00
parent 3cf644009f
commit 6743795a68
3 changed files with 33 additions and 26 deletions

View File

@ -465,27 +465,6 @@ int rdp_guac_client_clipboard_handler(guac_client* client, guac_stream* stream,
return guac_rdp_clipboard_handler(client, stream, mimetype); return guac_rdp_clipboard_handler(client, stream, mimetype);
#if 0
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
rdpChannels* channels = client_data->rdp_inst->context->channels;
RDP_CB_FORMAT_LIST_EVENT* format_list =
(RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(
CliprdrChannel_Class,
CliprdrChannel_FormatList,
NULL, NULL);
/* Store data in client */
strncpy(client_data->clipboard, data, GUAC_RDP_CLIPBOARD_MAX_LENGTH);
/* 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, (wMessage*) format_list);
#endif
} }
int rdp_guac_client_file_handler(guac_client* client, guac_stream* stream, int rdp_guac_client_file_handler(guac_client* client, guac_stream* stream,

View File

@ -175,7 +175,7 @@ void guac_rdp_process_cb_data_request(guac_client* client,
rdpChannels* channels = client_data->rdp_inst->context->channels; rdpChannels* channels = client_data->rdp_inst->context->channels;
guac_iconv_write* writer; guac_iconv_write* writer;
char* input = (char*) client_data->clipboard;; char* input = client_data->clipboard->buffer;
char* output = malloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH); char* output = malloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH);
RDP_CB_DATA_RESPONSE_EVENT* data_response; RDP_CB_DATA_RESPONSE_EVENT* data_response;
@ -206,7 +206,7 @@ void guac_rdp_process_cb_data_request(guac_client* client,
/* Set data and size */ /* Set data and size */
data_response->data = (BYTE*) output; data_response->data = (BYTE*) output;
guac_iconv(GUAC_READ_UTF8, &input, GUAC_RDP_CLIPBOARD_MAX_LENGTH, guac_iconv(GUAC_READ_UTF8, &input, client_data->clipboard->length,
writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH); writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH);
data_response->size = ((BYTE*) output) - data_response->data; data_response->size = ((BYTE*) output) - data_response->data;

View File

@ -27,11 +27,18 @@
#include "rdp_svc.h" #include "rdp_svc.h"
#include "rdp_stream.h" #include "rdp_stream.h"
#include <freerdp/channels/channels.h>
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/error.h> #include <guacamole/error.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>
#ifdef HAVE_FREERDP_CLIENT_CLIPRDR_H
#include <freerdp/client/cliprdr.h>
#else
#include "compat/client-cliprdr.h"
#endif
#ifdef ENABLE_WINPR #ifdef ENABLE_WINPR
#include <winpr/wtypes.h> #include <winpr/wtypes.h>
#else #else
@ -146,13 +153,14 @@ int guac_rdp_svc_pipe_handler(guac_client* client, guac_stream* stream,
int guac_rdp_clipboard_handler(guac_client* client, guac_stream* stream, int guac_rdp_clipboard_handler(guac_client* client, guac_stream* stream,
char* mimetype) { char* mimetype) {
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
guac_rdp_stream* rdp_stream; guac_rdp_stream* rdp_stream;
/* Init stream data */ /* Init stream data */
stream->data = rdp_stream = malloc(sizeof(guac_rdp_stream)); stream->data = rdp_stream = malloc(sizeof(guac_rdp_stream));
rdp_stream->type = GUAC_RDP_INBOUND_CLIPBOARD_STREAM; rdp_stream->type = GUAC_RDP_INBOUND_CLIPBOARD_STREAM;
guac_client_log_info(client, "Creating clipboard stream %s", mimetype); guac_common_clipboard_reset(client_data->clipboard, mimetype);
return 0; return 0;
} }
@ -221,7 +229,10 @@ int guac_rdp_svc_blob_handler(guac_client* client, guac_stream* stream,
int guac_rdp_clipboard_blob_handler(guac_client* client, guac_stream* stream, int guac_rdp_clipboard_blob_handler(guac_client* client, guac_stream* stream,
void* data, int length) { void* data, int length) {
guac_client_log_info(client, "Received %i bytes of clipboard data", length);
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
guac_common_clipboard_append(client_data->clipboard, (char*) data, length);
return 0; return 0;
} }
@ -252,7 +263,24 @@ int guac_rdp_upload_end_handler(guac_client* client, guac_stream* stream) {
} }
int guac_rdp_clipboard_end_handler(guac_client* client, guac_stream* stream) { int guac_rdp_clipboard_end_handler(guac_client* client, guac_stream* stream) {
guac_client_log_info(client, "Received end of clipboard data");
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
rdpChannels* channels = client_data->rdp_inst->context->channels;
RDP_CB_FORMAT_LIST_EVENT* format_list =
(RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(
CliprdrChannel_Class,
CliprdrChannel_FormatList,
NULL, NULL);
/* Notify server that text data is now available */
format_list->formats = (UINT32*) malloc(sizeof(UINT32));
format_list->formats[0] = CB_FORMAT_TEXT;
format_list->formats[1] = CB_FORMAT_UNICODETEXT;
format_list->num_formats = 2;
freerdp_channels_send_event(channels, (wMessage*) format_list);
return 0; return 0;
} }