cli: nmc_property_get_gvalue() nmc_property_set_gvalue()

Functions to
 - get property value and return it in GValue
 - set property value from GValue
This commit is contained in:
Jiří Klimeš
2013-03-20 10:21:19 +01:00
parent f96cd68d90
commit def37e4e0d
2 changed files with 37 additions and 0 deletions

View File

@@ -4664,6 +4664,41 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
nmcli_desc ? nmcli_desc : "");
}
/*
* Gets setting:prop property value and returns it in 'value'.
* Caller is responsible for freeing the GValue resources using g_value_unset()
*/
gboolean
nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value)
{
GParamSpec *param_spec;
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
if (param_spec) {
memset (value, 0, sizeof (GValue));
g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
g_object_get_property (G_OBJECT (setting), prop, value);
return TRUE;
}
return FALSE;
}
/*
* Sets setting:prop property value from 'value'.
*/
gboolean
nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value)
{
GParamSpec *param_spec;
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
if (param_spec && G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (param_spec)) {
g_object_set_property (G_OBJECT (setting), prop, value);
return TRUE;
}
return FALSE;
}
/*----------------------------------------------------------------------------*/
static gboolean

View File

@@ -76,6 +76,8 @@ gboolean nmc_setting_remove_property_option (NMSetting *setting,
GError **error);
void nmc_property_set_default_value (NMSetting *setting, const char *prop);
gboolean nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value);
gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value);
gboolean setting_details (NMSetting *ssetting, NmCli *nmc);