mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 23:20:15 +01:00
core: remove nm_device_get_best_auto_connection()
nm_device_get_best_auto_connection() was only used at one place. It was a very simple function, just iterated over a list finding the first can_auto_connect() connection. At the very least, the name was misleading, because it did not return the 'best', but the 'first' connection. Get rid of the function altogether. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
f68faccd7f
commit
91ec7dac90
3 changed files with 10 additions and 54 deletions
|
|
@ -1824,46 +1824,6 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
|
|||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_best_auto_connection:
|
||||
* @self: an #NMDevice
|
||||
* @connections: (element-type #NMConnection): a list of connections
|
||||
* @specific_object: (out) (transfer full): on output, the path of an
|
||||
* object associated with the returned connection, to be passed to
|
||||
* nm_manager_activate_connection(), or %NULL.
|
||||
*
|
||||
* Looks through @connections to see if there is a connection that can
|
||||
* be auto-activated on @self right now. This requires, at a minimum,
|
||||
* that the connection be compatible with @self, and that it have the
|
||||
* #NMSettingConnection:autoconnect property set. Some devices impose
|
||||
* additional requirements. (Eg, a Wi-Fi connection can only be
|
||||
* activated if its SSID was seen in the last scan.)
|
||||
*
|
||||
* Returns: an auto-activatable #NMConnection, or %NULL if none are
|
||||
* available.
|
||||
*/
|
||||
|
||||
NMConnection *
|
||||
nm_device_get_best_auto_connection (NMDevice *self,
|
||||
GSList *connections,
|
||||
char **specific_object)
|
||||
{
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
||||
g_return_val_if_fail (specific_object != NULL, NULL);
|
||||
g_return_val_if_fail (*specific_object == NULL, NULL);
|
||||
|
||||
for (iter = connections; iter; iter = iter->next) {
|
||||
NMConnection *connection = NM_CONNECTION (iter->data);
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, connection, specific_object))
|
||||
return connection;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_device_complete_connection (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
|
|
|
|||
|
|
@ -269,10 +269,6 @@ gboolean nm_device_master_update_slave_connection (NMDevice *master,
|
|||
NMConnection *connection,
|
||||
GError **error);
|
||||
|
||||
NMConnection * nm_device_get_best_auto_connection (NMDevice *dev,
|
||||
GSList *connections,
|
||||
char **specific_object);
|
||||
|
||||
gboolean nm_device_can_auto_connect (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
char **specific_object);
|
||||
|
|
|
|||
|
|
@ -1005,20 +1005,22 @@ auto_activate_device (gpointer user_data)
|
|||
if (nm_device_get_act_request (data->device))
|
||||
goto out;
|
||||
|
||||
iter = connections = nm_manager_get_activatable_connections (priv->manager);
|
||||
connections = nm_manager_get_activatable_connections (priv->manager);
|
||||
|
||||
/* Remove connections that shouldn't be auto-activated */
|
||||
while (iter) {
|
||||
/* Find the first connection that should be auto-activated */
|
||||
best_connection = NULL;
|
||||
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
||||
NMSettingsConnection *candidate = NM_SETTINGS_CONNECTION (iter->data);
|
||||
|
||||
/* Grab next item before we possibly delete the current item */
|
||||
iter = g_slist_next (iter);
|
||||
|
||||
if (!nm_settings_connection_can_autoconnect (candidate))
|
||||
connections = g_slist_remove (connections, candidate);
|
||||
continue;
|
||||
if (nm_device_can_auto_connect (data->device, (NMConnection *) candidate, &specific_object)) {
|
||||
best_connection = (NMConnection *) candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_slist_free (connections);
|
||||
|
||||
best_connection = nm_device_get_best_auto_connection (data->device, connections, &specific_object);
|
||||
if (best_connection) {
|
||||
GError *error = NULL;
|
||||
NMAuthSubject *subject;
|
||||
|
|
@ -1041,8 +1043,6 @@ auto_activate_device (gpointer user_data)
|
|||
g_object_unref (subject);
|
||||
}
|
||||
|
||||
g_slist_free (connections);
|
||||
|
||||
out:
|
||||
activate_data_free (data);
|
||||
return G_SOURCE_REMOVE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue