diff options
author | Dan Winship <danw@gnome.org> | 2014-10-11 14:44:10 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-10-22 08:29:08 -0400 |
commit | 69099f3e80dde14b4556c95fbdde7f01b913cdbc (patch) | |
tree | c22208fdc344dbe6b6875cf583308b06953cf304 /libnm/nm-device.c | |
parent | 5632ac6730b2bc35c8a3ec1d40b921dfadaef110 (diff) |
libnm: merge device-type-specific errors into NMDeviceError
As with the settings, each device type was defining its own error
type, containing either redundant or non-useful error codes. Drop all
of the subtype-specific errors, and reduce things to just
NM_DEVICE_ERROR_FAILED, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, and
NM_DEVICE_ERROR_INVALID_CONNECTION.
The device-type-specific errors were only returned from their
nm_device_connection_compatible() implementations, so this is also a
good opportunity to simplify those, by moving duplicated functionality
into the base NMDevice implementation, and then allowing the
subclasses to assume that the connection has already been validated in
their own code. Most of the implementations now just check that the
connection has the correct type for the device (which can't be done at
the NMDevice level since some device types (eg, Ethernet) support
multiple connection types.)
Also, make sure that all of the error messages are localized.
Diffstat (limited to 'libnm/nm-device.c')
-rw-r--r-- | libnm/nm-device.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libnm/nm-device.c b/libnm/nm-device.c index e1cadb1ae8..b715910f6b 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -2115,17 +2115,21 @@ nm_device_connection_valid (NMDevice *device, NMConnection *connection) gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; const char *config_iface, *device_iface; + GError *local = NULL; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!nm_connection_verify (connection, &local)) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection was not valid: %s"), local->message); + g_error_free (local); + return FALSE; + } - config_iface = nm_setting_connection_get_interface_name (s_con); + config_iface = nm_connection_get_interface_name (connection); device_iface = nm_device_get_iface (device); if (config_iface && g_strcmp0 (config_iface, device_iface) != 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INTERFACE_MISMATCH, - "The interface names of the device and the connection didn't match."); + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The interface names of the device and the connection didn't match.")); return FALSE; } |