Replaced direct settings access with getter/setter

This commit is contained in:
akallabeth
2022-06-22 12:42:48 +02:00
committed by akallabeth
parent 1d2261e884
commit 90ce22283d
14 changed files with 56 additions and 33 deletions

View File

@@ -75,7 +75,7 @@ static const char* filemap[] = { "PortDosName", "PnPName", "DriverName",
static char* get_printer_config_path(const rdpSettings* settings, const WCHAR* name, size_t length)
{
const char* path = settings->ConfigPath;
const char* path = freerdp_settings_get_string(settings, FreeRDP_ConfigPath);
char* dir = GetCombinedPath(path, "printers");
char* bname = crypto_base64_encode((const BYTE*)name, length);
char* config = GetCombinedPath(dir, bname);

View File

@@ -177,7 +177,7 @@ static BOOL android_desktop_resize(rdpContext* context)
freerdp_callback("OnGraphicsResize", "(JIII)V", (jlong)context->instance,
context->settings->DesktopWidth, context->settings->DesktopHeight,
context->freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth));
return TRUE;
}

View File

@@ -75,7 +75,7 @@ static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, COLORREF* col
if (!gdi || !settings)
return FALSE;
SrcFormat = gdi_get_pixel_format(gdi->context->settings->ColorDepth);
SrcFormat = gdi_get_pixel_format(freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
if (format)
*format = SrcFormat;
@@ -494,7 +494,8 @@ static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
if (!wf_decode_color(wfc, patblt->backColor, &bgcolor, NULL))
return FALSE;
brush = wf_create_brush(wfc, &patblt->brush, fgcolor, context->settings->ColorDepth);
brush = wf_create_brush(wfc, &patblt->brush, fgcolor,
freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth));
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);

View File

@@ -376,7 +376,8 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
UINT32 bpp = brush->bpp;
if ((bpp == 16) && (context->settings->ColorDepth == 15))
if ((bpp == 16) &&
(freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth) == 15))
bpp = 15;
Pixmap pattern = xf_brush_new(xfc, 8, 8, bpp, brush->data);
@@ -683,7 +684,8 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{
UINT32 bpp = brush->bpp;
if ((bpp == 16) && (context->settings->ColorDepth == 15))
if ((bpp == 16) &&
(freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth) == 15))
bpp = 15;
pattern = xf_brush_new(xfc, 8, 8, bpp, brush->data);
@@ -858,7 +860,8 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
{
UINT32 bpp = brush->bpp;
if ((bpp == 16) && (context->settings->ColorDepth == 15))
if ((bpp == 16) &&
(freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth) == 15))
bpp = 15;
pattern = xf_brush_new(xfc, 8, 8, bpp, brush->data);

View File

@@ -61,7 +61,7 @@ BOOL xf_decode_color(xfContext* xfc, const UINT32 srcColor, XColor* color)
if (!settings)
return FALSE;
switch (settings->ColorDepth)
switch (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth))
{
case 32:
case 24:

View File

@@ -318,7 +318,7 @@ out_free:
// TODO: This is a hack to ensure connections to RDVH with 16bpp don't have an odd screen
// resolution width
// Otherwise this could result in screen corruption ..
if (settings->ColorDepth <= 16)
if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) <= 16)
settings->DesktopWidth &= (~1);
[self performSelectorInBackground:@selector(runSession) withObject:nil];

View File

@@ -285,7 +285,8 @@ static BOOL mf_peer_post_connect(freerdp_peer* client)
settings->DesktopWidth = mfi->servscreen_width;
settings->DesktopHeight = mfi->servscreen_height;
settings->ColorDepth = bitsPerPixel;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, bitsPerPixel))
return FALSE;
WINPR_ASSERT(client->context->update);
WINPR_ASSERT(client->context->update->DesktopResize);
@@ -381,7 +382,8 @@ static void* mf_peer_main_loop(void* arg)
settings->NlaSecurity = FALSE;
settings->RemoteFxCodec = TRUE;
settings->ColorDepth = 32;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32))
return FALSE;
settings->SuppressOutput = TRUE;
settings->RefreshRect = FALSE;

View File

@@ -648,7 +648,8 @@ static BOOL tf_peer_post_connect(freerdp_peer* client)
WLog_DBG(TAG, "");
WLog_DBG(TAG, "Client requested desktop: %" PRIu32 "x%" PRIu32 "x%" PRIu32 "",
settings->DesktopWidth, settings->DesktopHeight, settings->ColorDepth);
settings->DesktopWidth, settings->DesktopHeight,
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
#if (SAMPLE_SERVER_USE_CLIENT_RESOLUTION == 1)
if (!rfx_context_reset(context->rfx_context, settings->DesktopWidth, settings->DesktopHeight))
@@ -1036,8 +1037,9 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
/* settings->EncryptionLevel = ENCRYPTION_LEVEL_LOW; */
/* settings->EncryptionLevel = ENCRYPTION_LEVEL_FIPS; */
settings->RemoteFxCodec = TRUE;
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE);
settings->ColorDepth = 32;
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE) ||
!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32))
return FALSE;
settings->SuppressOutput = TRUE;
settings->RefreshRect = TRUE;

View File

@@ -125,7 +125,8 @@ static BOOL wf_peer_post_connect(freerdp_peer* client)
*/
settings->DesktopWidth = wfi->servscreen_width;
settings->DesktopHeight = wfi->servscreen_height;
settings->ColorDepth = wfi->bitsPerPixel;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, wfi->bitsPerPixel))
return FALSE;
WINPR_ASSERT(client->context->update);
WINPR_ASSERT(client->context->update->DesktopResize);
@@ -263,7 +264,8 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
WINPR_ASSERT(settings);
settings->RemoteFxCodec = TRUE;
settings->ColorDepth = 32;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32))
goto fail_peer_init;
settings->NSCodec = FALSE;
settings->JpegCodec = FALSE;

