diff options
-rw-r--r-- | libnm-core/nm-errors.c | 4 | ||||
-rw-r--r-- | libnm-core/nm-errors.h | 27 | ||||
-rw-r--r-- | libnm/nm-device.c | 17 | ||||
-rw-r--r-- | libnm/nm-device.h | 18 | ||||
-rw-r--r-- | libnm/tests/test-nm-client.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device.c | 17 | ||||
-rw-r--r-- | src/devices/nm-device.h | 8 | ||||
-rwxr-xr-x | tools/test-networkmanager-service.py | 9 |
8 files changed, 46 insertions, 58 deletions
diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c index 9469740050..cf980e106b 100644 --- a/libnm-core/nm-errors.c +++ b/libnm-core/nm-errors.c @@ -28,6 +28,7 @@ G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error) G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_error) +G_DEFINE_QUARK (nm-device-error-quark, nm_device_error) static void register_error_domain (GQuark domain, @@ -57,4 +58,7 @@ _nm_dbus_errors_init (void) register_error_domain (NM_CONNECTION_ERROR, NM_DBUS_INTERFACE_SETTINGS_CONNECTION, NM_TYPE_CONNECTION_ERROR); + register_error_domain (NM_DEVICE_ERROR, + NM_DBUS_INTERFACE_DEVICE, + NM_TYPE_DEVICE_ERROR); } diff --git a/libnm-core/nm-errors.h b/libnm-core/nm-errors.h index a6b34e35f0..7a680e0a32 100644 --- a/libnm-core/nm-errors.h +++ b/libnm-core/nm-errors.h @@ -95,4 +95,31 @@ typedef enum { #define NM_CRYPTO_ERROR nm_crypto_error_quark () GQuark nm_crypto_error_quark (void); +/** + * NMDeviceError: + * @NM_DEVICE_ERROR_FAILED: unknown or unclassified error + * @NM_DEVICE_ERROR_INVALID_CONNECTION: the specified connection is not valid + * @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the specified connection is not + * compatible with this device. + * @NM_DEVICE_ERROR_NOT_ACTIVE: the device does not have an active connection + * @NM_DEVICE_ERROR_NOT_SOFTWARE: the requested operation is only valid on + * software devices. + * + * Device-related errors. + * + * These errors may be returned directly from #NMDevice methods, or may be + * returned from D-Bus operations (where they correspond to errors in the + * "org.freedesktop.NetworkManager.Device" namespace). + */ +typedef enum { + NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/ + NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/ + NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/ +} NMDeviceError; + +#define NM_DEVICE_ERROR nm_device_error_quark () +GQuark nm_device_error_quark (void); + #endif /* __NM_ERRORS_H__ */ diff --git a/libnm/nm-device.c b/libnm/nm-device.c index b715910f6b..89d8e7d26d 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -139,23 +139,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -/** - * nm_device_error_quark: - * - * Registers an error quark for #NMDevice if necessary. - * - * Returns: the error quark used for #NMDevice errors. - **/ -GQuark -nm_device_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-error-quark"); - return quark; -} - static void nm_device_init (NMDevice *device) { diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 4b209b8705..cbfe6d4309 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -37,24 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE)) #define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass)) -/** - * NMDeviceError: - * @NM_DEVICE_ERROR_FAILED: unknown or unclassified error - * @NM_DEVICE_ERROR_INVALID_CONNECTION: the connection is not valid - * @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the connection is not compatible - * with this device. - * - * Errors from #NMDevice methods. - */ -typedef enum { - NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/ - NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ - NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/ -} NMDeviceError; - -#define NM_DEVICE_ERROR nm_device_error_quark () -GQuark nm_device_error_quark (void); - #define NM_DEVICE_DEVICE_TYPE "device-type" #define NM_DEVICE_UDI "udi" #define NM_DEVICE_INTERFACE "interface" diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 26ffbec4ac..bad9e83997 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -101,6 +101,10 @@ test_device_added (void) g_assert (device); g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0"); + /* Try deleting the device via the ordinary NM interface, which should fail */ + nm_device_delete (device, NULL, &error); + g_assert_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_NOT_SOFTWARE); + g_object_unref (client); g_clear_pointer (&sinfo, nm_test_service_cleanup); } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 10dd77dbd7..45bcd22a83 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -334,19 +334,6 @@ static void nm_device_update_hw_address (NMDevice *self); /***********************************************************/ -static GQuark -nm_device_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-device-error"); - return quark; -} - -#define NM_DEVICE_ERROR (nm_device_error_quark ()) - -/***********************************************************/ - #define QUEUED_PREFIX "queued state change to " static const char *state_table[] = { @@ -1731,7 +1718,7 @@ nm_device_master_update_slave_connection (NMDevice *self, g_set_error (error, NM_DEVICE_ERROR, - NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE, + NM_DEVICE_ERROR_FAILED, "master device '%s' cannot update a slave connection for slave device '%s' (master type not supported?)", nm_device_get_iface (self), nm_device_get_iface (slave)); return FALSE; @@ -1837,7 +1824,7 @@ nm_device_complete_connection (NMDevice *self, g_return_val_if_fail (connection != NULL, FALSE); if (!NM_DEVICE_GET_CLASS (self)->complete_connection) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "Device class %s had no complete_connection method", G_OBJECT_TYPE_NAME (self)); return FALSE; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 00da022905..b053070388 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -85,14 +85,6 @@ G_BEGIN_DECLS typedef enum NMActStageReturn NMActStageReturn; -typedef enum { - NM_DEVICE_ERROR_CONNECTION_ACTIVATING = 0, /*< nick=ConnectionActivating >*/ - NM_DEVICE_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/ - NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE, /*< nick=UnsupportedDeviceType >*/ - NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/ -} NMDeviceError; - struct _NMDevice { GObject parent; }; diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 9be2e8541b..2973fd992e 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -113,6 +113,9 @@ class ExportedObj(dbus.service.Object): ################################################################### IFACE_DEVICE = 'org.freedesktop.NetworkManager.Device' +class NotSoftwareException(dbus.DBusException): + _dbus_error_name = IFACE_DEVICE + '.NotSoftware' + PD_UDI = "Udi" PD_IFACE = "Interface" PD_DRIVER = "Driver" @@ -170,6 +173,12 @@ class Device(ExportedObj): def Disconnect(self): pass + @dbus.service.method(dbus_interface=IFACE_DEVICE, in_signature='', out_signature='') + def Delete(self): + # We don't currently support any software device types, so... + raise NotSoftwareException() + pass + def __notify(self, propname): props = self._get_dbus_properties(IFACE_DEVICE) changed = { propname: props[propname] } |