mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-08 23:10:29 +01:00
config: use nm_config_data_get_value_boolean()
This removes duplicate parsing, but also makes all places use the same str-to-boolean convention.
This commit is contained in:
parent
a0e92799af
commit
1b0ab2129c
2 changed files with 12 additions and 30 deletions
|
|
@ -82,16 +82,9 @@ ignore_cb(NMSettingsConnectionInterface * connection,
|
|||
static gboolean
|
||||
is_managed_plugin (void)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
result = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED);
|
||||
if (result) {
|
||||
gboolean ret = is_true (result);
|
||||
g_free (result);
|
||||
return ret;
|
||||
}
|
||||
return IFNET_MANAGE_WELL_KNOWN_DEFAULT;
|
||||
return nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED,
|
||||
IFNET_MANAGE_WELL_KNOWN_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -199,8 +192,7 @@ reload_connections (NMSystemConfigInterface *config)
|
|||
SCPluginIfnet *self = SC_PLUGIN_IFNET (config);
|
||||
SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);
|
||||
GList *conn_names = NULL, *n_iter = NULL;
|
||||
gboolean auto_refresh = FALSE;
|
||||
char *str_auto_refresh;
|
||||
gboolean auto_refresh;
|
||||
GError *error = NULL;
|
||||
|
||||
/* save names for removing unused connections */
|
||||
|
|
@ -217,11 +209,9 @@ reload_connections (NMSystemConfigInterface *config)
|
|||
|
||||
nm_log_info (LOGD_SETTINGS, "Loading connections");
|
||||
|
||||
str_auto_refresh = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFNET_KEY_FILE_GROUP, "auto_refresh");
|
||||
if (str_auto_refresh && is_true (str_auto_refresh))
|
||||
auto_refresh = TRUE;
|
||||
g_free (str_auto_refresh);
|
||||
auto_refresh = nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFNET_KEY_FILE_GROUP, "auto_refresh",
|
||||
FALSE);
|
||||
|
||||
new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
||||
|
||||
|
|
|
|||
|
|
@ -302,7 +302,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||
SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self);
|
||||
GHashTable *auto_ifaces;
|
||||
if_block *block = NULL;
|
||||
char *value;
|
||||
GList *keys, *iter;
|
||||
GHashTableIter con_iter;
|
||||
const char *block_name;
|
||||
|
|
@ -328,8 +327,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||
} else
|
||||
g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self);
|
||||
|
||||
priv->unmanage_well_known = IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT;
|
||||
|
||||
/* Read in all the interfaces */
|
||||
ifparser_init (ENI_INTERFACES_FILE, 0);
|
||||
block = ifparser_getfirst ();
|
||||
|
|
@ -419,15 +416,10 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||
g_hash_table_destroy (auto_ifaces);
|
||||
|
||||
/* Check the config file to find out whether to manage interfaces */
|
||||
value = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED);
|
||||
if (value) {
|
||||
gboolean manage_well_known;
|
||||
|
||||
manage_well_known = !strcmp (value, "true") || !strcmp (value, "1");
|
||||
priv->unmanage_well_known = !manage_well_known;
|
||||
g_free (value);
|
||||
}
|
||||
priv->unmanage_well_known = !nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
|
||||
IFUPDOWN_KEY_FILE_GROUP,
|
||||
IFUPDOWN_KEY_FILE_KEY_MANAGED,
|
||||
!IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT);
|
||||
nm_log_info (LOGD_SETTINGS, "management mode: %s", priv->unmanage_well_known ? "unmanaged" : "managed");
|
||||
|
||||
/* Add well-known interfaces */
|
||||
|
|
@ -517,7 +509,7 @@ sc_plugin_ifupdown_init (SCPluginIfupdown *plugin)
|
|||
|
||||
static void
|
||||
GObject__get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue