GUAC-614: Migrate SSH to simpler stream API.

This commit is contained in:
Michael Jumper 2014-04-10 13:47:36 -07:00
parent 18407fdc37
commit 83093f1bd3
5 changed files with 12 additions and 9 deletions

View File

@ -24,6 +24,7 @@
#include "blank.h" #include "blank.h"
#include "client.h" #include "client.h"
#include "clipboard.h"
#include "guac_handlers.h" #include "guac_handlers.h"
#include "ibar.h" #include "ibar.h"
#include "ssh_client.h" #include "ssh_client.h"
@ -202,11 +203,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Set basic handlers */ /* Set basic handlers */
client->handle_messages = ssh_guac_client_handle_messages; 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->key_handler = ssh_guac_client_key_handler;
client->mouse_handler = ssh_guac_client_mouse_handler; client->mouse_handler = ssh_guac_client_mouse_handler;
client->size_handler = ssh_guac_client_size_handler; client->size_handler = ssh_guac_client_size_handler;
client->free_handler = ssh_guac_client_free_handler; client->free_handler = ssh_guac_client_free_handler;
client->clipboard_handler = guac_ssh_clipboard_handler;
/* Start client thread */ /* Start client thread */
if (pthread_create(&(client_data->client_thread), NULL, ssh_client_thread, (void*) client)) { if (pthread_create(&(client_data->client_thread), NULL, ssh_client_thread, (void*) client)) {

View File

@ -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; ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
guac_common_clipboard_reset(client_data->clipboard, mimetype); 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; return 0;
} }

View File

@ -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) { 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; ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;

View File

@ -128,6 +128,10 @@ int guac_sftp_file_handler(guac_client* client, guac_stream* stream,
guac_socket_flush(client->socket); 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 */ /* Store file within stream */
stream->data = file; stream->data = file;
return 0; return 0;
@ -241,6 +245,7 @@ guac_stream* guac_sftp_download_file(guac_client* client,
/* Allocate stream */ /* Allocate stream */
stream = guac_client_alloc_stream(client); stream = guac_client_alloc_stream(client);
stream->ack_handler = guac_sftp_ack_handler;
stream->data = file; stream->data = file;
/* Send stream start, strip name */ /* Send stream start, strip name */

View File

@ -382,11 +382,8 @@ void* ssh_client_thread(void* data) {
return NULL; return NULL;
} }
/* Set file handlers */ /* Set file handler */
client->ack_handler = guac_sftp_ack_handler;
client->file_handler = guac_sftp_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"); guac_client_log_info(client, "SFTP session initialized");