Read-only mode

This commit is contained in:
Michael Jumper 2011-02-10 22:56:47 -08:00
parent 935d18ba01
commit 6355be0f36

View File

@ -35,6 +35,7 @@
const char* GUAC_CLIENT_ARGS[] = { const char* GUAC_CLIENT_ARGS[] = {
"hostname", "hostname",
"port", "port",
"read-only",
"password", "password",
NULL NULL
}; };
@ -300,22 +301,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
vnc_guac_client_data* guac_client_data; vnc_guac_client_data* guac_client_data;
/*** INIT ***/ int read_only = 0;
rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */
/* Framebuffer update handler */ /*** PARSE ARGUMENTS ***/
rfb_client->GotFrameBufferUpdate = guac_vnc_update;
rfb_client->GotCopyRect = guac_vnc_copyrect;
/* Enable client-side cursor */
rfb_client->GotCursorShape = guac_vnc_cursor;
rfb_client->appData.useRemoteCursor = TRUE;
/* Clipboard */
rfb_client->GotXCutText = guac_vnc_cut_text;
/* Password */
rfb_client->GetPassword = guac_vnc_get_password;
if (argc < 2) { if (argc < 2) {
guac_send_error(client->io, "VNC client requires hostname and port arguments"); guac_send_error(client->io, "VNC client requires hostname and port arguments");
@ -327,15 +315,18 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_client_data = malloc(sizeof(vnc_guac_client_data)); guac_client_data = malloc(sizeof(vnc_guac_client_data));
client->data = guac_client_data; client->data = guac_client_data;
/* Store Guac client in rfb client */ /* If read-only specified, set flag */
rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); if (argc >= 3) {
if (strcmp(argv[2], "true") == 0)
read_only = 1;
}
/* Parse password from args if provided */ /* Parse password from args if provided */
if (argc >= 3) { 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[2], 63); strncpy(guac_client_data->password, argv[3], 63);
} }
else { else {
@ -346,6 +337,30 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
} }
/*** INIT RFB CLIENT ***/
rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */
/* Framebuffer update handler */
rfb_client->GotFrameBufferUpdate = guac_vnc_update;
rfb_client->GotCopyRect = guac_vnc_copyrect;
/* Do not handle clipboard and local cursor if read-only */
if (read_only == 0) {
/* Enable client-side cursor */
rfb_client->GotCursorShape = guac_vnc_cursor;
rfb_client->appData.useRemoteCursor = TRUE;
/* Clipboard */
rfb_client->GotXCutText = guac_vnc_cut_text;
}
/* Password */
rfb_client->GetPassword = guac_vnc_get_password;
/* Store Guac client in rfb client */
rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client);
/* Set hostname and port */ /* Set hostname and port */
rfb_client->serverHost = strdup(argv[0]); rfb_client->serverHost = strdup(argv[0]);
rfb_client->serverPort = atoi(argv[1]); rfb_client->serverPort = atoi(argv[1]);
@ -369,9 +384,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Set handlers */ /* Set handlers */
client->handle_messages = vnc_guac_client_handle_messages; client->handle_messages = vnc_guac_client_handle_messages;
client->mouse_handler = vnc_guac_client_mouse_handler; if (read_only == 0) {
client->key_handler = vnc_guac_client_key_handler; /* Do not handle mouse/keyboard/clipboard if read-only */
client->clipboard_handler = vnc_guac_client_clipboard_handler; client->mouse_handler = vnc_guac_client_mouse_handler;
client->key_handler = vnc_guac_client_key_handler;
client->clipboard_handler = vnc_guac_client_clipboard_handler;
}
/* Send name */ /* Send name */
guac_send_name(client->io, rfb_client->desktopName); guac_send_name(client->io, rfb_client->desktopName);