settings/trivial: rename settings-connection's autoconnect functions

Names like
  - nm_settings_connection_get_autoconnect_retries
  - nm_settings_connection_set_autoconnect_retries
  - nm_settings_connection_reset_autoconnect_retries
are about the same thing, but they are cumbersome to grep
because they share not a common prefix.

Rename them from SUBJECT_VERB_OBJECT to SUBJECT_OBJECT_VERB,
which sounds odd in English, but seems preferred to me.
Now you can grep for "nm_settings_connection_autoconnect_retries_" to
get all accessors of the retry count, or "nm_settings_connection_autoconnect_"
to get all accessors related to autoconnect in general.
This commit is contained in:
Thomas Haller
2017-10-24 08:26:25 +02:00
parent f0a23bf999
commit ec9bff293b
6 changed files with 48 additions and 48 deletions

View File

@@ -266,7 +266,7 @@ reset_8021x_autoconnect_retries (NMDevice *device)
connection = nm_act_request_get_settings_connection (req); connection = nm_act_request_get_settings_connection (req);
g_return_if_fail (connection); g_return_if_fail (connection);
/* Reset autoconnect retries on success, failure, or when deactivating */ /* Reset autoconnect retries on success, failure, or when deactivating */
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
} }
} }
@@ -688,11 +688,11 @@ handle_auth_or_fail (NMDeviceEthernet *self,
applied_connection = nm_act_request_get_applied_connection (req); applied_connection = nm_act_request_get_applied_connection (req);
settings_connection = nm_act_request_get_settings_connection (req); settings_connection = nm_act_request_get_settings_connection (req);
tries_left = nm_settings_connection_get_autoconnect_retries (settings_connection); tries_left = nm_settings_connection_autoconnect_retries_get (settings_connection);
if (tries_left == 0) if (tries_left == 0)
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
if (tries_left > 0) if (tries_left > 0)
nm_settings_connection_set_autoconnect_retries (settings_connection, tries_left - 1); nm_settings_connection_autoconnect_retries_set (settings_connection, tries_left - 1);
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);

View File

@@ -485,11 +485,11 @@ handle_auth_or_fail (NMDeviceMacsec *self,
applied_connection = nm_act_request_get_applied_connection (req); applied_connection = nm_act_request_get_applied_connection (req);
settings_connection = nm_act_request_get_settings_connection (req); settings_connection = nm_act_request_get_settings_connection (req);
tries_left = nm_settings_connection_get_autoconnect_retries (settings_connection); tries_left = nm_settings_connection_autoconnect_retries_get (settings_connection);
if (tries_left == 0) if (tries_left == 0)
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
if (tries_left > 0) if (tries_left > 0)
nm_settings_connection_set_autoconnect_retries (settings_connection, tries_left - 1); nm_settings_connection_autoconnect_retries_set (settings_connection, tries_left - 1);
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
@@ -748,7 +748,7 @@ reset_autoconnect_retries (NMDevice *device)
connection = nm_act_request_get_settings_connection (req); connection = nm_act_request_get_settings_connection (req);
g_return_if_fail (connection); g_return_if_fail (connection);
/* Reset autoconnect retries on success, failure, or when deactivating */ /* Reset autoconnect retries on success, failure, or when deactivating */
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
} }
} }

View File

