summary refs log tree commit diff
path: root/src/devices/bluetooth/nm-device-bt.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-09-23 10:10:27 +0200
committerMichael Biebl <biebl@debian.org>2018-09-23 10:10:27 +0200
commite126f3e804c35480c4f075777430419d6ece23da (patch)
tree5d5821ebcda8cd6ac34d2483bb3354910e508930 /src/devices/bluetooth/nm-device-bt.c
parentc240974325c552cad177c457d6ff04e381fd77a3 (diff)
New upstream version 1.12.4 upstream/1.12.4
Diffstat (limited to 'src/devices/bluetooth/nm-device-bt.c')
-rw-r--r--src/devices/bluetooth/nm-device-bt.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 1f650d33..92ad0b31 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -36,7 +36,6 @@
 #include "nm-setting-serial.h"
 #include "nm-setting-ppp.h"
 #include "NetworkManagerUtils.h"
-#include "settings/nm-settings-connection.h"
 #include "nm-utils.h"
 #include "nm-bt-error.h"
 #include "platform/nm-platform.h"
@@ -138,7 +137,7 @@ get_generic_capabilities (NMDevice *device)
 
 static gboolean
 can_auto_connect (NMDevice *device,
-                  NMSettingsConnection *sett_conn,
+                  NMConnection *connection,
                   char **specific_object)
 {
 	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
@@ -146,11 +145,11 @@ can_auto_connect (NMDevice *device,
 
 	nm_assert (!specific_object || !*specific_object);
 
-	if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, sett_conn, NULL))
+	if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, NULL))
 		return FALSE;
 
 	/* Can't auto-activate a DUN connection without ModemManager */
-	bt_type = get_connection_bt_type (nm_settings_connection_get_connection (sett_conn));
+	bt_type = get_connection_bt_type (connection);
 	if (bt_type == NM_BT_CAPABILITY_DUN && priv->mm_running == FALSE)
 		return FALSE;
 
@@ -158,36 +157,36 @@ can_auto_connect (NMDevice *device,
 }
 
 static gboolean
-check_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
+check_connection_compatible (NMDevice *device, NMConnection *connection)
 {
 	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
+	NMSettingConnection *s_con;
 	NMSettingBluetooth *s_bt;
 	const char *bdaddr;
 	guint32 bt_type;
 
-	if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection, error))
+	if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection))
 		return FALSE;
 
-	bt_type = get_connection_bt_type (connection);
-	if (!NM_FLAGS_ALL (priv->capabilities, bt_type)) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "device does not support bluetooth type of profile");
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
+
+	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME))
 		return FALSE;
-	}
 
 	s_bt = nm_connection_get_setting_bluetooth (connection);
+	if (!s_bt)
+		return FALSE;
+
+	bt_type = get_connection_bt_type (connection);
+	if (!(bt_type & priv->capabilities))
+		return FALSE;
 
 	bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
-	if (!bdaddr) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "profile lacks bdaddr setting");
+	if (!bdaddr)
 		return FALSE;
-	}
-	if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, bdaddr, -1)) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "devices bdaddr setting mismatches");
+	if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, bdaddr, -1))
 		return FALSE;
-	}
 
 	return TRUE;
 }
@@ -196,25 +195,18 @@ static gboolean
 check_connection_available (NMDevice *device,
                             NMConnection *connection,
                             NMDeviceCheckConAvailableFlags flags,
-                            const char *specific_object,
-                            GError **error)
+                            const char *specific_object)
 {
 	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
 	guint32 bt_type;
 
 	bt_type = get_connection_bt_type (connection);
-	if (!(bt_type & priv->capabilities)) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "device does not support bluetooth type");
+	if (!(bt_type & priv->capabilities))
 		return FALSE;
-	}
 
 	/* DUN connections aren't available without ModemManager */
-	if (bt_type == NM_BT_CAPABILITY_DUN && priv->mm_running == FALSE) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "ModemManager missing for DUN profile");
+	if (bt_type == NM_BT_CAPABILITY_DUN && priv->mm_running == FALSE)
 		return FALSE;
-	}
 
 	return TRUE;
 }
@@ -1185,8 +1177,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
 
 	dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_bluetooth);
 
-	device_class->connection_type_check_compatible = NM_SETTING_BLUETOOTH_SETTING_NAME;
-
 	device_class->get_generic_capabilities = get_generic_capabilities;
 	device_class->can_auto_connect = can_auto_connect;
 	device_class->deactivate = deactivate;