[channels] make settings opaque

This commit is contained in:
akallabeth 2023-10-13 09:32:46 +02:00 committed by akallabeth
parent 130501fcd5
commit eb445f7c43
6 changed files with 50 additions and 32 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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)

View File

@ -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)
{

View File

@ -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;

View File

@ -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)