settings: remove accessor functions to connection flags

The accessor functions just look whether a certain flag is set. As these
functions have a different name then the flags, this is more confusing
then helpful. For example, if you want to know where the NM_GENERATED
flag matters, you had to know to grep for nm_settings_connection_get_nm_generated()
in addition to NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED.

The accessor function hid that the property was implemented as
a connection flag. For example, it was not immediately obvious
that nm_settings_connection_get_nm_generated() is the same
as having the NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED flag
set.

Drop them.

(cherry picked from commit 545e3111c8)
This commit is contained in:
Thomas Haller 2017-12-05 12:10:16 +01:00
parent e3d81c167c
commit ab24d5356c
7 changed files with 18 additions and 53 deletions

View file

@ -1185,7 +1185,8 @@ dispose (GObject *object)
if (priv->pan_connection) {
/* Check whether we want to remove the created connection. If so, we take a reference
* and delete it at the end of dispose(). */
if (nm_settings_connection_get_nm_generated (NM_SETTINGS_CONNECTION (priv->pan_connection)))
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (NM_SETTINGS_CONNECTION (priv->pan_connection)),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED))
to_delete = g_object_ref (priv->pan_connection);
priv->pan_connection = NULL;

View file

@ -10173,7 +10173,8 @@ nm_device_set_ip4_config (NMDevice *self,
if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self))
&& nm_settings_connection_get_nm_generated (settings_connection)
&& NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED)
&& nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (priv->act_request)) == NM_ACTIVATION_TYPE_EXTERNAL) {
NMSetting *s_ip4;
@ -10344,7 +10345,8 @@ nm_device_set_ip6_config (NMDevice *self,
if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self))
&& nm_settings_connection_get_nm_generated (settings_connection)
&& NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED)
&& nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (priv->act_request)) == NM_ACTIVATION_TYPE_EXTERNAL) {
NMSetting *s_ip6;

View file

@ -866,7 +866,8 @@ _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
nm_assert (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL);
nm_assert (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->settings_connection == settings_connection);
if (nm_settings_connection_get_nm_generated (settings_connection))
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED))
return;
_set_activation_type_managed (self);

View file

@ -328,7 +328,8 @@ active_connection_remove (NMManager *self, NMActiveConnection *active)
g_signal_handlers_disconnect_by_func (active, active_connection_parent_active, self);
if ( (connection = nm_active_connection_get_settings_connection (active))
&& nm_settings_connection_get_volatile (connection))
&& NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
g_object_ref (connection);
else
connection = NULL;
@ -497,7 +498,8 @@ _get_activatable_connections_filter (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
if (nm_settings_connection_get_volatile (connection))
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
return FALSE;
return !active_connection_find_first (user_data, connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATING);
}

View file

@ -1224,7 +1224,8 @@ auto_activate_device (NMPolicy *self,
NMSettingConnection *s_con;
const char *permission;
if ( !nm_settings_connection_is_visible (candidate)
if ( !NM_FLAGS_HAS (nm_settings_connection_get_flags (candidate),
NM_SETTINGS_CONNECTION_FLAGS_VISIBLE)
|| nm_settings_connection_autoconnect_is_blocked (candidate))
continue;
@ -2382,7 +2383,8 @@ connection_flags_changed (NMSettings *settings,
NMPolicyPrivate *priv = user_data;
NMPolicy *self = _PRIV_TO_SELF (priv);
if (nm_settings_connection_is_visible (connection))
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
NM_SETTINGS_CONNECTION_FLAGS_VISIBLE))
schedule_activate_all (self);
else
_deactivate_if_active (self, connection);

View file

@ -324,14 +324,6 @@ set_visible (NMSettingsConnection *self, gboolean new_visible)
new_visible);
}
gboolean
nm_settings_connection_is_visible (NMSettingsConnection *self)
{
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE);
return NM_FLAGS_HAS (NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->flags, NM_SETTINGS_CONNECTION_FLAGS_VISIBLE);
}
void
nm_settings_connection_recheck_visibility (NMSettingsConnection *self)
{
@ -397,7 +389,8 @@ nm_settings_connection_check_permission (NMSettingsConnection *self,
priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
if (!nm_settings_connection_is_visible (self))
if (!NM_FLAGS_HAS (nm_settings_connection_get_flags (self),
NM_SETTINGS_CONNECTION_FLAGS_VISIBLE))
return FALSE;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
@ -2750,37 +2743,6 @@ nm_settings_connection_autoconnect_is_blocked (NMSettingsConnection *self)
/*****************************************************************************/
/**
* nm_settings_connection_get_nm_generated:
* @self: an #NMSettingsConnection
*
* Gets the "nm-generated" flag on @self.
*
* A connection is "nm-generated" if it was generated by
* nm_device_generate_connection() and has not been modified or
* saved by the user since then.
*/
gboolean
nm_settings_connection_get_nm_generated (NMSettingsConnection *self)
{
return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED);
}
/**
* nm_settings_connection_get_volatile:
* @self: an #NMSettingsConnection
*
* Gets the "volatile" flag on @self.
*
* The connection is marked as volatile and will be removed when
* it disconnects.
*/
gboolean
nm_settings_connection_get_volatile (NMSettingsConnection *self)
{
return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_VOLATILE);
}
gboolean
nm_settings_connection_get_ready (NMSettingsConnection *self)
{

View file

@ -176,8 +176,6 @@ NMSettingsConnectionCallId *nm_settings_connection_get_secrets (NMSettingsConnec
void nm_settings_connection_cancel_secrets (NMSettingsConnection *self,
NMSettingsConnectionCallId *call_id);
gboolean nm_settings_connection_is_visible (NMSettingsConnection *self);
void nm_settings_connection_recheck_visibility (NMSettingsConnection *self);
gboolean nm_settings_connection_check_permission (NMSettingsConnection *self,
@ -238,9 +236,6 @@ nm_settings_connection_autoconnect_blocked_reason_set (NMSettingsConnection *sel
gboolean nm_settings_connection_autoconnect_is_blocked (NMSettingsConnection *self);
gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *self);
gboolean nm_settings_connection_get_volatile (NMSettingsConnection *self);
gboolean nm_settings_connection_get_ready (NMSettingsConnection *self);
void nm_settings_connection_set_ready (NMSettingsConnection *self,
gboolean ready);