summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-26 15:18:47 +0200
committerThomas Haller <thaller@redhat.com>2014-10-12 20:13:18 +0200
commit91ec7dac90b3a8f0c45b4501b9e90027680a98e6 (patch)
treee81f2eb645c6acd0cdfe557dc7f126a19a6074af
parentf68faccd7fb2dad3bdd98242b2785da67ccdc314 (diff)
downloadNetworkManager-91ec7dac90b3a8f0c45b4501b9e90027680a98e6.tar.gz
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>
-rw-r--r--src/devices/nm-device.c40
-rw-r--r--src/devices/nm-device.h4
-rw-r--r--src/nm-policy.c20
3 files changed, 10 insertions, 54 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 46c64a771d..d2edef95f8 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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,
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 2b97a8cd62..00da022905 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -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);
diff --git a/src/nm-policy.c b/src/nm-policy.c
index f6ef476bf9..ca17ea0c8e 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -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;