mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 04:50:11 +01:00
settings: refactor autoconnect-blocked-reason to use own enum
Don't reuse NMDeviceStateReason for the autoconnect-blocked-reason. There are only two cases we care: blocked-due-to-no-secrets, blocked-otherwise. Encode these values in a new enum type.
This commit is contained in:
parent
9a64168c87
commit
71a22df337
4 changed files with 37 additions and 21 deletions
|
|
@ -390,8 +390,10 @@ device_state_changed (NMDevice *device,
|
|||
/* Block autoconnect of the just-failed connection for situations
|
||||
* where a retry attempt would just fail again.
|
||||
*/
|
||||
if (connection)
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, reason);
|
||||
if (connection) {
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_BLOCKED);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1155,7 +1155,7 @@ reset_autoconnect_all (NMPolicy *self, NMDevice *device)
|
|||
|
||||
if (!device || nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) {
|
||||
nm_settings_connection_reset_autoconnect_retries (connection);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NONE);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1173,9 +1173,9 @@ reset_autoconnect_for_failed_secrets (NMPolicy *self)
|
|||
for (i = 0; connections[i]; i++) {
|
||||
NMSettingsConnection *connection = connections[i];
|
||||
|
||||
if (nm_settings_connection_get_autoconnect_blocked_reason (connection) == NM_DEVICE_STATE_REASON_NO_SECRETS) {
|
||||
if (nm_settings_connection_get_autoconnect_blocked_reason (connection) == NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS) {
|
||||
nm_settings_connection_reset_autoconnect_retries (connection);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NONE);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1203,7 +1203,7 @@ block_autoconnect_for_device (NMPolicy *self, NMDevice *device)
|
|||
|
||||
if (nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) {
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection,
|
||||
NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_BLOCKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1469,7 +1469,7 @@ device_state_changed (NMDevice *device,
|
|||
_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
|
||||
nm_settings_connection_get_id (connection));
|
||||
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS);
|
||||
} else if (tries != 0) {
|
||||
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
|
||||
nm_settings_connection_get_id (connection), tries);
|
||||
|
|
@ -1534,7 +1534,7 @@ device_state_changed (NMDevice *device,
|
|||
_LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request",
|
||||
nm_settings_connection_get_id (connection));
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection,
|
||||
NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_BLOCKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1562,7 +1562,7 @@ device_state_changed (NMDevice *device,
|
|||
case NM_DEVICE_STATE_IP_CONFIG:
|
||||
/* We must have secrets if we got here. */
|
||||
if (connection)
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NONE);
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED);
|
||||
break;
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
if (connection)
|
||||
|
|
|
|||
|
|
@ -69,17 +69,24 @@ enum {
|
|||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
typedef struct _NMSettingsConnectionPrivate {
|
||||
gboolean removed;
|
||||
|
||||
NMAgentManager *agent_mgr;
|
||||
NMSessionMonitor *session_monitor;
|
||||
gulong session_changed_id;
|
||||
|
||||
NMSettingsConnectionFlags flags;
|
||||
gboolean ready;
|
||||
|
||||
bool removed:1;
|
||||
bool ready:1;
|
||||
|
||||
/* Is this connection visible by some session? */
|
||||
bool visible:1;
|
||||
|
||||
bool timestamp_set:1;
|
||||
|
||||
NMSettingsAutoconnectBlockedReason autoconnect_blocked_reason:3;
|
||||
|
||||
GSList *pending_auths; /* List of pending authentication requests */
|
||||
gboolean visible; /* Is this connection is visible by some session? */
|
||||
|
||||
GSList *get_secret_requests; /* in-progress secrets requests */
|
||||
|
||||
|
|
@ -99,12 +106,10 @@ typedef struct _NMSettingsConnectionPrivate {
|
|||
NMConnection *agent_secrets;
|
||||
|
||||
guint64 timestamp; /* Up-to-date timestamp of connection use */
|
||||
gboolean timestamp_set;
|
||||
GHashTable *seen_bssids; /* Up-to-date BSSIDs that's been seen for the connection */
|
||||
|
||||
int autoconnect_retries;
|
||||
gint32 autoconnect_retry_time;
|
||||
NMDeviceStateReason autoconnect_blocked_reason;
|
||||
|
||||
char *filename;
|
||||
} NMSettingsConnectionPrivate;
|
||||
|
|
@ -2604,7 +2609,7 @@ nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self)
|
|||
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retry_time;
|
||||
}
|
||||
|
||||
NMDeviceStateReason
|
||||
NMSettingsAutoconnectBlockedReason
|
||||
nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self)
|
||||
{
|
||||
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason;
|
||||
|
|
@ -2612,8 +2617,12 @@ nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *sel
|
|||
|
||||
void
|
||||
nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self,
|
||||
NMDeviceStateReason reason)
|
||||
NMSettingsAutoconnectBlockedReason reason)
|
||||
{
|
||||
g_return_if_fail (NM_IN_SET (reason,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_BLOCKED,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS));
|
||||
NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason = reason;
|
||||
}
|
||||
|
||||
|
|
@ -2626,7 +2635,7 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *self)
|
|||
|
||||
if ( !priv->visible
|
||||
|| priv->autoconnect_retries == 0
|
||||
|| priv->autoconnect_blocked_reason != NM_DEVICE_STATE_REASON_NONE)
|
||||
|| priv->autoconnect_blocked_reason != NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED)
|
||||
return FALSE;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
|
||||
|
|
@ -2766,7 +2775,6 @@ nm_settings_connection_init (NMSettingsConnection *self)
|
|||
priv->seen_bssids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
priv->autoconnect_retries = AUTOCONNECT_RETRIES_UNSET;
|
||||
priv->autoconnect_blocked_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
|
||||
g_signal_connect (self, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), NULL);
|
||||
g_signal_connect (self, NM_CONNECTION_CHANGED, G_CALLBACK (connection_changed_cb), NULL);
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ typedef enum { /*< skip >*/
|
|||
NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED = (1LL << 1),
|
||||
} NMSettingsConnectionCommitReason;
|
||||
|
||||
typedef enum {
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_UNBLOCKED = 0,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_BLOCKED = 1,
|
||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS = 2,
|
||||
} NMSettingsAutoconnectBlockedReason;
|
||||
|
||||
struct _NMSettingsConnectionCallId;
|
||||
typedef struct _NMSettingsConnectionCallId *NMSettingsConnectionCallId;
|
||||
|
||||
|
|
@ -215,9 +221,9 @@ void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *sel
|
|||
|
||||
gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self);
|
||||
|
||||
NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self);
|
||||
void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self,
|
||||
NMDeviceStateReason reason);
|
||||
NMSettingsAutoconnectBlockedReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self);
|
||||
void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self,
|
||||
NMSettingsAutoconnectBlockedReason reason);
|
||||
|
||||
gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue