diff options
author | Thomas Haller <thaller@redhat.com> | 2017-06-16 14:34:37 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-06-16 14:34:37 +0200 |
commit | eddf6cef61c78e25384b95d1e814a1a84e311812 (patch) | |
tree | 3262f20267e6489980332c267e71986e1f6c5794 | |
parent | 2656ba8d1d9400e79f0d9646f3f7b0e4acd93298 (diff) | |
download | NetworkManager-eddf6cef61c78e25384b95d1e814a1a84e311812.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.
-rw-r--r-- | src/nm-active-connection.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 19c0343fed..05feec2033 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -112,7 +112,8 @@ static void _settings_connection_notify_flags (NMSettingsConnection *settings_co GParamSpec *param, NMActiveConnection *self); static void _set_activation_type (NMActiveConnection *self, - NMActivationType activation_type); + NMActivationType activation_type, + gboolean verbose); /*****************************************************************************/ @@ -236,7 +237,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 (self, NM_ACTIVATION_TYPE_MANAGED, TRUE); } old_state = priv->state; @@ -748,18 +749,28 @@ nm_active_connection_get_activation_type (NMActiveConnection *self) static void _set_activation_type (NMActiveConnection *self, - NMActivationType activation_type) + NMActivationType activation_type, + gboolean verbose) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); if (priv->activation_type == activation_type) return; - _LOGD ("update activation type from %s to %s", - nm_activation_type_to_string (priv->activation_type), - nm_activation_type_to_string (activation_type)); + if (verbose) { + _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; + 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); + } + if ( priv->activation_type == NM_ACTIVATION_TYPE_MANAGED && priv->device && self == NM_ACTIVE_CONNECTION (nm_device_get_act_request (priv->device)) @@ -784,8 +795,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 (self, NM_ACTIVATION_TYPE_MANAGED, TRUE); nm_device_reapply_settings_immediately (nm_active_connection_get_device (self)); } @@ -1147,7 +1157,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, FALSE); break; case PROP_SPECIFIC_OBJECT: tmp = g_value_get_string (value); |