Support for encodings as an option.

This commit is contained in:
Michael Jumper 2011-03-13 18:58:31 -07:00
parent 555c7b9a97
commit 82fcbe98e5

View File

@ -54,6 +54,7 @@ const char* GUAC_CLIENT_ARGS[] = {
"hostname", "hostname",
"port", "port",
"read-only", "read-only",
"encodings",
"password", "password",
NULL NULL
}; };
@ -71,6 +72,7 @@ typedef struct vnc_guac_client_data {
int copy_rect_used; int copy_rect_used;
char* password; char* password;
char* encodings;
} vnc_guac_client_data; } vnc_guac_client_data;
@ -307,6 +309,10 @@ int vnc_guac_client_free_handler(guac_client* client) {
guac_free_png_buffer(png_buffer, guac_client_data->buffer_height); guac_free_png_buffer(png_buffer, guac_client_data->buffer_height);
guac_free_png_buffer(png_buffer_alpha, guac_client_data->buffer_height); guac_free_png_buffer(png_buffer_alpha, guac_client_data->buffer_height);
/* Free encodings string, if used */
if (guac_client_data->encodings != NULL)
free(guac_client_data->encodings);
/* Free generic data struct */ /* Free generic data struct */
free(client->data); free(client->data);
@ -330,8 +336,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/*** PARSE ARGUMENTS ***/ /*** PARSE ARGUMENTS ***/
if (argc < 2) { if (argc < 5) {
guac_send_error(client->io, "VNC client requires hostname and port arguments"); guac_send_error(client->io, "Wrong argument count received.");
guac_flush(client->io); guac_flush(client->io);
return 1; return 1;
} }
@ -341,27 +347,13 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
client->data = guac_client_data; client->data = guac_client_data;
/* If read-only specified, set flag */ /* If read-only specified, set flag */
if (argc >= 3) {
if (strcmp(argv[2], "true") == 0) if (strcmp(argv[2], "true") == 0)
read_only = 1; read_only = 1;
}
/* Parse password from args if provided */
if (argc >= 4) {
/* Freed after use by libvncclient */ /* Freed after use by libvncclient */
guac_client_data->password = malloc(64); guac_client_data->password = malloc(64);
strncpy(guac_client_data->password, argv[3], 63); strncpy(guac_client_data->password, argv[3], 63);
}
else {
/* Freed after use by libvncclient */
guac_client_data->password = malloc(64);
guac_client_data->password[0] = '\0';
}
/*** INIT RFB CLIENT ***/ /*** INIT RFB CLIENT ***/
rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */ rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */
@ -395,6 +387,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
rfb_client->serverHost = strdup(argv[0]); rfb_client->serverHost = strdup(argv[0]);
rfb_client->serverPort = atoi(argv[1]); rfb_client->serverPort = atoi(argv[1]);
/* Set encodings if specified */
if (argv[3][0] != '\0')
rfb_client->appData.encodingsString = guac_client_data->encodings = strdup(argv[3]);
else
guac_client_data->encodings = NULL;
/* Connect */ /* Connect */
if (!rfbInitClient(rfb_client, NULL, NULL)) { if (!rfbInitClient(rfb_client, NULL, NULL)) {
guac_send_error(client->io, "Error initializing VNC client"); guac_send_error(client->io, "Error initializing VNC client");