GUAC-614: Migrate RDP to simpler stream API. Add missing linkage to RDP build. Fix last character truncation bug.

This commit is contained in:
Michael Jumper 2014-04-10 14:53:32 -07:00
parent 83093f1bd3
commit 0096cf677c
5 changed files with 18 additions and 118 deletions

View File

@ -45,7 +45,8 @@ libguac_client_rdp_la_SOURCES = \
unicode.c unicode.c
guacsvc_sources = \ guacsvc_sources = \
guac_svc/svc_service.c guac_svc/svc_service.c \
rdp_svc.c
guacsnd_sources = \ guacsnd_sources = \
guac_rdpsnd/rdpsnd_messages.c \ guac_rdpsnd/rdpsnd_messages.c \
@ -61,6 +62,7 @@ guacdr_sources = \
guac_rdpdr/rdpdr_printer.c \ guac_rdpdr/rdpdr_printer.c \
guac_rdpdr/rdpdr_service.c \ guac_rdpdr/rdpdr_service.c \
rdp_fs.c \ rdp_fs.c \
rdp_stream.c \
unicode.c unicode.c
noinst_HEADERS = \ noinst_HEADERS = \
@ -109,7 +111,7 @@ guacsnd_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
guacdr_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@ guacdr_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
libguac_client_rdp_la_LIBADD = @LIBGUAC_LTLIB@ @COMMON_LTLIB@ libguac_client_rdp_la_LIBADD = @LIBGUAC_LTLIB@ @COMMON_LTLIB@
guacsvc_libadd = @LIBGUAC_LTLIB@ guacsvc_libadd = @LIBGUAC_LTLIB@ @COMMON_LTLIB@
guacsnd_libadd = @LIBGUAC_LTLIB@ guacsnd_libadd = @LIBGUAC_LTLIB@
guacdr_libadd = @LIBGUAC_LTLIB@ guacdr_libadd = @LIBGUAC_LTLIB@

View File