@@ -391,7 +391,7 @@ device_state_changed (NMDevice *device,
* where a retry attempt would just fail again. * where a retry attempt would just fail again.
*/ */
if (connection) { if (connection) {
nm_settings_connection_set_autoconnect_blocked_reason (connection, nm_settings_connection_autoconnect_blocked_reason_set (connection,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED); NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED);
} }
break; break;

View File

@@ -1193,7 +1193,7 @@ pending_ac_state_changed (NMActiveConnection *ac, guint state, guint reason, NMP
* loop. * loop.
*/ */
con = nm_active_connection_get_settings_connection (ac); con = nm_active_connection_get_settings_connection (ac);
nm_settings_connection_set_autoconnect_blocked_reason (con, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED); nm_settings_connection_autoconnect_blocked_reason_set (con, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED);
schedule_activate_check (self, nm_active_connection_get_device (ac)); schedule_activate_check (self, nm_active_connection_get_device (ac));
/* Cleanup */ /* Cleanup */
@@ -1266,7 +1266,7 @@ auto_activate_device (NMPolicy *self,
error->code, error->code,
error->message); error->message);
g_error_free (error); g_error_free (error);
nm_settings_connection_set_autoconnect_blocked_reason (best_connection, nm_settings_connection_autoconnect_blocked_reason_set (best_connection,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED); NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED);
schedule_activate_check (self, device); schedule_activate_check (self, device);
return; return;
@@ -1424,8 +1424,8 @@ reset_autoconnect_all (NMPolicy *self, NMDevice *device)
NMSettingsConnection *connection = connections[i]; NMSettingsConnection *connection = connections[i];
if (!device || nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) { if (!device || nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) {
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE); nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE);
} }
} }
} }
@@ -1443,9 +1443,9 @@ reset_autoconnect_for_failed_secrets (NMPolicy *self)
for (i = 0; connections[i]; i++) { for (i = 0; connections[i]; i++) {
NMSettingsConnection *connection = connections[i]; NMSettingsConnection *connection = connections[i];
if (nm_settings_connection_get_autoconnect_blocked_reason (connection) == NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS) { if (nm_settings_connection_autoconnect_blocked_reason_get (connection) == NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS) {
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE); nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE);
} }
} }
} }
@@ -1472,7 +1472,7 @@ block_autoconnect_for_device (NMPolicy *self, NMDevice *device)
NMSettingsConnection *connection = connections[i]; NMSettingsConnection *connection = connections[i];
if (nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) { if (nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) {
nm_settings_connection_set_autoconnect_blocked_reason (connection, nm_settings_connection_autoconnect_blocked_reason_set (connection,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST); NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST);
} }
} }
@@ -1556,12 +1556,12 @@ reset_connections_retries (gpointer user_data)
for (i = 0; connections[i]; i++) { for (i = 0; connections[i]; i++) {
NMSettingsConnection *connection = connections[i]; NMSettingsConnection *connection = connections[i];
con_stamp = nm_settings_connection_get_autoconnect_retry_time (connection); con_stamp = nm_settings_connection_autoconnect_blocked_until_get (connection);
if (con_stamp == 0) if (con_stamp == 0)
continue; continue;
if (con_stamp <= now) { if (con_stamp <= now) {
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
changed = TRUE; changed = TRUE;
} else if (min_stamp == 0 || min_stamp > con_stamp) } else if (min_stamp == 0 || min_stamp > con_stamp)
min_stamp = con_stamp; min_stamp = con_stamp;
@@ -1631,12 +1631,12 @@ activate_slave_connections (NMPolicy *self, NMDevice *device)
NMSettingsAutoconnectBlockedReason reason; NMSettingsAutoconnectBlockedReason reason;
if (!internal_activation) if (!internal_activation)
nm_settings_connection_reset_autoconnect_retries (settings); nm_settings_connection_autoconnect_retries_reset (settings);
reason = nm_settings_connection_get_autoconnect_blocked_reason (settings); reason = nm_settings_connection_autoconnect_blocked_reason_get (settings);
if (reason == NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED) { if (reason == NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED) {
reason = NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE; reason = NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE;
nm_settings_connection_set_autoconnect_blocked_reason (settings, reason); nm_settings_connection_autoconnect_blocked_reason_set (settings, reason);
} }
} }
} }
@@ -1744,29 +1744,29 @@ device_state_changed (NMDevice *device,
&& old_state <= NM_DEVICE_STATE_ACTIVATED) { && old_state <= NM_DEVICE_STATE_ACTIVATED) {
int tries; int tries;
tries = nm_settings_connection_get_autoconnect_retries (connection); tries = nm_settings_connection_autoconnect_retries_get (connection);
if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_NO_SECRETS) { if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_NO_SECRETS) {
_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets", _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
nm_settings_connection_get_id (connection)); nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS); nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS);
} else if (tries != 0) { } else if (tries != 0) {
if (tries > 0) { if (tries > 0) {
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left", _LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
nm_settings_connection_get_id (connection), tries); nm_settings_connection_get_id (connection), tries);
nm_settings_connection_set_autoconnect_retries (connection, --tries); nm_settings_connection_autoconnect_retries_set (connection, --tries);
} else { } else {
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; infinite tries left", _LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; infinite tries left",
nm_settings_connection_get_id (connection)); nm_settings_connection_get_id (connection));
} }
} }
if (nm_settings_connection_get_autoconnect_retries (connection) == 0) { if (nm_settings_connection_autoconnect_retries_get (connection) == 0) {
_LOGI (LOGD_DEVICE, "disabling autoconnect for connection '%s'.", _LOGI (LOGD_DEVICE, "disabling autoconnect for connection '%s'.",
nm_settings_connection_get_id (connection)); nm_settings_connection_get_id (connection));
/* Schedule a handler to reset retries count */ /* Schedule a handler to reset retries count */
if (!priv->reset_retries_id) { if (!priv->reset_retries_id) {
gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection); gint32 retry_time = nm_settings_connection_autoconnect_blocked_until_get (connection);
g_warn_if_fail (retry_time != 0); g_warn_if_fail (retry_time != 0);
priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, self); priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, self);
@@ -1778,7 +1778,7 @@ device_state_changed (NMDevice *device,
case NM_DEVICE_STATE_ACTIVATED: case NM_DEVICE_STATE_ACTIVATED:
if (connection) { if (connection) {
/* Reset auto retries back to default since connection was successful */ /* Reset auto retries back to default since connection was successful */
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
/* And clear secrets so they will always be requested from the /* And clear secrets so they will always be requested from the
* settings service when the next connection is made. * settings service when the next connection is made.
@@ -1817,7 +1817,7 @@ device_state_changed (NMDevice *device,
/* The connection was deactivated, so block just this connection */ /* The connection was deactivated, so block just this connection */
_LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request", _LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request",
nm_settings_connection_get_id (connection)); nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection, nm_settings_connection_autoconnect_blocked_reason_set (connection,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST); NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST);
} }
} }
@@ -1856,7 +1856,7 @@ device_state_changed (NMDevice *device,
case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_IP_CONFIG:
/* We must have secrets if we got here. */ /* We must have secrets if we got here. */
if (connection) if (connection)
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE); nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE);
break; break;
case NM_DEVICE_STATE_SECONDARIES: case NM_DEVICE_STATE_SECONDARIES:
if (connection) if (connection)
@@ -2309,7 +2309,7 @@ connection_updated (NMSettings *settings,
nm_device_reapply_settings_immediately (device); nm_device_reapply_settings_immediately (device);
/* Reset auto retries back to default since connection was updated */ /* Reset auto retries back to default since connection was updated */
nm_settings_connection_reset_autoconnect_retries (connection); nm_settings_connection_autoconnect_retries_reset (connection);
} }
schedule_activate_all (self); schedule_activate_all (self);

