You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/04/02 19:20:36 UTC

[03/23] guacamole-server git commit: GUACAMOLE-269: Allow backspace key to be configured.

GUACAMOLE-269: Allow backspace key to be configured.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/46e908c0
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/46e908c0
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/46e908c0

Branch: refs/heads/master
Commit: 46e908c06eae26d419f72bd3bd071287ca4c02f6
Parents: 2ace938
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Feb 23 22:14:11 2018 -0500
Committer: Nick Couchman <vn...@apache.org>
Committed: Thu Mar 8 10:48:21 2018 -0500

----------------------------------------------------------------------
 src/protocols/ssh/settings.c     | 13 +++++++++++++
 src/protocols/ssh/settings.h     |  5 +++++
 src/protocols/ssh/ssh.c          |  2 +-
 src/protocols/telnet/settings.c  | 11 +++++++++++
 src/protocols/telnet/settings.h  |  7 +++++++
 src/protocols/telnet/telnet.c    |  2 +-
 src/terminal/terminal.c          |  9 +++++++--
 src/terminal/terminal/terminal.h | 12 +++++++++++-
 8 files changed, 56 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/ssh/settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c
index 7c803ea..89b6e82 100644
--- a/src/protocols/ssh/settings.c
+++ b/src/protocols/ssh/settings.c
@@ -56,6 +56,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
     "create-recording-path",
     "read-only",
     "server-alive-interval",
+    "backspace",
     NULL
 };
 
@@ -209,6 +210,13 @@ enum SSH_ARGS_IDX {
      */
     IDX_SERVER_ALIVE_INTERVAL,
 
+    /**
+     * The ASCII code, in decimal, to send for the backspace key, as configured
+     * by the SSH connection from the client.  By default this will be 0x7f,
+     * the ASCII DELETE code.
+     */
+    IDX_BACKSPACE,
+
     SSH_ARGS_COUNT
 };
 
@@ -348,6 +356,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
         guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
                 IDX_SERVER_ALIVE_INTERVAL, 0);
 
+    /* Parse backspace key setting */
+    settings->backspace =
+        guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
+                IDX_BACKSPACE, 127);
+
     /* Parsing was successful */
     return settings;
 

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/ssh/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h
index 689d425..65f60fa 100644
--- a/src/protocols/ssh/settings.h
+++ b/src/protocols/ssh/settings.h
@@ -223,6 +223,11 @@ typedef struct guac_ssh_settings {
      */
     int server_alive_interval;
 
+    /**
+     * The decismal ASCII code of the command to send for backspace.
+     */
+    int backspace;
+
 } guac_ssh_settings;
 
 /**

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index 62bfbb2..86ebddb 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -207,7 +207,7 @@ void* ssh_client_thread(void* data) {
     ssh_client->term = guac_terminal_create(client,
             settings->font_name, settings->font_size,
             settings->resolution, settings->width, settings->height,
-            settings->color_scheme);
+            settings->color_scheme, settings->backspace);
 
     /* Fail if terminal init failed */
     if (ssh_client->term == NULL) {

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/telnet/settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/telnet/settings.c b/src/protocols/telnet/settings.c
index 082cff4..acb1f90 100644
--- a/src/protocols/telnet/settings.c
+++ b/src/protocols/telnet/settings.c
@@ -50,6 +50,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
     "recording-include-keys",
     "create-recording-path",
     "read-only",
+    "backspace",
     NULL
 };
 
@@ -174,6 +175,11 @@ enum TELNET_ARGS_IDX {
      */
     IDX_READ_ONLY,
 
+    /**
+     * ASCII code to use for the backspace key, or 127 if not specified.
+     */
+    IDX_BACKSPACE,
+
     TELNET_ARGS_COUNT
 };
 
@@ -328,6 +334,11 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
         guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
                 IDX_CREATE_RECORDING_PATH, false);
 