View File

@@ -162,9 +162,11 @@ static BOOL capture_plugin_send_frame(pClientContext* pc, SOCKET socket, const B
settings = pc->context.settings;
WINPR_ASSERT(settings);
frame_size = settings->DesktopWidth * settings->DesktopHeight * (settings->ColorDepth / 8);
bmp_header = winpr_bitmap_construct_header(settings->DesktopWidth, settings->DesktopHeight,
settings->ColorDepth);
frame_size = settings->DesktopWidth * settings->DesktopHeight *
(freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) / 8);
bmp_header =
winpr_bitmap_construct_header(settings->DesktopWidth, settings->DesktopHeight,
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
if (!bmp_header)
return FALSE;

View File

@@ -58,7 +58,8 @@ wStream* capture_plugin_create_session_info_packet(pClientContext* pc)
Stream_Write(s, settings->Username, username_length); /* username */
Stream_Write_UINT32(s, settings->DesktopWidth); /* desktop width (4 bytes) */
Stream_Write_UINT32(s, settings->DesktopHeight); /* desktop height (4 bytes) */
Stream_Write_UINT32(s, settings->ColorDepth); /* color depth (4 bytes) */
Stream_Write_UINT32(
s, freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)); /* color depth (4 bytes) */
Stream_Write(s, pc->pdata->session_id, PROXY_SESSION_ID_LENGTH); /* color depth (32 bytes) */
return s;
}

View File

@@ -512,7 +512,8 @@ static BOOL pf_server_initialize_peer_connection(freerdp_peer* peer)
settings->TlsSecurity = config->ServerTlsSecurity;
settings->NlaSecurity = config->ServerNlaSecurity;
settings->EncryptionLevel = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
settings->ColorDepth = 32;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32))
return FALSE;
settings->SuppressOutput = TRUE;
settings->RefreshRect = TRUE;
settings->DesktopResize = TRUE;

View File

@@ -306,7 +306,8 @@ static BOOL shw_freerdp_client_new(freerdp* instance, rdpContext* context)
settings->FrameMarkerCommandEnabled = TRUE;
settings->SurfaceFrameMarkerEnabled = TRUE;
settings->AltSecFrameMarkerSupport = TRUE;
settings->ColorDepth = 32;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32))
return FALSE;
settings->NSCodec = TRUE;
settings->RemoteFxCodec = TRUE;
settings->FastPathInput = TRUE;
@@ -314,7 +315,8 @@ static BOOL shw_freerdp_client_new(freerdp* instance, rdpContext* context)
settings->LargePointerFlag = TRUE;
settings->CompressionEnabled = FALSE;
settings->AutoReconnectionEnabled = FALSE;
settings->NetworkAutoDetect = FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, FALSE))
return FALSE;
settings->SupportHeartbeatPdu = FALSE;
settings->SupportMultitransport = FALSE;
settings->ConnectionType = CONNECTION_TYPE_LAN;

View File

@@ -180,7 +180,9 @@ static BOOL shadow_client_context_new(freerdp_peer* peer, rdpContext* context)
settings = peer->context->settings;
WINPR_ASSERT(settings);
settings->ColorDepth = srvSettings->ColorDepth;
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth,
freerdp_settings_get_uint32(srvSettings, FreeRDP_ColorDepth)))
return FALSE;
NSCodec = freerdp_settings_get_bool(srvSettings, FreeRDP_NSCodec);
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, NSCodec);
settings->RemoteFxCodec = srvSettings->RemoteFxCodec;
@@ -406,8 +408,11 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer)
subsystem = server->subsystem;
WINPR_ASSERT(subsystem);
if (settings->ColorDepth == 24)
settings->ColorDepth = 16; /* disable 24bpp */
if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) == 24)
{
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 16)) /* disable 24bpp */
return FALSE;
}
if (settings->MultifragMaxRequestSize < 0x3F0000)
{
@@ -419,19 +424,21 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer)
WLog_INFO(TAG, "Client from %s is activated (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
settings->ColorDepth);
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
/* Resize client if necessary */
if (shadow_client_recalc_desktop_size(client))
{
BOOL rc;
rdpUpdate* update = peer->context->update;
WINPR_ASSERT(update);
WINPR_ASSERT(update->DesktopResize);
update->DesktopResize(update->context);
rc = update->DesktopResize(update->context);
WLog_INFO(TAG, "Client from %s is resized (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
settings->ColorDepth);
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
return FALSE;
}
if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK)
@@ -1499,7 +1506,7 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
maxUpdateSize = settings->MultifragMaxRequestSize;
if (settings->ColorDepth < 32)
if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) < 32)
{
if (shadow_encoder_prepare(encoder, FREERDP_CODEC_INTERLEAVED) < 0)
{
@@ -1574,9 +1581,9 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
if ((bitmap->width < 4) || (bitmap->height < 4))
continue;
if (settings->ColorDepth < 32)
if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) < 32)
{
UINT32 bitsPerPixel = settings->ColorDepth;
UINT32 bitsPerPixel = freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth);
UINT32 bytesPerPixel = (bitsPerPixel + 7) / 8;
DstSize = 64 * 64 * 4;
buffer = encoder->grid[k];
@@ -1887,7 +1894,7 @@ static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS
LeaveCriticalSection(&(client->lock));
WLog_INFO(TAG, "Client from %s is resized (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
settings->ColorDepth);
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
return TRUE;
}