GUACAMOLE-265: Merge connection name update change.

This commit is contained in:
James Muehlner 2017-04-26 21:54:43 -07:00
commit 79b3b1029c
2 changed files with 47 additions and 0 deletions

View File

@ -138,6 +138,19 @@ int guac_terminal_open_pipe_stream(guac_terminal* term, unsigned char c);
*/
int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c);
/**
* Parses the remainder of an OSC sequence setting the window title. The
* window title is everything after the window title sequence begins, up to
* the end of the OSC sequence itself.
*
* @param term
* The terminal that received the given character of data.
*
* @param c
* The character that was received by the given terminal.
*/
int guac_terminal_window_title(guac_terminal* term, unsigned char c);
/**
* Parses the remainder of xterm's OSC sequence for redefining the terminal
* emulator's palette.

View File

@ -1156,6 +1156,36 @@ int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c) {
}
int guac_terminal_window_title(guac_terminal* term, unsigned char c) {
static int position = 0;
static char title[4096];
guac_socket* socket = term->client->socket;
/* Stop on ECMA-48 ST (String Terminator */
if (c == 0x9C || c == 0x5C || c == 0x07) {
/* Terminate and reset stored title */
title[position] = '\0';
position = 0;
/* Send title as connection name */
guac_protocol_send_name(socket, title);
guac_socket_flush(socket);
term->char_handler = guac_terminal_echo;
}
/* Store all other characters within title, space permitting */
else if (position < sizeof(title) - 1)
title[position++] = (char) c;
return 0;
}
int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c) {
/* NOTE: Currently unimplemented. Attempts to set the 256-color palette
@ -1196,6 +1226,10 @@ int guac_terminal_osc(guac_terminal* term, unsigned char c) {
else if (operation == 482203)
term->char_handler = guac_terminal_close_pipe_stream;
/* Set window title OSC */
else if (operation == 0 || operation == 2)
term->char_handler = guac_terminal_window_title;
/* xterm 256-color palette redefinition */
else if (operation == 4)
term->char_handler = guac_terminal_xterm_palette;