2011-08-07 09:52:40 -04:00
|
|
|
/**
|
2012-10-08 23:02:04 -04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-07 09:52:40 -04:00
|
|
|
* X11 Client
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2012-06-13 14:45:58 -05:00
|
|
|
* Copyright 2012 HP Development Company, LLC
|
2011-08-07 09:52:40 -04:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-16 11:20:38 +01:00
|
|
|
#include <freerdp/config.h>
|
2012-08-14 17:20:53 -04:00
|
|
|
|
2013-04-02 13:22:59 -04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
#include <winpr/synch.h>
|
|
|
|
|
#include <winpr/thread.h>
|
2012-11-21 21:22:06 -05:00
|
|
|
|
2021-09-23 14:52:03 +02:00
|
|
|
#include <freerdp/streamdump.h>
|
2013-04-02 13:22:59 -04:00
|
|
|
#include <freerdp/freerdp.h>
|
2013-06-15 15:13:38 -04:00
|
|
|
#include <freerdp/client/cmdline.h>
|
2012-09-18 19:40:54 -04:00
|
|
|
|
2016-05-03 10:44:42 +02:00
|
|
|
#include "../xf_client.h"
|
|
|
|
|
#include "../xfreerdp.h"
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2024-03-11 10:24:04 +01:00
|
|
|
static void xfreerdp_print_help(void)
|
|
|
|
|
{
|
|
|
|
|
printf("Keyboard Shortcuts:\n");
|
|
|
|
|
printf("\t<Right CTRL>\n");
|
|
|
|
|
printf("\t\treleases keyboard and mouse grab\n");
|
|
|
|
|
printf("\t<CTRL>+<ALT>+<Return>\n");
|
|
|
|
|
printf("\t\ttoggles fullscreen state of the application\n");
|
|
|
|
|
printf("\t<CTRL>+<ALT>+c\n");
|
|
|
|
|
printf("\t\ttoggles remote control in a remote assistance session\n");
|
2024-09-10 11:52:15 +02:00
|
|
|
printf("\t<CTRL>+<ALT>+m\n");
|
|
|
|
|
printf("\t\tminimizes the application\n");
|
2024-03-11 10:24:04 +01:00
|
|
|
printf("\tAction Script\n");
|
|
|
|
|
printf("\t\tExecutes a predefined script on key press.\n");
|
|
|
|
|
printf("\t\tShould the script not exist it is ignored.\n");
|
2024-07-10 07:09:32 +02:00
|
|
|
printf("\t\tScripts can be provided at the default location ~/.config/freerdp/action.sh or as "
|
2024-03-11 10:24:04 +01:00
|
|
|
"command line argument /action:script:<path>\n");
|
|
|
|
|
printf("\t\tThe script will receive the current key combination as argument.\n");
|
|
|
|
|
printf("\t\tThe output of the script is parsed for 'key-local' which tells that the script "
|
|
|
|
|
"used the key combination, otherwise the combination is forwarded to the remote.\n");
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-07 09:52:40 -04:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
2021-01-22 09:44:55 +01:00
|
|
|
int rc = 1;
|
2024-01-23 16:49:54 +01:00
|
|
|
int status = 0;
|
2026-02-26 14:35:00 +01:00
|
|
|
HANDLE thread = nullptr;
|
|
|
|
|
xfContext* xfc = nullptr;
|
2024-01-23 16:49:54 +01:00
|
|
|
DWORD dwExitCode = 0;
|
2026-02-26 14:35:00 +01:00
|
|
|
rdpContext* context = nullptr;
|
|
|
|
|
rdpSettings* settings = nullptr;
|
2026-02-24 20:18:25 +01:00
|
|
|
RDP_CLIENT_ENTRY_POINTS clientEntryPoints = WINPR_C_ARRAY_INIT;
|
2013-06-13 20:25:50 -04:00
|
|
|
|
|
|
|
|
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
|
|
|
|
|
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
|
|
|
|
|
|
|
|
|
|
RdpClientEntry(&clientEntryPoints);
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2013-06-13 22:11:23 -04:00
|
|
|
context = freerdp_client_context_new(&clientEntryPoints);
|
2015-03-23 17:25:23 +01:00
|
|
|
if (!context)
|
2018-04-03 12:55:17 +02:00
|
|
|
return 1;
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2013-06-13 21:34:46 -04:00
|
|
|
settings = context->settings;
|
2019-11-06 15:24:51 +01:00
|
|
|
xfc = (xfContext*)context;
|
2013-04-17 03:03:31 +02:00
|
|
|
|
2015-03-16 10:15:37 +01:00
|
|
|
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
|
2013-06-15 15:13:38 -04:00
|
|
|
if (status)
|
2013-06-13 21:34:46 -04:00
|
|
|
{
|
2021-01-22 09:44:55 +01:00
|
|
|
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
|
|
|
|
|
2023-10-13 09:48:44 +02:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
|
2013-06-15 15:13:38 -04:00
|
|
|
xf_list_monitors(xfc);
|
2024-10-23 16:32:14 +02:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (status)
|
|
|
|
|
{
|
|
|
|
|
case COMMAND_LINE_STATUS_PRINT:
|
|
|
|
|
case COMMAND_LINE_STATUS_PRINT_VERSION:
|
|
|
|
|
case COMMAND_LINE_STATUS_PRINT_BUILDCONFIG:
|
|
|
|
|
break;
|
|
|
|
|
case COMMAND_LINE_STATUS_PRINT_HELP:
|
|
|
|
|
default:
|
|
|
|
|
xfreerdp_print_help();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-22 09:44:55 +01:00
|
|
|
goto out;
|
2013-06-13 21:34:46 -04:00
|
|
|
}
|
2013-06-13 20:25:50 -04:00
|
|
|
|
2022-10-21 10:31:14 +02:00
|
|
|
if (!stream_dump_register_handlers(context, CONNECTION_STATE_MCS_CREATE_REQUEST, FALSE))
|
2021-09-23 14:52:03 +02:00
|
|
|
goto out;
|
|
|
|
|
|
2021-01-22 09:44:55 +01:00
|
|
|
if (freerdp_client_start(context) != 0)
|
|
|
|
|
goto out;
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2013-06-14 15:07:17 -04:00
|
|
|
thread = freerdp_client_get_thread(context);
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2024-09-16 05:06:07 +02:00
|
|
|
(void)WaitForSingleObject(thread, INFINITE);
|
2026-03-02 18:46:22 +01:00
|
|
|
if (!GetExitCodeThread(thread, &dwExitCode))
|
|
|
|
|
goto out;
|
2021-01-22 09:44:55 +01:00
|
|
|
rc = xf_exit_code_from_disconnect_reason(dwExitCode);
|
2012-03-16 16:42:56 +01:00
|
|
|
|
2013-06-13 22:11:23 -04:00
|
|
|
freerdp_client_stop(context);
|
2013-06-13 20:25:50 -04:00
|
|
|
|
2021-01-22 09:44:55 +01:00
|
|
|
out:
|
2013-06-13 22:11:23 -04:00
|
|
|
freerdp_client_context_free(context);
|
2011-08-07 09:52:40 -04:00
|
|
|
|
2021-01-22 09:44:55 +01:00
|
|
|
return rc;
|
2011-08-07 09:52:40 -04:00
|
|
|
}
|