From 2b2383e9c571fa5860c2fb7709a126cb043748c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0imerda?= Date: Fri, 23 Aug 2013 15:45:17 +0200 Subject: [PATCH] core: add device-generated connection to settings Only NMSettingsConnections can be activated on device, and get_connection() wasn't doing that. So the generated connection must be added to NMSettings. That also triggers the ConnectionProvider's 'connection-added' signal with the happy result of adding the new connection to the device's AvailableConnections list. Acked-by: Dan Williams --- src/nm-manager.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 1ff595d59f..3e5f86c8e0 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1775,9 +1775,12 @@ local_slist_free (void *loc) static NMConnection * get_connection (NMManager *manager, NMDevice *device) { + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); free_slist GSList *connections = nm_manager_get_activatable_connections (manager); NMConnection *connection = NULL; + NMSettingsConnection *added = NULL; GSList *iter; + GError *error = NULL; /* We still support the older API to match a NMDevice object to an * existing connection using nm_device_find_assumable_connection(). @@ -1835,7 +1838,18 @@ get_connection (NMManager *manager, NMDevice *device) nm_log_info (LOGD_DEVICE, "(%s): Using generated connection: '%s'", nm_device_get_iface (device), nm_connection_get_id (connection)); - return connection; + + added = nm_settings_add_connection (priv->settings, connection, FALSE, &error); + if (!added) { + nm_log_warn (LOGD_SETTINGS, "(%s) Couldn't save generated connection '%s': %s", + nm_device_get_iface (device), + nm_connection_get_id (connection), + (error && error->message) ? error->message : "(unknown)"); + g_clear_error (&error); + } + g_object_unref (connection); + + return added ? NM_CONNECTION (added) : NULL; } static void