GUAC-236: Add screen recording support to telnet.
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/e3d1af19 Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/e3d1af19 Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/e3d1af19 Branch: refs/heads/master Commit: e3d1af1953c238c6add5e44db317607ea5611df4 Parents: 570bcc3 Author: Michael Jumper <[email protected]> Authored: Mon Mar 14 20:26:31 2016 -0700 Committer: Michael Jumper <[email protected]> Committed: Mon Mar 14 20:26:31 2016 -0700 ---------------------------------------------------------------------- src/protocols/telnet/settings.c | 40 ++++++++++++++++++++++++++++++++++++ src/protocols/telnet/settings.h | 22 ++++++++++++++++++++ src/protocols/telnet/telnet.c | 9 ++++++++ 3 files changed, 71 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/e3d1af19/src/protocols/telnet/settings.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/settings.c b/src/protocols/telnet/settings.c index 38fbc22..edb74de 100644 --- a/src/protocols/telnet/settings.c +++ b/src/protocols/telnet/settings.c @@ -46,6 +46,9 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = { "typescript-path", "typescript-name", "create-typescript-path", + "recording-path", + "recording-name", + "create-recording-path", NULL }; @@ -120,6 +123,24 @@ enum TELNET_ARGS_IDX { */ IDX_CREATE_TYPESCRIPT_PATH, + /** + * The full absolute path to the directory in which screen recordings + * should be written. + */ + IDX_RECORDING_PATH, + + /** + * The name that should be given to screen recording which are written in + * the given path. + */ + IDX_RECORDING_NAME, + + /** + * Whether the specified screen recording path should automatically be + * created if it does not yet exist. + */ + IDX_CREATE_RECORDING_PATH, + TELNET_ARGS_COUNT }; @@ -239,6 +260,21 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user, guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv, IDX_CREATE_TYPESCRIPT_PATH, false); + /* Read recording path */ + settings->recording_path = + guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv, + IDX_RECORDING_PATH, NULL); + + /* Read recording name */ + settings->recording_name = + guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv, + IDX_RECORDING_NAME, GUAC_TELNET_DEFAULT_RECORDING_NAME); + + /* Parse path creation flag */ + settings->create_recording_path = + guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv, + IDX_CREATE_RECORDING_PATH, false); + /* Parsing was successful */ return settings; @@ -274,6 +310,10 @@ void guac_telnet_settings_free(guac_telnet_settings* settings) { free(settings->typescript_name); free(settings->typescript_path); + /* Free screen recording settings */ + free(settings->recording_name); + free(settings->recording_path); + /* Free overall structure */ free(settings); http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/e3d1af19/src/protocols/telnet/settings.h ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/settings.h b/src/protocols/telnet/settings.h index 5406220..3bf388d 100644 --- a/src/protocols/telnet/settings.h +++ b/src/protocols/telnet/settings.h @@ -54,6 +54,11 @@ #define GUAC_TELNET_DEFAULT_TYPESCRIPT_NAME "typescript" /** + * The filename to use for the screen recording, if not specified. + */ +#define GUAC_TELNET_DEFAULT_RECORDING_NAME "recording" + +/** * The regular expression to use when searching for the username/login prompt * if no other regular expression is specified. */ @@ -157,6 +162,23 @@ typedef struct guac_telnet_settings { */ bool create_typescript_path; + /** + * The path in which the screen recording should be saved, if enabled. If + * no screen recording should be saved, this will be NULL. + */ + char* recording_path; + + /** + * The filename to use for the screen recording, if enabled. + */ + char* recording_name; + + /** + * Whether the screen recording path should be automatically created if it + * does not already exist. + */ + bool create_recording_path; + } guac_telnet_settings; /** http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/e3d1af19/src/protocols/telnet/telnet.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c index 526000d..7ba0720 100644 --- a/src/protocols/telnet/telnet.c +++ b/src/protocols/telnet/telnet.c @@ -21,6 +21,7 @@ */ #include "config.h" +#include "guac_recording.h" #include "telnet.h" #include "terminal.h" @@ -468,6 +469,14 @@ void* guac_telnet_client_thread(void* data) { char buffer[8192]; int wait_result; + /* Set up screen recording, if requested */ + if (settings->recording_path != NULL) { + guac_common_recording_create(client, + settings->recording_path, + settings->recording_name, + settings->create_recording_path); + } + /* Create terminal */ telnet_client->term = guac_terminal_create(client, settings->font_name, settings->font_size,
