summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-06-27 17:00:55 +0200
committerThomas Haller <thaller@redhat.com>2018-07-24 09:39:09 +0200
commit33a88ca566e87adce9102c3389568dfa0e200c85 (patch)
tree59474d55dc74ba39274a103fc2e8e3780023ceff /src/devices/wwan/nm-device-modem.c
parent570e1fa75b3369eb324afceb32d15f2ba2051df7 (diff)
downloadNetworkManager-33a88ca566e87adce9102c3389568dfa0e200c85.tar.gz
core: give better error reason why device is incompatible with profile
Note the special error codes NM_UTILS_ERROR_CONNECTION_AVAILABLE_*. This will be used to determine, whether the profile is fundamentally incompatible with the device, or whether just some other properties mismatch. That information will be importand during a plain `nmcli connection up`, where NetworkManager searches all devices for a device to activate. If no device is found (and multiple errors happened), we want to show the error that is most likely relevant for the user. Also note, how NMDevice's check_connection_compatible() uses the new class field "device_class->connection_type_check_compatible" to simplify checks for compatible profiles. The error reason is still unused.
Diffstat (limited to 'src/devices/wwan/nm-device-modem.c')
-rw-r--r--src/devices/wwan/nm-device-modem.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 57c4853936..4119d5987a 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -397,12 +397,29 @@ get_type_description (NMDevice *device)
}
static gboolean
-check_connection_compatible (NMDevice *device, NMConnection *connection)
+check_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
- if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection))
+ GError *local = NULL;
+
+ if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection, error))
return FALSE;
- return nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, connection);
+ if (!nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem,
+ connection,
+ error ? &local : NULL)) {
+ if (error) {
+ g_set_error (error,
+ NM_UTILS_ERROR,
+ g_error_matches (local, NM_UTILS_ERROR, NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE)
+ ? NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE
+ : NM_UTILS_ERROR_UNKNOWN,
+ "modem is incompatible with connection: %s",
+ local->message);
+ g_error_free (local);
+ }
+ return FALSE;
+ }
+ return TRUE;
}
static gboolean