FreeRDP
Loading...
Searching...
No Matches
xfreerdp.c
1
21#include <freerdp/config.h>
22
23#include <winpr/crt.h>
24#include <winpr/synch.h>
25#include <winpr/thread.h>
26
27#include <freerdp/streamdump.h>
28#include <freerdp/freerdp.h>
29#include <freerdp/client/cmdline.h>
30
31#include "../xf_client.h"
32#include "../xfreerdp.h"
33
34static void xfreerdp_print_help(void)
35{
36 printf("Keyboard Shortcuts:\n");
37 printf("\t<Right CTRL>\n");
38 printf("\t\treleases keyboard and mouse grab\n");
39 printf("\t<CTRL>+<ALT>+<Return>\n");
40 printf("\t\ttoggles fullscreen state of the application\n");
41 printf("\t<CTRL>+<ALT>+c\n");
42 printf("\t\ttoggles remote control in a remote assistance session\n");
43 printf("\t<CTRL>+<ALT>+m\n");
44 printf("\t\tminimizes the application\n");
45 printf("\tAction Script\n");
46 printf("\t\tExecutes a predefined script on key press.\n");
47 printf("\t\tShould the script not exist it is ignored.\n");
48 printf("\t\tScripts can be provided at the default location ~/.config/freerdp/action.sh or as "
49 "command line argument /action:script:<path>\n");
50 printf("\t\tThe script will receive the current key combination as argument.\n");
51 printf("\t\tThe output of the script is parsed for 'key-local' which tells that the script "
52 "used the key combination, otherwise the combination is forwarded to the remote.\n");
53}
54
55int main(int argc, char* argv[])
56{
57 int rc = 1;
58 int status = 0;
59 HANDLE thread = NULL;
60 xfContext* xfc = NULL;
61 DWORD dwExitCode = 0;
62 rdpContext* context = NULL;
63 rdpSettings* settings = NULL;
64 RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 };
65
66 clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
67 clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
68
69 RdpClientEntry(&clientEntryPoints);
70
71 context = freerdp_client_context_new(&clientEntryPoints);
72 if (!context)
73 return 1;
74
75 settings = context->settings;
76 xfc = (xfContext*)context;
77
78 status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
79 if (status)
80 {
81 rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
82
83 if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
84 xf_list_monitors(xfc);
85 else
86 {
87 switch (status)
88 {
89 case COMMAND_LINE_STATUS_PRINT:
90 case COMMAND_LINE_STATUS_PRINT_VERSION:
91 case COMMAND_LINE_STATUS_PRINT_BUILDCONFIG:
92 break;
93 case COMMAND_LINE_STATUS_PRINT_HELP:
94 default:
95 xfreerdp_print_help();
96 break;
97 }
98 }
99 goto out;
100 }
101
102 if (!stream_dump_register_handlers(context, CONNECTION_STATE_MCS_CREATE_REQUEST, FALSE))
103 goto out;
104
105 if (freerdp_client_start(context) != 0)
106 goto out;
107
108 thread = freerdp_client_get_thread(context);
109
110 (void)WaitForSingleObject(thread, INFINITE);
111 GetExitCodeThread(thread, &dwExitCode);
112 rc = xf_exit_code_from_disconnect_reason(dwExitCode);
113
114 freerdp_client_stop(context);
115
116out:
117 freerdp_client_context_free(context);
118
119 return rc;
120}
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.