summaryrefslogtreecommitdiff
path: root/src/nm-active-connection.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-06-16 14:34:37 +0200
committerThomas Haller <thaller@redhat.com>2017-06-19 14:28:00 +0200
commitb84da2571372d1efc70750e358bf8713b1ca7934 (patch)
treeb9d9d4f24bad43cf432f2075d9c072d723aa126c /src/nm-active-connection.c
parent2656ba8d1d9400e79f0d9646f3f7b0e4acd93298 (diff)
downloadNetworkManager-b84da2571372d1efc70750e358bf8713b1ca7934.tar.gz
core: fix registering notify-flags hook in NMActiveConnection
We react on changes to NMSettingsConnection.flags, so that we can update from an external activation to a managed one. However, previously we would only register the _settings_connection_notify_flags callback during _set_settings_connection(). So, if via constructor properties we first set PROP_SETTINGS_CONNECTION and later PROP_ACTIVATION_TYPE, we wouldn't register the callback.
Diffstat (limited to 'src/nm-active-connection.c')
-rw-r--r--src/nm-active-connection.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 19c0343fed..f7088fa080 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -111,8 +111,7 @@ static void _device_cleanup (NMActiveConnection *self);
static void _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
GParamSpec *param,
NMActiveConnection *self);
-static void _set_activation_type (NMActiveConnection *self,
- NMActivationType activation_type);
+static void _set_activation_type_managed (NMActiveConnection *self);
/*****************************************************************************/
@@ -236,7 +235,7 @@ nm_active_connection_set_state (NMActiveConnection *self,
/* assuming connections mean to gracefully take over an externally
* configured device. Once activation is complete, an assumed
* activation *is* the same as a full activation. */
- _set_activation_type (self, NM_ACTIVATION_TYPE_MANAGED);
+ _set_activation_type_managed (self);
}
old_state = priv->state;
@@ -755,13 +754,31 @@ _set_activation_type (NMActiveConnection *self,
if (priv->activation_type == activation_type)
return;
+ priv->activation_type = activation_type;
+
+ if (priv->settings_connection) {
+ if (activation_type == NM_ACTIVATION_TYPE_EXTERNAL)
+ g_signal_connect (priv->settings_connection, "notify::"NM_SETTINGS_CONNECTION_FLAGS, (GCallback) _settings_connection_notify_flags, self);
+ else
+ g_signal_handlers_disconnect_by_func (priv->settings_connection, _settings_connection_notify_flags, self);
+ }
+}
+
+static void
+_set_activation_type_managed (NMActiveConnection *self)
+{
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+
+ if (priv->activation_type == NM_ACTIVATION_TYPE_MANAGED)
+ return;
+
_LOGD ("update activation type from %s to %s",
nm_activation_type_to_string (priv->activation_type),
- nm_activation_type_to_string (activation_type));
- priv->activation_type = activation_type;
+ nm_activation_type_to_string (NM_ACTIVATION_TYPE_MANAGED));
+
+ _set_activation_type (self, NM_ACTIVATION_TYPE_MANAGED);
- if ( priv->activation_type == NM_ACTIVATION_TYPE_MANAGED
- && priv->device
+ if ( priv->device
&& self == NM_ACTIVE_CONNECTION (nm_device_get_act_request (priv->device))
&& NM_IN_SET (nm_device_sys_iface_state_get (priv->device),
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
@@ -784,8 +801,7 @@ _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
if (nm_settings_connection_get_nm_generated (settings_connection))
return;
- g_signal_handlers_disconnect_by_func (settings_connection, _settings_connection_notify_flags, self);
- _set_activation_type (self, NM_ACTIVATION_TYPE_MANAGED);
+ _set_activation_type_managed (self);
nm_device_reapply_settings_immediately (nm_active_connection_get_device (self));
}
@@ -1147,7 +1163,7 @@ set_property (GObject *object, guint prop_id,
NM_ACTIVATION_TYPE_ASSUME,
NM_ACTIVATION_TYPE_EXTERNAL))
g_return_if_reached ();
- priv->activation_type = (NMActivationType) i;
+ _set_activation_type (self, (NMActivationType) i);
break;
case PROP_SPECIFIC_OBJECT:
tmp = g_value_get_string (value);