Unified command line options to list something

There are various options to list smartcards, monitors, keyboard
settings. Unify them all under a single /list:<something> option
This commit is contained in:
Armin Novak 2022-10-19 15:18:14 +02:00 committed by akallabeth
parent 7e82c9f19f
commit 119b8d4474
4 changed files with 62 additions and 14 deletions

View File

@ -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);

View File

@ -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)
{
}

View File

@ -215,12 +215,14 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = {
"Keyboard active language identifier" },
{ "kbd-fn-key", COMMAND_LINE_VALUE_REQUIRED, "<value>", 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 <key>=<value>,... 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, "<info-string>", 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, "<tag>:<level>[,<tag>:<level>[,...]]", 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:<sys>,][dev:<dev>,][format:<format>,][rate:<rate>,][channel:<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, "<id>[,<id>[,...]]", 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, "<setting:value>,<setting:value>", "", 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, "[[<domain>\\]<user>|<user>[@<domain>]]", NULL, NULL, -1,
NULL, "Username" },
{ "unmap-buttons", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,

View File

@ -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 },