+    /* Parse backspae key code */
+    settings->backspace =
+        guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
+                IDX_BACKSPACE, 127);
+
     /* Parsing was successful */
     return settings;
 

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/telnet/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/telnet/settings.h b/src/protocols/telnet/settings.h
index 11761c6..71c807a 100644
--- a/src/protocols/telnet/settings.h
+++ b/src/protocols/telnet/settings.h
@@ -207,6 +207,13 @@ typedef struct guac_telnet_settings {
      */
     bool recording_include_keys;
 
+    /**
+     * The ASCII code, in decimal, that the telnet client will use when the
+     * backspace key is pressed.  By default, this is 0x7f, ASCII delete,
+     * but can be configured in the client settings.
+     */
+    int backspace;
+
 } guac_telnet_settings;
 
 /**

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/protocols/telnet/telnet.c
----------------------------------------------------------------------
diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c
index 2a4000d..040d10b 100644
--- a/src/protocols/telnet/telnet.c
+++ b/src/protocols/telnet/telnet.c
@@ -480,7 +480,7 @@ void* guac_telnet_client_thread(void* data) {
     telnet_client->term = guac_terminal_create(client,
             settings->font_name, settings->font_size,
             settings->resolution, settings->width, settings->height,
-            settings->color_scheme);
+            settings->color_scheme, settings->backspace);
 
     /* Fail if terminal init failed */
     if (telnet_client->term == NULL) {

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/terminal/terminal.c
----------------------------------------------------------------------
diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c
index 4d2171a..0dae5cc 100644
--- a/src/terminal/terminal.c
+++ b/src/terminal/terminal.c
@@ -257,7 +257,8 @@ void* guac_terminal_thread(void* data) {
 
 guac_terminal* guac_terminal_create(guac_client* client,
         const char* font_name, int font_size, int dpi,
-        int width, int height, const char* color_scheme) {
+        int width, int height, const char* color_scheme,
+        const int backspace) {
 
     int default_foreground;
     int default_background;
@@ -406,6 +407,10 @@ guac_terminal* guac_terminal_create(guac_client* client,
         return NULL;
     }
 
+    /* Configure backspace */
+    term->backspace = backspace;
+    guac_client_log(client, GUAC_LOG_DEBUG, "Backspace has been set to %d", term->backspace);
+
     return term;
 
 }
@@ -1594,7 +1599,7 @@ static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed
         /* Non-printable keys */
         else {
 
-            if (keysym == 0xFF08) return guac_terminal_send_string(term, "\x7F"); /* Backspace */
+            if (keysym == 0xFF08) return guac_terminal_send_string(term, &term->backspace); /* Backspace */
             if (keysym == 0xFF09 || keysym == 0xFF89) return guac_terminal_send_string(term, "\x09"); /* Tab */
             if (keysym == 0xFF0D || keysym == 0xFF8D) return guac_terminal_send_string(term, "\x0D"); /* Enter */
             if (keysym == 0xFF1B) return guac_terminal_send_string(term, "\x1B"); /* Esc */

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/46e908c0/src/terminal/terminal/terminal.h
----------------------------------------------------------------------
diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h
index 37b0748..90cf06a 100644
--- a/src/terminal/terminal/terminal.h
+++ b/src/terminal/terminal/terminal.h
@@ -432,6 +432,11 @@ struct guac_terminal {
      */
     guac_common_clipboard* clipboard;
 
+    /**
+     * Hexidecimal ASCII code sent when backspace is pressed.
+     */
+    char backspace;
+
 };
 
 /**
@@ -464,13 +469,18 @@ struct guac_terminal {
  *     invalid, a warning will be logged, and the terminal will fall back on
  *     GUAC_TERMINAL_SCHEME_GRAY_BLACK.
  *
+ * @param backspace
+ *     The decimal ASCII code to send when backspace is pressed in
+ *     this terminal.
+ *
  * @return
  *     A new guac_terminal having the given font, dimensions, and attributes
  *     which renders all text to the given client.
  */
 guac_terminal* guac_terminal_create(guac_client* client,
         const char* font_name, int font_size, int dpi,
-        int width, int height, const char* color_scheme);
+        int width, int height, const char* color_scheme,
+        const int backspace);
 
 /**
  * Frees all resources associated with the given terminal.