FreeRDP
client_rails.c
1 
2 #include <winpr/cast.h>
3 
4 #include <freerdp/freerdp.h>
5 #include <freerdp/client/rail.h>
6 
7 #include "rail_main.h"
8 
9 UINT client_rail_server_start_cmd(RailClientContext* context)
10 {
11  UINT status = 0;
12  char argsAndFile[520] = { 0 };
13  RAIL_EXEC_ORDER exec = { 0 };
14  RAIL_SYSPARAM_ORDER sysparam = { 0 };
15  RAIL_CLIENT_STATUS_ORDER clientStatus = { 0 };
16 
17  WINPR_ASSERT(context);
18  railPlugin* rail = context->handle;
19  WINPR_ASSERT(rail);
20  WINPR_ASSERT(rail->rdpcontext);
21 
22  const rdpSettings* settings = rail->rdpcontext->settings;
23  WINPR_ASSERT(settings);
24 
25  clientStatus.flags = TS_RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE;
26 
27  if (freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled))
28  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_AUTORECONNECT;
29 
30  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_ZORDER_SYNC;
31  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_WINDOW_RESIZE_MARGIN_SUPPORTED;
32  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_APPBAR_REMOTING_SUPPORTED;
33  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_POWER_DISPLAY_REQUEST_SUPPORTED;
34  clientStatus.flags |= TS_RAIL_CLIENTSTATUS_BIDIRECTIONAL_CLOAK_SUPPORTED;
35  status = context->ClientInformation(context, &clientStatus);
36 
37  if (status != CHANNEL_RC_OK)
38  return status;
39 
40  if (freerdp_settings_get_bool(settings, FreeRDP_RemoteAppLanguageBarSupported))
41  {
42  RAIL_LANGBAR_INFO_ORDER langBarInfo;
43  langBarInfo.languageBarStatus = 0x00000008; /* TF_SFT_HIDDEN */
44  status = context->ClientLanguageBarInfo(context, &langBarInfo);
45 
46  /* We want the language bar, but the server might not support it. */
47  switch (status)
48  {
49  case CHANNEL_RC_OK:
50  case ERROR_BAD_CONFIGURATION:
51  break;
52  default:
53  return status;
54  }
55  }
56 
57  sysparam.params = 0;
58  sysparam.params |= SPI_MASK_SET_HIGH_CONTRAST;
59  sysparam.highContrast.colorScheme.string = NULL;
60  sysparam.highContrast.colorScheme.length = 0;
61  sysparam.highContrast.flags = 0x7E;
62  sysparam.params |= SPI_MASK_SET_MOUSE_BUTTON_SWAP;
63  sysparam.mouseButtonSwap = FALSE;
64  sysparam.params |= SPI_MASK_SET_KEYBOARD_PREF;
65  sysparam.keyboardPref = FALSE;
66  sysparam.params |= SPI_MASK_SET_DRAG_FULL_WINDOWS;
67  sysparam.dragFullWindows = FALSE;
68  sysparam.params |= SPI_MASK_SET_KEYBOARD_CUES;
69  sysparam.keyboardCues = FALSE;
70  sysparam.params |= SPI_MASK_SET_WORK_AREA;
71  sysparam.workArea.left = 0;
72  sysparam.workArea.top = 0;
73 
74  const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
75  const UINT32 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
76 
77  sysparam.workArea.right = WINPR_ASSERTING_INT_CAST(UINT16, w);
78  sysparam.workArea.bottom = WINPR_ASSERTING_INT_CAST(UINT16, h);
79  sysparam.dragFullWindows = FALSE;
80  status = context->ClientSystemParam(context, &sysparam);
81 
82  if (status != CHANNEL_RC_OK)
83  return status;
84 
85  const char* RemoteApplicationFile =
86  freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationFile);
87  const char* RemoteApplicationCmdLine =
88  freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationCmdLine);
89  if (RemoteApplicationFile && RemoteApplicationCmdLine)
90  {
91  (void)_snprintf(argsAndFile, ARRAYSIZE(argsAndFile), "%s %s", RemoteApplicationCmdLine,
92  RemoteApplicationFile);
93  exec.RemoteApplicationArguments = argsAndFile;
94  }
95  else if (RemoteApplicationFile)
96  exec.RemoteApplicationArguments = RemoteApplicationFile;
97  else
98  exec.RemoteApplicationArguments = RemoteApplicationCmdLine;
99  exec.RemoteApplicationProgram =
100  freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationProgram);
101  exec.RemoteApplicationWorkingDir =
102  freerdp_settings_get_string(settings, FreeRDP_ShellWorkingDirectory);
103  return context->ClientExecute(context, &exec);
104 }
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.