diff --git a/channels/rail/client/client_rails.c b/channels/rail/client/client_rails.c index 30759651e..6eced998f 100644 --- a/channels/rail/client/client_rails.c +++ b/channels/rail/client/client_rails.c @@ -22,7 +22,7 @@ UINT client_rail_server_start_cmd(RailClientContext* context) clientStatus.flags = TS_RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE; - if (settings->AutoReconnectionEnabled) + if (freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled)) clientStatus.flags |= TS_RAIL_CLIENTSTATUS_AUTORECONNECT; clientStatus.flags |= TS_RAIL_CLIENTSTATUS_ZORDER_SYNC; @@ -35,7 +35,7 @@ UINT client_rail_server_start_cmd(RailClientContext* context) if (status != CHANNEL_RC_OK) return status; - if (settings->RemoteAppLanguageBarSupported) + if (freerdp_settings_get_bool(settings, FreeRDP_RemoteAppLanguageBarSupported)) { RAIL_LANGBAR_INFO_ORDER langBarInfo; langBarInfo.languageBarStatus = 0x00000008; /* TF_SFT_HIDDEN */ @@ -68,25 +68,31 @@ UINT client_rail_server_start_cmd(RailClientContext* context) sysparam.params |= SPI_MASK_SET_WORK_AREA; sysparam.workArea.left = 0; sysparam.workArea.top = 0; - sysparam.workArea.right = settings->DesktopWidth; - sysparam.workArea.bottom = settings->DesktopHeight; + sysparam.workArea.right = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + sysparam.workArea.bottom = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); sysparam.dragFullWindows = FALSE; status = context->ClientSystemParam(context, &sysparam); if (status != CHANNEL_RC_OK) return status; - if (settings->RemoteApplicationFile && settings->RemoteApplicationCmdLine) + const char* RemoteApplicationFile = + freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationFile); + const char* RemoteApplicationCmdLine = + freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationCmdLine); + if (RemoteApplicationFile && RemoteApplicationCmdLine) { - _snprintf(argsAndFile, ARRAYSIZE(argsAndFile), "%s %s", settings->RemoteApplicationCmdLine, - settings->RemoteApplicationFile); + _snprintf(argsAndFile, ARRAYSIZE(argsAndFile), "%s %s", RemoteApplicationCmdLine, + RemoteApplicationFile); exec.RemoteApplicationArguments = argsAndFile; } - else if (settings->RemoteApplicationFile) - exec.RemoteApplicationArguments = settings->RemoteApplicationFile; + else if (RemoteApplicationFile) + exec.RemoteApplicationArguments = RemoteApplicationFile; else - exec.RemoteApplicationArguments = settings->RemoteApplicationCmdLine; - exec.RemoteApplicationProgram = settings->RemoteApplicationProgram; - exec.RemoteApplicationWorkingDir = settings->ShellWorkingDirectory; + exec.RemoteApplicationArguments = RemoteApplicationCmdLine; + exec.RemoteApplicationProgram = + freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationProgram); + exec.RemoteApplicationWorkingDir = + freerdp_settings_get_string(settings, FreeRDP_ShellWorkingDirectory); return context->ClientExecute(context, &exec); } diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c index 747b142d4..b16069117 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c @@ -176,7 +176,8 @@ static BOOL android_desktop_resize(rdpContext* context) WINPR_ASSERT(context->instance); freerdp_callback("OnGraphicsResize", "(JIII)V", (jlong)context->instance, - context->settings->DesktopWidth, context->settings->DesktopHeight, + freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopHeight), freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth)); return TRUE; } @@ -300,8 +301,9 @@ static BOOL android_post_connect(freerdp* instance) update->BeginPaint = android_begin_paint; update->EndPaint = android_end_paint; update->DesktopResize = android_desktop_resize; - freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance, settings->DesktopWidth, - settings->DesktopHeight, + freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)); freerdp_callback("OnConnectionSuccess", "(J)V", (jlong)instance); return TRUE; diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 8b1e12e74..838fbc987 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -92,10 +92,12 @@ static DWORD WINAPI mac_client_thread(void *param); NSScreen *screen = [[NSScreen screens] objectAtIndex:0]; NSRect screenFrame = [screen frame]; - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { - settings->DesktopWidth = screenFrame.size.width; - settings->DesktopHeight = screenFrame.size.height; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, screenFrame.size.width)) + return -1; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, screenFrame.size.height)) + return -1; [self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil]; } else @@ -103,8 +105,8 @@ static DWORD WINAPI mac_client_thread(void *param); [self exitFullScreenModeWithOptions:nil]; } - mfc->client_height = settings->DesktopHeight; - mfc->client_width = settings->DesktopWidth; + mfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + mfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); if (!(mfc->common.thread = CreateThread(NULL, 0, mac_client_thread, (void *)context, 0, &mfc->mainThreadId))) @@ -849,14 +851,16 @@ BOOL mac_pre_connect(freerdp *instance) settings = instance->context->settings; WINPR_ASSERT(settings); - if (!settings->ServerHostname) + if (!freerdp_settings_get_string(settings, FreeRDP_ServerHostname)) { WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]"); return FALSE; } - settings->OsMajorType = OSMAJORTYPE_MACINTOSH; - settings->OsMinorType = OSMINORTYPE_MACINTOSH; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_MACINTOSH)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_MACINTOSH)) + return FALSE; PubSub_SubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler); PubSub_SubscribeChannelDisconnected(instance->context->pubSub, mac_OnChannelDisconnectedEventHandler); @@ -1003,26 +1007,32 @@ static BOOL mac_authenticate_raw(freerdp *instance, char **username, char **pass { case AUTH_SMARTCARD_PIN: pinOnly = TRUE; - title = [NSString stringWithFormat:@"%@:%u", - [NSString stringWithCString:settings->ServerHostname - encoding:NSUTF8StringEncoding], - settings -> ServerPort]; + title = [NSString + stringWithFormat:@"%@:%u", + [NSString stringWithCString:freerdp_settings_get_string( + settings, FreeRDP_ServerHostname) + encoding:NSUTF8StringEncoding], + settings -> ServerPort]; break; case AUTH_TLS: case AUTH_RDP: case AUTH_NLA: - title = [NSString stringWithFormat:@"%@:%u", - [NSString stringWithCString:settings->ServerHostname - encoding:NSUTF8StringEncoding], - settings -> ServerPort]; + title = [NSString + stringWithFormat:@"%@:%u", + [NSString stringWithCString:freerdp_settings_get_string( + settings, FreeRDP_ServerHostname) + encoding:NSUTF8StringEncoding], + settings -> ServerPort]; break; case GW_AUTH_HTTP: case GW_AUTH_RDG: case GW_AUTH_RPC: - title = [NSString stringWithFormat:@"%@:%u", - [NSString stringWithCString:settings->GatewayHostname - encoding:NSUTF8StringEncoding], - settings -> GatewayPort]; + title = [NSString + stringWithFormat:@"%@:%u", + [NSString stringWithCString:freerdp_settings_get_string( + settings, FreeRDP_GatewayHostname) + encoding:NSUTF8StringEncoding], + settings -> GatewayPort]; break; default: return FALSE; @@ -1359,8 +1369,8 @@ BOOL mac_end_paint(rdpContext *context) ww = mfc->client_width; wh = mfc->client_height; - dw = mfc->common.context.settings->DesktopWidth; - dh = mfc->common.context.settings->DesktopHeight; + dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth); + dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight); if ((!context) || (!context->gdi)) return FALSE; @@ -1374,7 +1384,8 @@ BOOL mac_end_paint(rdpContext *context) newDrawRect.size.width = invalid->w; newDrawRect.size.height = invalid->h; - if (mfc->common.context.settings->SmartSizing && (ww != dw || wh != dh)) + if (freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) && + (ww != dw || wh != dh)) { newDrawRect.origin.y = newDrawRect.origin.y * wh / dh - 1; newDrawRect.size.height = newDrawRect.size.height * wh / dh + 1; @@ -1415,8 +1426,8 @@ BOOL mac_desktop_resize(rdpContext *context) CGContextRef old_context = view->bitmap_context; view->bitmap_context = NULL; CGContextRelease(old_context); - mfc->width = settings->DesktopWidth; - mfc->height = settings->DesktopHeight; + mfc->width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + mfc->height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (!gdi_resize(context->gdi, mfc->width, mfc->height)) return FALSE; @@ -1430,8 +1441,8 @@ BOOL mac_desktop_resize(rdpContext *context) mfc->client_height = mfc->height; [view setFrameSize:NSMakeSize(mfc->width, mfc->height)]; EventArgsInit(&e, "mfreerdp"); - e.width = settings->DesktopWidth; - e.height = settings->DesktopHeight; + e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); PubSub_OnResizeWindow(context->pubSub, context, &e); return TRUE; } diff --git a/client/Mac/mf_client.m b/client/Mac/mf_client.m index ca555665b..76c89b377 100644 --- a/client/Mac/mf_client.m +++ b/client/Mac/mf_client.m @@ -51,9 +51,12 @@ static int mfreerdp_client_start(rdpContext *context) if (mfc->view == NULL) { // view not specified beforehand. Create view dynamically - mfc->view = - [[MRDPView alloc] initWithFrame:NSMakeRect(0, 0, context->settings->DesktopWidth, - context->settings->DesktopHeight)]; + mfc->view = [[MRDPView alloc] + initWithFrame:NSMakeRect( + 0, 0, + freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(context->settings, + FreeRDP_DesktopHeight))]; mfc->view_ownership = TRUE; } @@ -117,10 +120,11 @@ static void mf_scale_mouse_coordinates(mfContext *mfc, UINT16 *px, UINT16 *py) UINT16 y = *py; UINT32 ww = mfc->client_width; UINT32 wh = mfc->client_height; - UINT32 dw = mfc->common.context.settings->DesktopWidth; - UINT32 dh = mfc->common.context.settings->DesktopHeight; + UINT32 dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth); + UINT32 dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight); - if (!mfc->common.context.settings->SmartSizing || ((ww == dw) && (wh == dh))) + if (!freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) || + ((ww == dw) && (wh == dh))) { y = y + mfc->yCurrentScroll; x = x + mfc->xCurrentScroll; diff --git a/client/SDL/sdl_disp.cpp b/client/SDL/sdl_disp.cpp index f5503eae9..d7bd288c0 100644 --- a/client/SDL/sdl_disp.cpp +++ b/client/SDL/sdl_disp.cpp @@ -46,13 +46,16 @@ BOOL sdlDispContext::settings_changed() if (_lastSentHeight != _targetHeight) return TRUE; - if (_lastSentDesktopOrientation != settings->DesktopOrientation) + if (_lastSentDesktopOrientation != + freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation)) return TRUE; - if (_lastSentDesktopScaleFactor != settings->DesktopScaleFactor) + if (_lastSentDesktopScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor)) return TRUE; - if (_lastSentDeviceScaleFactor != settings->DeviceScaleFactor) + if (_lastSentDeviceScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor)) return TRUE; /* TODO if (_fullscreen != _sdl->fullscreen) @@ -70,9 +73,9 @@ BOOL sdlDispContext::update_last_sent() _lastSentWidth = _targetWidth; _lastSentHeight = _targetHeight; - _lastSentDesktopOrientation = settings->DesktopOrientation; - _lastSentDesktopScaleFactor = settings->DesktopScaleFactor; - _lastSentDeviceScaleFactor = settings->DeviceScaleFactor; + _lastSentDesktopOrientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + _lastSentDesktopScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + _lastSentDeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); // TODO _fullscreen = _sdl->fullscreen; return TRUE; } @@ -96,9 +99,12 @@ BOOL sdlDispContext::sendResize() if (!settings_changed()) return TRUE; - if (_sdl->fullscreen && (settings->MonitorCount > 0)) + const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); + if (_sdl->fullscreen && (mcount > 0)) { - if (sendLayout(settings->MonitorDefArray, settings->MonitorCount) != CHANNEL_RC_OK) + auto monitors = static_cast( + freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray)); + if (sendLayout(monitors, mcount) != CHANNEL_RC_OK) return FALSE; } else @@ -108,9 +114,10 @@ BOOL sdlDispContext::sendResize() layout.Top = layout.Left = 0; layout.Width = _targetWidth; layout.Height = _targetHeight; - layout.Orientation = settings->DesktopOrientation; - layout.DesktopScaleFactor = settings->DesktopScaleFactor; - layout.DeviceScaleFactor = settings->DeviceScaleFactor; + layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + layout.DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); layout.PhysicalWidth = _targetWidth; layout.PhysicalHeight = _targetHeight; @@ -155,7 +162,7 @@ void sdlDispContext::OnActivated(void* context, const ActivatedEventArgs* e) sdlDisp->_waitingResize = FALSE; - if (sdlDisp->_activated && !settings->Fullscreen) + if (sdlDisp->_activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { sdlDisp->set_window_resizable(); @@ -178,7 +185,7 @@ void sdlDispContext::OnGraphicsReset(void* context, const GraphicsResetEventArgs sdlDisp->_waitingResize = FALSE; - if (sdlDisp->_activated && !settings->Fullscreen) + if (sdlDisp->_activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { sdlDisp->set_window_resizable(); sdlDisp->sendResize(); @@ -195,7 +202,7 @@ void sdlDispContext::OnTimer(void* context, const TimerEventArgs* e) if (!sdl_disp_check_context(context, &sdl, &sdlDisp, &settings)) return; - if (!sdlDisp->_activated || settings->Fullscreen) + if (!sdlDisp->_activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) return; sdlDisp->sendResize(); @@ -255,8 +262,10 @@ UINT sdlDispContext::sendLayout(const rdpMonitor* monitors, size_t nmonitors) break; } - layout->DesktopScaleFactor = settings->DesktopScaleFactor; - layout->DeviceScaleFactor = settings->DeviceScaleFactor; + layout->DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout->DeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); } WINPR_ASSERT(_disp); @@ -353,7 +362,7 @@ UINT sdlDispContext::DisplayControlCaps(UINT32 maxNumMonitors, UINT32 maxMonitor maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB); _activated = TRUE; - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) return CHANNEL_RC_OK; WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable"); @@ -373,7 +382,7 @@ BOOL sdlDispContext::init(DispClientContext* disp) _disp = disp; disp->custom = this; - if (settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { disp->DisplayControlCaps = sdlDispContext::DisplayControlCaps; } @@ -401,8 +410,8 @@ sdlDispContext::sdlDispContext(SdlContext* sdl) : _sdl(sdl) auto settings = _sdl->context()->settings; auto pubSub = _sdl->context()->pubSub; - _lastSentWidth = _targetWidth = settings->DesktopWidth; - _lastSentHeight = _targetHeight = settings->DesktopHeight; + _lastSentWidth = _targetWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + _lastSentHeight = _targetHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); PubSub_SubscribeActivated(pubSub, sdlDispContext::OnActivated); PubSub_SubscribeGraphicsReset(pubSub, sdlDispContext::OnGraphicsReset); PubSub_SubscribeTimer(pubSub, sdlDispContext::OnTimer); diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index a94d6f22b..5debc604d 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -530,7 +530,8 @@ static BOOL sdl_desktop_resize(rdpContext* context) WINPR_ASSERT(settings); gdi = context->gdi; - if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight)) + if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) return FALSE; return sdl_create_primary(sdl); } @@ -574,9 +575,11 @@ static BOOL sdl_pre_connect(freerdp* instance) WINPR_ASSERT(settings); /* Optional OS identifier sent to server */ - settings->OsMajorType = OSMAJORTYPE_UNIX; - settings->OsMinorType = OSMINORTYPE_NATIVE_SDL; - /* settings->OrderSupport is initialized at this point. + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_SDL)) + return FALSE; + /* OrderSupport is initialized at this point. * Only override it if you plan to implement custom order * callbacks or deactiveate certain features. */ /* Register the channel listeners. @@ -600,8 +603,10 @@ static BOOL sdl_pre_connect(freerdp* instance) !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { WLog_Print(sdl->log, WLOG_INFO, "Update size to %ux%u", maxWidth, maxHeight); - settings->DesktopWidth = maxWidth; - settings->DesktopHeight = maxHeight; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, maxWidth)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, maxHeight)) + return FALSE; } } else @@ -685,10 +690,11 @@ static BOOL sdl_create_windows(SdlContext* sdl) Uint32 w = monitor->width; Uint32 h = monitor->height; - if (!(settings->UseMultimon || settings->Fullscreen)) + if (!(freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) || + freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))) { - w = settings->DesktopWidth; - h = settings->DesktopHeight; + w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } sdl_window_t window = {}; @@ -703,12 +709,13 @@ static BOOL sdl_create_windows(SdlContext* sdl) #endif } - if (settings->Fullscreen && !settings->UseMultimon) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) && + !freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) { flags |= SDL_WINDOW_FULLSCREEN; } - if (settings->UseMultimon) + if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) { flags |= SDL_WINDOW_BORDERLESS; } @@ -723,7 +730,7 @@ static BOOL sdl_create_windows(SdlContext* sdl) if (!window.window) goto fail; - if (settings->UseMultimon) + if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) { int win_x; int win_y; @@ -1093,7 +1100,8 @@ static BOOL sdl_post_connect(freerdp* instance) context->update->SetKeyboardImeStatus = sdlInput::keyboard_set_ime_status; sdl->update_resizeable(FALSE); - sdl->update_fullscreen(context->settings->Fullscreen || context->settings->UseMultimon); + sdl->update_fullscreen(freerdp_settings_get_bool(context->settings, FreeRDP_Fullscreen) || + freerdp_settings_get_bool(context->settings, FreeRDP_UseMultimon)); return TRUE; } @@ -1522,7 +1530,7 @@ int main(int argc, char* argv[]) if (status) { rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv); - if (settings->ListMonitors) + if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors)) sdl_list_monitors(sdl); return rc; } diff --git a/client/SDL/sdl_monitor.cpp b/client/SDL/sdl_monitor.cpp index 24b19c31e..a5d972f43 100644 --- a/client/SDL/sdl_monitor.cpp +++ b/client/SDL/sdl_monitor.cpp @@ -87,12 +87,15 @@ static BOOL sdl_is_monitor_id_active(SdlContext* sdl, UINT32 id) settings = sdl->context()->settings; WINPR_ASSERT(settings); - if (!settings->NumMonitorIds) + const UINT32 NumMonitorIds = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds); + if (!NumMonitorIds) return TRUE; - for (index = 0; index < settings->NumMonitorIds; index++) + for (index = 0; index < NumMonitorIds; index++) { - if (settings->MonitorIds[index] == id) + auto cur = static_cast( + freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index)); + if (cur && (*cur == id)) return TRUE; } @@ -111,23 +114,24 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH *pMaxWidth = 0; *pMaxHeight = 0; - for (size_t x = 0; x < settings->MonitorCount; x++) + for (size_t x = 0; x < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); x++) { - const rdpMonitor* monitor = &settings->MonitorDefArray[x]; + auto monitor = static_cast( + freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, x)); - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { *pMaxWidth = monitor->width; *pMaxHeight = monitor->height; } - else if (settings->Workarea) + else if (freerdp_settings_get_bool(settings, FreeRDP_Workarea)) { SDL_Rect rect = {}; SDL_GetDisplayUsableBounds(monitor->orig_screen, &rect); *pMaxWidth = rect.w; *pMaxHeight = rect.h; } - else if (settings->PercentScreen) + else if (freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) > 0) { SDL_Rect rect = {}; SDL_GetDisplayUsableBounds(monitor->orig_screen, &rect); @@ -135,16 +139,19 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH *pMaxWidth = rect.w; *pMaxHeight = rect.h; - if (settings->PercentScreenUseWidth) - *pMaxWidth = (rect.w * settings->PercentScreen) / 100; + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)) + *pMaxWidth = + (rect.w * freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100; - if (settings->PercentScreenUseHeight) - *pMaxHeight = (rect.h * settings->PercentScreen) / 100; + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)) + *pMaxHeight = + (rect.h * freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100; } - else if (settings->DesktopWidth && settings->DesktopHeight) + else if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) && + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) { - *pMaxWidth = settings->DesktopWidth; - *pMaxHeight = settings->DesktopHeight; + *pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + *pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } } return TRUE; @@ -266,12 +273,14 @@ static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, UINT32* rdpSettings* settings = sdl->context()->settings; WINPR_ASSERT(settings); - if ((!settings->UseMultimon && !settings->SpanMonitors) || - (settings->Workarea && !settings->RemoteApplicationMode)) + if ((!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) && + !freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors)) || + (freerdp_settings_get_bool(settings, FreeRDP_Workarea) && + !freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode))) { /* If no monitors were specified on the command-line then set the current monitor as active */ - if (!settings->NumMonitorIds) + if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 0) { const size_t id = (sdl->windows.size() > 0) ? SDL_GetWindowDisplayIndex(sdl->windows[0].window) : 0; @@ -285,7 +294,8 @@ static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, UINT32* * If the monitor is invalid then we will default back to current monitor * later as a fallback. So, there is no need to validate command-line entry here. */ - settings->NumMonitorIds = 1; + if (!freerdp_settings_set_uint32(settings, FreeRDP_NumMonitorIds, 1)) + return FALSE; } // TODO: Fill monitor struct diff --git a/client/SDL/sdl_touch.cpp b/client/SDL/sdl_touch.cpp index 08901d058..328a35a70 100644 --- a/client/SDL/sdl_touch.cpp +++ b/client/SDL/sdl_touch.cpp @@ -71,7 +71,7 @@ BOOL sdl_scale_coordinates(SdlContext* sdl, Uint32 windowId, INT32* px, INT32* p break; } - if (sdl->context()->settings->SmartSizing) + if (freerdp_settings_get_bool(sdl->context()->settings, FreeRDP_SmartSizing)) { if (!fromLocalToRDP) { diff --git a/client/Sample/tf_freerdp.c b/client/Sample/tf_freerdp.c index d81904d01..aceb2ca95 100644 --- a/client/Sample/tf_freerdp.c +++ b/client/Sample/tf_freerdp.c @@ -99,7 +99,8 @@ static BOOL tf_desktop_resize(rdpContext* context) WINPR_ASSERT(settings); gdi = context->gdi; - return gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight); + return gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } /* This function is called to output a System BEEP */ @@ -147,9 +148,11 @@ static BOOL tf_pre_connect(freerdp* instance) WINPR_ASSERT(settings); /* Optional OS identifier sent to server */ - settings->OsMajorType = OSMAJORTYPE_UNIX; - settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER; - /* settings->OrderSupport is initialized at this point. + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER)) + return FALSE; + /* OrderSupport is initialized at this point. * Only override it if you plan to implement custom order * callbacks or deactiveate certain features. */ /* Register the channel listeners. @@ -234,7 +237,7 @@ static DWORD WINAPI tf_client_thread_proc(LPVOID arg) WINPR_ASSERT(instance->context); WINPR_ASSERT(instance->context->settings); - if (instance->context->settings->AuthenticationOnly) + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_AuthenticationOnly)) { result = freerdp_get_last_error(instance->context); freerdp_abort_connect_context(instance->context); diff --git a/client/Wayland/wlf_disp.c b/client/Wayland/wlf_disp.c index b0e33cde2..5418fddc9 100644 --- a/client/Wayland/wlf_disp.c +++ b/client/Wayland/wlf_disp.c @@ -62,13 +62,16 @@ static BOOL wlf_disp_settings_changed(wlfDispContext* wlfDisp) if (wlfDisp->lastSentHeight != wlfDisp->targetHeight) return TRUE; - if (wlfDisp->lastSentDesktopOrientation != settings->DesktopOrientation) + if (wlfDisp->lastSentDesktopOrientation != + freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation)) return TRUE; - if (wlfDisp->lastSentDesktopScaleFactor != settings->DesktopScaleFactor) + if (wlfDisp->lastSentDesktopScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor)) return TRUE; - if (wlfDisp->lastSentDeviceScaleFactor != settings->DeviceScaleFactor) + if (wlfDisp->lastSentDeviceScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor)) return TRUE; if (wlfDisp->fullscreen != wlfDisp->wlc->fullscreen) @@ -89,9 +92,12 @@ static BOOL wlf_update_last_sent(wlfDispContext* wlfDisp) wlfDisp->lastSentWidth = wlfDisp->targetWidth; wlfDisp->lastSentHeight = wlfDisp->targetHeight; - wlfDisp->lastSentDesktopOrientation = settings->DesktopOrientation; - wlfDisp->lastSentDesktopScaleFactor = settings->DesktopScaleFactor; - wlfDisp->lastSentDeviceScaleFactor = settings->DeviceScaleFactor; + wlfDisp->lastSentDesktopOrientation = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation); + wlfDisp->lastSentDesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + wlfDisp->lastSentDeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); wlfDisp->fullscreen = wlfDisp->wlc->fullscreen; return TRUE; } @@ -123,11 +129,11 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp) return TRUE; /* TODO: Multimonitor support for wayland - if (wlc->fullscreen && (settings->MonitorCount > 0)) + if (wlc->fullscreen && (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount > 0)) { - if (wlf_disp_sendLayout(wlfDisp->disp, settings->MonitorDefArray, - settings->MonitorCount) != CHANNEL_RC_OK) - return FALSE; + if (wlf_disp_sendLayout(wlfDisp->disp, setings->MonitorDefArray, + freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) != + CHANNEL_RC_OK) return FALSE; } else */ @@ -137,9 +143,10 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp) layout.Top = layout.Left = 0; layout.Width = wlfDisp->targetWidth; layout.Height = wlfDisp->targetHeight; - layout.Orientation = settings->DesktopOrientation; - layout.DesktopScaleFactor = settings->DesktopScaleFactor; - layout.DeviceScaleFactor = settings->DeviceScaleFactor; + layout.Orientation = freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation); + layout.DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); layout.PhysicalWidth = wlfDisp->targetWidth; layout.PhysicalHeight = wlfDisp->targetHeight; @@ -190,7 +197,7 @@ static void wlf_disp_OnActivated(void* context, const ActivatedEventArgs* e) wlfDisp->waitingResize = FALSE; - if (wlfDisp->activated && !settings->Fullscreen) + if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { wlf_disp_set_window_resizable(wlfDisp); @@ -213,7 +220,7 @@ static void wlf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs wlfDisp->waitingResize = FALSE; - if (wlfDisp->activated && !settings->Fullscreen) + if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { wlf_disp_set_window_resizable(wlfDisp); wlf_disp_sendResize(wlfDisp); @@ -230,7 +237,7 @@ static void wlf_disp_OnTimer(void* context, const TimerEventArgs* e) if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings)) return; - if (!wlfDisp->activated || settings->Fullscreen) + if (!wlfDisp->activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) return; wlf_disp_sendResize(wlfDisp); @@ -253,8 +260,10 @@ wlfDispContext* wlf_disp_new(wlfContext* wlc) return NULL; ret->wlc = wlc; - ret->lastSentWidth = ret->targetWidth = settings->DesktopWidth; - ret->lastSentHeight = ret->targetHeight = settings->DesktopHeight; + ret->lastSentWidth = ret->targetWidth = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + ret->lastSentHeight = ret->targetHeight = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); PubSub_SubscribeActivated(pubSub, wlf_disp_OnActivated); PubSub_SubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset); PubSub_SubscribeTimer(pubSub, wlf_disp_OnTimer); @@ -342,8 +351,10 @@ UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, si break; } - layout->DesktopScaleFactor = settings->DesktopScaleFactor; - layout->DeviceScaleFactor = settings->DeviceScaleFactor; + layout->DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout->DeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); } ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, nmonitors, layouts); @@ -383,7 +394,7 @@ static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitor maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB); wlfDisp->activated = TRUE; - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) return CHANNEL_RC_OK; WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable"); @@ -405,7 +416,7 @@ BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp) wlfDisp->disp = disp; disp->custom = (void*)wlfDisp; - if (settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { disp->DisplayControlCaps = wlf_DisplayControlCaps; } diff --git a/client/Wayland/wlf_input.c b/client/Wayland/wlf_input.c index c70ef5465..b3a42111a 100644 --- a/client/Wayland/wlf_input.c +++ b/client/Wayland/wlf_input.c @@ -331,7 +331,8 @@ BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev) return FALSE; WINPR_ASSERT(instance->context); - if (instance->context->settings->GrabKeyboard && ev->raw_key == KEY_RIGHTCTRL) + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard) && + ev->raw_key == KEY_RIGHTCTRL) wlf_handle_ungrab_key(instance, ev); input = instance->context->input; diff --git a/client/Wayland/wlf_pointer.c b/client/Wayland/wlf_pointer.c index 6feb7fc2f..2cbd143aa 100644 --- a/client/Wayland/wlf_pointer.c +++ b/client/Wayland/wlf_pointer.c @@ -101,7 +101,8 @@ static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer) area.bottom = (UINT16)pointer->height; if (!wlf_copy_image(ptr->data, pointer->width * 4, pointer->width, pointer->height, data, w * 4, - w, h, &area, context->settings->SmartSizing)) + w, h, &area, + freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))) goto fail; rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y); diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 5be10aae2..73452935d 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -91,9 +91,10 @@ static BOOL wl_update_buffer(wlfContext* context_w, INT32 ix, INT32 iy, INT32 iw area.right = x + w; area.bottom = y + h; - if (!wlf_copy_image(gdi->primary_buffer, gdi->stride, gdi->width, gdi->height, data, stride, - geometry.width, geometry.height, &area, - context_w->common.context.settings->SmartSizing)) + if (!wlf_copy_image( + gdi->primary_buffer, gdi->stride, gdi->width, gdi->height, data, stride, geometry.width, + geometry.height, &area, + freerdp_settings_get_bool(context_w->common.context.settings, FreeRDP_SmartSizing))) goto fail; if (!wlf_scale_coordinates(&context_w->common.context, &x, &y, FALSE)) @@ -161,7 +162,8 @@ static BOOL wl_resize_display(rdpContext* context) rdpGdi* gdi = context->gdi; rdpSettings* settings = context->settings; - if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight)) + if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) return FALSE; return wl_refresh_display(wlc); @@ -183,21 +185,27 @@ static BOOL wl_pre_connect(freerdp* instance) settings = instance->context->settings; WINPR_ASSERT(settings); - settings->OsMajorType = OSMAJORTYPE_UNIX; - settings->OsMinorType = OSMINORTYPE_NATIVE_WAYLAND; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_WAYLAND)) + return FALSE; PubSub_SubscribeChannelConnected(instance->context->pubSub, wlf_OnChannelConnectedEventHandler); PubSub_SubscribeChannelDisconnected(instance->context->pubSub, wlf_OnChannelDisconnectedEventHandler); - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { // Use the resolution of the first display output output = UwacDisplayGetOutput(context->display, 0); if ((output != NULL) && (UwacOutputGetResolution(output, &resolution) == UWAC_SUCCESS)) { - settings->DesktopWidth = (UINT32)resolution.width; - settings->DesktopHeight = (UINT32)resolution.height; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, + (UINT32)resolution.width)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, + (UINT32)resolution.height)) + return FALSE; } else { @@ -224,8 +232,9 @@ static BOOL wl_post_connect(freerdp* instance) context = (wlfContext*)instance->context; settings = instance->context->settings; - if (settings->WindowTitle) - title = settings->WindowTitle; + const char* wtitle = freerdp_settings_get_string(settings, FreeRDP_WindowTitle); + if (wtitle) + title = wtitle; if (!gdi_init(instance, PIXEL_FORMAT_BGRA32)) return FALSE; @@ -241,13 +250,15 @@ static BOOL wl_post_connect(freerdp* instance) w = (UINT32)gdi->width; h = (UINT32)gdi->height; - if (settings->SmartSizing && !context->fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !context->fullscreen) { - if (settings->SmartSizingWidth > 0) - w = settings->SmartSizingWidth; + const UINT32 sw = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); + if (sw > 0) + w = sw; - if (settings->SmartSizingHeight > 0) - h = settings->SmartSizingHeight; + const UINT32 sh = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); + if (sh > 0) + h = sh; } context->window = window = UwacCreateWindowShm(context->display, w, h, WL_SHM_FORMAT_XRGB8888); @@ -255,14 +266,19 @@ static BOOL wl_post_connect(freerdp* instance) if (!window) return FALSE; - UwacWindowSetFullscreenState(window, NULL, instance->context->settings->Fullscreen); + UwacWindowSetFullscreenState( + window, NULL, freerdp_settings_get_bool(instance->context->settings, FreeRDP_Fullscreen)); UwacWindowSetTitle(window, title); UwacWindowSetAppId(window, app_id); UwacWindowSetOpaqueRegion(context->window, 0, 0, w, h); instance->context->update->EndPaint = wl_end_paint; instance->context->update->DesktopResize = wl_resize_display; - freerdp_keyboard_init_ex(instance->context->settings->KeyboardLayout, - instance->context->settings->KeyboardRemappingList); + UINT32 KeyboardLayout = + freerdp_settings_get_uint32(instance->context->settings, FreeRDP_KeyboardLayout); + const char* KeyboardRemappingList = + freerdp_settings_get_string(instance->context->settings, FreeRDP_KeyboardRemappingList); + + freerdp_keyboard_init_ex(KeyboardLayout, KeyboardRemappingList); if (!(context->disp = wlf_disp_new(context))) return FALSE; @@ -393,7 +409,7 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) break; case UWAC_EVENT_KEYBOARD_ENTER: - if (instance->context->settings->GrabKeyboard) + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard)) UwacSeatInhibitShortcuts(event.keyboard_enter_leave.seat, true); if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave)) @@ -693,7 +709,7 @@ int main(int argc, char* argv[]) { rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv); - if (settings->ListMonitors) + if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors)) wlf_list_monitors(wlc); goto fail; @@ -759,7 +775,7 @@ BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fro if (!context || !px || !py || !context->gdi) return FALSE; - if (!context->settings->SmartSizing) + if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)) return TRUE; gdi = context->gdi; diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index fbcac79b0..66cf0b3c3 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -176,11 +176,14 @@ static BOOL wf_desktop_resize(rdpContext* context) { same = (wfc->primary == wfc->drawing) ? TRUE : FALSE; wf_image_free(wfc->primary); - wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, - context->gdi->dstFormat, NULL); + wfc->primary = + wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), + context->gdi->dstFormat, NULL); } - if (!gdi_resize_ex(context->gdi, settings->DesktopWidth, settings->DesktopHeight, 0, + if (!gdi_resize_ex(context->gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), 0, context->gdi->dstFormat, wfc->primary->pdata, NULL)) return FALSE; @@ -189,9 +192,11 @@ static BOOL wf_desktop_resize(rdpContext* context) if (wfc->fullscreen != TRUE) { - if (wfc->hwnd && !settings->SmartSizing) - SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x, - settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE); + if (wfc->hwnd && !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) + SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y, + SWP_NOMOVE); } else { @@ -219,24 +224,28 @@ static BOOL wf_pre_connect(freerdp* instance) context = instance->context; wfc = (wfContext*)instance->context; settings = context->settings; - settings->OsMajorType = OSMAJORTYPE_WINDOWS; - settings->OsMinorType = OSMINORTYPE_WINDOWS_NT; - wfc->fullscreen = settings->Fullscreen; - wfc->fullscreen_toggle = settings->ToggleFullscreen; - desktopWidth = settings->DesktopWidth; - desktopHeight = settings->DesktopHeight; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_WINDOWS)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_WINDOWS_NT)) + return FALSE; + wfc->fullscreen = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen); + wfc->fullscreen_toggle = freerdp_settings_get_bool(settings, FreeRDP_ToggleFullscreen); + desktopWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + desktopHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (wfc->percentscreen > 0) { desktopWidth = (GetSystemMetrics(SM_CXSCREEN) * wfc->percentscreen) / 100; - settings->DesktopWidth = desktopWidth; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth)) + return FALSE; desktopHeight = (GetSystemMetrics(SM_CYSCREEN) * wfc->percentscreen) / 100; - settings->DesktopHeight = desktopHeight; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight)) + return FALSE; } if (wfc->fullscreen) { - if (settings->UseMultimon) + if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) { desktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); desktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); @@ -252,12 +261,12 @@ static BOOL wf_pre_connect(freerdp* instance) * otherwise the screen will crash when connecting to an XP desktop.*/ desktopWidth = (desktopWidth + 3) & (~3); - if (desktopWidth != settings->DesktopWidth) + if (desktopWidth != freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) { freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth); } - if (desktopHeight != settings->DesktopHeight) + if (desktopHeight != freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) { freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight); } @@ -294,7 +303,7 @@ static void wf_add_system_menu(wfContext* wfc) return; } - if (wfc->common.context.settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_DynamicResolutionUpdate)) { return; } @@ -305,12 +314,12 @@ static void wf_add_system_menu(wfContext* wfc) MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_DATA, SYSCOMMAND_ID_SMARTSIZING, L"Smart sizing", wfc); - if (wfc->common.context.settings->SmartSizing) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing)) { CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, MF_CHECKED); } - if (wfc->common.context.settings->RemoteAssistanceMode) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_RemoteAssistanceMode)) wf_append_item_to_system_menu(hMenu, MIIM_FTYPE | MIIM_ID | MIIM_STRING, SYSCOMMAND_ID_REQUEST_CONTROL, L"Request control", wfc); } @@ -320,18 +329,18 @@ static WCHAR* wf_window_get_title(rdpSettings* settings) BOOL port; WCHAR* windowTitle = NULL; size_t size; - char* name; WCHAR prefix[] = L"FreeRDP:"; if (!settings) return NULL; - name = settings->ServerHostname; + const char* name = freerdp_settings_get_string(settings, FreeRDP_ServerHostname); - if (settings->WindowTitle) - return ConvertUtf8ToWCharAlloc(settings->WindowTitle, NULL); + if (freerdp_settings_get_string(settings, FreeRDP_WindowTitle)) + return ConvertUtf8ToWCharAlloc(freerdp_settings_get_string(settings, FreeRDP_WindowTitle), + NULL); - port = (settings->ServerPort != 3389); + port = (freerdp_settings_get_uint32(settings, FreeRDP_ServerPort) != 3389); size = strlen(name) + 16 + wcslen(prefix); windowTitle = calloc(size, sizeof(WCHAR)); @@ -341,7 +350,8 @@ static WCHAR* wf_window_get_title(rdpSettings* settings) if (!port) _snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S", prefix, name); else - _snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S:%u", prefix, name, settings->ServerPort); + _snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S:%u", prefix, name, + freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)); return windowTitle; } @@ -368,7 +378,9 @@ static BOOL wf_post_connect(freerdp* instance) wfc = (wfContext*)instance->context; WINPR_ASSERT(wfc); - wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL); + wfc->primary = + wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), format, NULL); if (!gdi_init_ex(instance, format, 0, wfc->primary->pdata, NULL)) return FALSE; @@ -378,7 +390,7 @@ static BOOL wf_post_connect(freerdp* instance) gdi = instance->context->gdi; - if (!settings->SoftwareGdi) + if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) { wf_gdi_register_update_callbacks(context->update); } @@ -388,12 +400,15 @@ static BOOL wf_post_connect(freerdp* instance) if (!wfc->window_title) return FALSE; - if (settings->EmbeddedWindow) - settings->Decorations = FALSE; + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) + { + if (!freerdp_settings_set_bool(settings, FreeRDP_Decorations, FALSE)) + return FALSE; + } if (wfc->fullscreen) dwStyle = WS_POPUP; - else if (!settings->Decorations) + else if (!freerdp_settings_get_bool(settings, FreeRDP_Decorations)) dwStyle = WS_CHILD | WS_BORDER; else dwStyle = @@ -408,8 +423,8 @@ static BOOL wf_post_connect(freerdp* instance) wf_resize_window(wfc); wf_add_system_menu(wfc); - BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight, NULL, 0, 0, - BLACKNESS); + BitBlt(wfc->primary->hdc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), NULL, 0, 0, BLACKNESS); wfc->drawing = wfc->primary; EventArgsInit(&e, "wfreerdp"); e.embed = FALSE; @@ -428,7 +443,8 @@ static BOOL wf_post_connect(freerdp* instance) context->update->EndPaint = wf_end_paint; wf_register_pointer(context->graphics); - wfc->floatbar = wf_floatbar_new(wfc, wfc->hInstance, settings->Floatbar); + wfc->floatbar = + wf_floatbar_new(wfc, wfc->hInstance, freerdp_settings_get_bool(settings, FreeRDP_Floatbar)); return TRUE; } @@ -518,9 +534,11 @@ static BOOL wf_authenticate_ex(freerdp* instance, char** username, char** passwo if (_wcsnlen(PasswordW, ARRAYSIZE(PasswordW)) == 0) { - if (!wfc->isConsole && wfc->common.context.settings->CredentialsFromStdin) + if (!wfc->isConsole && + freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin)) WLog_ERR(TAG, "Flag for stdin read present but stdin is redirected; using GUI"); - if (wfc->isConsole && wfc->common.context.settings->CredentialsFromStdin) + if (wfc->isConsole && + freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin)) status = CredUICmdLinePromptForCredentialsW(titleW, NULL, 0, UserNameW, ARRAYSIZE(UserNameW), PasswordW, ARRAYSIZE(PasswordW), &fSave, dwFlags); @@ -662,14 +680,10 @@ static void wf_report_error(char* wszMessage, DWORD dwErrCode) static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char* subject, const char* issuer, const char* fingerprint) { - DWORD derPubKeyLen; - char* derPubKey; - HRESULT hr = CRYPT_E_NOT_FOUND; DWORD dwChainFlags = CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT; PCCERT_CONTEXT pCert = NULL; - HCERTSTORE hStore = NULL; HCERTCHAINENGINE hChainEngine = NULL; PCCERT_CHAIN_CONTEXT pChainContext = NULL; @@ -680,8 +694,8 @@ static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char* CERT_CHAIN_POLICY_STATUS PolicyStatus = { 0 }; CERT_CHAIN_ENGINE_CONFIG EngineConfig = { 0 }; - derPubKeyLen = strlen(fingerprint); - derPubKey = calloc(derPubKeyLen, sizeof(char)); + DWORD derPubKeyLen = strlen(fingerprint); + char* derPubKey = calloc(derPubKeyLen, sizeof(char)); if (NULL == derPubKey) { WLog_ERR(TAG, "Could not allocate derPubKey"); @@ -1057,7 +1071,7 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam) { msg_ret = GetMessage(&msg, NULL, 0, 0); - if (settings->EmbeddedWindow) + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) { if ((msg.message == WM_SETFOCUS) && (msg.lParam == 1)) { @@ -1176,7 +1190,8 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh // prevent infinite message loop wfc->disablewindowtracking = TRUE; - if (settings->SmartSizing || settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { wfc->xCurrentScroll = 0; wfc->yCurrentScroll = 0; @@ -1196,22 +1211,26 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh BOOL horiz = wfc->xScrollVisible; BOOL vert = wfc->yScrollVisible; - if (!horiz && client_width < settings->DesktopWidth) + if (!horiz && client_width < freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) { horiz = TRUE; } else if (horiz && - client_width >= settings->DesktopWidth /* - GetSystemMetrics(SM_CXVSCROLL)*/) + client_width >= + freerdp_settings_get_uint32( + settings, FreeRDP_DesktopWidth) /* - GetSystemMetrics(SM_CXVSCROLL)*/) { horiz = FALSE; } - if (!vert && client_height < settings->DesktopHeight) + if (!vert && client_height < freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) { vert = TRUE; } else if (vert && - client_height >= settings->DesktopHeight /* - GetSystemMetrics(SM_CYHSCROLL)*/) + client_height >= + freerdp_settings_get_uint32( + settings, FreeRDP_DesktopHeight) /* - GetSystemMetrics(SM_CYHSCROLL)*/) { vert = FALSE; } @@ -1246,12 +1265,13 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh // The horizontal scrolling range is defined by // (bitmap_width) - (client_width). The current horizontal // scroll value remains within the horizontal scrolling range. - wfc->xMaxScroll = MAX(settings->DesktopWidth - client_width, 0); + wfc->xMaxScroll = + MAX(freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) - client_width, 0); wfc->xCurrentScroll = MIN(wfc->xCurrentScroll, wfc->xMaxScroll); si.cbSize = sizeof(si); si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; si.nMin = wfc->xMinScroll; - si.nMax = settings->DesktopWidth; + si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); si.nPage = client_width; si.nPos = wfc->xCurrentScroll; SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE); @@ -1262,12 +1282,13 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh // The vertical scrolling range is defined by // (bitmap_height) - (client_height). The current vertical // scroll value remains within the vertical scrolling range. - wfc->yMaxScroll = MAX(settings->DesktopHeight - client_height, 0); + wfc->yMaxScroll = MAX( + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) - client_height, 0); wfc->yCurrentScroll = MIN(wfc->yCurrentScroll, wfc->yMaxScroll); si.cbSize = sizeof(si); si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; si.nMin = wfc->yMinScroll; - si.nMax = settings->DesktopHeight; + si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); si.nPage = client_height; si.nPos = wfc->yCurrentScroll; SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE); @@ -1346,20 +1367,22 @@ static void wfreerdp_client_free(freerdp* instance, rdpContext* context) static int wfreerdp_client_start(rdpContext* context) { - HWND hWndParent; - HINSTANCE hInstance; wfContext* wfc = (wfContext*)context; - freerdp* instance; WINPR_ASSERT(context); WINPR_ASSERT(context->settings); - instance = context->instance; + freerdp* instance = context->instance; WINPR_ASSERT(instance); - hInstance = GetModuleHandle(NULL); - hWndParent = (HWND)context->settings->ParentWindowId; - context->settings->EmbeddedWindow = (hWndParent) ? TRUE : FALSE; + rdpContext* settings = context->instance; + WINPR_ASSERT(settings); + + HINSTANCE hInstance = GetModuleHandle(NULL); + HWND hWndParent = (HWND)freerdp_settings_get_uint32(context->settings, FreeRDP_ParentWindowId); + if (!freerdp_settings_set_bool(settings, FreeRDP_EmbeddedWindow, (hWndParent) ? TRUE : FALSE)) + return -1; + wfc->hWndParent = hWndParent; /* initial windows system item position where we will insert new menu item diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index 43ee68575..d4711e547 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -284,7 +284,9 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam) // Holding the CTRL key down while resizing the window will force the desktop aspect ratio. LPRECT rect; - if ((settings->SmartSizing || settings->DynamicResolutionUpdate) && ctrl_down()) + if ((freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) && + ctrl_down()) { rect = (LPRECT)wParam; @@ -294,23 +296,29 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam) case WMSZ_RIGHT: case WMSZ_BOTTOMRIGHT: // Adjust height - rect->bottom = rect->top + settings->DesktopHeight * (rect->right - rect->left) / - settings->DesktopWidth; + rect->bottom = + rect->top + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) * + (rect->right - rect->left) / + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); break; case WMSZ_TOP: case WMSZ_BOTTOM: case WMSZ_TOPRIGHT: // Adjust width - rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) / - settings->DesktopHeight; + rect->right = + rect->left + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) * + (rect->bottom - rect->top) / + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); break; case WMSZ_BOTTOMLEFT: case WMSZ_TOPLEFT: // adjust width - rect->left = rect->right - (settings->DesktopWidth * (rect->bottom - rect->top) / - settings->DesktopHeight); + rect->left = + rect->right - (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) * + (rect->bottom - rect->top) / + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); break; } } @@ -323,7 +331,7 @@ static void wf_send_resize(wfContext* wfc) int targetHeight = wfc->client_height; rdpSettings* settings = wfc->common.context.settings; - if (settings->DynamicResolutionUpdate && wfc->disp != NULL) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate) && wfc->disp != NULL) { if (GetTickCount64() - wfc->lastSentDate > RESIZE_MIN_DELAY) { @@ -333,8 +341,8 @@ static void wf_send_resize(wfContext* wfc) targetWidth = windowRect.right - windowRect.left; targetHeight = windowRect.bottom - windowRect.top; } - if (settings->SmartSizingWidth != targetWidth || - settings->SmartSizingHeight != targetHeight) + if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) != targetWidth || + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) != targetHeight) { DISPLAY_CONTROL_MONITOR_LAYOUT layout = { 0 }; @@ -342,9 +350,12 @@ static void wf_send_resize(wfContext* wfc) layout.Top = layout.Left = 0; layout.Width = targetWidth; layout.Height = targetHeight; - layout.Orientation = settings->DesktopOrientation; - layout.DesktopScaleFactor = settings->DesktopScaleFactor; - layout.DeviceScaleFactor = settings->DeviceScaleFactor; + layout.Orientation = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation); + layout.DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout.DeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); layout.PhysicalWidth = targetWidth; layout.PhysicalHeight = targetHeight; @@ -353,8 +364,8 @@ static void wf_send_resize(wfContext* wfc) { WLog_ERR("", "SendMonitorLayout failed."); } - settings->SmartSizingWidth = targetWidth; - settings->SmartSizingHeight = targetHeight; + freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingWidth, targetWidth); + freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingHeight, targetHeight); } wfc->lastSentDate = GetTickCount64(); } @@ -401,8 +412,9 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam break; case WM_GETMINMAXINFO: - if (wfc->common.context.settings->SmartSizing || - wfc->common.context.settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) || + (freerdp_settings_get_bool(wfc->common.context.settings, + FreeRDP_DynamicResolutionUpdate))) { processed = FALSE; } @@ -418,8 +430,12 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam if (!wfc->fullscreen) { // add window decoration - minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x; - minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y; + minmax->ptMaxTrackSize.x = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + + wfc->diff.x; + minmax->ptMaxTrackSize.y = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + + wfc->diff.y; } } @@ -713,17 +729,21 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam { if (wParam == SYSCOMMAND_ID_SMARTSIZING) { + rdpSettings* settings = wfc->common.context.settings; HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE); - freerdp_settings_set_bool(wfc->common.context.settings, FreeRDP_SmartSizing, - !wfc->common.context.settings->SmartSizing); + const BOOL rc = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing); + freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, !rc); CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, - wfc->common.context.settings->SmartSizing ? MF_CHECKED - : MF_UNCHECKED); - if (!wfc->common.context.settings->SmartSizing) + freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) + ? MF_CHECKED + : MF_UNCHECKED); + if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, - wfc->common.context.settings->DesktopWidth + wfc->diff.x, - wfc->common.context.settings->DesktopHeight + wfc->diff.y, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + + wfc->diff.x, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + + wfc->diff.y, SWP_NOMOVE); } else @@ -829,15 +849,15 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSr WINPR_ASSERT(settings); if (!wfc->client_width) - wfc->client_width = settings->DesktopWidth; + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); if (!wfc->client_height) - wfc->client_height = settings->DesktopHeight; + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); ww = wfc->client_width; wh = wfc->client_height; - dw = settings->DesktopWidth; - dh = settings->DesktopHeight; + dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (!ww) ww = dw; @@ -845,7 +865,8 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSr if (!wh) wh = dh; - if (wfc->fullscreen || !settings->SmartSizing || (ww == dw && wh == dh)) + if (wfc->fullscreen || !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + (ww == dw && wh == dh)) { return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY); } @@ -873,17 +894,17 @@ static BOOL wf_scale_mouse_pos(wfContext* wfc, INT32 x, INT32 y, UINT16* px, UIN return FALSE; if (!wfc->client_width) - wfc->client_width = settings->DesktopWidth; + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); if (!wfc->client_height) - wfc->client_height = settings->DesktopHeight; + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); ww = wfc->client_width; wh = wfc->client_height; - dw = settings->DesktopWidth; - dh = settings->DesktopHeight; + dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); - if (!settings->SmartSizing || ((ww == dw) && (wh == dh))) + if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || ((ww == dw) && (wh == dh))) { x += wfc->xCurrentScroll; y += wfc->yCurrentScroll; diff --git a/client/Windows/wf_floatbar.c b/client/Windows/wf_floatbar.c index 653253f6a..ab5ad864b 100644 --- a/client/Windows/wf_floatbar.c +++ b/client/Windows/wf_floatbar.c @@ -699,7 +699,8 @@ wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags) if (!update_locked_state(floatbar)) goto fail; - if (!wf_floatbar_toggle_fullscreen(floatbar, wfc->common.context.settings->Fullscreen)) + if (!wf_floatbar_toggle_fullscreen( + floatbar, freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Fullscreen))) goto fail; return floatbar; diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c index 60d3bd5da..c81aed806 100644 --- a/client/Windows/wf_gdi.c +++ b/client/Windows/wf_gdi.c @@ -222,8 +222,8 @@ BOOL wf_scale_rect(wfContext* wfc, RECT* source) if (!settings) return FALSE; - dw = settings->DesktopWidth; - dh = settings->DesktopHeight; + dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (!wfc->client_width) wfc->client_width = dw; @@ -240,7 +240,8 @@ BOOL wf_scale_rect(wfContext* wfc, RECT* source) if (!wh) wh = dh; - if (wfc->common.context.settings->SmartSizing && (ww != dw || wh != dh)) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) && + (ww != dw || wh != dh)) { source->bottom = source->bottom * wh / dh + 20; source->top = source->top * wh / dh - 20; @@ -280,30 +281,34 @@ void wf_update_offset(wfContext* wfc) if (wfc->fullscreen) { - if (wfc->common.context.settings->UseMultimon) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon)) { int x = GetSystemMetrics(SM_XVIRTUALSCREEN); int y = GetSystemMetrics(SM_YVIRTUALSCREEN); int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); int h = GetSystemMetrics(SM_CYVIRTUALSCREEN); - wfc->offset_x = (w - settings->DesktopWidth) / 2; + wfc->offset_x = (w - freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / 2; if (wfc->offset_x < x) wfc->offset_x = x; - wfc->offset_y = (h - settings->DesktopHeight) / 2; + wfc->offset_y = (h - freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / 2; if (wfc->offset_y < y) wfc->offset_y = y; } else { - wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - settings->DesktopWidth) / 2; + wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / + 2; if (wfc->offset_x < 0) wfc->offset_x = 0; - wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - settings->DesktopHeight) / 2; + wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / + 2; if (wfc->offset_y < 0) wfc->offset_y = 0; @@ -323,7 +328,7 @@ void wf_resize_window(wfContext* wfc) if (wfc->fullscreen) { - if (wfc->common.context.settings->UseMultimon) + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon)) { int x = GetSystemMetrics(SM_XVIRTUALSCREEN); int y = GetSystemMetrics(SM_YVIRTUALSCREEN); @@ -339,17 +344,17 @@ void wf_resize_window(wfContext* wfc) GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED); } } - else if (!wfc->common.context.settings->Decorations) + else if (!freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Decorations)) { SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD); - if (settings->EmbeddedWindow) + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) { if (!wfc->client_height) - wfc->client_height = settings->DesktopHeight; + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (!wfc->client_width) - wfc->client_width = settings->DesktopWidth; + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); wf_update_canvas_diff(wfc); /* Now resize to get full canvas size and room for caption and borders */ @@ -360,11 +365,15 @@ void wf_resize_window(wfContext* wfc) else { /* Now resize to get full canvas size and room for caption and borders */ - SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth, settings->DesktopHeight, + SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), SWP_FRAMECHANGED); wf_update_canvas_diff(wfc); - SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x, - settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED); + SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y, + SWP_NOMOVE | SWP_FRAMECHANGED); } } else @@ -374,10 +383,10 @@ void wf_resize_window(wfContext* wfc) WS_MAXIMIZEBOX); if (!wfc->client_height) - wfc->client_height = settings->DesktopHeight; + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); if (!wfc->client_width) - wfc->client_width = settings->DesktopWidth; + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); if (!wfc->client_x) wfc->client_x = 10; @@ -388,10 +397,12 @@ void wf_resize_window(wfContext* wfc) wf_update_canvas_diff(wfc); /* Now resize to get full canvas size and room for caption and borders */ int width, height; - if (settings->SmartSizing && settings->SmartSizingWidth && settings->SmartSizingHeight) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) && + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight)) { - width = settings->SmartSizingWidth; - height = settings->SmartSizingHeight; + width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); + height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); } else { @@ -400,10 +411,11 @@ void wf_resize_window(wfContext* wfc) } int xpos, ypos; - if ((settings->DesktopPosX != UINT32_MAX) && (settings->DesktopPosY != UINT32_MAX)) + if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) && + (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX)) { - xpos = settings->DesktopPosX; - ypos = settings->DesktopPosY; + xpos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX); + ypos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY); } else { @@ -804,7 +816,7 @@ static BOOL wf_gdi_surface_frame_marker(rdpContext* context, return FALSE; if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END && - settings->FrameAcknowledge > 0) + freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0) { IFCALL(context->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId); } diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index f64f7d14a..8c22d3419 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) { rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv); - if (settings->ListMonitors) + if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors)) xf_list_monitors(xfc); goto out; diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index 0681a54e4..d24203826 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -74,7 +74,7 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven } else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) { - if (settings->SoftwareGdi) + if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) gdi_video_control_init(xfc->common.context.gdi, (VideoClientContext*)e->pInterface); else xf_video_control_init(xfc, (VideoClientContext*)e->pInterface); @@ -122,7 +122,7 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect } else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) { - if (settings->SoftwareGdi) + if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) gdi_video_control_uninit(xfc->common.context.gdi, (VideoClientContext*)e->pInterface); else xf_video_control_uninit(xfc, (VideoClientContext*)e->pInterface); diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index ec66c6d72..db69f5d10 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -195,14 +195,17 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) return; } - if (settings->DesktopWidth <= 0 || settings->DesktopHeight <= 0) + if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) <= 0 || + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) <= 0) { WLog_ERR(TAG, "the window dimensions are invalid"); return; } - xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth; - yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight; + xScalingFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) / (double)xfc->scaledWidth; + yScalingFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) / (double)xfc->scaledHeight; XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, 0); /* Black out possible space between desktop and window borders */ @@ -277,8 +280,8 @@ BOOL xf_picture_transform_required(xfContext* xfc) WINPR_ASSERT(settings); if ((xfc->offset_x != 0) || (xfc->offset_y != 0) || - (xfc->scaledWidth != (INT64)settings->DesktopWidth) || - (xfc->scaledHeight != (INT64)settings->DesktopHeight)) + (xfc->scaledWidth != (INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) || + (xfc->scaledHeight != (INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) { return TRUE; } @@ -336,8 +339,10 @@ static BOOL xf_desktop_resize(rdpContext* context) XFreePixmap(xfc->display, xfc->primary); WINPR_ASSERT(xfc->depth != 0); - if (!(xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth, - settings->DesktopHeight, xfc->depth))) + if (!(xfc->primary = XCreatePixmap( + xfc->display, xfc->drawable, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), xfc->depth))) return FALSE; if (same) @@ -346,36 +351,39 @@ static BOOL xf_desktop_resize(rdpContext* context) #ifdef WITH_XRENDER - if (!settings->SmartSizing) + if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { - xfc->scaledWidth = settings->DesktopWidth; - xfc->scaledHeight = settings->DesktopHeight; + xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } #endif if (!xfc->fullscreen) { - xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth, settings->DesktopHeight); + xf_ResizeDesktopWindow(xfc, xfc->window, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } else { #ifdef WITH_XRENDER - if (!settings->SmartSizing) + if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) #endif { /* Update the saved width and height values the window will be * resized to when toggling out of fullscreen */ - xfc->savedWidth = settings->DesktopWidth; - xfc->savedHeight = settings->DesktopHeight; + xfc->savedWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + xfc->savedHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, 0); - XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, settings->DesktopWidth, - settings->DesktopHeight); + XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } return TRUE; @@ -461,7 +469,8 @@ static BOOL xf_sw_desktop_resize(rdpContext* context) BOOL ret = FALSE; xf_lock_x11(xfc); - if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight)) + if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) goto out; if (xfc->image) @@ -503,7 +512,8 @@ static BOOL xf_hw_desktop_resize(rdpContext* context) xf_lock_x11(xfc); - if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight)) + if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) goto out; ret = xf_desktop_resize(context); @@ -543,18 +553,18 @@ static char* xf_window_get_title(rdpSettings* settings) BOOL port; char* windowTitle; size_t size; - char* name; const char* prefix = "FreeRDP:"; if (!settings) return NULL; - name = settings->ServerHostname; + const char* name = freerdp_settings_get_string(settings, FreeRDP_ServerHostname); + const char* title = freerdp_settings_get_string(settings, FreeRDP_WindowTitle); - if (settings->WindowTitle) - return _strdup(settings->WindowTitle); + if (title) + return _strdup(title); - port = (settings->ServerPort != 3389); + port = (freerdp_settings_get_uint32(settings, FreeRDP_ServerPort) != 3389); /* Just assume a window title is never longer than a filename... */ size = strnlen(name, MAX_PATH) + 16; windowTitle = calloc(size, sizeof(char)); @@ -565,7 +575,8 @@ static char* xf_window_get_title(rdpSettings* settings) if (!port) sprintf_s(windowTitle, size, "%s %s", prefix, name); else - sprintf_s(windowTitle, size, "%s %s:%i", prefix, name, settings->ServerPort); + sprintf_s(windowTitle, size, "%s %s:%i", prefix, name, + freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)); return windowTitle; } @@ -580,8 +591,8 @@ BOOL xf_create_window(xfContext* xfc) rdpSettings* settings = xfc->common.context.settings; WINPR_ASSERT(settings); - int width = settings->DesktopWidth; - int height = settings->DesktopHeight; + int width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + int height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); const XSetWindowAttributes empty = { 0 }; xfc->attribs = empty; @@ -649,13 +660,13 @@ BOOL xf_create_window(xfContext* xfc) #ifdef WITH_XRENDER - if (settings->SmartSizing && !xfc->fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !xfc->fullscreen) { - if (settings->SmartSizingWidth) - width = settings->SmartSizingWidth; + if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) > 0) + width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); - if (settings->SmartSizingHeight) - height = settings->SmartSizingHeight; + if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) > 0) + height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); xfc->scaledWidth = width; xfc->scaledHeight = height; @@ -692,8 +703,10 @@ BOOL xf_create_window(xfContext* xfc) WINPR_ASSERT(xfc->depth != 0); if (!xfc->primary) - xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth, - settings->DesktopHeight, xfc->depth); + xfc->primary = + XCreatePixmap(xfc->display, xfc->drawable, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), xfc->depth); xfc->drawing = xfc->primary; @@ -706,8 +719,9 @@ BOOL xf_create_window(xfContext* xfc) XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen)); - XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, settings->DesktopWidth, - settings->DesktopHeight); + XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); XFlush(xfc->display); return TRUE; @@ -724,8 +738,10 @@ BOOL xf_create_image(xfContext* xfc) WINPR_ASSERT(xfc->depth != 0); xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, - (char*)cgdi->primary_buffer, settings->DesktopWidth, - settings->DesktopHeight, xfc->scanline_pad, cgdi->stride); + (char*)cgdi->primary_buffer, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), + xfc->scanline_pad, cgdi->stride); xfc->image->byte_order = LSBFirst; xfc->image->bitmap_bit_order = LSBFirst; } @@ -800,7 +816,8 @@ void xf_toggle_fullscreen(xfContext* xfc) xf_ungrab(xfc); xfc->fullscreen = (xfc->fullscreen) ? FALSE : TRUE; - xfc->decorations = (xfc->fullscreen) ? FALSE : settings->Decorations; + xfc->decorations = + (xfc->fullscreen) ? FALSE : freerdp_settings_get_bool(settings, FreeRDP_Decorations); xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen); EventArgsInit(&e, "xfreerdp"); e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0; @@ -1078,7 +1095,7 @@ static void xf_button_map_init(xfContext* xfc) x11_map[111] = 112; /* query system for actual remapping */ - if (xfc->common.context.settings->UnmapButtons) + if (freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_UnmapButtons)) { xf_get_x11_button_map(xfc, x11_map); } @@ -1145,12 +1162,16 @@ static BOOL xf_pre_connect(freerdp* instance) channels = context->channels; WINPR_ASSERT(channels); - settings->OsMajorType = OSMAJORTYPE_UNIX; - settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER)) + return FALSE; PubSub_SubscribeChannelConnected(context->pubSub, xf_OnChannelConnectedEventHandler); PubSub_SubscribeChannelDisconnected(context->pubSub, xf_OnChannelDisconnectedEventHandler); - if (!settings->Username && !settings->CredentialsFromStdin && !settings->SmartcardLogon) + if (!freerdp_settings_get_string(settings, FreeRDP_Username) && + !freerdp_settings_get_bool(settings, FreeRDP_CredentialsFromStdin) && + !freerdp_settings_get_bool(settings, FreeRDP_SmartcardLogon)) { char login_name[MAX_PATH] = { 0 }; ULONG size = sizeof(login_name) - 1; @@ -1160,7 +1181,8 @@ static BOOL xf_pre_connect(freerdp* instance) if (!freerdp_settings_set_string(settings, FreeRDP_Username, login_name)) return FALSE; - WLog_INFO(TAG, "No user name set. - Using login name: %s", settings->Username); + WLog_INFO(TAG, "No user name set. - Using login name: %s", + freerdp_settings_get_string(settings, FreeRDP_Username)); } } @@ -1185,8 +1207,10 @@ static BOOL xf_pre_connect(freerdp* instance) } if (maxWidth && maxHeight && !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { - settings->DesktopWidth = maxWidth; - settings->DesktopHeight = maxHeight; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, maxWidth)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, maxHeight)) + return FALSE; } #ifdef WITH_XRENDER @@ -1195,18 +1219,26 @@ static BOOL xf_pre_connect(freerdp* instance) * If /f is specified in combination with /smart-sizing:widthxheight then * we run the session in the /smart-sizing dimensions scaled to full screen */ - if (settings->Fullscreen && settings->SmartSizing && settings->SmartSizingWidth && - settings->SmartSizingHeight) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) && + freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && + (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) > 0) && + (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) > 0)) { - settings->DesktopWidth = settings->SmartSizingWidth; - settings->DesktopHeight = settings->SmartSizingHeight; + if (!freerdp_settings_set_uint32( + settings, FreeRDP_DesktopWidth, + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth))) + return FALSE; + if (!freerdp_settings_set_uint32( + settings, FreeRDP_DesktopHeight, + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight))) + return FALSE; } #endif - xfc->fullscreen = settings->Fullscreen; - xfc->decorations = settings->Decorations; - xfc->grab_keyboard = settings->GrabKeyboard; - xfc->fullscreen_toggle = settings->ToggleFullscreen; + xfc->fullscreen = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen); + xfc->decorations = freerdp_settings_get_bool(settings, FreeRDP_Decorations); + xfc->grab_keyboard = freerdp_settings_get_bool(settings, FreeRDP_GrabKeyboard); + xfc->fullscreen_toggle = freerdp_settings_get_bool(settings, FreeRDP_ToggleFullscreen); if (!freerdp_settings_get_bool(settings, FreeRDP_AuthenticationOnly)) xf_button_map_init(xfc); return TRUE; @@ -1329,7 +1361,7 @@ static BOOL xf_post_connect(freerdp* instance) rdpUpdate* update = context->update; WINPR_ASSERT(update); - if (settings->RemoteApplicationMode) + if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode)) xfc->remote_app = TRUE; if (!xf_create_window(xfc)) @@ -1347,7 +1379,7 @@ static BOOL xf_post_connect(freerdp* instance) if (!xf_register_pointer(context->graphics)) return FALSE; - if (!settings->SoftwareGdi) + if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) { if (!xf_register_graphics(context->graphics)) { @@ -1359,28 +1391,30 @@ static BOOL xf_post_connect(freerdp* instance) } #ifdef WITH_XRENDER - xfc->scaledWidth = settings->DesktopWidth; - xfc->scaledHeight = settings->DesktopHeight; + xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); xfc->offset_x = 0; xfc->offset_y = 0; #endif if (!xfc->xrenderAvailable) { - if (settings->SmartSizing) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { WLog_ERR(TAG, "XRender not available: disabling smart-sizing"); - settings->SmartSizing = FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, FALSE)) + return FALSE; } - if (settings->MultiTouchGestures) + if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)) { WLog_ERR(TAG, "XRender not available: disabling local multi-touch gestures"); - settings->MultiTouchGestures = FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchGestures, FALSE)) + return FALSE; } } - if (settings->SoftwareGdi) + if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) update->DesktopResize = xf_sw_desktop_resize; else update->DesktopResize = xf_hw_desktop_resize; @@ -1390,8 +1424,9 @@ static BOOL xf_post_connect(freerdp* instance) update->SetKeyboardIndicators = xf_keyboard_set_indicators; update->SetKeyboardImeStatus = xf_keyboard_set_ime_status; - const BOOL serverIsWindowsPlatform = (settings->OsMajorType == OSMAJORTYPE_WINDOWS); - if (settings->RedirectClipboard && + const BOOL serverIsWindowsPlatform = + (freerdp_settings_get_uint32(settings, FreeRDP_OsMajorType) == OSMAJORTYPE_WINDOWS); + if (freerdp_settings_get_bool(settings, FreeRDP_RedirectClipboard) && !(xfc->clipboard = xf_clipboard_new(xfc, !serverIsWindowsPlatform))) return FALSE; @@ -1407,8 +1442,8 @@ static BOOL xf_post_connect(freerdp* instance) } EventArgsInit(&e, "xfreerdp"); - e.width = settings->DesktopWidth; - e.height = settings->DesktopHeight; + e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); PubSub_OnResizeWindow(context->pubSub, xfc, &e); return TRUE; } @@ -1536,7 +1571,7 @@ static DWORD WINAPI xf_client_thread(LPVOID param) goto end; /* --authonly ? */ - if (settings->AuthenticationOnly) + if (freerdp_settings_get_bool(settings, FreeRDP_AuthenticationOnly)) { WLog_ERR(TAG, "Authentication only, exit status %" PRId32 "", !status); goto disconnect; @@ -1723,7 +1758,8 @@ static void xf_ZoomingChangeEventHandler(void* context, const ZoomingChangeEvent xfc->scaledWidth = w; xfc->scaledHeight = h; - xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight); + xf_draw_screen(xfc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } static void xf_PanningChangeEventHandler(void* context, const PanningChangeEventArgs* e) @@ -1742,7 +1778,8 @@ static void xf_PanningChangeEventHandler(void* context, const PanningChangeEvent xfc->offset_x += e->dx; xfc->offset_y += e->dy; - xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight); + xf_draw_screen(xfc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } #endif @@ -1769,7 +1806,7 @@ static int xfreerdp_client_start(rdpContext* context) xfContext* xfc = (xfContext*)context; rdpSettings* settings = context->settings; - if (!settings->ServerHostname) + if (!freerdp_settings_get_string(settings, FreeRDP_ServerHostname)) { WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]"); return -1; diff --git a/client/X11/xf_disp.c b/client/X11/xf_disp.c index 05f76091c..4af1054a2 100644 --- a/client/X11/xf_disp.c +++ b/client/X11/xf_disp.c @@ -79,13 +79,16 @@ static BOOL xf_disp_settings_changed(xfDispContext* xfDisp) if (xfDisp->lastSentHeight != xfDisp->targetHeight) return TRUE; - if (xfDisp->lastSentDesktopOrientation != settings->DesktopOrientation) + if (xfDisp->lastSentDesktopOrientation != + freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation)) return TRUE; - if (xfDisp->lastSentDesktopScaleFactor != settings->DesktopScaleFactor) + if (xfDisp->lastSentDesktopScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor)) return TRUE; - if (xfDisp->lastSentDeviceScaleFactor != settings->DeviceScaleFactor) + if (xfDisp->lastSentDeviceScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor)) return TRUE; if (xfDisp->fullscreen != xfDisp->xfc->fullscreen) @@ -106,9 +109,12 @@ static BOOL xf_update_last_sent(xfDispContext* xfDisp) xfDisp->lastSentWidth = xfDisp->targetWidth; xfDisp->lastSentHeight = xfDisp->targetHeight; - xfDisp->lastSentDesktopOrientation = settings->DesktopOrientation; - xfDisp->lastSentDesktopScaleFactor = settings->DesktopScaleFactor; - xfDisp->lastSentDeviceScaleFactor = settings->DeviceScaleFactor; + xfDisp->lastSentDesktopOrientation = + freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + xfDisp->lastSentDesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + xfDisp->lastSentDeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); xfDisp->fullscreen = xfDisp->xfc->fullscreen; return TRUE; } @@ -138,10 +144,13 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp) return TRUE; xfDisp->lastSentDate = GetTickCount64(); - if (xfc->fullscreen && (settings->MonitorCount > 0)) + + const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); + if (xfc->fullscreen && (mcount > 0)) { - if (xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) != - CHANNEL_RC_OK) + const rdpMonitor* monitors = + freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray); + if (xf_disp_sendLayout(xfDisp->disp, monitors, mcount) != CHANNEL_RC_OK) return FALSE; } else @@ -150,9 +159,10 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp) layout.Top = layout.Left = 0; layout.Width = xfDisp->targetWidth; layout.Height = xfDisp->targetHeight; - layout.Orientation = settings->DesktopOrientation; - layout.DesktopScaleFactor = settings->DesktopScaleFactor; - layout.DeviceScaleFactor = settings->DeviceScaleFactor; + layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + layout.DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); layout.PhysicalWidth = xfDisp->targetWidth / 75.0 * 25.4; layout.PhysicalHeight = xfDisp->targetHeight / 75.0 * 25.4; @@ -246,7 +256,7 @@ static void xf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs* if (!xf_disp_check_context(context, &xfc, &xfDisp, &settings)) return; - if (xfDisp->activated && !settings->Fullscreen) + if (xfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { xf_disp_set_window_resizable(xfDisp); xf_disp_sendResize(xfDisp); @@ -315,8 +325,10 @@ xfDispContext* xf_disp_new(xfContext* xfc) } #endif - ret->lastSentWidth = ret->targetWidth = settings->DesktopWidth; - ret->lastSentHeight = ret->targetHeight = settings->DesktopHeight; + ret->lastSentWidth = ret->targetWidth = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + ret->lastSentHeight = ret->targetHeight = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); PubSub_SubscribeActivated(pubSub, xf_disp_OnActivated); PubSub_SubscribeGraphicsReset(pubSub, xf_disp_OnGraphicsReset); PubSub_SubscribeTimer(pubSub, xf_disp_OnTimer); @@ -406,8 +418,10 @@ UINT xf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, UIN break; } - layout->DesktopScaleFactor = settings->DesktopScaleFactor; - layout->DeviceScaleFactor = settings->DeviceScaleFactor; + layout->DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout->DeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); } ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, nmonitors, layouts); @@ -444,8 +458,9 @@ BOOL xf_disp_handle_xevent(xfContext* xfc, const XEvent* event) #endif xf_detect_monitors(xfc, &maxWidth, &maxHeight); - return xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) == - CHANNEL_RC_OK; + const rdpMonitor* monitors = freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray); + const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); + return xf_disp_sendLayout(xfDisp->disp, monitors, mcount) == CHANNEL_RC_OK; } BOOL xf_disp_handle_configureNotify(xfContext* xfc, int width, int height) @@ -485,7 +500,7 @@ static UINT xf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB); xfDisp->activated = TRUE; - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) return CHANNEL_RC_OK; WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable"); @@ -507,12 +522,12 @@ BOOL xf_disp_init(xfDispContext* xfDisp, DispClientContext* disp) xfDisp->disp = disp; disp->custom = (void*)xfDisp; - if (settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { disp->DisplayControlCaps = xf_DisplayControlCaps; #ifdef USABLE_XRANDR - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { /* ask X11 to notify us of screen changes */ XRRSelectInput(xfDisp->xfc->display, DefaultRootWindow(xfDisp->xfc->display), diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 74411958e..f53cc703b 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -294,8 +294,10 @@ void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y) if (xf_picture_transform_required(xfc)) { - double xScalingFactor = xfc->scaledWidth / (double)settings->DesktopWidth; - double yScalingFactor = xfc->scaledHeight / (double)settings->DesktopHeight; + double xScalingFactor = xfc->scaledWidth / (double)freerdp_settings_get_uint32( + settings, FreeRDP_DesktopWidth); + double yScalingFactor = xfc->scaledHeight / (double)freerdp_settings_get_uint32( + settings, FreeRDP_DesktopHeight); tx = ((tx + xfc->offset_x) * xScalingFactor); ty = ((ty + xfc->offset_y) * yScalingFactor); } @@ -319,8 +321,10 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) rdpSettings* settings = xfc->common.context.settings; if (xf_picture_transform_required(xfc)) { - double xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth; - double yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight; + double xScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) / + (double)xfc->scaledWidth; + double yScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) / + (double)xfc->scaledHeight; *x = (int)((*x - xfc->offset_x) * xScalingFactor); *y = (int)((*y - xfc->offset_y) * yScalingFactor); } @@ -343,12 +347,13 @@ static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app) settings = xfc->common.context.settings; WINPR_ASSERT(settings); - if (!app && (settings->SmartSizing || settings->MultiTouchGestures)) + if (!app && (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))) { x = 0; y = 0; - w = settings->DesktopWidth; - h = settings->DesktopHeight; + w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } else { @@ -396,7 +401,7 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win rdpInput* input = xfc->common.context.input; WINPR_ASSERT(input); - if (!xfc->common.context.settings->MouseMotion) + if (!freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MouseMotion)) { if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0) return TRUE; @@ -784,22 +789,25 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* even xfc->offset_x = 0; xfc->offset_y = 0; - if (settings->SmartSizing || settings->MultiTouchGestures) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)) { xfc->scaledWidth = xfc->window->width; xfc->scaledHeight = xfc->window->height; - xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight); + xf_draw_screen(xfc, 0, 0, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); } else { - xfc->scaledWidth = settings->DesktopWidth; - xfc->scaledHeight = settings->DesktopHeight; + xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } #endif } - if (settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { int alignedWidth, alignedHeight; alignedWidth = (xfc->window->width / 2) * 2; @@ -1233,7 +1241,7 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event) break; default: - if (settings->SupportDisplayControl) + if (freerdp_settings_get_bool(settings, FreeRDP_SupportDisplayControl)) xf_disp_handle_xevent(xfc, event); break; diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 07de82da1..776015896 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -930,7 +930,7 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context, case SURFACECMD_FRAMEACTION_END: xfc->frame_begin = FALSE; - if (settings->FrameAcknowledge > 0) + if (freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0) { WINPR_ASSERT(xfc->common.context.update); IFCALL(xfc->common.context.update->SurfaceFrameAcknowledge, context, diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c index 7860a3718..441a33f0c 100644 --- a/client/X11/xf_gfx.c +++ b/client/X11/xf_gfx.c @@ -97,7 +97,8 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface) } else #ifdef WITH_XRENDER - if (settings->SmartSizing || settings->MultiTouchGestures) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)) { XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image, nXSrc, nYSrc, nXDst, nYDst, dwidth, dheight); @@ -454,7 +455,7 @@ void xf_graphics_pipeline_init(xfContext* xfc, RdpgfxClientContext* gfx) gdi_graphics_pipeline_init(gdi, gfx); - if (!settings->SoftwareGdi) + if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) { gfx->UpdateSurfaces = xf_UpdateSurfaces; gfx->CreateSurface = xf_CreateSurface; diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 267228840..ed6bc7c35 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -249,15 +249,21 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer* if (!settings) return FALSE; - const double xscale = - (settings->SmartSizing ? xfc->scaledWidth / (double)settings->DesktopWidth : 1); - const double yscale = - (settings->SmartSizing ? xfc->scaledHeight / (double)settings->DesktopHeight : 1); + const double xscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) + ? xfc->scaledWidth / (double)freerdp_settings_get_uint32( + settings, FreeRDP_DesktopWidth) + : 1); + const double yscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) + ? xfc->scaledHeight / (double)freerdp_settings_get_uint32( + settings, FreeRDP_DesktopHeight) + : 1); const UINT32 xTargetSize = MAX(1, pointer->width * xscale); const UINT32 yTargetSize = MAX(1, pointer->height * yscale); WLog_DBG(TAG, "scaled: %" PRIu32 "x%" PRIu32 ", desktop: %" PRIu32 "x%" PRIu32, - xfc->scaledWidth, xfc->scaledHeight, settings->DesktopWidth, settings->DesktopHeight); + xfc->scaledWidth, xfc->scaledHeight, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); for (UINT32 i = 0; i < xpointer->nCursors; i++) { if ((xpointer->cursorWidths[i] == xTargetSize) && diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index ed9023c14..3ea620f4e 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -101,7 +101,7 @@ static BOOL register_input_events(xfContext* xfc, Window window) switch (class->type) { case XITouchClass: - if (settings->MultiTouchInput) + if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchInput)) { const XITouchClassInfo* t = (const XITouchClassInfo*)class; if (t->mode == XIDirectTouch) @@ -933,11 +933,11 @@ int xf_input_handle_event(xfContext* xfc, const XEvent* event) settings = xfc->common.context.settings; WINPR_ASSERT(settings); - if (settings->MultiTouchInput) + if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchInput)) { return xf_input_handle_event_remote(xfc, event); } - else if (settings->MultiTouchGestures) + else if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)) { return xf_input_handle_event_local(xfc, event); } diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 2afe7129b..c0609f755 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -155,10 +155,11 @@ BOOL xf_keyboard_init(xfContext* xfc) WINPR_ASSERT(settings); xf_keyboard_clear(xfc); - xfc->KeyboardLayout = settings->KeyboardLayout; - xfc->KeyboardLayout = - freerdp_keyboard_init_ex(xfc->KeyboardLayout, settings->KeyboardRemappingList); - settings->KeyboardLayout = xfc->KeyboardLayout; + xfc->KeyboardLayout = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout); + xfc->KeyboardLayout = freerdp_keyboard_init_ex( + xfc->KeyboardLayout, freerdp_settings_get_string(settings, FreeRDP_KeyboardRemappingList)); + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, xfc->KeyboardLayout)) + return FALSE; if (!xf_keyboard_update_modifier_map(xfc)) return FALSE; @@ -597,7 +598,7 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) #if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */ #ifdef WITH_XRENDER - if (!xfc->remote_app && xfc->settings->MultiTouchGestures) + if (!xfc->remote_app && freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MultiTouchGestures)) { rdpContext* ctx = &xfc->common.context; @@ -610,20 +611,24 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) switch (keysym) { - case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */ - xfc->scaledWidth = xfc->sessionWidth; - xfc->scaledHeight = xfc->sessionHeight; + case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */{ + const UINT32 sessionWidth = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopWidth); + const UINT32 sessionHeight = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopHeight); + + xfc->scaledWidth = sessionWidth; + xfc->scaledHeight = sessionHeight; xfc->offset_x = 0; xfc->offset_y = 0; - if (!xfc->fullscreen && (xfc->sessionWidth != xfc->window->width || - xfc->sessionHeight != xfc->window->height)) + if (!xfc->fullscreen && (sessionWidth != xfc->window->width || + sessionHeight != xfc->window->height)) { - xf_ResizeDesktopWindow(xfc, xfc->window, xfc->sessionWidth, xfc->sessionHeight); + xf_ResizeDesktopWindow(xfc, xfc->window, sessionWidth, sessionHeight); } - xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight); + xf_draw_screen(xfc, 0, 0, sessionWidth, sessionHeight); return TRUE; +} case XK_1: /* Ctrl-Alt-1: Zoom in */ zdx = zdy = 10; diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index d32518bc7..8bc38d0a9 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -122,12 +122,14 @@ static BOOL xf_is_monitor_id_active(xfContext* xfc, UINT32 id) settings = xfc->common.context.settings; WINPR_ASSERT(settings); - if (!settings->NumMonitorIds) + const UINT32 NumMonitorIds = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds); + if (NumMonitorIds == 0) return TRUE; - for (index = 0; index < settings->NumMonitorIds; index++) + for (index = 0; index < NumMonitorIds; index++) { - if (settings->MonitorIds[index] == id) + const UINT32* cur = freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index); + if (cur && (*cur == id)) return TRUE; } @@ -138,7 +140,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) { BOOL rc = FALSE; int nmonitors = 0; - int monitor_index = 0; + UINT32 monitor_index = 0; BOOL primaryMonitorFound = FALSE; VIRTUAL_SCREEN* vscreen = NULL; rdpSettings* settings = NULL; @@ -159,15 +161,15 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) settings = xfc->common.context.settings; vscreen = &xfc->vscreen; - *pMaxWidth = settings->DesktopWidth; - *pMaxHeight = settings->DesktopHeight; + *pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + *pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); - if (settings->ParentWindowId) + if (freerdp_settings_get_uint64(settings, FreeRDP_ParentWindowId) > 0) { xfc->workArea.x = 0; xfc->workArea.y = 0; - xfc->workArea.width = settings->DesktopWidth; - xfc->workArea.height = settings->DesktopHeight; + xfc->workArea.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + xfc->workArea.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); return TRUE; } @@ -262,12 +264,14 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) without remote app, we force the number of monitors be 1 so later the rest of the client don't end up using more monitors than the user desires. */ - if ((!settings->UseMultimon && !settings->SpanMonitors) || - (settings->Workarea && !settings->RemoteApplicationMode)) + if ((!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) && + !freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors)) || + (freerdp_settings_get_bool(settings, FreeRDP_Workarea) && + !freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode))) { /* If no monitors were specified on the command-line then set the current monitor as active */ - if (!settings->NumMonitorIds) + if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 0) { UINT32 id = current_monitor; if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, &id, 1)) @@ -278,7 +282,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) * If the monitor is invalid then we will default back to current monitor * later as a fallback. So, there is no need to validate command-line entry here. */ - settings->NumMonitorIds = 1; + if (!freerdp_settings_set_uint32(settings, FreeRDP_NumMonitorIds, 1)) + goto fail; } /* WORKAROUND: With Remote Application Mode - using NET_WM_WORKAREA @@ -286,14 +291,15 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) * (the bottom of the window area is never updated). So, we just set * the workArea to match the full Screen width/height. */ - if (settings->RemoteApplicationMode || !xf_GetWorkArea(xfc)) + if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode) || !xf_GetWorkArea(xfc)) { /* if only 1 monitor is enabled, use monitor area this is required in case of a screen composed of more than one monitor but user did not enable multimonitor */ - if ((settings->NumMonitorIds == 1) && (vscreen->nmonitors > current_monitor)) + if ((freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 1) && + (vscreen->nmonitors > current_monitor)) { MONITOR_INFO* monitor = vscreen->monitors + current_monitor; @@ -314,17 +320,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) } } - if (settings->Fullscreen) + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) { *pMaxWidth = WidthOfScreen(xfc->screen); *pMaxHeight = HeightOfScreen(xfc->screen); } - else if (settings->Workarea) + else if (freerdp_settings_get_bool(settings, FreeRDP_Workarea)) { *pMaxWidth = xfc->workArea.width; *pMaxHeight = xfc->workArea.height; } - else if (settings->PercentScreen) + else if (freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) { /* If we have specific monitor information then limit the PercentScreen value * to only affect the current monitor vs. the entire desktop @@ -339,16 +345,16 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) *pMaxHeight = vscreen->monitors[current_monitor].area.bottom - vscreen->monitors[current_monitor].area.top + 1; - if (settings->PercentScreenUseWidth) + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)) *pMaxWidth = ((vscreen->monitors[current_monitor].area.right - vscreen->monitors[current_monitor].area.left + 1) * - settings->PercentScreen) / + freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100; - if (settings->PercentScreenUseHeight) + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)) *pMaxHeight = ((vscreen->monitors[current_monitor].area.bottom - vscreen->monitors[current_monitor].area.top + 1) * - settings->PercentScreen) / + freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100; } else @@ -356,28 +362,34 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) *pMaxWidth = xfc->workArea.width; *pMaxHeight = xfc->workArea.height; - if (settings->PercentScreenUseWidth) - *pMaxWidth = (xfc->workArea.width * settings->PercentScreen) / 100; + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)) + *pMaxWidth = (xfc->workArea.width * + freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / + 100; - if (settings->PercentScreenUseHeight) - *pMaxHeight = (xfc->workArea.height * settings->PercentScreen) / 100; + if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)) + *pMaxHeight = (xfc->workArea.height * + freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / + 100; } } - else if (settings->DesktopWidth && settings->DesktopHeight) + else if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) && + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) { - *pMaxWidth = settings->DesktopWidth; - *pMaxHeight = settings->DesktopHeight; + *pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + *pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } /* Create array of all active monitors by taking into account monitors requested on the * command-line */ { - int i; UINT32 nr = 0; - if (settings->MonitorIds) - nr = settings->MonitorIds[0]; - for (i = 0; i < vscreen->nmonitors; i++) + UINT32* ids = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0); + if (ids) + nr = *ids; + + for (UINT32 i = 0; i < vscreen->nmonitors; i++) { MONITOR_ATTRIBUTES* attrs; @@ -387,29 +399,37 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if (!vscreen->monitors) goto fail; - settings->MonitorDefArray[nmonitors].x = - (vscreen->monitors[i].area.left * - (settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) / - 100; - settings->MonitorDefArray[nmonitors].y = - (vscreen->monitors[i].area.top * - (settings->PercentScreenUseHeight ? settings->PercentScreen : 100)) / - 100; - settings->MonitorDefArray[nmonitors].width = + rdpMonitor* monitor = freerdp_settings_get_pointer_array_writable( + settings, FreeRDP_MonitorDefArray, nmonitors); + monitor->x = (vscreen->monitors[i].area.left * + (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100)) / + 100; + monitor->y = (vscreen->monitors[i].area.top * + (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100)) / + 100; + monitor->width = ((vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1) * - (settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) / + (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100)) / 100; - settings->MonitorDefArray[nmonitors].height = + monitor->height = ((vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1) * - (settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) / + (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100)) / 100; - settings->MonitorDefArray[nmonitors].orig_screen = i; + monitor->orig_screen = i; #ifdef USABLE_XRANDR if (useXRandr && rrmonitors) { Rotation rot, ret; - attrs = &settings->MonitorDefArray[nmonitors].attributes; + attrs = &monitor->attributes; attrs->physicalWidth = rrmonitors[i].mwidth; attrs->physicalHeight = rrmonitors[i].mheight; ret = XRRRotations(xfc->display, i, &rot); @@ -420,9 +440,11 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if ((UINT32)i == nr) { - settings->MonitorDefArray[nmonitors].is_primary = TRUE; - settings->MonitorLocalShiftX = settings->MonitorDefArray[nmonitors].x; - settings->MonitorLocalShiftY = settings->MonitorDefArray[nmonitors].y; + monitor->is_primary = TRUE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, monitor->x)) + goto fail; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, monitor->y)) + goto fail; primaryMonitorFound = TRUE; } @@ -443,60 +465,80 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) height = vscreen->monitors[current_monitor].area.bottom - vscreen->monitors[current_monitor].area.top + 1L; - settings->MonitorDefArray[0].x = vscreen->monitors[current_monitor].area.left; - settings->MonitorDefArray[0].y = vscreen->monitors[current_monitor].area.top; - settings->MonitorDefArray[0].width = MIN(width, (INT64)(*pMaxWidth)); - settings->MonitorDefArray[0].height = MIN(height, (INT64)(*pMaxHeight)); - settings->MonitorDefArray[0].orig_screen = current_monitor; + rdpMonitor* monitor = + freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, 0); + if (!monitor) + goto fail; + + monitor->x = vscreen->monitors[current_monitor].area.left; + monitor->y = vscreen->monitors[current_monitor].area.top; + monitor->width = MIN(width, (INT64)(*pMaxWidth)); + monitor->height = MIN(height, (INT64)(*pMaxHeight)); + monitor->orig_screen = current_monitor; nmonitors = 1; } - settings->MonitorCount = nmonitors; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, nmonitors)) + goto fail; /* If we have specific monitor information */ - if (settings->MonitorCount) + if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 0) { - UINT32 i; + const rdpMonitor* cmonitor = + freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, 0); + if (!cmonitor) + goto fail; + /* Initialize bounding rectangle for all monitors */ - int vX = settings->MonitorDefArray[0].x; - int vY = settings->MonitorDefArray[0].y; - int vR = vX + settings->MonitorDefArray[0].width; - int vB = vY + settings->MonitorDefArray[0].height; + int vX = cmonitor->x; + int vY = cmonitor->y; + int vR = vX + cmonitor->width; + int vB = vY + cmonitor->height; xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom = - xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right = - settings->MonitorDefArray[0].orig_screen; + xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right = cmonitor->orig_screen; /* Calculate bounding rectangle around all monitors to be used AND * also set the Xinerama indices which define left/top/right/bottom monitors. */ - for (i = 1; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++) { + rdpMonitor* monitor = + freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, i); + /* does the same as gdk_rectangle_union */ - int destX = MIN(vX, settings->MonitorDefArray[i].x); - int destY = MIN(vY, settings->MonitorDefArray[i].y); - int destR = - MAX(vR, settings->MonitorDefArray[i].x + settings->MonitorDefArray[i].width); - int destB = - MAX(vB, settings->MonitorDefArray[i].y + settings->MonitorDefArray[i].height); + int destX = MIN(vX, monitor->x); + int destY = MIN(vY, monitor->y); + int destR = MAX(vR, monitor->x + monitor->width); + int destB = MAX(vB, monitor->y + monitor->height); if (vX != destX) - xfc->fullscreenMonitors.left = settings->MonitorDefArray[i].orig_screen; + xfc->fullscreenMonitors.left = monitor->orig_screen; if (vY != destY) - xfc->fullscreenMonitors.top = settings->MonitorDefArray[i].orig_screen; + xfc->fullscreenMonitors.top = monitor->orig_screen; if (vR != destR) - xfc->fullscreenMonitors.right = settings->MonitorDefArray[i].orig_screen; + xfc->fullscreenMonitors.right = monitor->orig_screen; if (vB != destB) - xfc->fullscreenMonitors.bottom = settings->MonitorDefArray[i].orig_screen; + xfc->fullscreenMonitors.bottom = monitor->orig_screen; - vX = destX / ((settings->PercentScreenUseWidth ? settings->PercentScreen : 100) / 100.); - vY = - destY / ((settings->PercentScreenUseHeight ? settings->PercentScreen : 100) / 100.); - vR = destR / ((settings->PercentScreenUseWidth ? settings->PercentScreen : 100) / 100.); - vB = - destB / ((settings->PercentScreenUseHeight ? settings->PercentScreen : 100) / 100.); + vX = destX / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100) / + 100.); + vY = destY / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100) / + 100.); + vR = destR / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100) / + 100.); + vB = destB / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight) + ? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) + : 100) / + 100.); } vscreen->area.left = 0; @@ -504,7 +546,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) vscreen->area.top = 0; vscreen->area.bottom = vB - vY - 1; - if (settings->Workarea) + if (freerdp_settings_get_bool(settings, FreeRDP_Workarea)) { vscreen->area.top = xfc->workArea.y; vscreen->area.bottom = xfc->workArea.height + xfc->workArea.y - 1; @@ -513,11 +555,13 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if (!primaryMonitorFound) { /* If we have a command line setting we should use it */ - if (settings->NumMonitorIds) + if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) > 0) { /* The first monitor is the first in the setting which should be used */ - if (settings->MonitorIds) - monitor_index = settings->MonitorIds[0]; + UINT32* ids = + freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0); + if (ids) + monitor_index = *ids; } else { @@ -529,27 +573,37 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) monitor_index = XScreenNumberOfScreen(screen); } - int j = monitor_index; + UINT32 j = monitor_index; + rdpMonitor* pmonitor = + freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, j); /* If the "default" monitor is not 0,0 use it */ - if (settings->MonitorDefArray[j].x != 0 || settings->MonitorDefArray[j].y != 0) + if ((pmonitor->x != 0) || (pmonitor->y != 0)) { - settings->MonitorDefArray[j].is_primary = TRUE; - settings->MonitorLocalShiftX = settings->MonitorDefArray[j].x; - settings->MonitorLocalShiftY = settings->MonitorDefArray[j].y; + pmonitor->is_primary = TRUE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, pmonitor->x)) + goto fail; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, pmonitor->y)) + goto fail; } else { /* Lets try to see if there is a monitor with a 0,0 coordinate and use it as a * fallback*/ - for (i = 0; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); + i++) { - if (!primaryMonitorFound && settings->MonitorDefArray[i].x == 0 && - settings->MonitorDefArray[i].y == 0) + rdpMonitor* monitor = freerdp_settings_get_pointer_array_writable( + settings, FreeRDP_MonitorDefArray, i); + if (!primaryMonitorFound && monitor->x == 0 && monitor->y == 0) { - settings->MonitorDefArray[i].is_primary = TRUE; - settings->MonitorLocalShiftX = settings->MonitorDefArray[i].x; - settings->MonitorLocalShiftY = settings->MonitorDefArray[i].y; + monitor->is_primary = TRUE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, + monitor->x)) + goto fail; + if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, + monitor->y)) + goto fail; primaryMonitorFound = TRUE; } } @@ -563,12 +617,14 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) * So, we make sure to translate our primary monitor's upper-left corner to 0,0 on the * server. */ - for (i = 0; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++) { - settings->MonitorDefArray[i].x = - settings->MonitorDefArray[i].x - settings->MonitorLocalShiftX; - settings->MonitorDefArray[i].y = - settings->MonitorDefArray[i].y - settings->MonitorLocalShiftY; + rdpMonitor* monitor = + freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, i); + monitor->x = + monitor->x - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX); + monitor->y = + monitor->y - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY); } /* Set the desktop width and height according to the bounding rectangle around the active @@ -580,8 +636,11 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) /* some 2008 server freeze at logon if we announce support for monitor layout PDU with * #monitors < 2. So let's announce it only if we have more than 1 monitor. */ - if (settings->MonitorCount > 1) - settings->SupportMonitorLayoutPdu = TRUE; + if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 1) + { + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMonitorLayoutPdu, TRUE)) + goto fail; + } rc = TRUE; fail: diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 9844a9cd6..bd123aef2 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -573,8 +573,9 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings) if (!cache) return NULL; - cache->numCaches = settings->RemoteAppNumIconCaches; - cache->numCacheEntries = settings->RemoteAppNumIconCacheEntries; + cache->numCaches = freerdp_settings_get_uint32(settings, FreeRDP_RemoteAppNumIconCaches); + cache->numCacheEntries = + freerdp_settings_get_uint32(settings, FreeRDP_RemoteAppNumIconCacheEntries); cache->entries = calloc(1ull * cache->numCaches * cache->numCacheEntries, sizeof(xfRailIcon)); if (!cache->entries) diff --git a/client/X11/xf_video.c b/client/X11/xf_video.c index 36d96ded9..aa244bc8d 100644 --- a/client/X11/xf_video.c +++ b/client/X11/xf_video.c @@ -78,7 +78,8 @@ static BOOL xfVideoShowSurface(VideoClientContext* video, const VideoSurface* su #ifdef WITH_XRENDER - if (settings->SmartSizing || settings->MultiTouchGestures) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)) { XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0, surface->x, surface->y, surface->w, surface->h); diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 19d087b7b..0b0e29746 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -185,8 +185,12 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) xfc->savedPosX = xfc->window->left; xfc->savedPosY = xfc->window->top; - startX = (settings->DesktopPosX != UINT32_MAX) ? settings->DesktopPosX : 0; - startY = (settings->DesktopPosY != UINT32_MAX) ? settings->DesktopPosY : 0; + startX = (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) + ? freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) + : 0; + startY = (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX) + ? freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) + : 0; } else { @@ -199,22 +203,26 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) /* Determine the x,y starting location for the fullscreen window */ if (fullscreen) { + const rdpMonitor* firstMonitor = + freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, 0); /* Initialize startX and startY with reasonable values */ - startX = settings->MonitorDefArray[0].x; - startY = settings->MonitorDefArray[0].y; + startX = firstMonitor->x; + startY = firstMonitor->y; /* Search all monitors to find the lowest startX and startY values */ - for (i = 0; i < settings->MonitorCount; i++) + for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++) { - startX = MIN(startX, settings->MonitorDefArray[i].x); - startY = MIN(startY, settings->MonitorDefArray[i].y); + const rdpMonitor* monitor = + freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, i); + startX = MIN(startX, monitor->x); + startY = MIN(startY, monitor->y); } /* Lastly apply any monitor shift(translation from remote to local coordinate system) * to startX and startY values */ - startX += settings->MonitorLocalShiftX; - startY += settings->MonitorLocalShiftY; + startX += freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX); + startY += freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY); } /* @@ -223,7 +231,8 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) - The window manager supports multiple monitor full screen - The user requested to use a single monitor to render the remote desktop */ - if (xfc->_NET_WM_FULLSCREEN_MONITORS != None || settings->MonitorCount == 1) + if (xfc->_NET_WM_FULLSCREEN_MONITORS != None || + freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) == 1) { xf_ResizeDesktopWindow(xfc, window, width, height); @@ -249,7 +258,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) } /* Set monitor bounds */ - if (settings->MonitorCount > 1) + if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 1) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_FULLSCREEN_MONITORS, 5, xfc->fullscreenMonitors.top, xfc->fullscreenMonitors.bottom, @@ -494,7 +503,7 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig rdpSettings* settings = xfc->common.context.settings; WINPR_ASSERT(settings); - Window parentWindow = (Window)settings->ParentWindowId; + Window parentWindow = (Window)freerdp_settings_get_uint64(settings, FreeRDP_ParentWindowId); window->width = width; window->height = height; window->decorations = xfc->decorations; @@ -544,8 +553,9 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig { classHints->res_name = "xfreerdp"; - if (settings->WmClass) - classHints->res_class = settings->WmClass; + const char* WmClass = freerdp_settings_get_string(settings, FreeRDP_WmClass); + if (WmClass) + classHints->res_class = WmClass; else classHints->res_class = "xfreerdp"; @@ -589,13 +599,16 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig * monitor instead of the upper-left monitor for remote app mode (which uses all monitors). * This extra call after the window is mapped will position the login window correctly */ - if (settings->RemoteApplicationMode) + if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode)) { XMoveWindow(xfc->display, window->handle, 0, 0); } - else if (settings->DesktopPosX != UINT32_MAX && settings->DesktopPosY != UINT32_MAX) + else if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) && + (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX)) { - XMoveWindow(xfc->display, window->handle, settings->DesktopPosX, settings->DesktopPosY); + XMoveWindow(xfc->display, window->handle, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY)); } window->floatbar = xf_floatbar_new(xfc, window->handle, name, @@ -628,7 +641,8 @@ void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int hei XResizeWindow(xfc->display, window->handle, width, height); #ifdef WITH_XRENDER - if (!settings->SmartSizing && !settings->DynamicResolutionUpdate) + if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && + !freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) #endif { if (!xfc->fullscreen) @@ -836,10 +850,9 @@ BOOL xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow) { char* class = NULL; - if (settings->WmClass) - { - class_hints->res_class = settings->WmClass; - } + const char* WmClass = freerdp_settings_get_string(settings, FreeRDP_WmClass); + if (WmClass) + class_hints->res_class = WmClass; else { class = malloc(sizeof("RAIL:00000000")); @@ -1121,7 +1134,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i xf_lock_x11(xfc); - if (settings->SoftwareGdi) + if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) { XPutImage(xfc->display, appWindow->pixmap, appWindow->gc, xfc->image, ax, ay, x, y, width, height); diff --git a/client/common/client.c b/client/common/client.c index e23c5319a..5a4d7349c 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -219,20 +219,21 @@ static BOOL freerdp_client_settings_post_process(rdpSettings* settings) { /* Moved GatewayUseSameCredentials logic outside of cmdline.c, so * that the rdp file also triggers this functionality */ - if (settings->GatewayEnabled) + if (freerdp_settings_get_bool(settings, FreeRDP_GatewayEnabled)) { - if (settings->GatewayUseSameCredentials) + if (freerdp_settings_get_bool(settings, FreeRDP_GatewayUseSameCredentials)) { - if (settings->Username) + const char* Username = freerdp_settings_get_string(settings, FreeRDP_Username); + const char* Domain = freerdp_settings_get_string(settings, FreeRDP_Domain); + if (Username) { - if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername, - settings->Username)) + if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername, Username)) goto out_error; } - if (settings->Domain) + if (Domain) { - if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, settings->Domain)) + if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, Domain)) goto out_error; } @@ -248,30 +249,27 @@ static BOOL freerdp_client_settings_post_process(rdpSettings* settings) /* Moved logic for Multimon and Span monitors to force fullscreen, so * that the rdp file also triggers this functionality */ - if (settings->SpanMonitors) + if (freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors)) { - settings->UseMultimon = TRUE; - settings->Fullscreen = TRUE; + freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, TRUE); + freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, TRUE); } - else if (settings->UseMultimon) + else if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) { - settings->Fullscreen = TRUE; + freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, TRUE); } /* deal with the smartcard / smartcard logon stuff */ - if (settings->SmartcardLogon) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartcardLogon)) { - settings->TlsSecurity = TRUE; - settings->RedirectSmartCards = TRUE; - settings->DeviceRedirection = TRUE; + freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, TRUE); + freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, TRUE); + freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE); freerdp_settings_set_bool(settings, FreeRDP_PasswordIsSmartcardPin, TRUE); } return TRUE; out_error: - free(settings->GatewayUsername); - free(settings->GatewayDomain); - free(settings->GatewayPassword); return FALSE; } @@ -501,8 +499,10 @@ static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reaso if (!*password) goto fail; + const BOOL fromStdin = + freerdp_settings_get_bool(instance->context->settings, FreeRDP_CredentialsFromStdin); if (freerdp_passphrase_read(instance->context, prompt[2], *password, password_size, - instance->context->settings->CredentialsFromStdin) == NULL) + fromStdin) == NULL) goto fail; } @@ -594,7 +594,7 @@ BOOL client_cli_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_lis #if defined(WITH_FREERDP_DEPRECATED) BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain) { - if (instance->settings->SmartcardLogon) + if (freerdp_settings_get_bool(instance->settings, FreeRDP_SmartcardLogon)) { WLog_INFO(TAG, "Authentication via smartcard"); return TRUE; @@ -619,7 +619,9 @@ static DWORD client_cli_accept_certificate(freerdp* instance) const rdpSettings* settings = instance->context->settings; WINPR_ASSERT(settings); - if (settings->CredentialsFromStdin) + const BOOL fromStdin = + freerdp_settings_get_bool(instance->context->settings, FreeRDP_CredentialsFromStdin); + if (fromStdin) return 0; while (1) @@ -632,7 +634,7 @@ static DWORD client_cli_accept_certificate(freerdp* instance) { printf("\nError: Could not read answer from stdin."); - if (settings->CredentialsFromStdin) + if (fromStdin) printf(" - Run without parameter \"--from-stdin\" to set trust."); printf("\n"); @@ -1203,7 +1205,6 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* { BOOL retry = TRUE; UINT32 error; - UINT32 maxRetries; UINT32 numRetries = 0; rdpSettings* settings; @@ -1215,7 +1216,8 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* settings = instance->context->settings; WINPR_ASSERT(settings); - maxRetries = settings->AutoReconnectMaxRetries; + const UINT32 maxRetries = + freerdp_settings_get_uint32(settings, FreeRDP_AutoReconnectMaxRetries); /* Only auto reconnect on network disconnects. */ error = freerdp_error_info(instance); @@ -1234,7 +1236,7 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* return FALSE; } - if (!settings->AutoReconnectionEnabled) + if (!freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled)) { /* No auto-reconnect - just quit */ return FALSE; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 400e1f7e9..a1f55a405 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -243,29 +243,6 @@ static BOOL copy_value(const char* value, char** dst) return (*dst) != NULL; } -static BOOL append_value(const char* value, char** dst) -{ - size_t x = 0; - if (!dst || !value) - return FALSE; - - if (*dst) - x = strlen(*dst); - const size_t y = strlen(value); - - const size_t size = x + y + 2; - char* tmp = realloc(*dst, size); - if (!tmp) - return FALSE; - if (x == 0) - tmp[0] = '\0'; - else - winpr_str_append(",", tmp, size, NULL); - winpr_str_append(value, tmp, size, NULL); - *dst = tmp; - return TRUE; -} - static BOOL value_to_int(const char* value, LONGLONG* result, LONGLONG min, LONGLONG max) { long long rc; @@ -690,7 +667,8 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, cons if (count < 2) return FALSE; - settings->DeviceRedirection = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) + return FALSE; if (count < 3) rc = freerdp_client_add_drive(settings, params[1], NULL); else @@ -705,8 +683,10 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, cons if (count < 1) return FALSE; - settings->RedirectPrinters = TRUE; - settings->DeviceRedirection = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters, TRUE)) + return FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) + return FALSE; printer = freerdp_device_new(RDPDR_DTYP_PRINT, count - 1, ¶ms[1]); if (!printer) @@ -727,8 +707,10 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, cons if (count < 1) return FALSE; - settings->RedirectSmartCards = TRUE; - settings->DeviceRedirection = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, TRUE)) + return FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) + return FALSE; smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, count - 1, ¶ms[1]); @@ -750,8 +732,10 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, cons if (count < 1) return FALSE; - settings->RedirectSerialPorts = TRUE; - settings->DeviceRedirection = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, TRUE)) + return FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) + return FALSE; serial = freerdp_device_new(RDPDR_DTYP_SERIAL, count - 1, ¶ms[1]); @@ -773,8 +757,10 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, cons if (count < 1) return FALSE; - settings->RedirectParallelPorts = TRUE; - settings->DeviceRedirection = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, TRUE)) + return FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) + return FALSE; parallel = freerdp_device_new(RDPDR_DTYP_PARALLEL, count - 1, ¶ms[1]); @@ -944,7 +930,7 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A if ((status = freerdp_client_add_device_channel(settings, count, ptr.pc))) { - settings->DeviceRedirection = TRUE; + freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE); } free(ptr.p); @@ -1040,32 +1026,41 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A } CommandLineSwitchCase(arg, "multitouch") { - settings->MultiTouchInput = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchInput, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "gestures") { - settings->MultiTouchGestures = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchGestures, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "echo") { - settings->SupportEchoChannel = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportEchoChannel, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "ssh-agent") { - settings->SupportSSHAgentChannel = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportSSHAgentChannel, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "disp") { - settings->SupportDisplayControl = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDisplayControl, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "geometry") { - settings->SupportGeometryTracking = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGeometryTracking, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "video") { - settings->SupportGeometryTracking = enable; /* this requires geometry tracking */ - settings->SupportVideoOptimized = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGeometryTracking, + enable)) /* this requires geometry tracking */ + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportVideoOptimized, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "sound") { @@ -1096,17 +1091,21 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A #endif CommandLineSwitchCase(arg, "heartbeat") { - settings->SupportHeartbeatPdu = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportHeartbeatPdu, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "multitransport") { - settings->SupportMultitransport = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMultitransport, enable)) + return COMMAND_LINE_ERROR; - if (settings->SupportMultitransport) - settings->MultitransportFlags = + UINT32 flags = 0; + if (freerdp_settings_get_bool(settings, FreeRDP_SupportMultitransport)) + flags = (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED); - else - settings->MultitransportFlags = 0; + + if (!freerdp_settings_set_uint32(settings, FreeRDP_MultitransportFlags, flags)) + return COMMAND_LINE_ERROR; } CommandLineSwitchEnd(arg) @@ -1115,33 +1114,25 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A : -1; } -BOOL freerdp_parse_username(const char* username, char** user, char** domain) +static BOOL freerdp_parse_username_ptr(const char* username, const char** user, size_t* userlen, + const char** domain, size_t* domainlen) { - char* p; - size_t length = 0; - p = strchr(username, '\\'); + const char* p = strchr(username, '\\'); + *user = NULL; + *userlen = 0; + *domain = NULL; + *domainlen = 0; if (p) { - length = (size_t)(p - username); - *user = _strdup(&p[1]); + const size_t length = (size_t)(p - username); + *user = &p[1]; + *userlen = strlen(*user); - if (!*user) - return FALSE; - - *domain = (char*)calloc(length + 1UL, sizeof(char)); - - if (!*domain) - { - free(*user); - *user = NULL; - return FALSE; - } - - strncpy(*domain, username, length); - (*domain)[length] = '\0'; + *domain = username; + *domainlen = length; } else if (username) { @@ -1149,19 +1140,8 @@ BOOL freerdp_parse_username(const char* username, char** user, char** domain) * ClientInfo PDU expect 'user@corp.net' to be transmitted * as username 'user@corp.net', domain empty (not NULL!). */ - *user = _strdup(username); - - if (!*user) - return FALSE; - - *domain = _strdup("\0"); - - if (!*domain) - { - free(*user); - *user = NULL; - return FALSE; - } + *user = username; + *userlen = strlen(username); } else return FALSE; @@ -1169,6 +1149,57 @@ BOOL freerdp_parse_username(const char* username, char** user, char** domain) return TRUE; } +static BOOL freerdp_parse_username_settings(const char* username, rdpSettings* settings, + size_t userID, size_t domainID) +{ + const char* user = NULL; + const char* domain = NULL; + size_t userlen = 0; + size_t domainlen = 0; + + const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen); + if (!rc) + return FALSE; + if (!freerdp_settings_set_string_len(settings, userID, user, userlen)) + return FALSE; + return freerdp_settings_set_string_len(settings, domainID, domain, domainlen); +} + +BOOL freerdp_parse_username(const char* username, char** puser, char** pdomain) +{ + const char* user = NULL; + const char* domain = NULL; + size_t userlen = 0; + size_t domainlen = 0; + + *puser = NULL; + *pdomain = NULL; + + const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen); + if (!rc) + return FALSE; + + if (userlen > 0) + { + *puser = strndup(user, userlen); + if (!*puser) + return FALSE; + } + + if (domainlen > 0) + { + *pdomain = strndup(domain, domainlen); + if (!*pdomain) + { + free(*puser); + *puser = NULL; + return FALSE; + } + } + + return TRUE; +} + BOOL freerdp_parse_hostname(const char* hostname, char** host, int* port) { char* p; @@ -1631,7 +1662,10 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, else if (option_equals("kbd-scancode", arg->Value)) freerdp_client_print_scancodes(); else if (option_equals("monitor", arg->Value)) - settings->ListMonitors = TRUE; + { + if (!freerdp_settings_set_bool(settings, FreeRDP_ListMonitors, TRUE)) + return COMMAND_LINE_ERROR; + } else if (option_starts_with("smartcard", arg->Value)) { BOOL opts = FALSE; @@ -1715,7 +1749,8 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) { WLog_WARN(TAG, "Option /monitor-list is deprecated, use /list:monitor instead"); - settings->ListMonitors = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_ListMonitors, TRUE)) + return COMMAND_LINE_ERROR; } arg = CommandLineFindArgumentA(largs, "smartcard-list"); @@ -1818,8 +1853,7 @@ static BOOL prepare_default_settings(rdpSettings* settings, COMMAND_LINE_ARGUMEN static BOOL setSmartcardEmulation(const char* value, rdpSettings* settings) { - settings->SmartcardEmulation = TRUE; - return TRUE; + return freerdp_settings_set_bool(settings, FreeRDP_SmartcardEmulation, TRUE); } const char* option_starts_with(const char* what, const char* val) @@ -2101,7 +2135,10 @@ static int parse_gfx_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_ if (!value_to_uint(uv, &v, 0, UINT32_MAX)) rc = COMMAND_LINE_ERROR; else - settings->GfxCapsFilter = (UINT32)v; + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_GfxCapsFilter, v)) + rc = COMMAND_LINE_ERROR; + } } else if (option_starts_with("small-cache", val)) { @@ -2441,8 +2478,11 @@ static int parse_cache_options(rdpSettings* settings, const COMMAND_LINE_ARGUMEN if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, TRUE)) rc = COMMAND_LINE_ERROR; - if (settings->JpegQuality == 0) - settings->JpegQuality = 75; + if (freerdp_settings_get_uint32(settings, FreeRDP_JpegQuality) == 0) + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, 75)) + return COMMAND_LINE_ERROR; + } } #endif @@ -2524,8 +2564,8 @@ static BOOL parse_gateway_cred_option(rdpSettings* settings, const char* value, switch (what) { case FreeRDP_GatewayUsername: - if (!freerdp_parse_username(value, &settings->GatewayUsername, - &settings->GatewayDomain)) + if (!freerdp_parse_username_settings(value, settings, FreeRDP_GatewayUsername, + FreeRDP_GatewayDomain)) return FALSE; break; default: @@ -2881,8 +2921,7 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!arg->Value) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - free(settings->ServerHostname); - settings->ServerHostname = NULL; + freerdp_settings_set_string(settings, FreeRDP_ServerHostname, NULL); p = strchr(arg->Value, '['); /* ipv4 */ @@ -2899,13 +2938,11 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; length = (size_t)(p - arg->Value); - settings->ServerPort = (UINT16)val; - - if (!(settings->ServerHostname = (char*)calloc(length + 1UL, sizeof(char)))) - return COMMAND_LINE_ERROR_MEMORY; - - strncpy(settings->ServerHostname, arg->Value, length); - settings->ServerHostname[length] = '\0'; + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, val)) + return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; + if (!freerdp_settings_set_string_len(settings, FreeRDP_ServerHostname, + arg->Value, length)) + return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } else { @@ -2923,12 +2960,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( continue; length = (size_t)(p2 - p); - - if (!(settings->ServerHostname = (char*)calloc(length, sizeof(char)))) + if (!freerdp_settings_set_string_len(settings, FreeRDP_ServerHostname, p + 1, + length - 1)) return COMMAND_LINE_ERROR_MEMORY; - strncpy(settings->ServerHostname, p + 1, length - 1); - if (*(p2 + 1) == ':') { LONGLONG val; @@ -2936,11 +2971,13 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(&p2[2], &val, 0, UINT16_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->ServerPort = (UINT16)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, (UINT16)val)) + return COMMAND_LINE_ERROR; } - printf("hostname %s port %" PRIu32 "\n", settings->ServerHostname, - settings->ServerPort); + printf("hostname %s port %" PRIu32 "\n", + freerdp_settings_get_string(settings, FreeRDP_ServerHostname), + freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)); } } CommandLineSwitchCase(arg, "spn-class") @@ -2965,8 +3002,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( char* cur = arg->Value; if (!arg->Value) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->RedirectionPreferType = 0; + if (!freerdp_settings_set_uint32(settings, FreeRDP_RedirectionPreferType, 0)) + return COMMAND_LINE_ERROR; + UINT32 value = 0; do { UINT32 mask; @@ -2989,16 +3028,20 @@ static int freerdp_client_settings_parse_command_line_arguments_int( cur = next; mask = (mask & 0x07); - settings->RedirectionPreferType |= mask << (count * 3); + value |= mask << (count * 3); count++; } while (cur != NULL); + if (!freerdp_settings_set_uint32(settings, FreeRDP_RedirectionPreferType, value)) + return COMMAND_LINE_ERROR; + if (count > 3) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } CommandLineSwitchCase(arg, "credentials-delegation") { - settings->DisableCredentialsDelegation = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_DisableCredentialsDelegation, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "prevent-session-lock") { @@ -3019,13 +3062,17 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "vmconnect") { - settings->VmConnectMode = TRUE; - settings->ServerPort = 2179; - settings->NegotiateSecurityLayer = FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 2179)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE)) + return COMMAND_LINE_ERROR; if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) { - settings->SendPreconnectionPdu = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE)) + return COMMAND_LINE_ERROR; if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value)) return COMMAND_LINE_ERROR_MEMORY; @@ -3038,7 +3085,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, -1, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->DesktopWidth = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "h") { @@ -3047,7 +3095,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, -1, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->DesktopHeight = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "size") { @@ -3063,8 +3112,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->DesktopWidth = (UINT32)w; - settings->DesktopHeight = (UINT32)h; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, (UINT32)w)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, (UINT32)h)) + return COMMAND_LINE_ERROR; } else { @@ -3079,20 +3130,28 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (strchr(p, 'w')) { - settings->PercentScreenUseWidth = 1; + if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseWidth, + TRUE)) + return COMMAND_LINE_ERROR; partial = TRUE; } if (strchr(p, 'h')) { - settings->PercentScreenUseHeight = 1; + if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseHeight, + TRUE)) + return COMMAND_LINE_ERROR; partial = TRUE; } if (!partial) { - settings->PercentScreenUseWidth = 1; - settings->PercentScreenUseHeight = 1; + if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseWidth, + TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseHeight, + TRUE)) + return COMMAND_LINE_ERROR; } *p = '\0'; @@ -3105,7 +3164,9 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } - settings->PercentScreen = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_PercentScreen, + (UINT32)val)) + return COMMAND_LINE_ERROR; } } @@ -3114,31 +3175,37 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "f") { - settings->Fullscreen = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "suppress-output") { - settings->SuppressOutput = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SuppressOutput, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "multimon") { - settings->UseMultimon = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, TRUE)) + return COMMAND_LINE_ERROR; if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) { if (option_equals(arg->Value, "force")) { - settings->ForceMultimon = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_ForceMultimon, TRUE)) + return COMMAND_LINE_ERROR; } } } CommandLineSwitchCase(arg, "span") { - settings->SpanMonitors = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_SpanMonitors, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "workarea") { - settings->Workarea = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_Workarea, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "monitors") { @@ -3188,28 +3255,32 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "decorations") { - settings->Decorations = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_Decorations, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "dynamic-resolution") { - if (settings->SmartSizing) + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) { WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options"); return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } - settings->SupportDisplayControl = TRUE; - settings->DynamicResolutionUpdate = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDisplayControl, TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_DynamicResolutionUpdate, TRUE)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "smart-sizing") { - if (settings->DynamicResolutionUpdate) + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) { WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options"); return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } - settings->SmartSizing = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, TRUE)) + return COMMAND_LINE_ERROR; if (arg->Value) { @@ -3218,8 +3289,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->SmartSizingWidth = (UINT32)w; - settings->SmartSizingHeight = (UINT32)h; + if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingWidth, (UINT32)w)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingHeight, (UINT32)h)) + return COMMAND_LINE_ERROR; } } CommandLineSwitchCase(arg, "bpp") @@ -3246,21 +3319,28 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "admin") { - settings->ConsoleSession = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "relax-order-checks") { - settings->AllowUnanouncedOrdersFromServer = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_AllowUnanouncedOrdersFromServer, + enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "restricted-admin") { - settings->ConsoleSession = enable; - settings->RestrictedAdminModeRequired = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, enable)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeRequired, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "pth") { - settings->ConsoleSession = TRUE; - settings->RestrictedAdminModeRequired = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeRequired, TRUE)) + return COMMAND_LINE_ERROR; if (!freerdp_settings_set_string(settings, FreeRDP_PasswordHash, arg->Value)) return COMMAND_LINE_ERROR_MEMORY; @@ -3296,7 +3376,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; } - settings->KeyboardCodePage = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardCodePage, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "kbd-type") { @@ -3306,7 +3387,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->KeyboardType = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardType, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "kbd-unicode") { @@ -3322,7 +3404,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->KeyboardSubType = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardSubType, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "kbd-fn-key") { @@ -3332,7 +3415,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->KeyboardFunctionKey = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardFunctionKey, (UINT32)val)) + return COMMAND_LINE_ERROR; } #endif CommandLineSwitchCase(arg, "u") @@ -3421,10 +3505,9 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "load-balance-info") { - if (!copy_value(arg->Value, (char**)&settings->LoadBalanceInfo)) - return COMMAND_LINE_ERROR_MEMORY; - - settings->LoadBalanceInfoLength = (UINT32)strlen((char*)settings->LoadBalanceInfo); + if (!freerdp_settings_set_pointer_len(settings, FreeRDP_LoadBalanceInfo, arg->Value, + strlen(arg->Value))) + return COMMAND_LINE_ERROR; } #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE) CommandLineSwitchCase(arg, "app-workdir") @@ -3470,7 +3553,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( #endif CommandLineSwitchCase(arg, "compression") { - settings->CompressionEnabled = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "compression-level") { @@ -3479,11 +3563,13 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->CompressionLevel = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "drives") { - settings->RedirectDrives = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "dump") { @@ -3527,17 +3613,21 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "home-drive") { - settings->RedirectHomeDrive = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectHomeDrive, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "ipv6") { - settings->PreferIPv6OverIPv4 = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_PreferIPv6OverIPv4, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "clipboard") { if (arg->Value == BoolValueTrue || arg->Value == BoolValueFalse) { - settings->RedirectClipboard = (arg->Value == BoolValueTrue); + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, + (arg->Value == BoolValueTrue))) + return COMMAND_LINE_ERROR; } else { @@ -3560,7 +3650,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!freerdp_settings_set_string(settings, FreeRDP_ClipboardUseSelection, val)) rc = COMMAND_LINE_ERROR_MEMORY; - settings->RedirectClipboard = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, TRUE)) + return COMMAND_LINE_ERROR; } else if (option_starts_with("direction-to", cur)) { @@ -3659,16 +3750,20 @@ static int freerdp_client_settings_parse_command_line_arguments_int( switch (val) { case AUDIO_MODE_REDIRECT: - settings->AudioPlayback = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, TRUE)) + return COMMAND_LINE_ERROR; break; case AUDIO_MODE_PLAY_ON_SERVER: - settings->RemoteConsoleAudio = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE)) + return COMMAND_LINE_ERROR; break; case AUDIO_MODE_NONE: - settings->AudioPlayback = FALSE; - settings->RemoteConsoleAudio = FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, FALSE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE)) + return COMMAND_LINE_ERROR; break; default: @@ -3711,15 +3806,18 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "fonts") { - settings->AllowFontSmoothing = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "wallpaper") { - settings->DisableWallpaper = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "window-drag") { - settings->DisableFullWindowDrag = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "window-position") { @@ -3734,16 +3832,20 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return COMMAND_LINE_ERROR_MISSING_ARGUMENT; } - settings->DesktopPosX = (UINT32)x; - settings->DesktopPosY = (UINT32)y; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosX, (UINT32)x)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosY, (UINT32)y)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "menu-anims") { - settings->DisableMenuAnims = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "themes") { - settings->DisableThemes = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "timeout") { @@ -3755,14 +3857,19 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "aero") { - settings->AllowDesktopComposition = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "gdi") { if (option_equals(arg->Value, "sw")) - settings->SoftwareGdi = TRUE; - else if (option_equals(arg->Value, "hw")) - settings->SoftwareGdi = FALSE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SoftwareGdi, TRUE)) + return COMMAND_LINE_ERROR; + else if (option_equals(arg->Value, "hw")) + { + if (!freerdp_settings_set_bool(settings, FreeRDP_SoftwareGdi, FALSE)) + return COMMAND_LINE_ERROR; + } } CommandLineSwitchCase(arg, "gfx") { @@ -3774,29 +3881,41 @@ static int freerdp_client_settings_parse_command_line_arguments_int( CommandLineSwitchCase(arg, "gfx-thin-client") { WLog_WARN(TAG, "/gfx-thin-client is deprecated, use /gfx:thin-client[:on|off] instead"); - settings->GfxThinClient = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient, enable)) + return COMMAND_LINE_ERROR; - if (settings->GfxThinClient) - settings->GfxSmallCache = TRUE; + if (freerdp_settings_get_bool(settings, FreeRDP_GfxThinClient)) + { + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache, TRUE)) + return COMMAND_LINE_ERROR; + } - settings->SupportGraphicsPipeline = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "gfx-small-cache") { WLog_WARN(TAG, "/gfx-small-cache is deprecated, use /gfx:small-cache[:on|off] instead"); - settings->GfxSmallCache = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache, enable)) + return COMMAND_LINE_ERROR; if (enable) - settings->SupportGraphicsPipeline = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "gfx-progressive") { WLog_WARN(TAG, "/gfx-progressive is deprecated, use /gfx:progressive[:on|off] instead"); - settings->GfxProgressive = enable; - settings->GfxThinClient = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, enable)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient, !enable)) + return COMMAND_LINE_ERROR; if (enable) - settings->SupportGraphicsPipeline = TRUE; + { + if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE)) + return COMMAND_LINE_ERROR; + } } #ifdef WITH_GFX_H264 CommandLineSwitchCase(arg, "gfx-h264") @@ -3810,7 +3929,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( #endif CommandLineSwitchCase(arg, "rfx") { - settings->RemoteFxCodec = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "rfx-mode") { @@ -3818,11 +3938,16 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; if (option_equals(arg->Value, "video")) - settings->RemoteFxCodecMode = 0x00; + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_RemoteFxCodecMode, 0x00)) + return COMMAND_LINE_ERROR; + } else if (option_equals(arg->Value, "image")) { - settings->RemoteFxImageCodec = TRUE; - settings->RemoteFxCodecMode = 0x02; + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxImageCodec, TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_RemoteFxCodecMode, 0x02)) + return COMMAND_LINE_ERROR; } } CommandLineSwitchCase(arg, "frame-ack") @@ -3832,7 +3957,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->FrameAcknowledge = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_FrameAcknowledge, (UINT32)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "nsc") { @@ -3841,8 +3967,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( #if defined(WITH_JPEG) CommandLineSwitchCase(arg, "jpeg") { - settings->JpegCodec = enable; - settings->JpegQuality = 75; + if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, enable)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, 75)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "jpeg-quality") { @@ -3851,16 +3979,19 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, 100)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->JpegQuality = (UINT32)val; + if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, (UINT32)val)) + return COMMAND_LINE_ERROR; } #endif CommandLineSwitchCase(arg, "nego") { - settings->NegotiateSecurityLayer = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "pcb") { - settings->SendPreconnectionPdu = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE)) + return COMMAND_LINE_ERROR; if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value)) return COMMAND_LINE_ERROR_MEMORY; @@ -3872,8 +4003,10 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_int(arg->Value, &val, 0, UINT32_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->SendPreconnectionPdu = TRUE; - settings->PreconnectionId = (UINT32)val; + if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE)) + return COMMAND_LINE_ERROR; + if (!freerdp_settings_set_uint32(settings, FreeRDP_PreconnectionId, (UINT32)val)) + return COMMAND_LINE_ERROR; } #ifdef _WIN32 CommandLineSwitchCase(arg, "connect-child-session") @@ -3972,20 +4105,24 @@ static int freerdp_client_settings_parse_command_line_arguments_int( size_t count = 0; ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count); + UINT32 EncryptionMethods = 0; for (i = 0; i < count; i++) { if (option_equals(ptr.pc[i], "40")) - settings->EncryptionMethods |= ENCRYPTION_METHOD_40BIT; + EncryptionMethods |= ENCRYPTION_METHOD_40BIT; else if (option_equals(ptr.pc[i], "56")) - settings->EncryptionMethods |= ENCRYPTION_METHOD_56BIT; + EncryptionMethods |= ENCRYPTION_METHOD_56BIT; else if (option_equals(ptr.pc[i], "128")) - settings->EncryptionMethods |= ENCRYPTION_METHOD_128BIT; + EncryptionMethods |= ENCRYPTION_METHOD_128BIT; else if (option_equals(ptr.pc[i], "FIPS")) - settings->EncryptionMethods |= ENCRYPTION_METHOD_FIPS; + EncryptionMethods |= ENCRYPTION_METHOD_FIPS; else WLog_ERR(TAG, "unknown encryption method '%s'", ptr.pc[i]); } + if (!freerdp_settings_set_uint32(settings, FreeRDP_EncryptionMethods, + EncryptionMethods)) + return COMMAND_LINE_ERROR; free(ptr.p); } } @@ -3997,7 +4134,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "from-stdin") { - settings->CredentialsFromStdin = TRUE; + if (!freerdp_settings_set_bool(settings, FreeRDP_CredentialsFromStdin, TRUE)) + return COMMAND_LINE_ERROR; if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) { @@ -4025,22 +4163,26 @@ static int freerdp_client_settings_parse_command_line_arguments_int( CommandLineSwitchCase(arg, "sec-rdp") { WLog_WARN(TAG, "/sec-rdp is deprecated, use /sec:rdp[:on|off] instead"); - settings->RdpSecurity = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "sec-tls") { WLog_WARN(TAG, "/sec-tls is deprecated, use /sec:tls[:on|off] instead"); - settings->TlsSecurity = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "sec-nla") { WLog_WARN(TAG, "/sec-nla is deprecated, use /sec:nla[:on|off] instead"); - settings->NlaSecurity = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "sec-ext") { WLog_WARN(TAG, "/sec-ext is deprecated, use /sec:ext[:on|off] instead"); - settings->ExtSecurity = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, enable)) + return COMMAND_LINE_ERROR; } #endif CommandLineSwitchCase(arg, "tls") @@ -4114,11 +4256,20 @@ static int freerdp_client_settings_parse_command_line_arguments_int( const char* cur = ptr.pc[x]; if (option_equals(deny, cur)) - settings->AutoDenyCertificate = TRUE; + { + if (!freerdp_settings_set_bool(settings, FreeRDP_AutoDenyCertificate, TRUE)) + return COMMAND_LINE_ERROR; + } else if (option_equals(ignore, cur)) - settings->IgnoreCertificate = TRUE; + { + if (!freerdp_settings_set_bool(settings, FreeRDP_IgnoreCertificate, TRUE)) + return COMMAND_LINE_ERROR; + } else if (option_equals(tofu, cur)) - settings->AutoAcceptCertificate = TRUE; + { + if (!freerdp_settings_set_bool(settings, FreeRDP_AutoAcceptCertificate, TRUE)) + return COMMAND_LINE_ERROR; + } else if (option_starts_with(name, cur)) { const char* val = &cur[strnlen(name, sizeof(name))]; @@ -4128,7 +4279,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( else if (option_starts_with(fingerprints, cur)) { const char* val = &cur[strnlen(fingerprints, sizeof(fingerprints))]; - if (!append_value(val, &settings->CertificateAcceptedFingerprints)) + if (!freerdp_settings_append_string( + settings, FreeRDP_CertificateAcceptedFingerprints, ",", val)) rc = COMMAND_LINE_ERROR_MEMORY; } else @@ -4150,38 +4302,46 @@ static int freerdp_client_settings_parse_command_line_arguments_int( CommandLineSwitchCase(arg, "cert-ignore") { WLog_WARN(TAG, "/cert-ignore is deprecated, use /cert:ignore instead"); - settings->IgnoreCertificate = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_IgnoreCertificate, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "cert-tofu") { WLog_WARN(TAG, "/cert-tofu is deprecated, use /cert:tofu instead"); - settings->AutoAcceptCertificate = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_AutoAcceptCertificate, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "cert-deny") { WLog_WARN(TAG, "/cert-deny is deprecated, use /cert:deny instead"); - settings->AutoDenyCertificate = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_AutoDenyCertificate, enable)) + return COMMAND_LINE_ERROR; } #endif CommandLineSwitchCase(arg, "authentication") { - settings->Authentication = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_Authentication, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "encryption") { - settings->UseRdpSecurityLayer = !enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, !enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "grab-keyboard") { - settings->GrabKeyboard = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_GrabKeyboard, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "grab-mouse") { - settings->GrabMouse = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_GrabMouse, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "mouse-relative") { - settings->MouseUseRelativeMove = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "mouse") { @@ -4308,7 +4468,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( } CommandLineSwitchCase(arg, "mouse-motion") { - settings->MouseMotion = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_MouseMotion, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "parent-window") { @@ -4317,7 +4478,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!value_to_uint(arg->Value, &val, 0, UINT64_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - settings->ParentWindowId = (UINT64)val; + if (!freerdp_settings_set_uint64(settings, FreeRDP_ParentWindowId, (UINT64)val)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "client-build-number") { @@ -4338,7 +4500,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( CommandLineSwitchCase(arg, "bitmap-cache") { WLog_WARN(TAG, "/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead"); - settings->BitmapCacheEnabled = enable; + if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCacheEnabled, enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "persist-cache") { @@ -4359,12 +4522,16 @@ static int freerdp_client_settings_parse_command_line_arguments_int( CommandLineSwitchCase(arg, "offscreen-cache") { WLog_WARN(TAG, "/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead"); - settings->OffscreenSupportLevel = (UINT32)enable; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenSupportLevel, + (UINT32)enable)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "glyph-cache") { WLog_WARN(TAG, "/glyph-cache is deprecated, use /cache:glyph[:on|off] instead"); - settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_GlyphSupportLevel, + arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE)) + return COMMAND_LINE_ERROR; } CommandLineSwitchCase(arg, "codec-cache") { @@ -4372,11 +4539,13 @@ static int freerdp_client_settings_parse_command_line_arguments_int( "/codec-cache: