mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[client,common] add freerdp_client_populate_settings_from_rdp_file_unchecked
Sometimes it is required to have raw values from a RDP file converted to rdpSettings without consistency modifications. Expose this with a new function.
This commit is contained in:
@@ -1750,13 +1750,55 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSettings* settings)
|
||||
BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(const rdpFile* file,
|
||||
rdpSettings* settings)
|
||||
{
|
||||
BOOL setDefaultConnectionType = TRUE;
|
||||
|
||||
if (!file || !settings)
|
||||
return FALSE;
|
||||
|
||||
/* Start with connection type.
|
||||
* This setting initializes certain defaults which might be overridden by later options.
|
||||
*/
|
||||
if (~file->BandwidthAutoDetect)
|
||||
{
|
||||
if (file->BandwidthAutoDetect != 0)
|
||||
{
|
||||
if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
||||
". Correcting to networkautodetect:i:1",
|
||||
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
||||
WLog_WARN(TAG,
|
||||
"Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
|
||||
}
|
||||
}
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
||||
(file->BandwidthAutoDetect != 0) ||
|
||||
(file->NetworkAutoDetect != 0)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (~file->NetworkAutoDetect)
|
||||
{
|
||||
if (file->NetworkAutoDetect != 0)
|
||||
{
|
||||
if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
||||
". Correcting to bandwidthautodetect:i:1",
|
||||
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
||||
WLog_WARN(
|
||||
TAG, "Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
|
||||
}
|
||||
}
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
||||
(file->BandwidthAutoDetect != 0) ||
|
||||
(file->NetworkAutoDetect != 0)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (~((size_t)file->Domain))
|
||||
{
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, file->Domain))
|
||||
@@ -2013,9 +2055,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett
|
||||
|
||||
if (~file->ConnectionType)
|
||||
{
|
||||
if (!freerdp_set_connection_type(settings, file->ConnectionType))
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType))
|
||||
return FALSE;
|
||||
setDefaultConnectionType = FALSE;
|
||||
}
|
||||
|
||||
if (~file->AudioMode)
|
||||
@@ -2276,55 +2317,6 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (~file->BandwidthAutoDetect)
|
||||
{
|
||||
if (file->BandwidthAutoDetect != 0)
|
||||
{
|
||||
if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
||||
". Correcting to networkautodetect:i:1",
|
||||
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
||||
WLog_WARN(TAG,
|
||||
"Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
|
||||
}
|
||||
|
||||
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
||||
return FALSE;
|
||||
setDefaultConnectionType = FALSE;
|
||||
}
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
||||
(file->BandwidthAutoDetect != 0) ||
|
||||
(file->NetworkAutoDetect != 0)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (~file->NetworkAutoDetect)
|
||||
{
|
||||
if (file->NetworkAutoDetect != 0)
|
||||
{
|
||||
if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
||||
". Correcting to bandwidthautodetect:i:1",
|
||||
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
||||
WLog_WARN(
|
||||
TAG, "Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
|
||||
}
|
||||
|
||||
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
||||
return FALSE;
|
||||
|
||||
setDefaultConnectionType = FALSE;
|
||||
}
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
||||
(file->BandwidthAutoDetect != 0) ||
|
||||
(file->NetworkAutoDetect != 0)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (~file->AutoReconnectionEnabled)
|
||||
{
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoReconnectionEnabled,
|
||||
@@ -2628,15 +2620,23 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (setDefaultConnectionType)
|
||||
{
|
||||
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSettings* settings)
|
||||
{
|
||||
if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
|
||||
return FALSE;
|
||||
|
||||
DWORD type = freerdp_settings_get_uint32(settings, FreeRDP_ConnectionType);
|
||||
if ((~file->ConnectionType) == 0)
|
||||
{
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_NetworkAutoDetect))
|
||||
type = CONNECTION_TYPE_AUTODETECT;
|
||||
}
|
||||
return freerdp_set_connection_type(settings, type);
|
||||
}
|
||||
|
||||
static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(const rdpFile* file, const char* name)
|
||||
{
|
||||
BOOL bFound = FALSE;
|
||||
|
||||
@@ -47,6 +47,26 @@ extern "C"
|
||||
size_t size);
|
||||
FREERDP_API BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer,
|
||||
size_t size, rdp_file_fkt_parse parse);
|
||||
|
||||
/** @brief Populate \b settings from RDP \b file. Do only notify about inconsistencies and not
|
||||
* correct them.
|
||||
*
|
||||
* @param file A pointer to the RDP file to use
|
||||
* @param settings A pointer to the settings to update
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
* @version since 3.17.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
|
||||
const rdpFile* file, rdpSettings* settings);
|
||||
|
||||
/** @brief Populate \b settings from RDP \b file. Do correct inconsistencies detected.
|
||||
*
|
||||
* @param file A pointer to the RDP file to use
|
||||
* @param settings A pointer to the settings to update
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file,
|
||||
rdpSettings* settings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user