From 119b8d4474ab8578101f86226e0d20a53460dd51 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 19 Oct 2022 15:18:14 +0200 Subject: [PATCH] Unified command line options to list something There are various options to list smartcards, monitors, keyboard settings. Unify them all under a single /list: option --- client/X11/xf_monitor.c | 2 +- client/common/cmdline.c | 44 ++++++++++++++++++++++---- client/common/cmdline.h | 20 ++++++++---- client/common/test/TestClientCmdLine.c | 10 ++++++ 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index fb7749421..9ed148417 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -522,7 +522,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) { /* This is the same as when we would trust the Xinerama results.. and set the monitor index to zero. - The monitor listed with /monitor-list on index zero is always the primary + The monitor listed with /list:monitor on index zero is always the primary */ screen = DefaultScreenOfDisplay(xfc->display); monitor_index = XScreenNumberOfScreen(screen); diff --git a/client/common/cmdline.c b/client/common/cmdline.c index c20db6e03..411a0572a 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1527,6 +1527,40 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, { CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL); + arg = CommandLineFindArgumentA(largs, "list"); + WINPR_ASSERT(arg); + + if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) + { + if (_strnicmp("tune", arg->Value, 5) == 0) + freerdp_client_print_tune_list(settings); + else if (_strnicmp("kbd", arg->Value, 4) == 0) + freerdp_client_print_keyboard_list(); + else if (_strnicmp("kbd-lang", arg->Value, 8) == 0) + { + const char* val = NULL; + if (_strnicmp("kbd-lang:", arg->Value, 9) == 0) + val = &arg->Value[9]; + freerdp_client_print_codepages(val); + } + else if (_strnicmp("kbd-scancode", arg->Value, 13) == 0) + freerdp_client_print_scancodes(); + else if (_strnicmp("monitor", arg->Value, 8) == 0) + settings->ListMonitors = TRUE; + else if (_strnicmp("smartcard", arg->Value, 10) == 0) + freerdp_smartcard_list(settings); + else + return COMMAND_LINE_ERROR; + } +#if defined(WITH_FREERDP_DEPRECATED) + arg = CommandLineFindArgumentA(largs, "tune-list"); + WINPR_ASSERT(arg); + + if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) + { + freerdp_client_print_tune_list(settings); + } + arg = CommandLineFindArgumentA(largs, "kbd-lang-list"); WINPR_ASSERT(arg); @@ -1567,6 +1601,7 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, freerdp_client_print_scancodes(); goto out; } +#endif goto out; } else if (status < 0) @@ -2232,7 +2267,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, if (rc == 0) { WLog_ERR(TAG, "Could not identify keyboard layout: %s", arg->Value); - WLog_ERR(TAG, "Use /kbd-list to list available layouts"); + WLog_ERR(TAG, "Use /list:kbd to list available layouts"); return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } @@ -2255,7 +2290,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, if (!value_to_int(arg->Value, &val, 1, UINT32_MAX)) { WLog_ERR(TAG, "Could not identify keyboard active language %s", arg->Value); - WLog_ERR(TAG, "Use /kbd-lang-list to list available layouts"); + WLog_ERR(TAG, "Use /list:kbd-lang to list available layouts"); return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } @@ -3602,11 +3637,6 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, free(ptr.p); } - CommandLineSwitchCase(arg, "tune-list") - { - freerdp_client_print_tune_list(settings); - return COMMAND_LINE_STATUS_PRINT; - } CommandLineSwitchDefault(arg) { } diff --git a/client/common/cmdline.h b/client/common/cmdline.h index 8a4c06ee2..6ffd84954 100644 --- a/client/common/cmdline.h +++ b/client/common/cmdline.h @@ -215,12 +215,14 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { "Keyboard active language identifier" }, { "kbd-fn-key", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Function key value" }, +#if defined(WITH_FREERDP_DEPRECATED) { "kbd-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "List keyboard layouts" }, + "[deprecated use /list:kbd instead] List keyboard layouts" }, { "kbd-scancode-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "List keyboard RDP scancodes" }, + "[deprecated use list:kbd-scancode instead] List keyboard RDP scancodes" }, { "kbd-lang-list", COMMAND_LINE_VALUE_OPTIONAL | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "List keyboard languages" }, + "[deprecated use /list:kbd-lang instead] List keyboard languages" }, +#endif { "kbd-remap", COMMAND_LINE_VALUE_REQUIRED, "List of =,... pairs to remap scancodes", NULL, NULL, -1, NULL, "Keyboard scancode remapping" }, @@ -236,6 +238,8 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { NULL, NULL, -1, NULL, "Kerberos options" }, { "load-balance-info", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Load balance info" }, + { "list", COMMAND_LINE_VALUE_REQUIRED | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, + "[kbd|kbd-scancode|kbd-lang|smartcard|monitor|tune]" }, { "log-filters", COMMAND_LINE_VALUE_REQUIRED, ":[,:[,...]]", NULL, NULL, -1, NULL, "Set logger filters, see wLog(7) for details" }, { "log-level", COMMAND_LINE_VALUE_REQUIRED, "[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]", NULL, @@ -249,10 +253,12 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { { "microphone", COMMAND_LINE_VALUE_OPTIONAL, "[sys:,][dev:,][format:,][rate:,][channel:]", NULL, NULL, -1, "mic", "Audio input (microphone)" }, +#if defined(WITH_FREERDP_DEPRECATED) { "smartcard-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "List smartcard informations" }, + "[deprecated use /list:smartcard instead] List smartcard informations" }, { "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "List detected monitors" }, + "[deprecated use /list:monitor instead] List detected monitors" }, +#endif { "monitors", COMMAND_LINE_VALUE_REQUIRED, "[,[,...]]", NULL, NULL, -1, NULL, "Select monitors to use" }, { "mouse-motion", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, @@ -401,8 +407,10 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { "Alt+Ctrl+Enter to toggle fullscreen" }, { "tune", COMMAND_LINE_VALUE_REQUIRED, ",", "", NULL, -1, NULL, "[experimental] directly manipulate freerdp settings, use with extreme caution!" }, +#if defined(WITH_FREERDP_DEPRECATED) { "tune-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, - "Print options allowed for /tune" }, + "[deprecated use /list:tune instead] Print options allowed for /tune" }, +#endif { "u", COMMAND_LINE_VALUE_REQUIRED, "[[\\]|[@]]", NULL, NULL, -1, NULL, "Username" }, { "unmap-buttons", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index 03e61f865..b74f8ab03 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -174,6 +174,7 @@ static const test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "--invalid", 0 }, { { 0 } } }, +#if defined(WITH_FREERDP_DEPRECATED) { COMMAND_LINE_STATUS_PRINT, check_settings_smartcard_no_redirection, { "testfreerdp", "/kbd-list", 0 }, @@ -182,6 +183,15 @@ static const test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "/monitor-list", 0 }, { { 0 } } }, +#endif + { COMMAND_LINE_STATUS_PRINT, + check_settings_smartcard_no_redirection, + { "testfreerdp", "/list:kbd", 0 }, + { { 0 } } }, + { COMMAND_LINE_STATUS_PRINT, + check_settings_smartcard_no_redirection, + { "testfreerdp", "/list:monitor", 0 }, + { { 0 } } }, { COMMAND_LINE_ERROR, check_settings_smartcard_no_redirection, { "testfreerdp", "/sound", "/drive:media:" DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0 },