@ -33,6 +33,7 @@
#include "rdp_glyph.h" #include "rdp_glyph.h"
#include "rdp_keymap.h" #include "rdp_keymap.h"
#include "rdp_pointer.h" #include "rdp_pointer.h"
#include "rdp_stream.h"
#include "rdp_svc.h" #include "rdp_svc.h"
#include <errno.h> #include <errno.h>
@ -349,14 +350,11 @@ BOOL rdp_freerdp_post_connect(freerdp* instance) {
client->handle_messages = rdp_guac_client_handle_messages; client->handle_messages = rdp_guac_client_handle_messages;
client->mouse_handler = rdp_guac_client_mouse_handler; client->mouse_handler = rdp_guac_client_mouse_handler;
client->key_handler = rdp_guac_client_key_handler; client->key_handler = rdp_guac_client_key_handler;
client->clipboard_handler = rdp_guac_client_clipboard_handler;
/* File transfer handlers */ /* Stream handlers */
client->file_handler = rdp_guac_client_file_handler; client->clipboard_handler = guac_rdp_clipboard_handler;
client->pipe_handler = rdp_guac_client_pipe_handler; client->file_handler = guac_rdp_upload_file_handler;
client->blob_handler = rdp_guac_client_blob_handler; client->pipe_handler = guac_rdp_svc_pipe_handler;
client->end_handler = rdp_guac_client_end_handler;
client->ack_handler = rdp_guac_client_ack_handler;
return TRUE; return TRUE;

View File

@ -461,112 +461,3 @@ int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
} }
int rdp_guac_client_clipboard_handler(guac_client* client, guac_stream* stream,
char* mimetype) {
return guac_rdp_clipboard_handler(client, stream, mimetype);
}
int rdp_guac_client_file_handler(guac_client* client, guac_stream* stream,
char* mimetype, char* filename) {
/* All inbound files are file uploads */
return guac_rdp_upload_file_handler(client, stream, mimetype, filename);
}
int rdp_guac_client_pipe_handler(guac_client* client, guac_stream* stream,
char* mimetype, char* name) {
/* All inbound pipes are SVC-related */
return guac_rdp_svc_pipe_handler(client, stream, mimetype, name);
}
int rdp_guac_client_blob_handler(guac_client* client, guac_stream* stream,
void* data, int length) {
guac_rdp_stream* rdp_stream = (guac_rdp_stream*) stream->data;
/* Handle based on stream type */
switch (rdp_stream->type) {
/* Inbound file stream */
case GUAC_RDP_UPLOAD_STREAM:
return guac_rdp_upload_blob_handler(client, stream, data, length);
/* SVC stream */
case GUAC_RDP_INBOUND_SVC_STREAM:
return guac_rdp_svc_blob_handler(client, stream, data, length);
/* Clipboard stream */
case GUAC_RDP_INBOUND_CLIPBOARD_STREAM:
return guac_rdp_clipboard_blob_handler(client, stream, data, length);
/* Other streams do not accept blobs */
default:
guac_protocol_send_ack(client->socket, stream,
"FAIL (BLOB NOT EXPECTED)",
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
guac_socket_flush(client->socket);
return 0;
}
}
int rdp_guac_client_end_handler(guac_client* client, guac_stream* stream) {
guac_rdp_stream* rdp_stream = (guac_rdp_stream*) stream->data;
/* Handle based on stream type */
switch (rdp_stream->type) {
/* Inbound file stream */
case GUAC_RDP_UPLOAD_STREAM:
return guac_rdp_upload_end_handler(client, stream);
/* Clipboard stream */
case GUAC_RDP_INBOUND_CLIPBOARD_STREAM:
return guac_rdp_clipboard_end_handler(client, stream);
/* Other streams do not accept explicit closure */
default:
guac_protocol_send_ack(client->socket, stream,
"FAIL (END NOT EXPECTED)",
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
guac_socket_flush(client->socket);
return 0;
}
}
int rdp_guac_client_ack_handler(guac_client* client, guac_stream* stream,
char* message, guac_protocol_status status) {
guac_rdp_stream* rdp_stream = (guac_rdp_stream*) stream->data;
/* Ignore acks for non-download stream data */
if (rdp_stream == NULL)
return 0;
/* Handle other acks based on stream type */
switch (rdp_stream->type) {
/* Inbound file stream */
case GUAC_RDP_DOWNLOAD_STREAM:
return guac_rdp_download_ack_handler(
client, stream, message, status);
/* Ignore acks on all other streams */
default:
return 0;
}
}

View File

@ -243,6 +243,7 @@ void guac_rdpdr_start_download(guac_rdpdr_device* device, const char* path) {
/* Associate stream with transfer status */ /* Associate stream with transfer status */
guac_stream* stream = guac_client_alloc_stream(client); guac_stream* stream = guac_client_alloc_stream(client);
stream->data = rdp_stream = malloc(sizeof(guac_rdp_stream)); stream->data = rdp_stream = malloc(sizeof(guac_rdp_stream));
stream->ack_handler = guac_rdp_download_ack_handler;
rdp_stream->type = GUAC_RDP_DOWNLOAD_STREAM; rdp_stream->type = GUAC_RDP_DOWNLOAD_STREAM;
rdp_stream->download_status.file_id = file_id; rdp_stream->download_status.file_id = file_id;
rdp_stream->download_status.offset = 0; rdp_stream->download_status.offset = 0;

View File

@ -112,6 +112,8 @@ int guac_rdp_upload_file_handler(guac_client* client, guac_stream* stream,
rdp_stream->upload_status.offset = 0; rdp_stream->upload_status.offset = 0;
rdp_stream->upload_status.file_id = file_id; rdp_stream->upload_status.file_id = file_id;
stream->data = rdp_stream; stream->data = rdp_stream;
stream->blob_handler = guac_rdp_upload_blob_handler;
stream->end_handler = guac_rdp_upload_end_handler;
guac_protocol_send_ack(client->socket, stream, "OK (STREAM BEGIN)", guac_protocol_send_ack(client->socket, stream, "OK (STREAM BEGIN)",
GUAC_PROTOCOL_STATUS_SUCCESS); GUAC_PROTOCOL_STATUS_SUCCESS);
@ -143,6 +145,7 @@ int guac_rdp_svc_pipe_handler(guac_client* client, guac_stream* 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));
stream->blob_handler = guac_rdp_svc_blob_handler;
rdp_stream->type = GUAC_RDP_INBOUND_SVC_STREAM; rdp_stream->type = GUAC_RDP_INBOUND_SVC_STREAM;
rdp_stream->svc = svc; rdp_stream->svc = svc;
svc->input_pipe = stream; svc->input_pipe = stream;
@ -159,6 +162,8 @@ int guac_rdp_clipboard_handler(guac_client* client, guac_stream* 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));
stream->blob_handler = guac_rdp_clipboard_blob_handler;
stream->end_handler = guac_rdp_clipboard_end_handler;
rdp_stream->type = GUAC_RDP_INBOUND_CLIPBOARD_STREAM; rdp_stream->type = GUAC_RDP_INBOUND_CLIPBOARD_STREAM;
guac_common_clipboard_reset(client_data->clipboard, mimetype); guac_common_clipboard_reset(client_data->clipboard, mimetype);
@ -274,6 +279,9 @@ int guac_rdp_clipboard_end_handler(guac_client* client, guac_stream* stream) {
CliprdrChannel_FormatList, CliprdrChannel_FormatList,
NULL, NULL); NULL, NULL);
/* Terminate clipboard data with NULL */
guac_common_clipboard_append(client_data->clipboard, "", 1);
/* Notify server that text data is now available */ /* Notify server that text data is now available */
format_list->formats = (UINT32*) malloc(sizeof(UINT32)); format_list->formats = (UINT32*) malloc(sizeof(UINT32));
format_list->formats[0] = CB_FORMAT_TEXT; format_list->formats[0] = CB_FORMAT_TEXT;