summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-13 16:26:23 +0200
committerThomas Haller <thaller@redhat.com>2016-04-13 18:08:00 +0200
commit108ce823a5f3df6ef02153a996610e7c23545ee7 (patch)
tree8b49773f337001ab8228923f728e8478fef9025c
parentfb37c053d67114bf22972f3f48262ee2d445bade (diff)
downloadNetworkManager-th/settings-cleanup-bgo765000.tar.gz
active-connection: update D-Bus properties of active-connection when settings-connection changesth/settings-cleanup-bgo765000
$ nmcli connection up my-connection Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/42) $ nmcli connection modify my-connection connection.id other-name $ nmcli -f connection.id connection show other-name connection.id: other-name $ nmcli -f GENERAL.CONNECTION device show enp0s25 GENERAL.CONNECTION: my-connection $ nmcli connection down other-name Error: 'other-name' is not an active connection. Error: no active connection provided. $ nmcli connection down my-connection Connection 'my-connection' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13) When modifying a connection, NMActiveConnection must update the D-Bus properties that belong to the settings-connection.
-rw-r--r--src/nm-active-connection.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 8f5114f8a7..dd70286aa2 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -134,6 +134,41 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState,
/****************************************************************/
+static void
+_settings_connection_updated (NMSettingsConnection *connection,
+ gboolean by_user,
+ gpointer user_data)
+{
+ NMActiveConnection *self = user_data;
+
+ _notify (self, PROP_ID);
+
+ /* it's a bit odd to update the TYPE of an active connection. But the alternative
+ * is unexpected too. */
+ _notify (self, PROP_TYPE);
+
+ /* currently, the UUID and the exported CONNECTION path cannot change. Later, we might
+ * want to support a re-link operation, which associates an active-connection with a different
+ * settings-connection. */
+}
+
+static void
+_set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection)
+{
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+
+ if (priv->settings_connection == connection)
+ return;
+ if (priv->settings_connection) {
+ g_signal_handlers_disconnect_by_func (priv->settings_connection, _settings_connection_updated, self);
+ g_clear_object (&priv->settings_connection);
+ }
+ if (connection) {
+ priv->settings_connection = g_object_ref (connection);
+ g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
+ }
+}
+
NMActiveConnectionState
nm_active_connection_get_state (NMActiveConnection *self)
{
@@ -273,7 +308,7 @@ nm_active_connection_set_settings_connection (NMActiveConnection *self,
* For example, we'd have to cancel all pending seret requests. */
g_return_if_fail (!nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self)));
- priv->settings_connection = g_object_ref (connection);
+ _set_settings_connection (self, connection);
priv->applied_connection = nm_simple_connection_new_clone (NM_CONNECTION (priv->settings_connection));
nm_connection_clear_secrets (priv->applied_connection);
}
@@ -918,7 +953,8 @@ static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
+ NMActiveConnection *self = (NMActiveConnection *) object;
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
const char *tmp;
NMSettingsConnection *con;
@@ -927,20 +963,20 @@ set_property (GObject *object, guint prop_id,
/* construct-only */
con = g_value_get_object (value);
if (con) {
- priv->settings_connection = g_object_ref (con);
- priv->applied_connection = nm_simple_connection_new_clone (NM_CONNECTION (con));
+ _set_settings_connection (self, con);
+ priv->applied_connection = nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection);
nm_connection_clear_secrets (priv->applied_connection);
}
break;
case PROP_INT_DEVICE:
/* construct-only */
- nm_active_connection_set_device (NM_ACTIVE_CONNECTION (object), g_value_get_object (value));
+ nm_active_connection_set_device (self, g_value_get_object (value));
break;
case PROP_INT_SUBJECT:
priv->subject = g_value_dup_object (value);
break;
case PROP_INT_MASTER:
- nm_active_connection_set_master (NM_ACTIVE_CONNECTION (object), g_value_get_object (value));
+ nm_active_connection_set_master (self, g_value_get_object (value));
break;
case PROP_SPECIFIC_OBJECT:
tmp = g_value_get_string (value);
@@ -1080,7 +1116,7 @@ dispose (GObject *object)
g_free (priv->specific_object);
priv->specific_object = NULL;
- g_clear_object (&priv->settings_connection);
+ _set_settings_connection (self, NULL);
g_clear_object (&priv->applied_connection);
_device_cleanup (self);