mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 13:38:40 +02:00
connectivity: refactor converting connectivity states to string
This commit is contained in:
parent
a79e9fdbb0
commit
78e3b4866a
3 changed files with 8 additions and 8 deletions
|
|
@ -69,8 +69,8 @@ nm_connectivity_get_state (NMConnectivity *connectivity)
|
|||
return NM_CONNECTIVITY_GET_PRIVATE (connectivity)->state;
|
||||
}
|
||||
|
||||
static const char *
|
||||
state_name (NMConnectivityState state)
|
||||
const char *
|
||||
nm_connectivity_state_to_string (NMConnectivityState state)
|
||||
{
|
||||
switch (state) {
|
||||
case NM_CONNECTIVITY_UNKNOWN:
|
||||
|
|
@ -84,7 +84,7 @@ state_name (NMConnectivityState state)
|
|||
case NM_CONNECTIVITY_FULL:
|
||||
return "FULL";
|
||||
default:
|
||||
return "???";
|
||||
g_return_val_if_reached ("???");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,8 @@ update_state (NMConnectivity *self, NMConnectivityState state)
|
|||
|
||||
if (priv->state != state) {
|
||||
nm_log_dbg (LOGD_CONCHECK, "Connectivity state changed from %s to %s",
|
||||
state_name (priv->state), state_name (state));
|
||||
nm_connectivity_state_to_string (priv->state),
|
||||
nm_connectivity_state_to_string (state));
|
||||
priv->state = state;
|
||||
g_object_notify (G_OBJECT (self), NM_CONNECTIVITY_STATE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ typedef struct {
|
|||
|
||||
GType nm_connectivity_get_type (void);
|
||||
|
||||
const char *nm_connectivity_state_to_string (NMConnectivityState state);
|
||||
|
||||
NMConnectivity *nm_connectivity_new (void);
|
||||
|
||||
void nm_connectivity_set_online (NMConnectivity *self,
|
||||
|
|
|
|||
|
|
@ -4274,12 +4274,9 @@ connectivity_changed (NMConnectivity *connectivity,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMManager *self = NM_MANAGER (user_data);
|
||||
NMConnectivityState state;
|
||||
static const char *connectivity_states[] = { "UNKNOWN", "NONE", "PORTAL", "LIMITED", "FULL" };
|
||||
|
||||
state = nm_connectivity_get_state (connectivity);
|
||||
nm_log_dbg (LOGD_CORE, "connectivity checking indicates %s",
|
||||
connectivity_states[state]);
|
||||
nm_connectivity_state_to_string (nm_connectivity_get_state (connectivity)));
|
||||
|
||||
nm_manager_update_state (self);
|
||||
g_object_notify (G_OBJECT (self), NM_MANAGER_CONNECTIVITY);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue