From eb445f7c430ef20e1e04979091c7210fde4e5d43 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 13 Oct 2023 09:32:46 +0200 Subject: [PATCH] [channels] make settings opaque --- channels/client/addin.c | 9 ++++++--- channels/drdynvc/client/drdynvc_main.c | 3 ++- channels/rail/client/rail_orders.c | 7 +++++-- channels/rdpdr/client/rdpdr_main.c | 21 +++++++++++---------- channels/rdpgfx/client/rdpgfx_main.c | 24 ++++++++++++++++-------- channels/remdesk/client/remdesk_main.c | 18 ++++++++++-------- 6 files changed, 50 insertions(+), 32 deletions(-) diff --git a/channels/client/addin.c b/channels/client/addin.c index 183891cd6..9723e432a 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -611,7 +611,8 @@ void* channel_client_create_handler(rdpContext* ctx, LPVOID userdata, MsgHandler WINPR_ASSERT(ctx); WINPR_ASSERT(ctx->settings); internals->ctx = ctx; - if (!(ctx->settings->ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS)) + if ((freerdp_settings_get_uint32(ctx->settings, FreeRDP_ThreadingFlags) & + THREADING_FLAGS_DISABLE_THREADS) == 0) { wObject obj = { 0 }; obj.fnObjectFree = free_msg; @@ -687,7 +688,8 @@ UINT channel_client_post_message(void* MsgsHandle, LPVOID pData, UINT32 dataLeng Stream_SealLength(data_in); Stream_SetPosition(data_in, 0); - if (internals->ctx->settings->ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS) + if ((freerdp_settings_get_uint32(internals->ctx->settings, FreeRDP_ThreadingFlags) & + THREADING_FLAGS_DISABLE_THREADS) != 0) { UINT error = CHANNEL_RC_OK; if ((error = internals->msg_handler(internals->userdata, data_in))) @@ -721,7 +723,8 @@ UINT channel_client_quit_handler(void* MsgsHandle) WINPR_ASSERT(internals->ctx); WINPR_ASSERT(internals->ctx->settings); - if (!(internals->ctx->settings->ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS)) + if ((freerdp_settings_get_uint32(internals->ctx->settings, FreeRDP_ThreadingFlags) & + THREADING_FLAGS_DISABLE_THREADS) == 0) { if (internals->queue && internals->thread) { diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 56db6447b..ba77f2286 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -1693,7 +1693,8 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); index++) { - const ADDIN_ARGV* args = settings->DynamicChannelArray[index]; + const ADDIN_ARGV* args = + freerdp_settings_get_pointer_array(settings, FreeRDP_DynamicChannelArray, index); error = dvcman_load_addin(drdynvc, drdynvc->channel_mgr, args, drdynvc->rdpcontext); if (CHANNEL_RC_OK != error) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 4f62ebb1f..386769afd 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -421,8 +421,11 @@ BOOL rail_is_feature_supported(const rdpContext* context, UINT32 featureMask) if (!context || !context->settings) return FALSE; - supported = context->settings->RemoteApplicationSupportLevel & - context->settings->RemoteApplicationSupportMask; + const UINT32 level = + freerdp_settings_get_uint32(context->settings, FreeRDP_RemoteApplicationSupportLevel); + const UINT32 mask = + freerdp_settings_get_uint32(context->settings, FreeRDP_RemoteApplicationSupportMask); + supported = level & mask; masked = (supported & featureMask); if (masked != featureMask) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index c726c7cbb..9da1ef045 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1127,8 +1127,6 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr) */ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr) { - UINT32 index; - rdpSettings* settings; UINT error = CHANNEL_RC_OK; WINPR_ASSERT(rdpdr); @@ -1142,19 +1140,22 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr) } WINPR_ASSERT(rdpdr->rdpcontext); - settings = rdpdr->rdpcontext->settings; + + rdpSettings* settings = rdpdr->rdpcontext->settings; WINPR_ASSERT(settings); - rdpdr->ignoreInvalidDevices = settings->IgnoreInvalidDevices; + rdpdr->ignoreInvalidDevices = freerdp_settings_get_bool(settings, FreeRDP_IgnoreInvalidDevices); - if (settings->ClientHostname) - strncpy(rdpdr->computerName, settings->ClientHostname, sizeof(rdpdr->computerName) - 1); - else - strncpy(rdpdr->computerName, settings->ComputerName, sizeof(rdpdr->computerName) - 1); + const char* name = freerdp_settings_get_string(settings, FreeRDP_ClientHostname); + if (!name) + name = freerdp_settings_get_string(settings, FreeRDP_ComputerName); + strncpy(rdpdr->computerName, name, sizeof(rdpdr->computerName) - 1); - for (index = 0; index < settings->DeviceCount; index++) + for (UINT32 index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DeviceCount); + index++) { - const RDPDR_DEVICE* device = settings->DeviceArray[index]; + const RDPDR_DEVICE* device = + freerdp_settings_get_pointer_array(settings, FreeRDP_DeviceArray, index); if (device->Type == RDPDR_DTYP_FILESYSTEM) { diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index b3962d823..64b861550 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -641,7 +641,9 @@ static UINT rdpgfx_load_cache_import_offer(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled)) return CHANNEL_RC_OK; - if (!settings->BitmapCachePersistFile) + const char* BitmapCachePersistFile = + freerdp_settings_get_string(settings, FreeRDP_BitmapCachePersistFile); + if (!BitmapCachePersistFile) return CHANNEL_RC_OK; persistent = persistent_cache_new(); @@ -649,7 +651,7 @@ static UINT rdpgfx_load_cache_import_offer(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO if (!persistent) return CHANNEL_RC_NO_MEMORY; - if (persistent_cache_open(persistent, settings->BitmapCachePersistFile, FALSE, 3) < 1) + if (persistent_cache_open(persistent, BitmapCachePersistFile, FALSE, 3) < 1) { error = CHANNEL_RC_INITIALIZATION_ERROR; goto fail; @@ -719,7 +721,9 @@ static UINT rdpgfx_save_persistent_cache(RDPGFX_PLUGIN* gfx) if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled)) return CHANNEL_RC_OK; - if (!settings->BitmapCachePersistFile) + const char* BitmapCachePersistFile = + freerdp_settings_get_string(settings, FreeRDP_BitmapCachePersistFile); + if (!BitmapCachePersistFile) return CHANNEL_RC_OK; if (!context->ExportCacheEntry) @@ -730,7 +734,7 @@ static UINT rdpgfx_save_persistent_cache(RDPGFX_PLUGIN* gfx) if (!persistent) return CHANNEL_RC_NO_MEMORY; - if (persistent_cache_open(persistent, settings->BitmapCachePersistFile, TRUE, 3) < 1) + if (persistent_cache_open(persistent, BitmapCachePersistFile, TRUE, 3) < 1) { error = CHANNEL_RC_INITIALIZATION_ERROR; goto fail; @@ -849,7 +853,9 @@ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx) if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled)) return CHANNEL_RC_OK; - if (!settings->BitmapCachePersistFile) + const char* BitmapCachePersistFile = + freerdp_settings_get_string(settings, FreeRDP_BitmapCachePersistFile); + if (!BitmapCachePersistFile) return CHANNEL_RC_OK; persistent = persistent_cache_new(); @@ -857,7 +863,7 @@ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx) if (!persistent) return CHANNEL_RC_NO_MEMORY; - if (persistent_cache_open(persistent, settings->BitmapCachePersistFile, FALSE, 3) < 1) + if (persistent_cache_open(persistent, BitmapCachePersistFile, FALSE, 3) < 1) { error = CHANNEL_RC_INITIALIZATION_ERROR; goto fail; @@ -934,7 +940,9 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled)) return CHANNEL_RC_OK; - if (!settings->BitmapCachePersistFile) + const char* BitmapCachePersistFile = + freerdp_settings_get_string(settings, FreeRDP_BitmapCachePersistFile); + if (!BitmapCachePersistFile) return CHANNEL_RC_OK; persistent = persistent_cache_new(); @@ -942,7 +950,7 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO if (!persistent) return CHANNEL_RC_NO_MEMORY; - if (persistent_cache_open(persistent, settings->BitmapCachePersistFile, FALSE, 3) < 1) + if (persistent_cache_open(persistent, BitmapCachePersistFile, FALSE, 3) < 1) { error = CHANNEL_RC_INITIALIZATION_ERROR; goto fail; diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index a5b56856b..6fdb73a2f 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -83,9 +83,8 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk) if (remdesk->ExpertBlob) return CHANNEL_RC_OK; - if (settings->RemoteAssistancePassword) - password = settings->RemoteAssistancePassword; - else + password = freerdp_settings_get_string(settings, FreeRDP_RemoteAssistancePassword); + if (!password) password = freerdp_settings_get_string(settings, FreeRDP_Password); if (!password) @@ -94,13 +93,14 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk) return ERROR_INTERNAL_ERROR; } - name = settings->Username; + name = freerdp_settings_get_string(settings, FreeRDP_Username); if (!name) name = "Expert"; - remdesk->EncryptedPassStub = freerdp_assistance_encrypt_pass_stub( - password, settings->RemoteAssistancePassStub, &(remdesk->EncryptedPassStubSize)); + const char* stub = freerdp_settings_get_string(settings, FreeRDP_RemoteAssistancePassStub); + remdesk->EncryptedPassStub = + freerdp_assistance_encrypt_pass_stub(password, stub, &(remdesk->EncryptedPassStubSize)); if (!remdesk->EncryptedPassStub) { @@ -369,7 +369,8 @@ static UINT remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk) settings = remdesk->rdpcontext->settings; WINPR_ASSERT(settings); - pdu.raConnectionString = settings->RemoteAssistanceRCTicket; + pdu.raConnectionString = + freerdp_settings_get_string(settings, FreeRDP_RemoteAssistanceRCTicket); raConnectionStringW = ConvertUtf8ToWCharAlloc(pdu.raConnectionString, &cbRaConnectionStringW); if (!raConnectionStringW || (cbRaConnectionStringW > UINT32_MAX / sizeof(WCHAR))) @@ -429,7 +430,8 @@ static UINT remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk) settings = remdesk->rdpcontext->settings; WINPR_ASSERT(settings); - pdu.raConnectionString = settings->RemoteAssistanceRCTicket; + pdu.raConnectionString = + freerdp_settings_get_string(settings, FreeRDP_RemoteAssistanceRCTicket); raConnectionStringW = ConvertUtf8ToWCharAlloc(pdu.raConnectionString, &length); if (!raConnectionStringW)