From c57abf34111054bba946944e29d3fa42cd19ba48 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 20 Sep 2015 16:15:13 -0700 Subject: [PATCH] GUAC-1305: Add image mimetypes to Guacamole protocol handshake. --- src/guacd/daemon.c | 23 +++++++++++++++++++++++ src/libguac/guacamole/client.h | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c index 8a189b6a..89c607f9 100644 --- a/src/guacd/daemon.c +++ b/src/guacd/daemon.c @@ -91,6 +91,7 @@ static void guacd_handle_connection(guacd_client_map* map, guac_socket* socket) guac_instruction* size; guac_instruction* audio; guac_instruction* video; + guac_instruction* image; guac_instruction* connect; int init_result; @@ -205,6 +206,20 @@ static void guacd_handle_connection(guacd_client_map* map, guac_socket* socket) return; } + /* Get supported image formats */ + image = guac_instruction_expect( + socket, GUACD_USEC_TIMEOUT, "image"); + if (image == NULL) { + + /* Log error */ + guacd_log_handshake_failure(); + guacd_log_guac_error(GUAC_LOG_DEBUG, "Error reading \"image\""); + + /* Free resources */ + guac_socket_free(socket); + return; + } + /* Get args from connect instruction */ connect = guac_instruction_expect( socket, GUACD_USEC_TIMEOUT, "connect"); @@ -257,6 +272,12 @@ static void guacd_handle_connection(guacd_client_map* map, guac_socket* socket) sizeof(char*) * video->argc); client->info.video_mimetypes[video->argc] = NULL; + /* Store image mimetypes */ + client->info.image_mimetypes = malloc(sizeof(char*) * (image->argc+1)); + memcpy(client->info.image_mimetypes, image->argv, + sizeof(char*) * image->argc); + client->info.image_mimetypes[image->argc] = NULL; + /* Store client */ if (guacd_client_map_add(map, client)) guacd_log(GUAC_LOG_ERROR, "Unable to add client. Internal client storage has failed"); @@ -300,10 +321,12 @@ static void guacd_handle_connection(guacd_client_map* map, guac_socket* socket) /* Free mimetype lists */ free(client->info.audio_mimetypes); free(client->info.video_mimetypes); + free(client->info.image_mimetypes); /* Free remaining instructions */ guac_instruction_free(audio); guac_instruction_free(video); + guac_instruction_free(image); guac_instruction_free(size); /* Clean up */ diff --git a/src/libguac/guacamole/client.h b/src/libguac/guacamole/client.h index 3aabf2af..27bb7901 100644 --- a/src/libguac/guacamole/client.h +++ b/src/libguac/guacamole/client.h @@ -73,6 +73,13 @@ struct guac_client_info { */ const char** video_mimetypes; + /** + * NULL-terminated array of client-supported image mimetypes. Though all + * supported image mimetypes will be listed here, it can be safely assumed + * that all clients will support at least "image/png" and "image/jpeg". + */ + const char** image_mimetypes; + /** * The DPI of the physical remote display if configured for the optimal * width/height combination described here. This need not be honored by