core: rename nm_config_run_state* to nm_config_state*
After all, this state is stored persistently to /var/lib/NetworkManager,
and not to volatile storage in /var/run. Hence the name is better.
It's also shorter, so rename it.
The commit is mostly trivial, including update of code comments
and logging messages.
Fixes: 1b43c880ba
This commit is contained in:
@@ -335,8 +335,8 @@ main (int argc, char *argv[])
|
|||||||
nm_log_info (LOGD_CORE, "Read config: %s", nm_config_data_get_config_description (nm_config_get_data (config)));
|
nm_log_info (LOGD_CORE, "Read config: %s", nm_config_data_get_config_description (nm_config_get_data (config)));
|
||||||
nm_config_data_log (nm_config_get_data (config), "CONFIG: ", " ", NULL);
|
nm_config_data_log (nm_config_get_data (config), "CONFIG: ", " ", NULL);
|
||||||
|
|
||||||
/* the first access to RunState causes the file to be read (and possibly print a warning) */
|
/* the first access to State causes the file to be read (and possibly print a warning) */
|
||||||
nm_config_run_state_get (config);
|
nm_config_state_get (config);
|
||||||
|
|
||||||
nm_log_dbg (LOGD_CORE, "WEXT support is %s",
|
nm_log_dbg (LOGD_CORE, "WEXT support is %s",
|
||||||
#if HAVE_WEXT
|
#if HAVE_WEXT
|
||||||
@@ -400,7 +400,7 @@ done:
|
|||||||
|
|
||||||
nm_manager_stop (nm_manager_get ());
|
nm_manager_stop (nm_manager_get ());
|
||||||
|
|
||||||
nm_config_run_state_set (config, TRUE, TRUE);
|
nm_config_state_set (config, TRUE, TRUE);
|
||||||
|
|
||||||
if (global_opt.pidfile && wrote_pidfile)
|
if (global_opt.pidfile && wrote_pidfile)
|
||||||
unlink (global_opt.pidfile);
|
unlink (global_opt.pidfile);
|
||||||
|
144
src/nm-config.c
144
src/nm-config.c
@@ -73,8 +73,8 @@ struct NMConfigCmdLineOptions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMConfigRunState p;
|
NMConfigState p;
|
||||||
} RunState;
|
} State;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMConfigCmdLineOptions cli;
|
NMConfigCmdLineOptions cli;
|
||||||
@@ -101,15 +101,18 @@ typedef struct {
|
|||||||
|
|
||||||
char **atomic_section_prefixes;
|
char **atomic_section_prefixes;
|
||||||
|
|
||||||
/* The run-state. This is actually a mutable data member and it makes sense:
|
/* The state. This is actually a mutable data member and it makes sense:
|
||||||
* The regular config is immutable (NMConfigData) which allows atomic updates
|
* The regular config is immutable (NMConfigData) and can old be swapped
|
||||||
* which is handy during reload. Also, we invoke a config-changed signal when
|
* as a whole (via nm_config_set_values() or during reload). Thus, it can
|
||||||
* the config changes.
|
* be changed, but it is still immutable and is swapped atomically as a
|
||||||
|
* whole. Also, we emit a config-changed signal on that occasion.
|
||||||
*
|
*
|
||||||
* For run-state, there are no events. You can query it and set it.
|
* For state, there are no events. You can query it and set it.
|
||||||
* It only gets read once at startup, and later is cached and only written
|
* It only gets read *once* at startup, and later is cached and only
|
||||||
* out to disk. Hence, no need for the immutable dance here. */
|
* written out to disk. Hence, no need for the immutable dance here
|
||||||
RunState *run_state;
|
* because the state changes only on explicit actions from the daemon
|
||||||
|
* itself. */
|
||||||
|
State *state;
|
||||||
} NMConfigPrivate;
|
} NMConfigPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -1678,76 +1681,75 @@ nm_config_set_values (NMConfig *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* RunState
|
* State
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
run_state_get_filename (const NMConfigCmdLineOptions *cli)
|
state_get_filename (const NMConfigCmdLineOptions *cli)
|
||||||
{
|
{
|
||||||
/* For an empty filename, we assume the user wants to disable
|
/* For an empty filename, we assume the user wants to disable
|
||||||
* persistent run-state. NMConfig will not try to read it nor
|
* state. NMConfig will not try to read it nor write it out. */
|
||||||
* write it out. */
|
|
||||||
if (!cli->state_file)
|
if (!cli->state_file)
|
||||||
return DEFAULT_STATE_FILE;
|
return DEFAULT_STATE_FILE;
|
||||||
return cli->state_file[0] ? cli->state_file : NULL;
|
return cli->state_file[0] ? cli->state_file : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RunState *
|
static State *
|
||||||
run_state_new (void)
|
state_new (void)
|
||||||
{
|
{
|
||||||
RunState *run_state;
|
State *state;
|
||||||
|
|
||||||
run_state = g_slice_new0 (RunState);
|
state = g_slice_new0 (State);
|
||||||
run_state->p.net_enabled = TRUE;
|
state->p.net_enabled = TRUE;
|
||||||
run_state->p.wifi_enabled = TRUE;
|
state->p.wifi_enabled = TRUE;
|
||||||
run_state->p.wwan_enabled = TRUE;
|
state->p.wwan_enabled = TRUE;
|
||||||
|
|
||||||
return run_state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_state_free (RunState *run_state)
|
state_free (State *state)
|
||||||
{
|
{
|
||||||
if (!run_state)
|
if (!state)
|
||||||
return;
|
return;
|
||||||
g_slice_free (RunState, run_state);
|
g_slice_free (State, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RunState *
|
static State *
|
||||||
run_state_new_from_file (const char *filename)
|
state_new_from_file (const char *filename)
|
||||||
{
|
{
|
||||||
GKeyFile *keyfile;
|
GKeyFile *keyfile;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
RunState *run_state;
|
State *state;
|
||||||
|
|
||||||
run_state = run_state_new ();
|
state = state_new ();
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return run_state;
|
return state;
|
||||||
|
|
||||||
keyfile = g_key_file_new ();
|
keyfile = g_key_file_new ();
|
||||||
g_key_file_set_list_separator (keyfile, ',');
|
g_key_file_set_list_separator (keyfile, ',');
|
||||||
if (!g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error)) {
|
if (!g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error)) {
|
||||||
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||||
_LOGD ("run-state: missing state file \"%s\": %s", filename, error->message);
|
_LOGD ("state: missing state file \"%s\": %s", filename, error->message);
|
||||||
else
|
else
|
||||||
_LOGW ("run-state: error reading state file \"%s\": %s", filename, error->message);
|
_LOGW ("state: error reading state file \"%s\": %s", filename, error->message);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGD ("run-state: successfully read state file \"%s\"", filename);
|
_LOGD ("state: successfully read state file \"%s\"", filename);
|
||||||
|
|
||||||
run_state->p.net_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "NetworkingEnabled", run_state->p.net_enabled);
|
state->p.net_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "NetworkingEnabled", state->p.net_enabled);
|
||||||
run_state->p.wifi_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "WirelessEnabled", run_state->p.wifi_enabled);
|
state->p.wifi_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "WirelessEnabled", state->p.wifi_enabled);
|
||||||
run_state->p.wwan_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "WWANEnabled", run_state->p.wwan_enabled);
|
state->p.wwan_enabled = nm_config_keyfile_get_boolean (keyfile, "main", "WWANEnabled", state->p.wwan_enabled);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_key_file_unref (keyfile);
|
g_key_file_unref (keyfile);
|
||||||
return run_state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NMConfigRunState *
|
const NMConfigState *
|
||||||
nm_config_run_state_get (NMConfig *self)
|
nm_config_state_get (NMConfig *self)
|
||||||
{
|
{
|
||||||
NMConfigPrivate *priv;
|
NMConfigPrivate *priv;
|
||||||
|
|
||||||
@@ -1755,29 +1757,31 @@ nm_config_run_state_get (NMConfig *self)
|
|||||||
|
|
||||||
priv = NM_CONFIG_GET_PRIVATE (self);
|
priv = NM_CONFIG_GET_PRIVATE (self);
|
||||||
|
|
||||||
if (G_UNLIKELY (!priv->run_state)) {
|
if (G_UNLIKELY (!priv->state)) {
|
||||||
/* read the runstate from file lazy on first access. The reason is that
|
/* read the state from file lazy on first access. The reason is that
|
||||||
* we want to log a failure to read the file via nm-logging. But during
|
* we want to log a failure to read the file via nm-logging.
|
||||||
* construction of NMConfig, nm-logging is not yet configured.
|
*
|
||||||
|
* So we cannot read the state during construction of NMConfig,
|
||||||
|
* because at that time nm-logging is not yet configured.
|
||||||
*/
|
*/
|
||||||
priv->run_state = run_state_new_from_file (run_state_get_filename (&priv->cli));
|
priv->state = state_new_from_file (state_get_filename (&priv->cli));
|
||||||
}
|
}
|
||||||
|
|
||||||
return &priv->run_state->p;
|
return &priv->state->p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_state_write (NMConfig *self)
|
state_write (NMConfig *self)
|
||||||
{
|
{
|
||||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (self);
|
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (self);
|
||||||
const char *filename;
|
const char *filename;
|
||||||
GString *str;
|
GString *str;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
filename = run_state_get_filename (&priv->cli);
|
filename = state_get_filename (&priv->cli);
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
priv->run_state->p.dirty = FALSE;
|
priv->state->p.dirty = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1786,31 +1790,31 @@ run_state_write (NMConfig *self)
|
|||||||
/* Let's construct the keyfile data by hand. */
|
/* Let's construct the keyfile data by hand. */
|
||||||
|
|
||||||
g_string_append (str, "[main]\n");
|
g_string_append (str, "[main]\n");
|
||||||
g_string_append_printf (str, "NetworkingEnabled=%s\n", priv->run_state->p.net_enabled ? "true" : "false");
|
g_string_append_printf (str, "NetworkingEnabled=%s\n", priv->state->p.net_enabled ? "true" : "false");
|
||||||
g_string_append_printf (str, "WirelessEnabled=%s\n", priv->run_state->p.wifi_enabled ? "true" : "false");
|
g_string_append_printf (str, "WirelessEnabled=%s\n", priv->state->p.wifi_enabled ? "true" : "false");
|
||||||
g_string_append_printf (str, "WWANEnabled=%s\n", priv->run_state->p.wwan_enabled ? "true" : "false");
|
g_string_append_printf (str, "WWANEnabled=%s\n", priv->state->p.wwan_enabled ? "true" : "false");
|
||||||
|
|
||||||
if (!g_file_set_contents (filename,
|
if (!g_file_set_contents (filename,
|
||||||
str->str, str->len,
|
str->str, str->len,
|
||||||
&error)) {
|
&error)) {
|
||||||
_LOGD ("run-state: error writing state file \"%s\": %s", filename, error->message);
|
_LOGD ("state: error writing state file \"%s\": %s", filename, error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
/* we leave the state dirty. That potentally means, that we try to
|
/* we leave the state dirty. That potentally means, that we try to
|
||||||
* write the file over and over again, although it isn't possible. */
|
* write the file over and over again, although it isn't possible. */
|
||||||
priv->run_state->p.dirty = TRUE;
|
priv->state->p.dirty = TRUE;
|
||||||
} else
|
} else
|
||||||
priv->run_state->p.dirty = FALSE;
|
priv->state->p.dirty = FALSE;
|
||||||
|
|
||||||
_LOGT ("run-state: success writing state file \"%s\"", filename);
|
_LOGT ("state: success writing state file \"%s\"", filename);
|
||||||
|
|
||||||
g_string_free (str, TRUE);
|
g_string_free (str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_nm_config_run_state_set (NMConfig *self,
|
_nm_config_state_set (NMConfig *self,
|
||||||
gboolean allow_persist,
|
gboolean allow_persist,
|
||||||
gboolean force_persist,
|
gboolean force_persist,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
NMConfigPrivate *priv;
|
NMConfigPrivate *priv;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -1827,18 +1831,18 @@ _nm_config_run_state_set (NMConfig *self,
|
|||||||
* Larger would be a problem, also, because we want that "0" is a valid sentinel. */
|
* Larger would be a problem, also, because we want that "0" is a valid sentinel. */
|
||||||
G_STATIC_ASSERT_EXPR (sizeof (NMConfigRunStatePropertyType) <= sizeof (int));
|
G_STATIC_ASSERT_EXPR (sizeof (NMConfigRunStatePropertyType) <= sizeof (int));
|
||||||
|
|
||||||
while ((property_type = va_arg (ap, int)) != NM_CONFIG_RUN_STATE_PROPERTY_NONE) {
|
while ((property_type = va_arg (ap, int)) != NM_CONFIG_STATE_PROPERTY_NONE) {
|
||||||
bool *p_bool, v_bool;
|
bool *p_bool, v_bool;
|
||||||
|
|
||||||
switch (property_type) {
|
switch (property_type) {
|
||||||
case NM_CONFIG_RUN_STATE_PROPERTY_NETWORKING_ENABLED:
|
case NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED:
|
||||||
p_bool = &priv->run_state->p.net_enabled;
|
p_bool = &priv->state->p.net_enabled;
|
||||||
goto handle_p_bool;
|
goto handle_p_bool;
|
||||||
case NM_CONFIG_RUN_STATE_PROPERTY_WIFI_ENABLED:
|
case NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED:
|
||||||
p_bool = &priv->run_state->p.wifi_enabled;
|
p_bool = &priv->state->p.wifi_enabled;
|
||||||
goto handle_p_bool;
|
goto handle_p_bool;
|
||||||
case NM_CONFIG_RUN_STATE_PROPERTY_WWAN_ENABLED:
|
case NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED:
|
||||||
p_bool = &priv->run_state->p.wwan_enabled;
|
p_bool = &priv->state->p.wwan_enabled;
|
||||||
goto handle_p_bool;
|
goto handle_p_bool;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1851,14 +1855,14 @@ handle_p_bool:
|
|||||||
if (*p_bool == v_bool)
|
if (*p_bool == v_bool)
|
||||||
continue;
|
continue;
|
||||||
*p_bool = v_bool;
|
*p_bool = v_bool;
|
||||||
priv->run_state->p.dirty = TRUE;
|
priv->state->p.dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
if ( allow_persist
|
if ( allow_persist
|
||||||
&& (force_persist || priv->run_state->p.dirty))
|
&& (force_persist || priv->state->p.dirty))
|
||||||
run_state_write (self);
|
state_write (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -2134,7 +2138,7 @@ finalize (GObject *gobject)
|
|||||||
{
|
{
|
||||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (gobject);
|
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (gobject);
|
||||||
|
|
||||||
run_state_free (priv->run_state);
|
state_free (priv->state);
|
||||||
|
|
||||||
g_free (priv->config_dir);
|
g_free (priv->config_dir);
|
||||||
g_free (priv->system_config_dir);
|
g_free (priv->system_config_dir);
|
||||||
|
@@ -84,12 +84,12 @@ G_BEGIN_DECLS
|
|||||||
typedef struct NMConfigCmdLineOptions NMConfigCmdLineOptions;
|
typedef struct NMConfigCmdLineOptions NMConfigCmdLineOptions;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_NONE,
|
NM_CONFIG_STATE_PROPERTY_NONE,
|
||||||
|
|
||||||
/* 1 set-argument: (gboolean enabled) */
|
/* 1 set-argument: (gboolean enabled) */
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_NETWORKING_ENABLED,
|
NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED,
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_WIFI_ENABLED,
|
NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED,
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_WWAN_ENABLED,
|
NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED,
|
||||||
} NMConfigRunStatePropertyType;
|
} NMConfigRunStatePropertyType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -99,7 +99,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Whether the runstate is modified and not saved to disk. */
|
/* Whether the runstate is modified and not saved to disk. */
|
||||||
bool dirty;
|
bool dirty;
|
||||||
} NMConfigRunState;
|
} NMConfigState;
|
||||||
|
|
||||||
struct _NMConfig {
|
struct _NMConfig {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
@@ -149,14 +149,14 @@ NMConfig *nm_config_new (const NMConfigCmdLineOptions *cli, char **atomic_sectio
|
|||||||
NMConfig *nm_config_setup (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes, GError **error);
|
NMConfig *nm_config_setup (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes, GError **error);
|
||||||
void nm_config_reload (NMConfig *config, int signal);
|
void nm_config_reload (NMConfig *config, int signal);
|
||||||
|
|
||||||
const NMConfigRunState *nm_config_run_state_get (NMConfig *config);
|
const NMConfigState *nm_config_state_get (NMConfig *config);
|
||||||
|
|
||||||
void _nm_config_run_state_set (NMConfig *config,
|
void _nm_config_state_set (NMConfig *config,
|
||||||
gboolean allow_persist,
|
gboolean allow_persist,
|
||||||
gboolean force_persist,
|
gboolean force_persist,
|
||||||
...);
|
...);
|
||||||
#define nm_config_run_state_set(config, allow_persist, force_persist, ...) \
|
#define nm_config_state_set(config, allow_persist, force_persist, ...) \
|
||||||
_nm_config_run_state_set (config, allow_persist, force_persist, ##__VA_ARGS__, 0)
|
_nm_config_state_set (config, allow_persist, force_persist, ##__VA_ARGS__, 0)
|
||||||
|
|
||||||
gint nm_config_parse_boolean (const char *str, gint default_value);
|
gint nm_config_parse_boolean (const char *str, gint default_value);
|
||||||
|
|
||||||
|
@@ -4011,9 +4011,8 @@ _internal_enable (NMManager *self, gboolean enable)
|
|||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
|
|
||||||
/* Update "NetworkingEnabled" key in state file */
|
nm_config_state_set (priv->config, TRUE, FALSE,
|
||||||
nm_config_run_state_set (priv->config, TRUE, FALSE,
|
NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED, enable);
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_NETWORKING_ENABLED, enable);
|
|
||||||
|
|
||||||
_LOGI (LOGD_SUSPEND, "%s requested (sleeping: %s enabled: %s)",
|
_LOGI (LOGD_SUSPEND, "%s requested (sleeping: %s enabled: %s)",
|
||||||
enable ? "enable" : "disable",
|
enable ? "enable" : "disable",
|
||||||
@@ -4964,8 +4963,8 @@ manager_radio_user_toggled (NMManager *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update enabled key in state file */
|
/* Update enabled key in state file */
|
||||||
nm_config_run_state_set (priv->config, TRUE, FALSE,
|
nm_config_state_set (priv->config, TRUE, FALSE,
|
||||||
rstate->key, enabled);
|
rstate->key, enabled);
|
||||||
|
|
||||||
/* When the user toggles the radio, their request should override any
|
/* When the user toggles the radio, their request should override any
|
||||||
* daemon (like ModemManager) enabled state that can be changed. For WWAN
|
* daemon (like ModemManager) enabled state that can be changed. For WWAN
|
||||||
@@ -5064,7 +5063,7 @@ constructed (GObject *object)
|
|||||||
NMManager *self = NM_MANAGER (object);
|
NMManager *self = NM_MANAGER (object);
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
NMConfigData *config_data;
|
NMConfigData *config_data;
|
||||||
const NMConfigRunState *run_state;
|
const NMConfigState *state;
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_manager_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nm_manager_parent_class)->constructed (object);
|
||||||
|
|
||||||
@@ -5107,12 +5106,12 @@ constructed (GObject *object)
|
|||||||
g_signal_connect (priv->connectivity, "notify::" NM_CONNECTIVITY_STATE,
|
g_signal_connect (priv->connectivity, "notify::" NM_CONNECTIVITY_STATE,
|
||||||
G_CALLBACK (connectivity_changed), self);
|
G_CALLBACK (connectivity_changed), self);
|
||||||
|
|
||||||
run_state = nm_config_run_state_get (priv->config);
|
state = nm_config_state_get (priv->config);
|
||||||
|
|
||||||
priv->net_enabled = run_state->net_enabled;
|
priv->net_enabled = state->net_enabled;
|
||||||
|
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = run_state->wifi_enabled;
|
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = state->wifi_enabled;
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = run_state->wwan_enabled;
|
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = state->wwan_enabled;
|
||||||
|
|
||||||
priv->rfkill_mgr = nm_rfkill_manager_new ();
|
priv->rfkill_mgr = nm_rfkill_manager_new ();
|
||||||
g_signal_connect (priv->rfkill_mgr,
|
g_signal_connect (priv->rfkill_mgr,
|
||||||
@@ -5140,14 +5139,14 @@ nm_manager_init (NMManager *self)
|
|||||||
memset (priv->radio_states, 0, sizeof (priv->radio_states));
|
memset (priv->radio_states, 0, sizeof (priv->radio_states));
|
||||||
|
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = TRUE;
|
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = TRUE;
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].key = NM_CONFIG_RUN_STATE_PROPERTY_WIFI_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WLAN].key = NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].prop = NM_MANAGER_WIRELESS_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WLAN].prop = NM_MANAGER_WIRELESS_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].hw_prop = NM_MANAGER_WIRELESS_HARDWARE_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WLAN].hw_prop = NM_MANAGER_WIRELESS_HARDWARE_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].desc = "WiFi";
|
priv->radio_states[RFKILL_TYPE_WLAN].desc = "WiFi";
|
||||||
priv->radio_states[RFKILL_TYPE_WLAN].rtype = RFKILL_TYPE_WLAN;
|
priv->radio_states[RFKILL_TYPE_WLAN].rtype = RFKILL_TYPE_WLAN;
|
||||||
|
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = TRUE;
|
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = TRUE;
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].key = NM_CONFIG_RUN_STATE_PROPERTY_WWAN_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WWAN].key = NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].prop = NM_MANAGER_WWAN_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WWAN].prop = NM_MANAGER_WWAN_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].hw_prop = NM_MANAGER_WWAN_HARDWARE_ENABLED;
|
priv->radio_states[RFKILL_TYPE_WWAN].hw_prop = NM_MANAGER_WWAN_HARDWARE_ENABLED;
|
||||||
priv->radio_states[RFKILL_TYPE_WWAN].desc = "WWAN";
|
priv->radio_states[RFKILL_TYPE_WWAN].desc = "WWAN";
|
||||||
|
@@ -934,7 +934,7 @@ static void
|
|||||||
test_config_state_file (void)
|
test_config_state_file (void)
|
||||||
{
|
{
|
||||||
NMConfig *config;
|
NMConfig *config;
|
||||||
const NMConfigRunState *state;
|
const NMConfigState *state;
|
||||||
gs_unref_object GFile *src = NULL, *dst = NULL;
|
gs_unref_object GFile *src = NULL, *dst = NULL;
|
||||||
const char *tmp_file = BUILDDIR "/tmp.state";
|
const char *tmp_file = BUILDDIR "/tmp.state";
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -952,19 +952,19 @@ test_config_state_file (void)
|
|||||||
"--state-file", tmp_file, NULL);
|
"--state-file", tmp_file, NULL);
|
||||||
g_assert (config);
|
g_assert (config);
|
||||||
|
|
||||||
state = nm_config_run_state_get (config);
|
state = nm_config_state_get (config);
|
||||||
g_assert (state);
|
g_assert (state);
|
||||||
|
|
||||||
g_assert_cmpint (state->net_enabled, ==, TRUE);
|
g_assert_cmpint (state->net_enabled, ==, TRUE);
|
||||||
g_assert_cmpint (state->wifi_enabled, ==, TRUE);
|
g_assert_cmpint (state->wifi_enabled, ==, TRUE);
|
||||||
g_assert_cmpint (state->wwan_enabled, ==, TRUE);
|
g_assert_cmpint (state->wwan_enabled, ==, TRUE);
|
||||||
|
|
||||||
nm_config_run_state_set (config, TRUE, TRUE,
|
nm_config_state_set (config, TRUE, TRUE,
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_NETWORKING_ENABLED, FALSE,
|
NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED, FALSE,
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_WIFI_ENABLED, TRUE,
|
NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED, TRUE,
|
||||||
NM_CONFIG_RUN_STATE_PROPERTY_WWAN_ENABLED, FALSE);
|
NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED, FALSE);
|
||||||
|
|
||||||
state = nm_config_run_state_get (config);
|
state = nm_config_state_get (config);
|
||||||
g_assert (state);
|
g_assert (state);
|
||||||
|
|
||||||
g_assert_cmpint (state->net_enabled, ==, FALSE);
|
g_assert_cmpint (state->net_enabled, ==, FALSE);
|
||||||
@@ -978,7 +978,7 @@ test_config_state_file (void)
|
|||||||
"--state-file", tmp_file, NULL);
|
"--state-file", tmp_file, NULL);
|
||||||
g_assert (config);
|
g_assert (config);
|
||||||
|
|
||||||
state = nm_config_run_state_get (config);
|
state = nm_config_state_get (config);
|
||||||
g_assert (state);
|
g_assert (state);
|
||||||
|
|
||||||
g_assert_cmpint (state->net_enabled, ==, FALSE);
|
g_assert_cmpint (state->net_enabled, ==, FALSE);
|
||||||
|
Reference in New Issue
Block a user