summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-26 15:10:38 +0200
committerThomas Haller <thaller@redhat.com>2014-10-12 20:13:18 +0200
commitf68faccd7fb2dad3bdd98242b2785da67ccdc314 (patch)
tree41e00f508d4c34d331be578333482acc57568006 /src
parent2e8a2921e5ae7bb12dbed9e94311203292ddc9a9 (diff)
downloadNetworkManager-f68faccd7fb2dad3bdd98242b2785da67ccdc314.tar.gz
core: add nm_device_can_auto_connect() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/devices/nm-device.c28
-rw-r--r--src/devices/nm-device.h4
2 files changed, 32 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c2755ef5a2..46c64a771d 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1640,6 +1640,34 @@ can_auto_connect (NMDevice *self,
return nm_device_connection_is_available (self, connection, FALSE);
}
+/**
+ * nm_device_can_auto_connect:
+ * @self: an #NMDevice
+ * @connection: a #NMConnection
+ * @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.
+ *
+ * Checks if @connection 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: %TRUE, if the @connection can be auto-activated.
+ **/
+gboolean
+nm_device_can_auto_connect (NMDevice *self,
+ NMConnection *connection,
+ char **specific_object)
+{
+ g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
+ g_return_val_if_fail (specific_object && !*specific_object, FALSE);
+
+ return NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, connection, specific_object);
+}
+
static gboolean
device_has_config (NMDevice *self)
{
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 28a2ff0be9..2b97a8cd62 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -273,6 +273,10 @@ 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);
+
gboolean nm_device_complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,