Repository: incubator-guacamole-server Updated Branches: refs/heads/master d88b5d101 -> 79b3b1029
GUACAMOLE-265: Set connection name when terminal window title is changed. Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/4b7c6798 Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/4b7c6798 Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/4b7c6798 Branch: refs/heads/master Commit: 4b7c679808c7c299f6750802af923d5908e03f5b Parents: d88b5d1 Author: Michael Jumper <[email protected]> Authored: Sun Apr 23 15:13:37 2017 -0700 Committer: Michael Jumper <[email protected]> Committed: Wed Apr 26 21:19:56 2017 -0700 ---------------------------------------------------------------------- src/terminal/terminal/terminal_handlers.h | 13 ++++++++++ src/terminal/terminal_handlers.c | 34 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/4b7c6798/src/terminal/terminal/terminal_handlers.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/terminal_handlers.h b/src/terminal/terminal/terminal_handlers.h index 0a8fdce..0b2f9bb 100644 --- a/src/terminal/terminal/terminal_handlers.h +++ b/src/terminal/terminal/terminal_handlers.h @@ -139,6 +139,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. * http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/4b7c6798/src/terminal/terminal_handlers.c ---------------------------------------------------------------------- diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index 8e83fb1..633798b 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -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;
