clients: add validate_fcn for string property
This commit is contained in:
@@ -764,14 +764,21 @@ _get_fcn_gobject_enum (ARGS_GET_FCN)
|
|||||||
static gboolean
|
static gboolean
|
||||||
_set_fcn_gobject_string (ARGS_SET_FCN)
|
_set_fcn_gobject_string (ARGS_SET_FCN)
|
||||||
{
|
{
|
||||||
if ( property_info->property_typ_data
|
gs_free char *to_free = NULL;
|
||||||
&& property_info->property_typ_data->values_static) {
|
|
||||||
|
if (property_info->property_typ_data) {
|
||||||
|
if (property_info->property_typ_data->subtype.gobject_string.validate_fcn) {
|
||||||
|
value = property_info->property_typ_data->subtype.gobject_string.validate_fcn (value, &to_free, error);
|
||||||
|
if (!value)
|
||||||
|
return FALSE;
|
||||||
|
} else if (property_info->property_typ_data->values_static) {
|
||||||
value = nmc_string_is_valid (value,
|
value = nmc_string_is_valid (value,
|
||||||
(const char **) property_info->property_typ_data->values_static,
|
(const char **) property_info->property_typ_data->values_static,
|
||||||
error);
|
error);
|
||||||
if (!value)
|
if (!value)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
g_object_set (setting, property_info->property_name, value, NULL);
|
g_object_set (setting, property_info->property_name, value, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -4284,15 +4291,14 @@ _set_fcn_wireless_security_wep_key_type (ARGS_SET_FCN)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static const char *
|
||||||
_set_fcn_wireless_security_psk (ARGS_SET_FCN)
|
_validate_fcn_wireless_security_psk (const char *value, char **out_to_free, GError **error)
|
||||||
{
|
{
|
||||||
if (!nm_utils_wpa_psk_valid (value)) {
|
if (!nm_utils_wpa_psk_valid (value)) {
|
||||||
g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), value);
|
g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), value);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
g_object_set (setting, property_info->property_name, value, NULL);
|
return value;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -6516,9 +6522,9 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
|
|||||||
),
|
),
|
||||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PSK,
|
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PSK,
|
||||||
.is_secret = TRUE,
|
.is_secret = TRUE,
|
||||||
.property_type = DEFINE_PROPERTY_TYPE (
|
.property_type = &_pt_gobject_string,
|
||||||
.get_fcn = _get_fcn_gobject,
|
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_string,
|
||||||
.set_fcn = _set_fcn_wireless_security_psk,
|
.validate_fcn = _validate_fcn_wireless_security_psk,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS,
|
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS,
|
||||||
|
@@ -236,6 +236,9 @@ struct _NMMetaPropertyTypData {
|
|||||||
int max;
|
int max;
|
||||||
const struct _NMUtilsEnumValueInfo *value_infos;
|
const struct _NMUtilsEnumValueInfo *value_infos;
|
||||||
} gobject_enum;
|
} gobject_enum;
|
||||||
|
struct {
|
||||||
|
const char *(*validate_fcn) (const char *value, char **out_to_free, GError **error);
|
||||||
|
} gobject_string;
|
||||||
struct {
|
struct {
|
||||||
guint32 (*get_fcn) (NMSetting *setting);
|
guint32 (*get_fcn) (NMSetting *setting);
|
||||||
} mtu;
|
} mtu;
|
||||||
|
Reference in New Issue
Block a user