From 83093f1bd37dcf1d94d8f485805815737bbc8162 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 10 Apr 2014 13:47:36 -0700 Subject: [PATCH] GUAC-614: Migrate SSH to simpler stream API. --- src/protocols/ssh/client.c | 3 ++- src/protocols/ssh/clipboard.c | 4 ++++ src/protocols/ssh/guac_handlers.c | 4 ---- src/protocols/ssh/sftp.c | 5 +++++ src/protocols/ssh/ssh_client.c | 5 +---- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c index 90a9dd54..0b5a14f6 100644 --- a/src/protocols/ssh/client.c +++ b/src/protocols/ssh/client.c @@ -24,6 +24,7 @@ #include "blank.h" #include "client.h" +#include "clipboard.h" #include "guac_handlers.h" #include "ibar.h" #include "ssh_client.h" @@ -202,11 +203,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Set basic handlers */ client->handle_messages = ssh_guac_client_handle_messages; - client->clipboard_handler = ssh_guac_client_clipboard_handler; client->key_handler = ssh_guac_client_key_handler; client->mouse_handler = ssh_guac_client_mouse_handler; client->size_handler = ssh_guac_client_size_handler; client->free_handler = ssh_guac_client_free_handler; + client->clipboard_handler = guac_ssh_clipboard_handler; /* Start client thread */ if (pthread_create(&(client_data->client_thread), NULL, ssh_client_thread, (void*) client)) { diff --git a/src/protocols/ssh/clipboard.c b/src/protocols/ssh/clipboard.c index 7edd39ee..fce9d77f 100644 --- a/src/protocols/ssh/clipboard.c +++ b/src/protocols/ssh/clipboard.c @@ -33,6 +33,10 @@ int guac_ssh_clipboard_handler(guac_client* client, guac_stream* stream, ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data; guac_common_clipboard_reset(client_data->clipboard, mimetype); + /* Set handlers for clipboard stream */ + stream->blob_handler = guac_ssh_clipboard_blob_handler; + stream->end_handler = guac_ssh_clipboard_end_handler; + return 0; } diff --git a/src/protocols/ssh/guac_handlers.c b/src/protocols/ssh/guac_handlers.c index 719759d0..f575a425 100644 --- a/src/protocols/ssh/guac_handlers.c +++ b/src/protocols/ssh/guac_handlers.c @@ -103,10 +103,6 @@ int ssh_guac_client_handle_messages(guac_client* client) { } -int ssh_guac_client_clipboard_handler(guac_client* client, guac_stream* stream, char* mimetype) { - return guac_ssh_clipboard_handler(client, stream, mimetype); -} - int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data; diff --git a/src/protocols/ssh/sftp.c b/src/protocols/ssh/sftp.c index da411fee..18c3b407 100644 --- a/src/protocols/ssh/sftp.c +++ b/src/protocols/ssh/sftp.c @@ -128,6 +128,10 @@ int guac_sftp_file_handler(guac_client* client, guac_stream* stream, guac_socket_flush(client->socket); } + /* Set handlers for file stream */ + stream->blob_handler = guac_sftp_blob_handler; + stream->end_handler = guac_sftp_end_handler; + /* Store file within stream */ stream->data = file; return 0; @@ -241,6 +245,7 @@ guac_stream* guac_sftp_download_file(guac_client* client, /* Allocate stream */ stream = guac_client_alloc_stream(client); + stream->ack_handler = guac_sftp_ack_handler; stream->data = file; /* Send stream start, strip name */ diff --git a/src/protocols/ssh/ssh_client.c b/src/protocols/ssh/ssh_client.c index cbf058c0..ecb601b1 100644 --- a/src/protocols/ssh/ssh_client.c +++ b/src/protocols/ssh/ssh_client.c @@ -382,11 +382,8 @@ void* ssh_client_thread(void* data) { return NULL; } - /* Set file handlers */ - client->ack_handler = guac_sftp_ack_handler; + /* Set file handler */ client->file_handler = guac_sftp_file_handler; - client->blob_handler = guac_sftp_blob_handler; - client->end_handler = guac_sftp_end_handler; guac_client_log_info(client, "SFTP session initialized");