From f20910516d7b44d6f87e7fbbe2fad6745506e992 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 3 Feb 2015 16:15:37 +0100 Subject: [PATCH] manager: reuse a device connection is active on if none was given upon activation If a connection is already active let's keep it on the same device. This makes it possible to reactivate a connection without client knowing which device is it active on. https://bugzilla.gnome.org/show_bug.cgi?id=730492 (cherry picked from commit 6e94f302b219a3a6bb7fad15c25fefea6f2f4fde) --- 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 3356bef51c..a458cf7241 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2266,6 +2266,17 @@ nm_manager_get_devices (NMManager *manager) return NM_MANAGER_GET_PRIVATE (manager)->devices; } +static NMDevice * +nm_manager_get_connection_device (NMManager *self, + NMConnection *connection) +{ + NMActiveConnection *ac = find_ac_for_connection (self, connection); + if (ac == NULL) + return NULL; + + return nm_active_connection_get_device (ac); +} + static gboolean impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err) { @@ -3101,7 +3112,10 @@ validate_activation_request (NMManager *self, "Device not found"); goto error; } - } else { + } else + device = nm_manager_get_connection_device (self, connection); + + if (!device) { gboolean is_software = nm_connection_is_virtual (connection); /* VPN and software-device connections don't need a device yet */