View File

@@ -109,7 +109,7 @@ typedef struct _NMSettingsConnectionPrivate {
GHashTable *seen_bssids; /* Up-to-date BSSIDs that's been seen for the connection */ GHashTable *seen_bssids; /* Up-to-date BSSIDs that's been seen for the connection */
int autoconnect_retries; int autoconnect_retries;
gint32 autoconnect_retry_time; gint32 autoconnect_blocked_until;
char *filename; char *filename;
} NMSettingsConnectionPrivate; } NMSettingsConnectionPrivate;
@@ -2532,7 +2532,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self)
} }
/** /**
* nm_settings_connection_get_autoconnect_retries: * nm_settings_connection_autoconnect_retries_get:
* @self: the settings connection * @self: the settings connection
* *
* Returns the number of autoconnect retries left. If the value is * Returns the number of autoconnect retries left. If the value is
@@ -2540,7 +2540,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self)
* with the global default. * with the global default.
*/ */
int int
nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self) nm_settings_connection_autoconnect_retries_get (NMSettingsConnection *self)
{ {
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
@@ -2577,7 +2577,7 @@ nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self)
} }
void void
nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, nm_settings_connection_autoconnect_retries_set (NMSettingsConnection *self,
int retries) int retries)
{ {
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
@@ -2589,31 +2589,31 @@ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self,
priv->autoconnect_retries = retries; priv->autoconnect_retries = retries;
} }
if (retries) if (retries)
priv->autoconnect_retry_time = 0; priv->autoconnect_blocked_until = 0;
else else
priv->autoconnect_retry_time = nm_utils_get_monotonic_timestamp_s () + AUTOCONNECT_RESET_RETRIES_TIMER; priv->autoconnect_blocked_until = nm_utils_get_monotonic_timestamp_s () + AUTOCONNECT_RESET_RETRIES_TIMER;
} }
void void
nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self) nm_settings_connection_autoconnect_retries_reset (NMSettingsConnection *self)
{ {
nm_settings_connection_set_autoconnect_retries (self, AUTOCONNECT_RETRIES_UNSET); nm_settings_connection_autoconnect_retries_set (self, AUTOCONNECT_RETRIES_UNSET);
} }
gint32 gint32
nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self) nm_settings_connection_autoconnect_blocked_until_get (NMSettingsConnection *self)
{ {
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retry_time; return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_until;
} }
NMSettingsAutoconnectBlockedReason NMSettingsAutoconnectBlockedReason
nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self) nm_settings_connection_autoconnect_blocked_reason_get (NMSettingsConnection *self)
{ {
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason; return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason;
} }
void void
nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, nm_settings_connection_autoconnect_blocked_reason_set (NMSettingsConnection *self,
NMSettingsAutoconnectBlockedReason reason) NMSettingsAutoconnectBlockedReason reason)
{ {
g_return_if_fail (NM_IN_SET (reason, g_return_if_fail (NM_IN_SET (reason,
@@ -2632,7 +2632,7 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *self)
const char *permission; const char *permission;
if ( !priv->visible if ( !priv->visible
|| nm_settings_connection_get_autoconnect_retries (self) == 0 || nm_settings_connection_autoconnect_retries_get (self) == 0
|| priv->autoconnect_blocked_reason != NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE) || priv->autoconnect_blocked_reason != NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE)
return FALSE; return FALSE;

View File

@@ -213,15 +213,15 @@ void nm_settings_connection_add_seen_bssid (NMSettingsConnection *self,
void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self); void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self);
int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self); int nm_settings_connection_autoconnect_retries_get (NMSettingsConnection *self);
void nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, void nm_settings_connection_autoconnect_retries_set (NMSettingsConnection *self,
int retries); int retries);
void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self); void nm_settings_connection_autoconnect_retries_reset (NMSettingsConnection *self);
gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self); gint32 nm_settings_connection_autoconnect_blocked_until_get (NMSettingsConnection *self);
NMSettingsAutoconnectBlockedReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self); NMSettingsAutoconnectBlockedReason nm_settings_connection_autoconnect_blocked_reason_get (NMSettingsConnection *self);
void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, void nm_settings_connection_autoconnect_blocked_reason_set (NMSettingsConnection *self,
NMSettingsAutoconnectBlockedReason reason); NMSettingsAutoconnectBlockedReason reason);
gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self); gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self);