[core] fix persistent bitmap cache setting

* Only activate if both, client and server support the capability
* Use settings getter to access setting
This commit is contained in:
Armin Novak 2023-01-09 15:56:20 +01:00 committed by akallabeth
parent 1dc2225bd2
commit 70f6c09ff4
6 changed files with 15 additions and 13 deletions

View File

@ -637,7 +637,7 @@ static UINT rdpgfx_load_cache_import_offer(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO
offer->cacheEntriesCount = 0;
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return CHANNEL_RC_OK;
if (!settings->BitmapCachePersistFile)
@ -715,7 +715,7 @@ static UINT rdpgfx_save_persistent_cache(RDPGFX_PLUGIN* gfx)
WINPR_ASSERT(context);
WINPR_ASSERT(settings);
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return CHANNEL_RC_OK;
if (!settings->BitmapCachePersistFile)
@ -845,7 +845,7 @@ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx)
RdpgfxClientContext* context = gfx->context;
rdpSettings* settings = gfx->rdpcontext->settings;
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return CHANNEL_RC_OK;
if (!settings->BitmapCachePersistFile)
@ -930,7 +930,7 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO
WINPR_ASSERT(settings);
WINPR_ASSERT(reply);
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return CHANNEL_RC_OK;
if (!settings->BitmapCachePersistFile)

View File

@ -3825,7 +3825,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
CommandLineSwitchCase(arg, "persist-cache")
{
WLog_WARN(TAG, "/persist-cache is deprecated, use /cache:persist[:on|off] instead");
settings->BitmapCachePersistEnabled = enable;
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, enable))
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
CommandLineSwitchCase(arg, "persist-cache-file")
{
@ -3834,7 +3835,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (!freerdp_settings_set_string(settings, FreeRDP_BitmapCachePersistFile, arg->Value))
return COMMAND_LINE_ERROR_MEMORY;
settings->BitmapCachePersistEnabled = TRUE;
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, TRUE))
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
CommandLineSwitchCase(arg, "offscreen-cache")
{

View File

@ -296,7 +296,7 @@ static int bitmap_cache_save_persistent(rdpBitmapCache* bitmapCache)
if (version != 2)
return 0; /* persistent bitmap cache already saved in egfx channel */
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return 0;
if (!settings->BitmapCachePersistFile)

View File

@ -282,7 +282,7 @@ static UINT32 rdp_load_persistent_key_list(rdpRdp* rdp, UINT64** pKeyList)
*pKeyList = NULL;
if (!settings->BitmapCachePersistEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
return 0;
if (!settings->BitmapCachePersistFile)

View File

@ -1861,9 +1861,9 @@ static BOOL rdp_print_offscreen_bitmap_cache_capability_set(wStream* s)
static BOOL rdp_apply_bitmap_cache_host_support_capability_set(rdpSettings* settings,
const rdpSettings* src)
{
if (freerdp_settings_get_bool(src, FreeRDP_BitmapCachePersistEnabled))
return freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, TRUE);
return TRUE;
const BOOL val = (freerdp_settings_get_bool(src, FreeRDP_BitmapCachePersistEnabled) &&
freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled));
return freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, val);
}
/*
@ -2052,7 +2052,7 @@ static BOOL rdp_write_bitmap_cache_v2_capability_set(wStream* s, const rdpSettin
return FALSE;
cacheFlags = ALLOW_CACHE_WAITING_LIST_FLAG;
if (settings->BitmapCachePersistEnabled)
if (freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled))
{
cacheFlags |= PERSISTENT_KEYS_EXPECTED_FLAG;
settings->BitmapCacheV2CellInfo[0].persistent = 1;

View File

@ -1261,7 +1261,7 @@ state_run_t rdp_client_connect_finalize(rdpRdp* rdp)
*/
if (!rdp_finalize_is_flag_set(rdp, FINALIZE_DEACTIVATE_REACTIVATE) &&
rdp->settings->BitmapCachePersistEnabled)
freerdp_settings_get_bool(rdp->settings, FreeRDP_BitmapCachePersistEnabled))
{
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_PERSISTENT_KEY_LIST))
return STATE_RUN_FAILED;